Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/evm devnet ready #772

Merged
merged 65 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
3fedd89
Update to polkadot SDK release-polkadot-v1.11.0
gztensor Aug 28, 2024
4886e96
Add EVM pallets, rpc, and precompiles
gztensor Aug 29, 2024
dee91c0
Format
gztensor Aug 29, 2024
8dd904e
Fix clippy issues
gztensor Aug 29, 2024
86167cb
Format
gztensor Aug 29, 2024
ca953f4
Fix try-runtime build
gztensor Aug 29, 2024
fa7d30f
Fix runtime-benchmarks build
gztensor Aug 29, 2024
069bea4
Format
gztensor Aug 29, 2024
f0dde3c
Fix configuration of pallet_transaction_payment, reduce linear fees t…
gztensor Aug 29, 2024
3f3b546
Format
gztensor Aug 29, 2024
8c1de0d
Fix zepter check
gztensor Aug 29, 2024
072bdea
Fix zepter check
gztensor Aug 29, 2024
0d571b4
Cleanup and fix gas to weight to fees conversion
gztensor Aug 30, 2024
020fb2a
Format
gztensor Aug 30, 2024
9609bd2
Change chain ID to 945 for testnet
gztensor Aug 30, 2024
e88f428
Add staking precompile implementation notes
gztensor Sep 3, 2024
8285c39
add add staking logic
soring323 Sep 4, 2024
609005b
refactor execute function
soring323 Sep 4, 2024
231e586
add remove staking function
soring323 Sep 4, 2024
074c9b6
fix lint issue
soring323 Sep 4, 2024
fad6d17
add refund logic to caller
soring323 Sep 5, 2024
7e047fa
fix lint issue
soring323 Sep 5, 2024
9d0391c
Merge pull request #777 from DedicatedDev/mz/feat/staking-precompile
gztensor Sep 5, 2024
600e6d1
fix clippy lint issues
soring323 Sep 5, 2024
27797ae
fix clippy lint issues
soring323 Sep 5, 2024
74fe08d
Merge pull request #784 from DedicatedDev/mz/feat/fix-clippy-issue
gztensor Sep 5, 2024
1c2c12f
Address code review comments: Separate RPC merging into helper functions
gztensor Sep 5, 2024
89c8910
Use TryFrom for converting bytes to AccountId32 with error
gztensor Sep 5, 2024
767ed55
Bump runtime version to 197
gztensor Sep 6, 2024
bc65af2
Merge branch 'devnet-ready' into feat/evm-devnet-ready
gztensor Sep 6, 2024
56a9809
Re-add staking precompile implementation notes
gztensor Sep 6, 2024
f8632e3
Format
gztensor Sep 6, 2024
0478b8d
Fix removing stake in staking precompile
gztensor Sep 17, 2024
4cdfeb5
Remove payable modifier from removeStake precompile method
gztensor Sep 17, 2024
517fabf
bump spec above mainnet (#829)
camfairchild Sep 23, 2024
453a7af
Update EVM to polkadot dsk 1.16
gztensor Sep 26, 2024
5372f5e
Format
gztensor Sep 26, 2024
f706122
Make linter happy again
gztensor Sep 26, 2024
a2b8bb6
Format
gztensor Sep 26, 2024
3f147b8
Remove unused manifest key: dependencies.scale-codec.package (linter)
gztensor Sep 26, 2024
1c72c6f
Fix benchmarks
gztensor Sep 26, 2024
bb9ee35
Format
gztensor Sep 26, 2024
4966c2c
Cleanup RPC create_full bounds
gztensor Sep 27, 2024
7064b52
Add ed25519 verify precompile
gztensor Sep 30, 2024
c587301
Implement ed25519 verification precompile
gztensor Oct 1, 2024
129d3d9
Propagate features for ed25519-dalek
gztensor Oct 2, 2024
ac24a8f
Add ed25519-dalek to std feature in runtime
gztensor Oct 2, 2024
6ead778
Implement subtensor evm balance converter, use in balance transfer pr…
gztensor Oct 4, 2024
bdd85cd
Use evm balance converter in staking precompile
gztensor Oct 4, 2024
638f521
Merge devnet-ready into feat/evm-devnet-ready
gztensor Oct 4, 2024
40fff23
Recalculate decimals for gas price
gztensor Oct 4, 2024
4ea9663
Fix decimals in gas fees (max_fee_per_gas and max_priority_fee_per_gas)
gztensor Oct 15, 2024
f39520c
Format
gztensor Oct 15, 2024
d3f7013
Merge main into feat/evm-devnet-ready
gztensor Oct 15, 2024
6622905
add ability to skip cargo audit
sam0x17 Oct 16, 2024
70e86e2
Cargo update after updating frontier version of sqlx
gztensor Oct 16, 2024
3c17e7c
fix
sam0x17 Oct 16, 2024
7c4126f
Fix decimals in gas price rpc
gztensor Oct 16, 2024
042d5d7
Update frontier fork to master branch
gztensor Oct 29, 2024
a85e207
fix: whitelist
orriin Oct 30, 2024
f58977b
pin frontier version
orriin Oct 31, 2024
29cd71e
Merge branch 'devnet-ready' into feat/evm-devnet-ready
orriin Oct 31, 2024
8d084b1
fix merge
orriin Oct 31, 2024
6513d46
update cargo.lock
orriin Oct 31, 2024
d8eadf3
fix feature propagation
orriin Oct 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,327 changes: 1,874 additions & 453 deletions Cargo.lock

Large diffs are not rendered by default.

180 changes: 106 additions & 74 deletions Cargo.toml

Large diffs are not rendered by default.

34 changes: 33 additions & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ targets = ["x86_64-unknown-linux-gnu"]
name = "node-subtensor"

[dependencies]
async-trait = { workspace = true }
clap = { workspace = true, features = ["derive"] }
futures = { workspace = true, features = ["thread-pool"] }
serde = { workspace = true, features = ["derive"] }
Expand Down Expand Up @@ -74,6 +75,22 @@ pallet-transaction-payment-rpc = { workspace = true }
frame-benchmarking = { workspace = true }
frame-benchmarking-cli = { workspace = true }

# Needed for Frontier
sc-consensus-manual-seal = { workspace = true }
sc-network-sync = { workspace = true }
substrate-prometheus-endpoint = { workspace = true }

# Frontier
fc-storage = { workspace = true }
fc-db = { workspace = true }
fc-consensus = { workspace = true }
fp-dynamic-fee = { workspace = true }
fc-api = { workspace = true }
fc-rpc = { workspace = true }
fc-rpc-core = { workspace = true }
fp-rpc = { workspace = true }
fc-mapping-sync = { workspace = true }

# Local Dependencies
node-subtensor-runtime = { path = "../runtime" }
subtensor-custom-rpc = { path = "../pallets/subtensor/rpc" }
Expand All @@ -83,7 +100,22 @@ subtensor-custom-rpc-runtime-api = { path = "../pallets/subtensor/runtime-api" }
substrate-build-script-utils = { workspace = true }

[features]
default = []
default = [
"rocksdb",
"sql",
"txpool",
]
sql = [
"fc-db/sql",
"fc-mapping-sync/sql",
]
rocksdb = [
"sc-service/rocksdb",
"fc-db/rocksdb",
"fc-mapping-sync/rocksdb",
]
txpool = ["fc-rpc/txpool"]

# Dependencies that are only required if runtime benchmarking should be build.
runtime-benchmarks = [
"node-subtensor-runtime/runtime-benchmarks",
Expand Down
18 changes: 18 additions & 0 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::ethereum::EthConfiguration;
use sc_cli::RunCmd;

#[derive(Debug, clap::Parser)]
Expand All @@ -7,6 +8,13 @@ pub struct Cli {

#[clap(flatten)]
pub run: RunCmd,

/// Choose sealing method.
#[arg(long, value_enum, ignore_case = true)]
pub sealing: Option<Sealing>,

#[command(flatten)]
pub eth: EthConfiguration,
}

#[allow(clippy::large_enum_variant)]
Expand Down Expand Up @@ -45,3 +53,13 @@ pub enum Subcommand {
// Db meta columns information.
ChainInfo(sc_cli::ChainInfoCmd),
}

/// Available Sealing methods.
#[derive(Copy, Clone, Debug, Default, clap::ValueEnum)]
pub enum Sealing {
/// Seal using rpc method.
#[default]
Manual,
/// Seal when transaction is executed.
Instant,
}
126 changes: 79 additions & 47 deletions node/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::{
chain_spec,
cli::{Cli, Subcommand},
ethereum::db_config_dir,
service,
};
use fc_db::{kv::frontier_database_dir, DatabaseSource};

#[cfg(feature = "runtime-benchmarks")]
pub use crate::benchmarking::{inherent_benchmark_data, RemarkBuilder, TransferKeepAliveBuilder};
Expand All @@ -15,9 +17,10 @@ pub use sp_keyring::Sr25519Keyring;
#[cfg(feature = "runtime-benchmarks")]
use sp_runtime::traits::HashingFor;

use futures::TryFutureExt;
use node_subtensor_runtime::Block;
use sc_cli::SubstrateCli;
use sc_service::{Configuration, PartialComponents};
use sc_service::Configuration;

impl SubstrateCli for Cli {
fn impl_name() -> String {
Expand Down Expand Up @@ -68,64 +71,89 @@ pub fn run() -> sc_cli::Result<()> {
}
Some(Subcommand::CheckBlock(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents {
client,
task_manager,
import_queue,
..
} = service::new_partial(&config)?;
runner.async_run(|mut config| {
let (client, _, import_queue, task_manager, _) =
service::new_chain_ops(&mut config, &cli.eth)?;
Ok((cmd.run(client, import_queue), task_manager))
})
}
Some(Subcommand::ExportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents {
client,
task_manager,
..
} = service::new_partial(&config)?;
runner.async_run(|mut config| {
let (client, _, _, task_manager, _) =
service::new_chain_ops(&mut config, &cli.eth)?;
Ok((cmd.run(client, config.database), task_manager))
})
}
Some(Subcommand::ExportState(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents {
client,
task_manager,
..
} = service::new_partial(&config)?;
runner.async_run(|mut config| {
let (client, _, _, task_manager, _) =
service::new_chain_ops(&mut config, &cli.eth)?;
Ok((cmd.run(client, config.chain_spec), task_manager))
})
}
Some(Subcommand::ImportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents {
client,
task_manager,
import_queue,
..
} = service::new_partial(&config)?;
runner.async_run(|mut config| {
let (client, _, import_queue, task_manager, _) =
service::new_chain_ops(&mut config, &cli.eth)?;
Ok((cmd.run(client, import_queue), task_manager))
})
}
Some(Subcommand::PurgeChain(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.database))
runner.sync_run(|config| {
// Remove Frontier offchain db
let db_config_dir = db_config_dir(&config);
match cli.eth.frontier_backend_type {
crate::ethereum::BackendType::KeyValue => {
let frontier_database_config = match config.database {
DatabaseSource::RocksDb { .. } => DatabaseSource::RocksDb {
path: frontier_database_dir(&db_config_dir, "db"),
cache_size: 0,
},
DatabaseSource::ParityDb { .. } => DatabaseSource::ParityDb {
path: frontier_database_dir(&db_config_dir, "paritydb"),
},
_ => {
return Err(format!(
"Cannot purge `{:?}` database",
config.database
)
.into())
}
};
cmd.run(frontier_database_config)?;
}
crate::ethereum::BackendType::Sql => {
let db_path = db_config_dir.join("sql");
match std::fs::remove_dir_all(&db_path) {
Ok(_) => {
println!("{:?} removed.", &db_path);
}
Err(ref err) if err.kind() == std::io::ErrorKind::NotFound => {
eprintln!("{:?} did not exist.", &db_path);
}
Err(err) => {
return Err(format!(
"Cannot purge `{:?}` database: {:?}",
db_path, err,
)
.into())
}
};
}
};
cmd.run(config.database)
})
}
Some(Subcommand::Revert(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents {
client,
task_manager,
backend,
..
} = service::new_partial(&config)?;
let aux_revert = Box::new(|client, _, blocks| {
runner.async_run(|mut config| {
let (client, backend, _, task_manager, _) =
service::new_chain_ops(&mut config, &cli.eth)?;
let aux_revert = Box::new(move |client, _, blocks| {
sc_consensus_grandpa::revert(client, blocks)?;
Ok(())
});
Expand All @@ -137,6 +165,14 @@ pub fn run() -> sc_cli::Result<()> {
let runner = cli.create_runner(cmd)?;

runner.sync_run(|config| {
let sc_service::PartialComponents {
client, backend, ..
} = crate::service::new_partial(
&config,
&cli.eth,
crate::service::build_manual_seal_import_queue,
)?;

// This switch needs to be in the client, since the client decides
// which sub-commands it wants to support.
match cmd {
Expand All @@ -149,29 +185,24 @@ pub fn run() -> sc_cli::Result<()> {
);
}

cmd.run::<HashingFor<Block>, service::ExecutorDispatch>(config)
}
BenchmarkCmd::Block(cmd) => {
let PartialComponents { client, .. } = service::new_partial(&config)?;
cmd.run(client)
cmd.run_with_spec::<HashingFor<Block>, service::ExecutorDispatch>(Some(
config.chain_spec,
))
}
BenchmarkCmd::Block(cmd) => cmd.run(client),
#[cfg(not(feature = "runtime-benchmarks"))]
BenchmarkCmd::Storage(_) => Err(
"Storage benchmarking can be enabled with `--features runtime-benchmarks`."
.into(),
),
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => {
let PartialComponents {
client, backend, ..
} = service::new_partial(&config)?;
let db = backend.expose_db();
let storage = backend.expose_storage();

cmd.run(config, client, db, storage)
}
BenchmarkCmd::Overhead(cmd) => {
let PartialComponents { client, .. } = service::new_partial(&config)?;
let ext_builder = RemarkBuilder::new(client.clone());

cmd.run(
Expand All @@ -183,7 +214,6 @@ pub fn run() -> sc_cli::Result<()> {
)
}
BenchmarkCmd::Extrinsic(cmd) => {
let PartialComponents { client, .. } = service::new_partial(&config)?;
// Register the *Remark* and *TKA* builders.
let ext_factory = ExtrinsicFactory(vec![
Box::new(RemarkBuilder::new(client.clone())),
Expand All @@ -210,7 +240,9 @@ pub fn run() -> sc_cli::Result<()> {
let runner = cli.create_runner(&cli.run)?;
runner.run_node_until_exit(|config| async move {
let config = override_default_heap_pages(config, 60_000);
service::new_full(config).map_err(sc_cli::Error::Service)
service::new_full::<sc_network::Litep2pNetworkBackend>(config, cli.eth, cli.sealing)
.map_err(Into::into)
.await
})
}
}
Expand Down
Loading
Loading