diff --git a/Cargo.lock b/Cargo.lock index 6607189a0..33a6cff95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20384,7 +20384,7 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "tesseract" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "async-trait", diff --git a/docs/pages/developers/network/relayer.mdx b/docs/pages/developers/network/relayer.mdx index b4fa255a2..a17729d0e 100644 --- a/docs/pages/developers/network/relayer.mdx +++ b/docs/pages/developers/network/relayer.mdx @@ -232,6 +232,13 @@ tracing_batch_size = 5 # 5 transactions would be traced concurrently on this cli # Buffer to add to gas price as a percentage of the current gas price # to increase likelihood of the transactions going through e.g 1%, 2% gas_price_buffer = 1 +# (Optional) +# The execution client implementation only Geth or Erigon are fully supported +# The possible values: +# client_type = Geth +# client_type = Erigon +# If this field is not set, the default is Geth +client_type = Erigon [substrate] type = "substrate" diff --git a/tesseract/evm/src/gas_oracle.rs b/tesseract/evm/src/gas_oracle.rs index efa6eccbe..d9f927b8b 100644 --- a/tesseract/evm/src/gas_oracle.rs +++ b/tesseract/evm/src/gas_oracle.rs @@ -270,7 +270,7 @@ pub async fn get_l2_data_cost( async fn make_request(url: &str, header_map: HeaderMap) -> anyhow::Result { // Retry a request twice in case the response does not deserialize correctly the first time - for _ in 0..2 { + for _ in 0..3 { // Retry up to 3 times with increasing intervals between attempts. let mut retry_policy = ExponentialBackoff::builder().build_with_max_retries(5); retry_policy.max_retry_interval = Duration::from_secs(3 * 60); diff --git a/tesseract/evm/src/lib.rs b/tesseract/evm/src/lib.rs index 25d5aecbb..d023e2536 100644 --- a/tesseract/evm/src/lib.rs +++ b/tesseract/evm/src/lib.rs @@ -33,6 +33,27 @@ pub mod provider; mod test; pub mod tx; +#[derive(Debug, Clone, Serialize, Deserialize)] +pub enum ClientType { + Geth, + Erigon +} + +impl Default for ClientType { + fn default() -> Self { + Self::Geth + } +} + +impl ClientType { + pub fn erigon(&self) -> bool { + match &self { + ClientType::Erigon => true, + _ => false + } + } +} + #[derive(Debug, Clone, Serialize, Deserialize)] pub struct EvmConfig { /// RPC urls for the execution client @@ -58,6 +79,8 @@ pub struct EvmConfig { /// An optional buffer to add to gas price as a percentage of the current gas price /// to increase likelihood of the transactions going through e.g 1%, 2% pub gas_price_buffer: Option, + /// The client type the rpc is running, defaults to Geth + pub client_type: Option } impl EvmConfig { @@ -87,6 +110,7 @@ impl Default for EvmConfig { query_batch_size: Default::default(), poll_interval: Default::default(), gas_price_buffer: Default::default(), + client_type: Default::default() } } } @@ -109,6 +133,8 @@ pub struct EvmClient { config: EvmConfig, /// EVM chain Id. pub chain_id: u64, + /// Client type + pub client_type: ClientType } impl EvmClient { @@ -151,6 +177,7 @@ impl EvmClient { initial_height: latest_height, config: config_clone, chain_id, + client_type: config.client_type.unwrap_or_default() }) } @@ -267,6 +294,7 @@ impl Clone for EvmClient { initial_height: self.initial_height, config: self.config.clone(), chain_id: self.chain_id.clone(), + client_type: self.client_type.clone() } } } diff --git a/tesseract/evm/src/provider.rs b/tesseract/evm/src/provider.rs index 47dbcafc0..86e1362a0 100644 --- a/tesseract/evm/src/provider.rs +++ b/tesseract/evm/src/provider.rs @@ -344,6 +344,7 @@ impl IsmpProvider for EvmClient { use tokio_stream::StreamExt; let messages = _msg.clone(); + // The clients we support(erigon and geth) both use Geth style tracing let debug_trace_call_options = GethDebugTracingCallOptions { tracing_options: GethDebugTracingOptions { disable_storage: Some(true), diff --git a/tesseract/evm/src/tx.rs b/tesseract/evm/src/tx.rs index a4651c3d2..ee13a67f6 100644 --- a/tesseract/evm/src/tx.rs +++ b/tesseract/evm/src/tx.rs @@ -218,7 +218,14 @@ pub async fn generate_contract_calls( let contract = IsmpHandler::new(client.config.handler, client.signer.clone()); let ismp_host = client.config.ismp_host; let mut calls = Vec::new(); - let gas_price = if !debug_trace { + // If debug trace is false or the client type is erigon, then the gas price must be set + // Geth does not require gas price to be set when debug tracing, but the erigon implementation does + // https://github.com/ledgerwatch/erigon/blob/cfb55a3cd44736ac092003be41659cc89061d1be/core/state_transition.go#L246 + // Erigon does not support block overrides when tracing so we don't have the option of omiting the gas price by overriding the base fee + let set_gas_price = || { + !debug_trace || client.client_type.erigon() + }; + let gas_price = if set_gas_price() { get_current_gas_cost_in_usd( client.chain_id, client.state_machine, @@ -288,7 +295,7 @@ pub async fn generate_contract_calls( requests: leaves, }; - let call = if !debug_trace { + let call = if set_gas_price() { contract .handle_post_requests(ismp_host, post_message) .gas_price(gas_price) @@ -352,7 +359,7 @@ pub async fn generate_contract_calls( responses: leaves, }; - if !debug_trace { + if set_gas_price() { contract .handle_post_responses(ismp_host, message) .gas_price(gas_price) diff --git a/tesseract/relayer/Cargo.toml b/tesseract/relayer/Cargo.toml index 816fee0b0..45fdadec0 100644 --- a/tesseract/relayer/Cargo.toml +++ b/tesseract/relayer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tesseract" -version = "0.3.5" +version = "0.3.6" edition = "2021" description = "Chain agnostic relayer implementation for Hyperbridge" authors = ["Polytope Labs "]