diff --git a/template/node/src/service.rs b/template/node/src/service.rs index 778fc94ffa..5bc361d11c 100644 --- a/template/node/src/service.rs +++ b/template/node/src/service.rs @@ -27,7 +27,7 @@ type FullBackend = sc_service::TFullBackend; type FullSelectChain = sc_consensus::LongestChain; pub enum ConsensusResult { - Aura(( + Aura( sc_consensus_aura::AuraBlockImport< Block, FullClient, @@ -39,8 +39,8 @@ pub enum ConsensusResult { AuraPair >, sc_finality_grandpa::LinkHalf - )), - ManualSeal + ), + ManualSeal(FrontierBlockImport, FullClient>) } pub fn new_partial(config: &Configuration, manual_seal: bool) -> Result< @@ -71,8 +71,14 @@ pub fn new_partial(config: &Configuration, manual_seal: bool) -> Result< .map_err(Into::into) .map_err(sp_consensus::error::Error::InherentData)?; + let frontier_block_import = FrontierBlockImport::new( + client.clone(), + client.clone(), + true, + ); + let import_queue = sc_consensus_manual_seal::import_queue( - Box::new(client.clone()), + Box::new(frontier_block_import.clone()), &task_manager.spawn_handle(), config.prometheus_registry(), ); @@ -80,7 +86,7 @@ pub fn new_partial(config: &Configuration, manual_seal: bool) -> Result< return Ok(sc_service::PartialComponents { client, backend, task_manager, import_queue, keystore, select_chain, transaction_pool, inherent_data_providers, - other: ConsensusResult::ManualSeal + other: ConsensusResult::ManualSeal(frontier_block_import) }) } @@ -113,7 +119,7 @@ pub fn new_partial(config: &Configuration, manual_seal: bool) -> Result< Ok(sc_service::PartialComponents { client, backend, task_manager, import_queue, keystore, select_chain, transaction_pool, inherent_data_providers, - other: ConsensusResult::Aura((aura_block_import, grandpa_link)) + other: ConsensusResult::Aura(aura_block_import, grandpa_link) }) } @@ -126,7 +132,7 @@ pub fn new_full(config: Configuration, manual_seal: bool) -> Result { + ConsensusResult::ManualSeal(_) => { sc_service::build_network(sc_service::BuildNetworkParams { config: &config, client: client.clone(), @@ -139,7 +145,7 @@ pub fn new_full(config: Configuration, manual_seal: bool) -> Result { + ConsensusResult::Aura(_, _) => { sc_service::build_network(sc_service::BuildNetworkParams { config: &config, client: client.clone(), @@ -203,7 +209,7 @@ pub fn new_full(config: Configuration, manual_seal: bool) -> Result { + ConsensusResult::ManualSeal(block_import) => { if role.is_authority() { let env = sc_basic_authorship::ProposerFactory::new( client.clone(), @@ -214,7 +220,7 @@ pub fn new_full(config: Configuration, manual_seal: bool) -> Result Result { + ConsensusResult::Aura(aura_block_import, grandpa_link) => { if role.is_authority() { let proposer = sc_basic_authorship::ProposerFactory::new( client.clone(), diff --git a/ts-tests/tests/test-block.ts b/ts-tests/tests/test-block.ts index ea5b0a91ea..e92b722f57 100644 --- a/ts-tests/tests/test-block.ts +++ b/ts-tests/tests/test-block.ts @@ -106,6 +106,17 @@ describeWithFrontier("Frontier RPC (Block)", `simple-specs.json`, (context) => { expect(block.timestamp).to.be.a("number"); }); + step("get block by hash", async function() { + const latest_block = await context.web3.eth.getBlock("latest"); + const block = await context.web3.eth.getBlock(latest_block.hash); + expect(block.hash).to.be.eq(latest_block.hash); + }); + + step("get block by number", async function() { + const block = await context.web3.eth.getBlock(1); + expect(block).not.null; + }); + it.skip("should include previous block hash as parent", async function () { this.timeout(15000); await createAndFinalizeBlock(context.web3); diff --git a/ts-tests/tests/test-contract-methods.ts b/ts-tests/tests/test-contract-methods.ts index 525f6bed0f..6b36029f57 100644 --- a/ts-tests/tests/test-contract-methods.ts +++ b/ts-tests/tests/test-contract-methods.ts @@ -39,6 +39,15 @@ describeWithFrontier("Frontier RPC (Contract Methods)", `simple-specs.json`, (co await createAndFinalizeBlock(context.web3); }); + it("get transaction by hash", async () => { + const latestBlock = await context.web3.eth.getBlock("latest"); + expect(latestBlock.transactions.length).to.equal(1); + + const tx_hash = latestBlock.transactions[0]; + const tx = await context.web3.eth.getTransaction(tx_hash); + expect(tx.hash).to.equal(tx_hash); + }); + it("should return contract method result", async function () { const contract = new context.web3.eth.Contract([TEST_CONTRACT_ABI], FIRST_CONTRACT_ADDRESS, { from: GENESIS_ACCOUNT,