Skip to content

Commit dae1b74

Browse files
Merge pull request #3732 from autonomys/add-eth-rpc-farmerless-node
Enable ethereum rpc endpoints for farmerless dev node
2 parents 4dca14d + f45985c commit dae1b74

File tree

3 files changed

+62
-9
lines changed

3 files changed

+62
-9
lines changed

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

domains/test/service/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ include = [
1515
domain-check-weight.workspace = true
1616
auto-id-domain-test-runtime.workspace = true
1717
cross-domain-message-gossip.workspace = true
18+
domain-block-preprocessor.workspace = true
1819
domain-client-operator.workspace = true
20+
domain-eth-service.workspace = true
1921
domain-service.workspace = true
2022
domain-test-primitives.workspace = true
2123
domain-runtime-primitives.workspace = true
@@ -32,6 +34,7 @@ sc-network.workspace = true
3234
sc-network-sync.workspace = true
3335
sc-service.workspace = true
3436
sc-tracing.workspace = true
37+
sc-transaction-pool.workspace = true
3538
sc-transaction-pool-api.workspace = true
3639
sc-utils.workspace = true
3740
serde = { workspace = true, features = ["derive"] }

domains/test/service/src/domain.rs

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ use crate::{
77
UncheckedExtrinsicFor, construct_extrinsic_generic, node_config,
88
};
99
use cross_domain_message_gossip::ChainMsg;
10+
use domain_block_preprocessor::inherents::CreateInherentDataProvider;
1011
use domain_client_operator::snap_sync::ConsensusChainSyncParams;
1112
use domain_client_operator::{BootstrapResult, OperatorStreams, fetch_domain_bootstrap_info};
13+
use domain_eth_service::provider::EthProvider;
14+
use domain_eth_service::{DefaultEthConfig, EthConfiguration};
1215
use domain_runtime_primitives::opaque::Block;
1316
use domain_runtime_primitives::{Balance, EthereumAccountId};
14-
use domain_service::FullClient;
1517
use domain_service::providers::DefaultProvider;
18+
use domain_service::{FullBackend, FullClient, FullPool};
1619
use domain_test_primitives::{EvmOnchainStateApi, OnchainStateApi};
1720
use frame_support::dispatch::{DispatchInfo, PostDispatchInfo};
1821
use frame_system::pallet_prelude::{BlockNumberFor, RuntimeCallFor};
@@ -24,6 +27,7 @@ use sc_network::{NetworkStateInfo, ReputationChange};
2427
use sc_network_sync::SyncingService;
2528
use sc_service::config::MultiaddrWithPeerId;
2629
use sc_service::{BasePath, Role, RpcHandlers, TFullBackend, TaskManager, TransactionPool};
30+
use sc_transaction_pool::FullChainApi;
2731
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
2832
use sc_utils::mpsc::{TracingUnboundedSender, tracing_unbounded};
2933
use sp_api::{ApiExt, ConstructRuntimeApi, Metadata, ProvideRuntimeApi};
@@ -136,7 +140,7 @@ where
136140
AsSystemOriginSigner<<Runtime as frame_system::Config>::AccountId> + Clone,
137141
{
138142
#[allow(clippy::too_many_arguments)]
139-
async fn build(
143+
async fn build<Provider>(
140144
domain_id: DomainId,
141145
tokio_handle: tokio::runtime::Handle,
142146
key: Runtime::Keyring,
@@ -149,7 +153,20 @@ where
149153
mock_consensus_node: &mut MockConsensusNode,
150154
rpc_addr: Option<SocketAddr>,
151155
rpc_port: Option<u16>,
152-
) -> Self {
156+
provider: Provider,
157+
) -> Self
158+
where
159+
Provider: domain_service::providers::BlockImportProvider<Block, Client<RuntimeApi>>
160+
+ domain_service::providers::RpcProvider<
161+
Block,
162+
Client<RuntimeApi>,
163+
FullPool<RuntimeApi>,
164+
FullChainApi<Client<RuntimeApi>, Block>,
165+
Backend,
166+
<Runtime as DomainRuntime>::AccountId,
167+
CreateInherentDataProvider<subspace_test_client::Client, CBlock>,
168+
> + 'static,
169+
{
153170
let mut domain_config = node_config(
154171
domain_id,
155172
tokio_handle.clone(),
@@ -245,7 +262,7 @@ where
245262
operator_streams,
246263
gossip_message_sink: gossip_msg_sink,
247264
domain_message_receiver,
248-
provider: DefaultProvider,
265+
provider,
249266
skip_empty_bundle_production,
250267
skip_out_of_order_slot: true,
251268
maybe_operator_id,
@@ -641,22 +658,47 @@ impl DomainNodeBuilder {
641658
self
642659
}
643660

661+
fn evm_eth_provider(
662+
base_path: &std::path::Path,
663+
) -> EthProvider<
664+
evm_domain_test_runtime::TransactionConverter,
665+
DefaultEthConfig<
666+
FullClient<Block, evm_domain_test_runtime::RuntimeApi>,
667+
FullBackend<Block>,
668+
>,
669+
> {
670+
EthProvider::with_configuration(
671+
Some(base_path),
672+
EthConfiguration {
673+
max_past_logs: 10000,
674+
fee_history_limit: 2048,
675+
enable_dev_signer: true,
676+
target_gas_price: 1,
677+
execute_gas_limit_multiplier: 10,
678+
eth_log_block_cache: 50,
679+
eth_statuses_cache: 50,
680+
},
681+
)
682+
}
683+
644684
/// Build an EVM domain node
645685
pub async fn build_evm_node(
646686
self,
647687
role: Role,
648688
key: EcdsaKeyring,
649689
mock_consensus_node: &mut MockConsensusNode,
650690
) -> EvmDomainNode {
691+
let domain_base_path = self
692+
.base_path
693+
.path()
694+
.join(format!("domain-{EVM_DOMAIN_ID}"));
695+
let eth_provider = Self::evm_eth_provider(&domain_base_path);
696+
651697
DomainNode::build(
652698
EVM_DOMAIN_ID,
653699
self.tokio_handle,
654700
key,
655-
BasePath::new(
656-
self.base_path
657-
.path()
658-
.join(format!("domain-{EVM_DOMAIN_ID}")),
659-
),
701+
BasePath::new(domain_base_path),
660702
self.domain_nodes,
661703
self.domain_nodes_exclusive,
662704
self.skip_empty_bundle_production,
@@ -665,6 +707,7 @@ impl DomainNodeBuilder {
665707
mock_consensus_node,
666708
self.rpc_addr,
667709
self.rpc_port,
710+
eth_provider,
668711
)
669712
.await
670713
}
@@ -693,6 +736,7 @@ impl DomainNodeBuilder {
693736
mock_consensus_node,
694737
self.rpc_addr,
695738
self.rpc_port,
739+
DefaultProvider,
696740
)
697741
.await
698742
}
@@ -705,6 +749,8 @@ impl DomainNodeBuilder {
705749
mock_consensus_node: &mut MockConsensusNode,
706750
domain_id: DomainId,
707751
) -> EvmDomainNode {
752+
let eth_provider = Self::evm_eth_provider(self.base_path.path());
753+
708754
DomainNode::build(
709755
domain_id,
710756
self.tokio_handle,
@@ -718,6 +764,7 @@ impl DomainNodeBuilder {
718764
mock_consensus_node,
719765
self.rpc_addr,
720766
self.rpc_port,
767+
eth_provider,
721768
)
722769
.await
723770
}

0 commit comments

Comments
 (0)