Skip to content

Commit

Permalink
Improve template node (polkadot-evm#956)
Browse files Browse the repository at this point in the history
* improve template node

* fix

* update clap

* update some deps

* remove aura and manual-seal features

* fix fmt

* rename feature name `rpc_binary_search_estimate` => `rpc-binary-search-estimate`

* remove useless step from build job
  • Loading branch information
koushiro authored Jan 18, 2023
1 parent fb3ccae commit 239e040
Show file tree
Hide file tree
Showing 22 changed files with 1,008 additions and 773 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests
run: cargo test --locked --verbose --all
- name: Ensure runtime-benchmarks and try-runtime features compiles
run: cargo check --release --features=runtime-benchmarks,try-runtime

integration:
name: 'Run integration tests'
Expand All @@ -48,10 +46,10 @@ jobs:
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build manual seal client
- name: Build client
run: |
cd template/node
cargo build --release --locked --verbose --no-default-features --features manual-seal,rpc_binary_search_estimate
cargo build --release --locked --verbose --features rpc-binary-search-estimate
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
Expand Down
43 changes: 26 additions & 17 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ sp-keyring = { version = "7.0.0", git = "https://github.com/paritytech/substrate
sp-offchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-runtime = { version = "7.0.0", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-session = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-state-machine = { version = "0.13.0", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-std = { version = "5.0.0", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-storage = { version = "7.0.0", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-trie = { version = "7.0.0", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-version = { version = "5.0.0", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
# Substrate FRAME
frame-benchmarking = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions client/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = { workspace = true }
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
clap = { version = "4.0", features = ["derive"] }
clap = { version = "4.1", features = ["derive", "deprecated"] }
ethereum-types = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
Expand All @@ -36,4 +36,4 @@ sp-consensus = { workspace = true }
sp-io = { workspace = true }
substrate-test-runtime-client = { workspace = true }
# Frontier
frontier-template-runtime = { workspace = true, features = ["std", "aura", "with-rocksdb-weights"] }
frontier-template-runtime = { workspace = true, features = ["std", "with-rocksdb-weights"] }
4 changes: 2 additions & 2 deletions client/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ prometheus = { version = "0.13.1", default-features = false }
rand = "0.8"
rlp = { workspace = true }
scale-codec = { package = "parity-scale-codec", workspace = true }
tokio = { version = "1.19", features = ["sync"] }
tokio = { version = "1.24", features = ["sync"] }

# Substrate
prometheus-endpoint = { workspace = true }
Expand Down Expand Up @@ -59,4 +59,4 @@ sp-consensus = { workspace = true }
substrate-test-runtime-client = { workspace = true }

[features]
rpc_binary_search_estimate = []
rpc-binary-search-estimate = []
6 changes: 3 additions & 3 deletions client/rpc/src/eth/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ where

// Verify that the transaction succeed with highest capacity
let cap = highest;
let estimate_mode = !cfg!(feature = "rpc_binary_search_estimate");
let estimate_mode = !cfg!(feature = "rpc-binary-search-estimate");
let ExecutableResult {
data,
exit_reason,
Expand Down Expand Up @@ -656,11 +656,11 @@ where
other => error_on_execution_failure(&other, &data)?,
};

#[cfg(not(feature = "rpc_binary_search_estimate"))]
#[cfg(not(feature = "rpc-binary-search-estimate"))]
{
Ok(used_gas)
}
#[cfg(feature = "rpc_binary_search_estimate")]
#[cfg(feature = "rpc-binary-search-estimate")]
{
// On binary search, evm estimate mode is disabled
let estimate_mode = false;
Expand Down
4 changes: 3 additions & 1 deletion template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ The node also supports to use manual seal (to produce block manually through RPC
This is also used by the ts-tests:

```
$ ./target/release/frontier-template-node --dev --manual-seal
$ ./target/release/frontier-template-node --dev --sealing=manual
# Or
$ ./target/release/frontier-template-node --dev --sealing=instant
```

### Docker Based Development
Expand Down
29 changes: 15 additions & 14 deletions template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,30 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
async-trait = "0.1"
clap = { version = "4.0", features = ["derive"] }
clap = { version = "4.1", features = ["derive", "deprecated"] }
futures = "0.3.25"
jsonrpsee = { workspace = true, features = ["server", "macros"] }
log = "0.4.17"
scale-codec = { package = "parity-scale-codec", workspace = true }
serde = { workspace = true }

# Substrate
prometheus-endpoint = { package = "substrate-prometheus-endpoint", workspace = true }
sc-basic-authorship = { workspace = true }
sc-cli = { workspace = true }
sc-client-api = { workspace = true }
sc-consensus = { workspace = true }
sc-consensus-aura = { workspace = true, optional = true }
sc-consensus-manual-seal = { workspace = true, optional = true }
sc-consensus-aura = { workspace = true }
sc-consensus-manual-seal = { workspace = true }
sc-executor = { workspace = true }
sc-finality-grandpa = { workspace = true }
sc-keystore = { workspace = true }
sc-network = { workspace = true }
sc-rpc = { workspace = true }
sc-rpc-api = { workspace = true }
sc-service = { workspace = true }
sc-telemetry = { workspace = true }
sc-transaction-pool = { workspace = true }
sc-transaction-pool-api = { workspace = true }
sp-api = { workspace = true, features = ["std"] }
sp-block-builder = { workspace = true }
sp-blockchain = { workspace = true }
Expand All @@ -44,10 +46,17 @@ sp-core = { workspace = true, features = ["std"] }
sp-finality-grandpa = { workspace = true, features = ["std"] }
sp-inherents = { workspace = true, features = ["std"] }
sp-keyring = { workspace = true }
sp-offchain = { workspace = true, features = ["std"] }
sp-runtime = { workspace = true, features = ["std"] }
sp-session = { workspace = true, features = ["std"] }
sp-state-machine = { workspace = true, features = ["std"] }
sp-timestamp = { workspace = true, features = ["std"] }
sp-transaction-pool = { workspace = true, features = ["std"] }
sp-trie = { workspace = true, features = ["std"] }
# These dependencies are used for RPC
frame-system-rpc-runtime-api = { workspace = true }
pallet-transaction-payment-rpc = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
substrate-frame-rpc-system = { workspace = true }
# These dependencies are used for runtime benchmarking
frame-benchmarking = { workspace = true, optional = true }
Expand All @@ -72,18 +81,10 @@ frontier-template-runtime = { workspace = true, features = ["std"] }
substrate-build-script-utils = { workspace = true }

[features]
default = ["aura", "with-rocksdb-weights"]
aura = [
"sc-consensus-aura",
"frontier-template-runtime/aura",
]
manual-seal = [
"sc-consensus-manual-seal",
"frontier-template-runtime/manual-seal",
]
default = ["with-rocksdb-weights"]
with-rocksdb-weights = ["frontier-template-runtime/with-rocksdb-weights"]
with-paritydb-weights = ["frontier-template-runtime/with-paritydb-weights"]
rpc_binary_search_estimate = ["fc-rpc/rpc_binary_search_estimate"]
rpc-binary-search-estimate = ["fc-rpc/rpc-binary-search-estimate"]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-benchmarking-cli/runtime-benchmarks",
Expand Down
12 changes: 6 additions & 6 deletions template/node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ use sp_runtime::{generic::Era, AccountId32, OpaqueExtrinsic, SaturatedConversion
// Frontier
use frontier_template_runtime::{self as runtime, AccountId, Balance, BalancesCall, SystemCall};

use crate::service::FullClient;
use crate::client::Client;

/// Generates extrinsics for the `benchmark overhead` command.
///
/// Note: Should only be used for benchmarking.
pub struct RemarkBuilder {
client: Arc<FullClient>,
client: Arc<Client>,
}

impl RemarkBuilder {
/// Creates a new [`Self`] from the given client.
pub fn new(client: Arc<FullClient>) -> Self {
pub fn new(client: Arc<Client>) -> Self {
Self { client }
}
}
Expand Down Expand Up @@ -75,14 +75,14 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
///
/// Note: Should only be used for benchmarking.
pub struct TransferKeepAliveBuilder {
client: Arc<FullClient>,
client: Arc<Client>,
dest: AccountId,
value: Balance,
}

impl TransferKeepAliveBuilder {
/// Creates a new [`Self`] from the given client.
pub fn new(client: Arc<FullClient>, dest: AccountId, value: Balance) -> Self {
pub fn new(client: Arc<Client>, dest: AccountId, value: Balance) -> Self {
Self {
client,
dest,
Expand Down Expand Up @@ -122,7 +122,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
///
/// Note: Should only be used for benchmarking.
pub fn create_benchmark_extrinsic(
client: &FullClient,
client: &Client,
sender: sr25519::Pair,
call: runtime::RuntimeCall,
nonce: u32,
Expand Down
Loading

0 comments on commit 239e040

Please sign in to comment.