From 8889ae99dbbf0ff63e2c46fd9239e0e0bc770537 Mon Sep 17 00:00:00 2001 From: greged93 <82421016+greged93@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:31:55 +0100 Subject: [PATCH] dev: set minimal base fee at start up (#1505) set the minimal base fee at rpc start up Signed-off-by: Gregory Edison --- src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index dedf9397f..888acb7ae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,13 +7,16 @@ use kakarot_rpc::{ constants::{KAKAROT_RPC_CONFIG, RPC_CONFIG}, eth_rpc::{rpc::KakarotRpcModuleBuilder, run_server}, pool::mempool::{maintain_transaction_pool, AccountManager}, - providers::eth_provider::database::Database, + providers::eth_provider::{ + database::Database, + starknet::kakarot_core::{core::KakarotCoreReader, KAKAROT_ADDRESS}, + }, }; use mongodb::options::{DatabaseOptions, ReadConcern, WriteConcern}; use opentelemetry_sdk::runtime::Tokio; use reth_transaction_pool::PoolConfig; use starknet::{ - core::types::Felt, + core::types::{BlockId, BlockTag, Felt}, providers::{jsonrpc::HttpTransport, JsonRpcClient}, }; use tracing_opentelemetry::MetricsLayer; @@ -46,9 +49,12 @@ async fn main() -> Result<()> { let starknet_provider = Arc::new(starknet_provider); // Get the pool config - // TODO call Kakarot.get_base_fee - let config = PoolConfig { minimal_protocol_basefee: 0, ..Default::default() }; + let contract_reader = KakarotCoreReader::new(*KAKAROT_ADDRESS, starknet_provider.clone()); + let base_fee = contract_reader.get_base_fee().block_id(BlockId::Tag(BlockTag::Pending)).call().await?.base_fee; + let base_fee = base_fee.try_into()?; + let config = PoolConfig { minimal_protocol_basefee: base_fee, ..Default::default() }; + // Init the Ethereum Client let eth_client = EthClient::new(starknet_provider, config, db.clone()); let eth_client = Arc::new(eth_client);