Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
0d9c3f7
revert and rebase
Nathy-bajo Mar 25, 2026
2786548
nit
Nathy-bajo Mar 25, 2026
185f34c
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Mar 25, 2026
1009229
revert dev-node changes
Nathy-bajo Mar 26, 2026
daacdbc
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Mar 26, 2026
acf5bbf
make eth-rpc default
Nathy-bajo Mar 26, 2026
23c2124
dd a negation to revive_chain.scale
Nathy-bajo Mar 27, 2026
323ffb9
fix tests
Nathy-bajo Mar 27, 2026
7393a4d
rename BuildParachainReviveRpcExtensions back to BuildParachainRpcExt…
Nathy-bajo Mar 27, 2026
7760fef
nit
Nathy-bajo Mar 27, 2026
d8d53dd
fix ci
Nathy-bajo Mar 27, 2026
f0dafc2
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Mar 27, 2026
31781bc
rewrite revive_chain.scale
Nathy-bajo Mar 27, 2026
4c11964
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Mar 30, 2026
b67f636
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Mar 31, 2026
d9c831d
nit
Nathy-bajo Mar 31, 2026
88898f6
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Mar 31, 2026
2b15119
fix ci
Nathy-bajo Mar 31, 2026
dead909
try seperatting the eth-rpc into a library and server crate
Nathy-bajo Mar 31, 2026
082736e
revert server
Nathy-bajo Mar 31, 2026
75616fd
remove pallet-dev-runtime from eth-rpc
Nathy-bajo Apr 1, 2026
1811c6a
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 1, 2026
f52bb44
add state_overrides parameter
Nathy-bajo Apr 1, 2026
e3341ad
fmt
Nathy-bajo Apr 1, 2026
7ac1c85
rebuild revive_chain.scale
Nathy-bajo Apr 1, 2026
af13200
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 1, 2026
7b8a67d
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 2, 2026
3ae15a2
apply suggestions
Nathy-bajo Apr 2, 2026
d26d84e
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 2, 2026
47676d5
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 7, 2026
25274c8
fix circular dependency breakage
Nathy-bajo Apr 7, 2026
cc93e0e
remove redundant revivce_chain.scale file
Nathy-bajo Apr 7, 2026
70d53fa
Update from github-actions[bot] running command 'prdoc --audience nod…
github-actions[bot] Apr 7, 2026
3ecd89d
nit
Nathy-bajo Apr 7, 2026
bb4ead6
gate import behind subxt
Nathy-bajo Apr 7, 2026
2e26619
fix missing polkadot_sdk feature flags
Nathy-bajo Apr 8, 2026
bc364dc
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 8, 2026
0d7f4a9
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 8, 2026
8a56fed
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 8, 2026
9616961
fix cargo workspace dependency
Nathy-bajo Apr 8, 2026
0051604
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 9, 2026
cb884db
resolve conflicts
Nathy-bajo Apr 10, 2026
15da846
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 10, 2026
54a88a0
fmt
Nathy-bajo Apr 10, 2026
80dbbac
nit
Nathy-bajo Apr 10, 2026
2e02e5b
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 10, 2026
eae7ecd
fix tests
Nathy-bajo Apr 10, 2026
2fc3fbe
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 10, 2026
e06a869
smol nits
Nathy-bajo Apr 10, 2026
885ef91
fix eth-rpc node spawn and test failures
Nathy-bajo Apr 10, 2026
9a73f9e
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 10, 2026
5a3ceb5
fix umbrella crate ci check failure
Nathy-bajo Apr 10, 2026
9c1856d
fix eth-rpc rpc error
Nathy-bajo Apr 11, 2026
4adabab
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 17, 2026
f61ad8a
improve background-task panic messages
Nathy-bajo Apr 17, 2026
311f3eb
nit
Nathy-bajo Apr 17, 2026
ffd5be4
fix cli::run()
Nathy-bajo Apr 21, 2026
eacc755
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 21, 2026
cf3e009
resolve conflicts
Nathy-bajo Apr 21, 2026
8966aef
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 21, 2026
b3f96d0
resolve new conflict again
Nathy-bajo Apr 21, 2026
4278d01
nit
Nathy-bajo Apr 21, 2026
c0c2fcd
nit
Nathy-bajo Apr 21, 2026
2e800c9
fix pallet-revive tests
Nathy-bajo Apr 21, 2026
6ec18c1
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 22, 2026
f820dbd
resolve new conflicts
Nathy-bajo Apr 22, 2026
65df8e8
nit
Nathy-bajo Apr 22, 2026
43a1303
nit
Nathy-bajo Apr 22, 2026
977d75b
fix run_all_eth_roc_tests
Nathy-bajo Apr 22, 2026
629ca55
fix run_all_eth_roc_tests
Nathy-bajo Apr 22, 2026
f5e7917
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 22, 2026
cb03385
fix get_storage
Nathy-bajo Apr 22, 2026
e193dfe
cargo fmt
Nathy-bajo Apr 22, 2026
37c828a
Fix block_hash_for_tag to use earliest_block_number()
Nathy-bajo Apr 22, 2026
9f9d3ba
fix trace_block_by_number
Nathy-bajo Apr 23, 2026
f91b8d9
add estimate_gas back to runtime_api
Nathy-bajo Apr 23, 2026
247526d
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 23, 2026
578c5ee
make SystemHealthRpcServerImpl opt-in via a new include_system_health…
Nathy-bajo Apr 24, 2026
b306558
Merge branch 'master' into pallet_revive_refactor
Nathy-bajo Apr 24, 2026
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
28 changes: 27 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,7 @@ pallet-ranked-collective = { path = "substrate/frame/ranked-collective", default
pallet-recovery = { path = "substrate/frame/recovery", default-features = false }
pallet-referenda = { path = "substrate/frame/referenda", default-features = false }
pallet-revive = { path = "substrate/frame/revive", default-features = false }
pallet-revive-eth-rpc = { path = "substrate/frame/revive/rpc", default-features = false }
pallet-revive-fixtures = { path = "substrate/frame/revive/fixtures", default-features = false }
pallet-revive-proc-macro = { path = "substrate/frame/revive/proc-macro", default-features = false }
pallet-revive-uapi = { path = "substrate/frame/revive/uapi", default-features = false }
Expand Down
5 changes: 5 additions & 0 deletions cumulus/polkadot-omni-node/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ frame-benchmarking-cli = { workspace = true, default-features = true }
frame-support = { optional = true, workspace = true, default-features = true }
frame-system-rpc-runtime-api = { workspace = true, default-features = true }
frame-try-runtime = { optional = true, workspace = true, default-features = true }
pallet-revive = { workspace = true, default-features = true }
pallet-revive-eth-rpc = { workspace = true, default-features = false }
pallet-transaction-payment = { workspace = true, default-features = true }
pallet-transaction-payment-rpc = { workspace = true, default-features = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true, default-features = true }
Expand Down Expand Up @@ -108,6 +110,7 @@ cumulus-primitives-core = { workspace = true, default-features = true }
cumulus-relay-chain-interface = { workspace = true, default-features = true }
futures-timer = { workspace = true }
sc-consensus-aura = { workspace = true }
tokio = { workspace = true, features = ["rt-multi-thread"] }

[dev-dependencies]
assert_cmd = { workspace = true }
Expand All @@ -125,6 +128,7 @@ runtime-benchmarks = [
"frame-benchmarking-cli/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"pallet-revive/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
"polkadot-cli/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
Expand All @@ -135,6 +139,7 @@ runtime-benchmarks = [
try-runtime = [
"frame-support/try-runtime",
"frame-try-runtime/try-runtime",
"pallet-revive/try-runtime",
"pallet-transaction-payment/try-runtime",
"polkadot-cli/try-runtime",
"sp-runtime/try-runtime",
Expand Down
10 changes: 7 additions & 3 deletions cumulus/polkadot-omni-node/lib/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn new_aura_node_spec<Block>(
extra_args: &NodeExtraArgs,
) -> Box<dyn DynNodeSpec>
where
Block: NodeBlock,
Block: NodeBlock<BoundedNumber = u32>,
{
match aura_id {
AuraConsensusId::Sr25519 => crate::nodes::aura::new_aura_node_spec::<
Expand Down Expand Up @@ -91,8 +91,12 @@ fn new_node_spec(
(BlockNumber::U32, Consensus::Aura(aura_id)) => {
new_aura_node_spec::<Block<u32>>(aura_id, extra_args)
},
(BlockNumber::U64, Consensus::Aura(aura_id)) => {
new_aura_node_spec::<Block<u64>>(aura_id, extra_args)
(BlockNumber::U64, Consensus::Aura(_)) => {
return Err(sc_cli::Error::Application(
"u64 block numbers are not supported when the ETH RPC (pallet-revive) \
is enabled; the runtime must use u32 block numbers"
.into(),
))
},
},
})
Expand Down
223 changes: 182 additions & 41 deletions cumulus/polkadot-omni-node/lib/src/common/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,188 @@ use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer
/// A type representing all RPC extensions.
pub type RpcExtension = jsonrpsee::RpcModule<()>;

pub(crate) use eth_rpc::BuildParachainRpcExtensions;

mod eth_rpc {
use super::*;
use pallet_revive_eth_rpc::{
cli::{build_eth_rpc_module, build_native_inmemory_client},
client::SubscriptionType,
native_client::ReviveRuntimeApiT,
NativeClientBlockInfoProvider, NativeSubstrateClient,
};
use sp_api::{Metadata as _, ProvideRuntimeApi};
use sp_core::H256;

/// The default number of recent blocks kept in the in-memory receipt cache.
const DEFAULT_KEEP_LATEST_BLOCKS: usize = 256;

/// Reads the `ChainId` constant from the `Revive` pallet via the runtime metadata.
fn read_revive_chain_id<B, C>(
client: &Arc<C>,
best_hash: B::Hash,
) -> Result<u64, Box<dyn std::error::Error + Send + Sync>>
where
B: BlockT,
C: ProvideRuntimeApi<B>,
C::Api: sp_api::Metadata<B>,
{
use codec::Decode as _;

let opaque = client
.runtime_api()
.metadata(best_hash)
.map_err(|e| format!("metadata API error: {e}"))?;

let meta = subxt_metadata::Metadata::decode(&mut &opaque[..])
.map_err(|e| format!("metadata decode error: {e}"))?;

let value = meta
.pallet_by_name("Revive")
.and_then(|p| p.constant_by_name("ChainId"))
.map(|c| c.value().to_vec())
.ok_or("Revive pallet `ChainId` constant not found in runtime metadata")?;

u64::decode(&mut &value[..]).map_err(|e| format!("ChainId decode error: {e}").into())
}

pub(crate) struct BuildParachainRpcExtensions<Block, RuntimeApi>(
PhantomData<(Block, RuntimeApi)>,
);

impl<Block, RuntimeApi>
BuildRpcExtensions<
ParachainClient<Block, RuntimeApi>,
ParachainBackend<Block>,
sc_transaction_pool::TransactionPoolHandle<Block, ParachainClient<Block, RuntimeApi>>,
sc_statement_store::Store,
> for BuildParachainRpcExtensions<Block, RuntimeApi>
where
Block: BlockT<Hash = H256, Extrinsic = sp_runtime::OpaqueExtrinsic> + Send + Sync + 'static,
Block::Header:
sp_runtime::traits::Header<Number = u32, Hash = H256> + Unpin + Send + Sync + 'static,
RuntimeApi: ConstructNodeRuntimeApi<Block, ParachainClient<Block, RuntimeApi>>
+ Send
+ Sync
+ 'static,
RuntimeApi::RuntimeApi: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>
+ ReviveRuntimeApiT<Block, u64>,
{
fn build_rpc_extensions(
client: Arc<ParachainClient<Block, RuntimeApi>>,
backend: Arc<ParachainBackend<Block>>,
pool: Arc<
sc_transaction_pool::TransactionPoolHandle<
Block,
ParachainClient<Block, RuntimeApi>,
>,
>,
statement_store: Option<Arc<sc_statement_store::Store>>,
spawn_handle: Arc<dyn sp_core::traits::SpawnNamed>,
) -> sc_service::error::Result<RpcExtension> {
let build = || -> Result<RpcExtension, Box<dyn std::error::Error + Send + Sync>> {
let mut module = RpcExtension::new(());

// Standard parachain RPCs.
module.merge(System::new(client.clone(), pool.clone()).into_rpc())?;
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
module.merge(StateMigration::new(client.clone(), backend).into_rpc())?;
if let Some(statement_store) = statement_store {
module.merge(
StatementStore::new(statement_store, spawn_handle.clone()).into_rpc(),
)?;
}
module.merge(Dev::new(client.clone()).into_rpc())?;

// ETH RPC server.
let best_hash = client.chain_info().best_hash;
match read_revive_chain_id::<Block, _>(&client, best_hash) {
Ok(chain_id) => {
let block_provider = NativeClientBlockInfoProvider::new(client.clone())
.map_err(|e| format!("block info provider: {e}"))?;

let native_client =
NativeSubstrateClient::new(client.clone(), pool, chain_id, false)
.map_err(|e| format!("native substrate client: {e}"))?;

let (bootstrap_tx, bootstrap_rx) = std::sync::mpsc::sync_channel(1);
spawn_handle.spawn(
"eth-rpc-bootstrap",
Some("eth-rpc"),
Box::pin(async move {
let result = build_native_inmemory_client(
native_client,
block_provider,
DEFAULT_KEEP_LATEST_BLOCKS,
false,
)
.await
.map_err(|e| format!("ETH RPC client init: {e}"));
let _ = bootstrap_tx.send(result);
}),
);
let eth_client = bootstrap_rx
.recv()
.map_err(|_| "eth-rpc bootstrap task did not return".to_string())??;

let eth_best = eth_client.clone();
spawn_handle.spawn(
"eth-rpc-best-blocks",
Some("eth-rpc"),
Box::pin(async move {
if let Err(e) = eth_best
.subscribe_and_cache_new_blocks(SubscriptionType::BestBlocks)
.await
{
log::error!(
target: "eth-rpc",
"Best-block subscription error: {e:?}"
);
}
}),
);
let eth_finalized = eth_client.clone();
spawn_handle.spawn(
"eth-rpc-finalized-blocks",
Some("eth-rpc"),
Box::pin(async move {
if let Err(e) = eth_finalized
.subscribe_and_cache_new_blocks(
SubscriptionType::FinalizedBlocks,
)
.await
{
log::error!(
target: "eth-rpc",
"Finalized-block subscription error: {e:?}"
);
}
}),
);

// `include_system_health = false` because the parachain node already
// merges `sc_rpc::system::System` (which exposes `system_health`)
// in `sc_service::gen_rpc_module` — adding the eth-rpc one here
// would fail with a duplicate-method error and tear down the node.
let eth_module = build_eth_rpc_module(false, eth_client, false, false)?;
module.merge(eth_module)?;
},
Err(e) => {
log::debug!(
target: "eth-rpc",
"Revive pallet not found in runtime metadata, ETH RPC disabled: {e}"
);
},
}

Ok(module)
};
build().map_err(Into::into)
}
}
}

pub(crate) trait BuildRpcExtensions<Client, Backend, Pool, StatementStore> {
fn build_rpc_extensions(
client: Arc<Client>,
Expand All @@ -44,44 +226,3 @@ pub(crate) trait BuildRpcExtensions<Client, Backend, Pool, StatementStore> {
spawn_handle: Arc<dyn sp_core::traits::SpawnNamed>,
) -> sc_service::error::Result<RpcExtension>;
}

pub(crate) struct BuildParachainRpcExtensions<Block, RuntimeApi>(PhantomData<(Block, RuntimeApi)>);
Comment thread
Nathy-bajo marked this conversation as resolved.

impl<Block: BlockT, RuntimeApi>
BuildRpcExtensions<
ParachainClient<Block, RuntimeApi>,
ParachainBackend<Block>,
sc_transaction_pool::TransactionPoolHandle<Block, ParachainClient<Block, RuntimeApi>>,
sc_statement_store::Store,
> for BuildParachainRpcExtensions<Block, RuntimeApi>
where
RuntimeApi:
ConstructNodeRuntimeApi<Block, ParachainClient<Block, RuntimeApi>> + Send + Sync + 'static,
RuntimeApi::RuntimeApi: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
{
fn build_rpc_extensions(
client: Arc<ParachainClient<Block, RuntimeApi>>,
backend: Arc<ParachainBackend<Block>>,
pool: Arc<
sc_transaction_pool::TransactionPoolHandle<Block, ParachainClient<Block, RuntimeApi>>,
>,
statement_store: Option<Arc<sc_statement_store::Store>>,
spawn_handle: Arc<dyn sp_core::traits::SpawnNamed>,
) -> sc_service::error::Result<RpcExtension> {
let build = || -> Result<RpcExtension, Box<dyn std::error::Error + Send + Sync>> {
let mut module = RpcExtension::new(());

module.merge(System::new(client.clone(), pool).into_rpc())?;
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
module.merge(StateMigration::new(client.clone(), backend).into_rpc())?;
if let Some(statement_store) = statement_store {
module.merge(StatementStore::new(statement_store, spawn_handle).into_rpc())?;
}
module.merge(Dev::new(client).into_rpc())?;

Ok(module)
};
build().map_err(Into::into)
}
}
Loading
Loading