Skip to content

Commit

Permalink
Fix pending runtime api
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest committed Oct 9, 2024
1 parent e9c5fad commit 38503ae
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions 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 @@ -107,6 +107,7 @@ cumulus-primitives-core = { git = "https://github.com/darwini
cumulus-primitives-parachain-inherent = { git = "https://github.com/darwinia-network/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
cumulus-primitives-utility = { git = "https://github.com/darwinia-network/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
cumulus-relay-chain-interface = { git = "https://github.com/darwinia-network/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
cumulus-test-relay-sproof-builder = { git = "https://github.com/darwinia-network/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
frame-benchmarking = { git = "https://github.com/darwinia-network/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
frame-benchmarking-cli = { git = "https://github.com/darwinia-network/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
frame-executive = { git = "https://github.com/darwinia-network/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ cumulus-primitives-aura = { workspace = true, features = ["std"] }
cumulus-primitives-core = { workspace = true, features = ["std"] }
cumulus-primitives-parachain-inherent = { workspace = true, features = ["std"] }
cumulus-relay-chain-interface = { workspace = true }
cumulus-test-relay-sproof-builder = { workspace = true }
frame-benchmarking = { workspace = true, optional = true, features = ["std"] }
frame-benchmarking-cli = { workspace = true }
pallet-transaction-payment-rpc = { workspace = true }
Expand Down
17 changes: 16 additions & 1 deletion node/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ use futures::FutureExt;
// darwinia
use dc_primitives::*;
// polkadot-sdk
use cumulus_primitives_core::PersistedValidationData;
use cumulus_primitives_parachain_inherent::ParachainInherentData;
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
use sc_client_api::{Backend, HeaderBackend};
use sc_consensus::ImportQueue;
use sc_network::NetworkBlock;
Expand Down Expand Up @@ -905,7 +908,19 @@ where
*timestamp,
slot_duration,
);
Ok((slot, timestamp))
let (relay_parent_storage_root, relay_chain_state) =
RelayStateSproofBuilder::default().into_state_root_and_proof();
let parachain_inherent_data = ParachainInherentData {
validation_data: PersistedValidationData {
relay_parent_number: u32::MAX,
relay_parent_storage_root,
..Default::default()
},
relay_chain_state,
downward_messages: Default::default(),
horizontal_messages: Default::default(),
};
Ok((slot, timestamp, parachain_inherent_data))
};

Box::new(move |deny_unsafe, subscription_task_executor| {
Expand Down
11 changes: 11 additions & 0 deletions tests/ethereum/test-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ describe("Test Block RPC", () => {
expect(await web3.eth.getBlockNumber()).to.not.equal(0);
});

it("Get block by tags", async () => {
let earliest = await web3.eth.getBlock("earliest");
expect(earliest.number).to.equal(0);

let latest = await web3.eth.getBlock("latest");
expect(latest.number).to.be.a("number");

let pending = await web3.eth.getBlock("pending");
expect(pending.number).to.be.a("number");
});

it("Get block by hash", async () => {
let latest_block = await web3.eth.getBlock("latest");
let block = await web3.eth.getBlock(latest_block.hash);
Expand Down

0 comments on commit 38503ae

Please sign in to comment.