Skip to content

Commit

Permalink
Bring back support for erigon when debug tracing (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizdave97 authored Jul 5, 2024
1 parent 8e12979 commit 361ed60
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions docs/pages/developers/network/relayer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tesseract/evm/src/gas_oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ pub async fn get_l2_data_cost(

async fn make_request<T: DeserializeOwned>(url: &str, header_map: HeaderMap) -> anyhow::Result<T> {
// 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);
Expand Down
28 changes: 28 additions & 0 deletions tesseract/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<u32>,
/// The client type the rpc is running, defaults to Geth
pub client_type: Option<ClientType>
}

impl EvmConfig {
Expand Down Expand Up @@ -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()
}
}
}
Expand All @@ -109,6 +133,8 @@ pub struct EvmClient {
config: EvmConfig,
/// EVM chain Id.
pub chain_id: u64,
/// Client type
pub client_type: ClientType
}

impl EvmClient {
Expand Down Expand Up @@ -151,6 +177,7 @@ impl EvmClient {
initial_height: latest_height,
config: config_clone,
chain_id,
client_type: config.client_type.unwrap_or_default()
})
}

Expand Down Expand Up @@ -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()
}
}
}
1 change: 1 addition & 0 deletions tesseract/evm/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
13 changes: 10 additions & 3 deletions tesseract/evm/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tesseract/relayer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
Expand Down

0 comments on commit 361ed60

Please sign in to comment.