Skip to content

Commit

Permalink
Merge branch 'master' into bko-frame-omni-bencher-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ggwpez authored Jul 22, 2024
2 parents 33e76ff + d0d8e29 commit fea3954
Show file tree
Hide file tree
Showing 23 changed files with 1,053 additions and 186 deletions.
65 changes: 65 additions & 0 deletions .github/commands-readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,36 @@ Each command will have the same two required values, but it could have more.

GitHub's official documentation: [Manually running a workflow](https://docs.github.com/en/actions/using-workflows/manually-running-a-workflow)

#### Running from CLI

You can use [`gh cli`](https://cli.github.com/) to run the commands too. Refers to the [`gh workflow run`](https://cli.github.com/manual/gh_workflow_run) section from the documentation for more information.

### Number of the Pull Request

The number of the pull request. Required so the action can fetch the correct branch and comment if it fails.

## Action configurations

### FMT

For FMT you only need the PR number.

You can use the following [`gh cli`](https://cli.github.com/) inside the repo:

```bash
gh workflow run command-fmt.yml -f pr=1000
```

### Update UI

For Update UI you only need the PR number.

You can use the following [`gh cli`](https://cli.github.com/) inside the repo:

```bash
gh workflow run command-update-ui.yml -f pr=1000
```

### Bench

Runs `benchmark pallet` or `benchmark overhead` against your PR and commits back updated weights.
Expand Down Expand Up @@ -136,6 +160,12 @@ Posible combinations based on the `benchmark` dropdown.
- Requires `Runtime Dir` to be `testing`
- Requires `Target Directory` to be `cumulus`

You can use the following [`gh cli`](https://cli.github.com/) inside the repo:

```bash
gh workflow run command-bench.yml -f pr=1000 -f benchmark=polkadot-pallet -f subcommand=pallet -f runtime=rococo -f pallet=pallet_name -f target_dir=polkadot
```

### Bench-all

This is a wrapper to run `bench` for all pallets.
Expand Down Expand Up @@ -174,6 +204,12 @@ Posible combinations based on the `benchmark` dropdown.
- `people-westend`
- Requires `Target Directory` to be `cumulus`

You can use the following [`gh cli`](https://cli.github.com/) inside the repo:

```bash
gh workflow run command-bench-all.yml -f pr=1000 -f benchmark=pallet -f pallet=pallet_name -f target_dir=polkadot -f runtime=rococo
```

### Bench-overhead

Run benchmarks overhead and commit back results to PR.
Expand All @@ -193,6 +229,35 @@ Posible combinations based on the `benchmark` dropdown.
- `asset-hub-westend`
- Requires `Target directory` to be `cumulus`

You can use the following [`gh cli`](https://cli.github.com/) inside the repo:

```bash
gh workflow run command-bench-overheard.yml -f pr=1000 -f benchmark=substrate -f runtime=rococo -f target_dir=substrate
```

### Sync

Run sync and commit back results to PR.

Posible combinations based on the `benchmark` dropdown.

- `chain`
- Requires one of the following:
- `rococo`
- `westend`
- `sync-type`
- Requires one of the following:
- `warp`
- `full`
- `fast`
- `fast-unsafe`

You can use the following [`gh cli`](https://cli.github.com/) inside the repo:

```bash
gh workflow run command-sync.yml -f pr=1000 -f chain=rococo -f sync-type=full
```

## How to modify an action

If you want to modify an action and test it, you can do by simply pushing your changes and then selecting your branch in the `Use worflow from` option.
Expand Down
20 changes: 16 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ ark-ed-on-bls12-381-bandersnatch-ext = { version = "0.4.1", default-features = f
ark-scale = { version = "0.0.12", default-features = false }
array-bytes = { version = "6.2.2", default-features = false }
arrayvec = { version = "0.7.4" }
assert_cmd = { version = "2.0.10" }
assert_cmd = { version = "2.0.14" }
assert_matches = { version = "1.5.0" }
asset-hub-rococo-emulated-chain = { path = "cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-rococo" }
asset-hub-rococo-runtime = { path = "cumulus/parachains/runtimes/assets/asset-hub-rococo", default-features = false }
Expand Down Expand Up @@ -815,7 +815,7 @@ kvdb-rocksdb = { version = "0.19.0" }
kvdb-shared-tests = { version = "0.11.0" }
landlock = { version = "0.3.0" }
lazy_static = { version = "1.4.0" }
libc = { version = "0.2.153" }
libc = { version = "0.2.155" }
libfuzzer-sys = { version = "0.4" }
libp2p = { version = "0.52.4" }
libp2p-identity = { version = "0.2.3" }
Expand Down
2 changes: 1 addition & 1 deletion polkadot/node/core/pvf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test-parachain-adder = { workspace = true }
test-parachain-halt = { workspace = true }

[target.'cfg(target_os = "linux")'.dev-dependencies]
libc = "0.2.153"
libc = "0.2.155"
procfs = "0.16.0"
rusty-fork = "0.3.0"
sc-sysinfo = { workspace = true, default-features = true }
Expand Down
13 changes: 13 additions & 0 deletions prdoc/pr_4936.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: "Balances Pallet: Emit events when TI is updated in currency impl"

doc:
- audience: Runtime Dev
description: |
Previously, in the Currency impl, the implementation of pallet_balances was not emitting any instances of Issued and Rescinded events, even though the Fungible equivalent was. This PR adds the Issued and Rescinded events in appropriate places in impl_currency along with tests.

crates:
- name: pallet-balances
bump: patch
7 changes: 4 additions & 3 deletions substrate/bin/node/bench/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,23 @@ impl core::Benchmark for ImportBenchmark {
.inspect_state(|| {
match self.block_type {
BlockType::RandomTransfersKeepAlive => {
// should be 8 per signed extrinsic + 1 per unsigned
// should be 9 per signed extrinsic + 1 per unsigned
// we have 2 unsigned (timestamp and glutton bloat) while the rest are
// signed in the block.
// those 8 events per signed are:
// those 9 events per signed are:
// - transaction paid for the transaction payment
// - withdraw (Balances::Withdraw) for charging the transaction fee
// - new account (System::NewAccount) as we always transfer fund to
// non-existent account
// - endowed (Balances::Endowed) for this new account
// - issued (Balances::Issued) as total issuance is increased
// - successful transfer (Event::Transfer) for this transfer operation
// - 2x deposit (Balances::Deposit and Treasury::Deposit) for depositing
// the transaction fee into the treasury
// - extrinsic success
assert_eq!(
kitchensink_runtime::System::events().len(),
(self.block.extrinsics.len() - 2) * 8 + 2,
(self.block.extrinsics.len() - 2) * 9 + 2,
);
},
BlockType::Noop => {
Expand Down
1 change: 1 addition & 0 deletions substrate/bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ wait-timeout = { workspace = true }
wat = { workspace = true }
serde_json = { workspace = true, default-features = true }
scale-info = { features = ["derive", "serde"], workspace = true, default-features = true }
pretty_assertions.workspace = true

# These testing-only dependencies are not exported by the Polkadot-SDK crate:
node-testing = { workspace = true }
Expand Down
22 changes: 22 additions & 0 deletions substrate/bin/node/cli/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use kitchensink_runtime::{
};
use node_primitives::{Balance, Hash};
use node_testing::keyring::*;
use pretty_assertions::assert_eq;
use wat;

pub mod common;
Expand Down Expand Up @@ -380,6 +381,13 @@ fn full_native_block_import_works() {
}),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: RuntimeEvent::Balances(pallet_balances::Event::Rescinded {
amount: fees * 2 / 10,
}),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: RuntimeEvent::TransactionPayment(
Expand Down Expand Up @@ -465,6 +473,13 @@ fn full_native_block_import_works() {
}),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: RuntimeEvent::Balances(pallet_balances::Event::Rescinded {
amount: fees - fees * 8 / 10,
}),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: RuntimeEvent::TransactionPayment(
Expand Down Expand Up @@ -515,6 +530,13 @@ fn full_native_block_import_works() {
}),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(2),
event: RuntimeEvent::Balances(pallet_balances::Event::Rescinded {
amount: fees - fees * 8 / 10,
}),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(2),
event: RuntimeEvent::TransactionPayment(
Expand Down
5 changes: 5 additions & 0 deletions substrate/client/consensus/beefy/src/communication/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ impl<B: Block> KnownPeers<B> {
pub fn contains(&self, peer: &PeerId) -> bool {
self.live.contains_key(peer)
}

/// Number of peers in the set.
pub fn len(&self) -> usize {
self.live.len()
}
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,16 @@ impl<B: Block, AuthorityId: AuthorityIdBound> OnDemandJustificationsEngine<B, Au
if let Some(peer) = self.try_next_peer() {
self.request_from_peer(peer, req_info);
} else {
metric_inc!(
self.metrics,
beefy_on_demand_justification_no_peer_to_request_from
);

let num_cache = self.peers_cache.len();
let num_live = self.live_peers.lock().len();
warn!(
target: BEEFY_SYNC_LOG_TARGET,
"🥩 ran out of peers to request justif #{:?} from", block
"🥩 ran out of peers to request justif #{block:?} from num_cache={num_cache} num_live={num_live} err={err:?}",
);
}
// Report peer based on error type.
Expand All @@ -265,7 +272,7 @@ impl<B: Block, AuthorityId: AuthorityIdBound> OnDemandJustificationsEngine<B, Au
metric_inc!(self.metrics, beefy_on_demand_justification_good_proof);
debug!(
target: BEEFY_SYNC_LOG_TARGET,
"🥩 received valid on-demand justif #{:?} from {:?}", block, peer
"🥩 received valid on-demand justif #{block:?} from {peer:?}",
);
let peer_report = PeerReport { who: peer, cost_benefit: benefit::VALIDATED_PROOF };
ResponseInfo::ValidProof(proof, peer_report)
Expand Down
22 changes: 12 additions & 10 deletions substrate/client/network/src/litep2p/shim/request_response/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::{
peer_store::PeerStoreProvider,
request_responses::{IncomingRequest, OutgoingResponse},
service::{metrics::Metrics, traits::RequestResponseConfig as RequestResponseConfigT},
IfDisconnected, ProtocolName, RequestFailure,
IfDisconnected, OutboundFailure, ProtocolName, RequestFailure,
};

use futures::{channel::oneshot, future::BoxFuture, stream::FuturesUnordered, StreamExt};
Expand Down Expand Up @@ -369,10 +369,12 @@ impl RequestResponseProtocol {
return
};

let error = match error {
RequestResponseError::NotConnected => Some(RequestFailure::NotConnected),
RequestResponseError::Rejected | RequestResponseError::Timeout =>
Some(RequestFailure::Refused),
let status = match error {
RequestResponseError::NotConnected =>
Some((RequestFailure::NotConnected, "not-connected")),
RequestResponseError::Rejected => Some((RequestFailure::Refused, "rejected")),
RequestResponseError::Timeout =>
Some((RequestFailure::Network(OutboundFailure::Timeout), "timeout")),
RequestResponseError::Canceled => {
log::debug!(
target: LOG_TARGET,
Expand All @@ -387,7 +389,7 @@ impl RequestResponseProtocol {
"{}: tried to send too large request to {peer:?} ({request_id:?})",
self.protocol,
);
Some(RequestFailure::Refused)
Some((RequestFailure::Refused, "payload-too-large"))
},
RequestResponseError::UnsupportedProtocol => match fallback_request {
Some((request, protocol)) => match self.request_tx.get(&protocol) {
Expand Down Expand Up @@ -426,15 +428,15 @@ impl RequestResponseProtocol {
peer,
);

Some(RequestFailure::Refused)
Some((RequestFailure::Refused, "invalid-fallback-protocol"))
},
},
None => Some(RequestFailure::Refused),
None => Some((RequestFailure::Refused, "unsupported-protocol")),
},
};

if let Some(error) = error {
self.metrics.register_outbound_request_failure(error.to_string().as_ref());
if let Some((error, reason)) = status {
self.metrics.register_outbound_request_failure(reason);
let _ = tx.send(Err(error));
}
}
Expand Down
Loading

0 comments on commit fea3954

Please sign in to comment.