Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/nightly' into rakanalh/verify-ch…
Browse files Browse the repository at this point in the history
…unked-txs
  • Loading branch information
rakanalh committed Dec 21, 2024
2 parents bae6c56 + 6428659 commit b75acbd
Show file tree
Hide file tree
Showing 12 changed files with 578 additions and 791 deletions.
1 change: 1 addition & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ jobs:
validate_and_check_DA_ID:
runs-on: ubicloud-standard-2
needs: build
continue-on-error: true
steps:
- uses: actions/checkout@v4

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

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

13 changes: 1 addition & 12 deletions bin/citrea/src/eth.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::str::FromStr;
use std::sync::Arc;

use anyhow::Context as _;
Expand All @@ -20,15 +19,13 @@ pub(crate) fn register_ethereum<Da: DaService>(
soft_confirmation_rx: Option<broadcast::Receiver<u64>>,
) -> Result<(), anyhow::Error> {
let eth_rpc_config = {
let eth_signer = eth_dev_signer();
EthRpcConfig {
eth_signer,
gas_price_oracle_config: GasPriceOracleConfig::default(),
fee_history_cache_config: FeeHistoryCacheConfig::default(),
}
};

let ethereum_rpc = ethereum_rpc::get_ethereum_rpc::<DefaultContext, Da>(
let ethereum_rpc = ethereum_rpc::create_rpc_module::<DefaultContext, Da>(
da_service,
eth_rpc_config,
storage,
Expand All @@ -40,11 +37,3 @@ pub(crate) fn register_ethereum<Da: DaService>(
.merge(ethereum_rpc)
.context("Failed to merge Ethereum RPC modules")
}

// TODO: #840
fn eth_dev_signer() -> ethereum_rpc::DevSigner {
ethereum_rpc::DevSigner::new(vec![secp256k1::SecretKey::from_str(
"ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
)
.unwrap()])
}
6 changes: 0 additions & 6 deletions bin/citrea/tests/evm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,6 @@ async fn execute(client: &Box<TestClient>) -> Result<(), Box<dyn std::error::Err
pub async fn init_test_rollup(rpc_address: SocketAddr) -> Box<TestClient> {
let test_client = make_test_client(rpc_address).await.unwrap();

let etc_accounts = test_client.eth_accounts().await;
assert_eq!(
vec![Address::from_str("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266").unwrap()],
etc_accounts
);

let eth_chain_id = test_client.eth_chain_id().await;
assert_eq!(5655, eth_chain_id);

Expand Down
44 changes: 38 additions & 6 deletions bin/citrea/tests/evm/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use alloy_primitives::Address;
use alloy_rpc_types_trace::geth::GethTrace::{self, CallTracer, FourByteTracer};
use alloy_rpc_types_trace::geth::{
CallConfig, CallFrame, FourByteFrame, GethDebugBuiltInTracerType, GethDebugTracerType,
GethDebugTracingOptions,
GethDebugTracingOptions, TraceResult,
};
use citrea_common::SequencerConfig;
use citrea_evm::smart_contracts::{CallerContract, SimpleStorageContract};
Expand Down Expand Up @@ -222,7 +222,14 @@ async fn tracing_tests() -> Result<(), Box<dyn std::error::Error>> {
GethDebugTracerType::BuiltInTracer(GethDebugBuiltInTracerType::CallTracer),
)),
)
.await;
.await
.into_iter()
.map(|trace| match trace {
TraceResult::Success { result, .. } => Ok(result),
_ => anyhow::bail!("Unexpected trace result"),
})
.collect::<Result<Vec<_>, _>>()?;

assert_eq!(traces.len(), 2);
assert_eq!(traces[1], CallTracer(expected_send_eth_trace.clone()));
assert_eq!(traces[0], CallTracer(expected_call_get_trace.clone()));
Expand All @@ -240,7 +247,13 @@ async fn tracing_tests() -> Result<(), Box<dyn std::error::Error>> {
GethDebugTracerType::BuiltInTracer(GethDebugBuiltInTracerType::CallTracer),
)),
)
.await;
.await
.into_iter()
.map(|trace| match trace {
TraceResult::Success { result, .. } => Ok(result),
_ => anyhow::bail!("Unexpected trace result"),
})
.collect::<Result<Vec<_>, _>>()?;

assert_eq!(traces.len(), 2);
assert_eq!(traces[1], CallTracer(expected_send_eth_trace.clone()));
Expand All @@ -253,7 +266,13 @@ async fn tracing_tests() -> Result<(), Box<dyn std::error::Error>> {
GethDebugTracerType::BuiltInTracer(GethDebugBuiltInTracerType::FourByteTracer),
)),
)
.await;
.await
.into_iter()
.map(|trace| match trace {
TraceResult::Success { result, .. } => Ok(result),
_ => anyhow::bail!("Unexpected trace result"),
})
.collect::<Result<Vec<_>, _>>()?;

let expected_call_get_4byte_trace =
serde_json::from_value::<FourByteFrame>(json![{"35c152bd-32": 1, "6d4ce63c-0": 1}])
Expand Down Expand Up @@ -285,7 +304,13 @@ async fn tracing_tests() -> Result<(), Box<dyn std::error::Error>> {
}),
),
)
.await;
.await
.into_iter()
.map(|trace| match trace {
TraceResult::Success { result, .. } => Ok(result),
_ => anyhow::bail!("Unexpected trace result"),
})
.collect::<Result<Vec<_>, _>>()?;

let expected_top_call_only_call_get_trace = serde_json::from_value::<CallFrame>(
json![{"from":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","gas":"0x1886","gasUsed":"0x6b64","to":"0xe7f1725e7734ce288f8367e1bb143e90bb3f0512",
Expand Down Expand Up @@ -313,7 +338,14 @@ async fn tracing_tests() -> Result<(), Box<dyn std::error::Error>> {
GethDebugTracerType::BuiltInTracer(GethDebugBuiltInTracerType::CallTracer),
)),
)
.await;
.await
.into_iter()
.map(|trace| match trace {
TraceResult::Success { result, .. } => Ok(result),
_ => anyhow::bail!("Unexpected trace result"),
})
.collect::<Result<Vec<_>, _>>()?;

assert_eq!(traces.len(), 8);
assert_eq!(traces[5], CallTracer(reth_json));
assert_eq!(traces[6], CallTracer(expected_call_get_trace));
Expand Down
17 changes: 5 additions & 12 deletions bin/citrea/tests/test_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use alloy::transports::http::{Http, HyperClient};
use alloy_primitives::{Address, Bytes, TxHash, TxKind, B256, U256, U64};
// use reth_rpc_types::TransactionReceipt;
use alloy_rpc_types::AnyNetworkBlock;
use alloy_rpc_types_trace::geth::{GethDebugTracingOptions, GethTrace};
use alloy_rpc_types_trace::geth::{GethDebugTracingOptions, GethTrace, TraceResult};
use citrea_batch_prover::GroupCommitments;
use citrea_evm::{Filter, LogResponse};
use ethereum_rpc::SyncStatus;
Expand Down Expand Up @@ -307,13 +307,6 @@ impl TestClient {
.unwrap()
}

pub(crate) async fn eth_accounts(&self) -> Vec<Address> {
self.http_client
.request("eth_accounts", rpc_params![])
.await
.unwrap()
}

pub(crate) async fn eth_chain_id(&self) -> u64 {
self.client.get_chain_id().await.unwrap()
}
Expand Down Expand Up @@ -608,7 +601,7 @@ impl TestClient {
&self,
block_number: BlockNumberOrTag,
opts: Option<GethDebugTracingOptions>,
) -> Vec<GethTrace> {
) -> Vec<TraceResult> {
self.http_client
.request("debug_traceBlockByNumber", rpc_params![block_number, opts])
.await
Expand All @@ -619,7 +612,7 @@ impl TestClient {
&self,
block_hash: B256,
opts: Option<GethDebugTracingOptions>,
) -> Vec<GethTrace> {
) -> Vec<TraceResult> {
self.http_client
.request("debug_traceBlockByHash", rpc_params![block_hash, opts])
.await
Expand All @@ -631,7 +624,7 @@ impl TestClient {
start_block: BlockNumberOrTag,
end_block: BlockNumberOrTag,
opts: Option<GethDebugTracingOptions>,
) -> Vec<GethTrace> {
) -> Vec<TraceResult> {
let mut subscription = self
.ws_client
.subscribe(
Expand All @@ -650,7 +643,7 @@ impl TestClient {
BlockNumberOrTag::Latest => self.eth_block_number().await,
_ => panic!("Only number and latest"),
};
let mut traces: Vec<Vec<GethTrace>> = vec![];
let mut traces: Vec<Vec<TraceResult>> = vec![];
for _ in start_block..end_block {
let block_traces = subscription.next().await.unwrap().unwrap();
traces.push(block_traces);
Expand Down
5 changes: 1 addition & 4 deletions crates/ethereum-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ resolver = "2"
[dependencies]
# 3rd-party dependencies
anyhow = { workspace = true }
async-trait = { workspace = true }
borsh = { workspace = true }
citrea-evm = { path = "../evm", features = ["native"] }
citrea-primitives = { path = "../primitives" }
Expand Down Expand Up @@ -46,7 +47,3 @@ sov-rollup-interface = { path = "../sovereign-sdk/rollup-interface", features =

[dev-dependencies]
tokio = { workspace = true }

[features]
default = ["local"]
local = []
13 changes: 2 additions & 11 deletions crates/ethereum-rpc/src/ethereum.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::sync::{Arc, Mutex};

use alloy_primitives::U256;
use alloy_rpc_types_trace::geth::GethTrace;
#[cfg(feature = "local")]
use citrea_evm::DevSigner;
use alloy_rpc_types_trace::geth::TraceResult;
use citrea_evm::Evm;
use jsonrpsee::http_client::HttpClient;
use rustc_version_runtime::version;
Expand All @@ -26,21 +24,17 @@ const DEFAULT_PRIORITY_FEE: U256 = U256::from_limbs([100, 0, 0, 0]);
pub struct EthRpcConfig {
pub gas_price_oracle_config: GasPriceOracleConfig,
pub fee_history_cache_config: FeeHistoryCacheConfig,
#[cfg(feature = "local")]
pub eth_signer: DevSigner,
}

pub struct Ethereum<C: sov_modules_api::Context, Da: DaService> {
#[allow(dead_code)]
pub(crate) da_service: Arc<Da>,
pub(crate) gas_price_oracle: GasPriceOracle<C>,
#[cfg(feature = "local")]
pub(crate) eth_signer: DevSigner,
pub(crate) storage: C::Storage,
pub(crate) ledger_db: LedgerDB,
pub(crate) sequencer_client: Option<HttpClient>,
pub(crate) web3_client_version: String,
pub(crate) trace_cache: Mutex<LruMap<u64, Vec<GethTrace>, ByLength>>,
pub(crate) trace_cache: Mutex<LruMap<u64, Vec<TraceResult>, ByLength>>,
pub(crate) subscription_manager: Option<SubscriptionManager>,
}

Expand All @@ -50,7 +44,6 @@ impl<C: sov_modules_api::Context, Da: DaService> Ethereum<C, Da> {
da_service: Arc<Da>,
gas_price_oracle_config: GasPriceOracleConfig,
fee_history_cache_config: FeeHistoryCacheConfig,
#[cfg(feature = "local")] eth_signer: DevSigner,
storage: C::Storage,
ledger_db: LedgerDB,
sequencer_client: Option<HttpClient>,
Expand All @@ -74,8 +67,6 @@ impl<C: sov_modules_api::Context, Da: DaService> Ethereum<C, Da> {
Self {
da_service,
gas_price_oracle,
#[cfg(feature = "local")]
eth_signer,
storage,
ledger_db,
sequencer_client,
Expand Down
Loading

0 comments on commit b75acbd

Please sign in to comment.