From bd0362e33a43659b32656235184cc1450af3c9fa Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 22 Mar 2024 22:42:38 +0800 Subject: [PATCH 1/7] Fix: calc l1 fee unconditionally but deduct only if tx is ok (#283) --- .../module-implementations/sov-evm/src/evm/handler.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/module-system/module-implementations/sov-evm/src/evm/handler.rs b/module-system/module-implementations/sov-evm/src/evm/handler.rs index 6c9e6d3f8..7cd063c47 100644 --- a/module-system/module-implementations/sov-evm/src/evm/handler.rs +++ b/module-system/module-implementations/sov-evm/src/evm/handler.rs @@ -103,11 +103,12 @@ impl CitreaHandler { context: &mut Context, result: FrameResult, ) -> Result::Error>> { - if !result.interpreter_result().is_error() { - let diff_size = calc_diff_size(context).map_err(EVMError::Database)? as u64; - let l1_fee_rate = U256::from(context.external.l1_fee_rate()); - let l1_fee = U256::from(diff_size) * l1_fee_rate; - context.external.set_tx_info(TxInfo { diff_size }); + let diff_size = calc_diff_size(context).map_err(EVMError::Database)? as u64; + let l1_fee_rate = U256::from(context.external.l1_fee_rate()); + let l1_fee = U256::from(diff_size) * l1_fee_rate; + context.external.set_tx_info(TxInfo { diff_size }); + if result.interpreter_result().is_ok() { + // Deduct L1 fee only if tx is successful. if let Some(_out_of_funds) = decrease_caller_balance(context, l1_fee)? { return Err(EVMError::Custom(format!( "Not enought funds for L1 fee: {}", From afca077515c56fa8f270d9dbfc1175ec8794046a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Talip=20Akal=C4=B1n?= <56600661+otaliptus@users.noreply.github.com> Date: Mon, 25 Mar 2024 15:42:05 +0300 Subject: [PATCH 2/7] Implement soft batch save for full nodes (#289) * Init * Add test * Lint fix * PR Fixes * Change name * Add execute blocks * Increase sync time --- .../demo-rollup/bitcoin_rollup_config.toml | 1 + .../demo-rollup/celestia_rollup_config.toml | 4 +- .../mock_dockerized_rollup_config.toml | 1 + examples/demo-rollup/mock_rollup_config.toml | 1 + .../demo-rollup/mocknet_rollup_config.toml | 1 + examples/demo-rollup/tests/e2e/mod.rs | 106 ++++++++++++++++++ .../demo-rollup/tests/evm/archival_state.rs | 1 + examples/demo-rollup/tests/evm/gas_price.rs | 1 + examples/demo-rollup/tests/evm/mod.rs | 3 + examples/demo-rollup/tests/evm/tracing.rs | 1 + examples/demo-rollup/tests/mempool/mod.rs | 1 + .../tests/sequencer_commitments/mod.rs | 1 + .../soft_confirmation_rule_enforcer/mod.rs | 1 + examples/demo-rollup/tests/test_helpers.rs | 3 + full-node/chainway-sequencer/src/sequencer.rs | 3 +- full-node/db/sov-db/src/ledger_db/mod.rs | 4 +- full-node/sov-stf-runner/src/config.rs | 4 + full-node/sov-stf-runner/src/runner.rs | 6 +- .../tests/runner_initialization_tests.rs | 2 + .../tests/runner_reorg_tests.rs | 2 + .../sov-modules-rollup-blueprint/src/lib.rs | 1 + 21 files changed, 142 insertions(+), 6 deletions(-) diff --git a/examples/demo-rollup/bitcoin_rollup_config.toml b/examples/demo-rollup/bitcoin_rollup_config.toml index 83a7f7ba0..746db006c 100644 --- a/examples/demo-rollup/bitcoin_rollup_config.toml +++ b/examples/demo-rollup/bitcoin_rollup_config.toml @@ -1,5 +1,6 @@ sequencer_public_key = "0000000000000000000000000000000000000000000000000000000000000000" min_soft_confirmations_per_commitment = 1000 +include_tx_body = false [da] node_url = "http://localhost:38332" diff --git a/examples/demo-rollup/celestia_rollup_config.toml b/examples/demo-rollup/celestia_rollup_config.toml index e950ee8c5..22368d078 100644 --- a/examples/demo-rollup/celestia_rollup_config.toml +++ b/examples/demo-rollup/celestia_rollup_config.toml @@ -1,3 +1,5 @@ +include_tx_body = false + [da] # The JWT used to authenticate with the celestia light client. Instructions for generating this token can be found in the README celestia_rpc_auth_token = "MY.SECRET.TOKEN" @@ -23,4 +25,4 @@ bind_host = "127.0.0.1" bind_port = 12345 [prover_service] -aggregated_proof_block_jump = 1 \ No newline at end of file +aggregated_proof_block_jump = 1 diff --git a/examples/demo-rollup/mock_dockerized_rollup_config.toml b/examples/demo-rollup/mock_dockerized_rollup_config.toml index c901a57aa..668fa583e 100644 --- a/examples/demo-rollup/mock_dockerized_rollup_config.toml +++ b/examples/demo-rollup/mock_dockerized_rollup_config.toml @@ -1,4 +1,5 @@ sequencer_public_key = "204040e364c10f2bec9c1fe500a1cd4c247c89d650a01ed7e82caba867877c21" +include_tx_body = false [da] sender_address = "0000000000000000000000000000000000000000000000000000000000000000" diff --git a/examples/demo-rollup/mock_rollup_config.toml b/examples/demo-rollup/mock_rollup_config.toml index ebc2f2338..040cdb09a 100644 --- a/examples/demo-rollup/mock_rollup_config.toml +++ b/examples/demo-rollup/mock_rollup_config.toml @@ -1,4 +1,5 @@ sequencer_public_key = "204040e364c10f2bec9c1fe500a1cd4c247c89d650a01ed7e82caba867877c21" +include_tx_body = false [da] sender_address = "0000000000000000000000000000000000000000000000000000000000000000" diff --git a/examples/demo-rollup/mocknet_rollup_config.toml b/examples/demo-rollup/mocknet_rollup_config.toml index 156733c42..a5e83f8d1 100644 --- a/examples/demo-rollup/mocknet_rollup_config.toml +++ b/examples/demo-rollup/mocknet_rollup_config.toml @@ -1,5 +1,6 @@ sequencer_public_key = "204040e364c10f2bec9c1fe500a1cd4c247c89d650a01ed7e82caba867877c21" min_soft_confirmations_per_commitment = 1000 +include_tx_body = false [da] sender_address = "0000000000000000000000000000000000000000000000000000000000000000" diff --git a/examples/demo-rollup/tests/e2e/mod.rs b/examples/demo-rollup/tests/e2e/mod.rs index 4a4592613..fa625a96e 100644 --- a/examples/demo-rollup/tests/e2e/mod.rs +++ b/examples/demo-rollup/tests/e2e/mod.rs @@ -55,6 +55,7 @@ async fn initialize_test( NodeMode::SequencerNode, None, config.seq_min_soft_confirmations, + true, ) .await; }); @@ -75,6 +76,7 @@ async fn initialize_test( NodeMode::FullNode(seq_port), None, DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); @@ -91,6 +93,101 @@ async fn initialize_test( ) } +#[tokio::test] +async fn test_soft_batch_save() -> Result<(), anyhow::Error> { + let config = TestConfig::default(); + + let (seq_port_tx, seq_port_rx) = tokio::sync::oneshot::channel(); + + let seq_task = tokio::spawn(async move { + start_rollup( + seq_port_tx, + GenesisPaths::from_dir("../test-data/genesis/integration-tests"), + BasicKernelGenesisPaths { + chain_state: "../test-data/genesis/integration-tests/chain_state.json".into(), + }, + RollupProverConfig::Execute, + NodeMode::SequencerNode, + None, + config.seq_min_soft_confirmations, + true, + ) + .await; + }); + + let seq_port = seq_port_rx.await.unwrap(); + let seq_test_client = init_test_rollup(seq_port).await; + + let (full_node_port_tx, full_node_port_rx) = tokio::sync::oneshot::channel(); + + let full_node_task = tokio::spawn(async move { + start_rollup( + full_node_port_tx, + GenesisPaths::from_dir("../test-data/genesis/integration-tests"), + BasicKernelGenesisPaths { + chain_state: "../test-data/genesis/integration-tests/chain_state.json".into(), + }, + RollupProverConfig::Execute, + NodeMode::FullNode(seq_port), + None, + DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, + ) + .await; + }); + + let full_node_port = full_node_port_rx.await.unwrap(); + let full_node_test_client = make_test_client(full_node_port).await; + + let _ = execute_blocks(&seq_test_client, &full_node_test_client).await; + + sleep(Duration::from_secs(10)).await; + + let (full_node_port_tx_2, full_node_port_rx_2) = tokio::sync::oneshot::channel(); + + let full_node_task_2 = tokio::spawn(async move { + start_rollup( + full_node_port_tx_2, + GenesisPaths::from_dir("../test-data/genesis/integration-tests"), + BasicKernelGenesisPaths { + chain_state: "../test-data/genesis/integration-tests/chain_state.json".into(), + }, + RollupProverConfig::Execute, + NodeMode::FullNode(full_node_port), + None, + DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + false, + ) + .await; + }); + + let full_node_port_2 = full_node_port_rx_2.await.unwrap(); + let full_node_test_client_2 = make_test_client(full_node_port_2).await; + + sleep(Duration::from_secs(20)).await; + + let seq_block = seq_test_client + .eth_get_block_by_number(Some(BlockNumberOrTag::Latest)) + .await; + let full_node_block = full_node_test_client + .eth_get_block_by_number(Some(BlockNumberOrTag::Latest)) + .await; + let full_node_block_2 = full_node_test_client_2 + .eth_get_block_by_number(Some(BlockNumberOrTag::Latest)) + .await; + + assert_eq!(seq_block.state_root, full_node_block.state_root); + assert_eq!(full_node_block.state_root, full_node_block_2.state_root); + assert_eq!(seq_block.hash, full_node_block.hash); + assert_eq!(full_node_block.hash, full_node_block_2.hash); + + seq_task.abort(); + full_node_task.abort(); + full_node_task_2.abort(); + + Ok(()) +} + #[tokio::test] async fn test_full_node_send_tx() -> Result<(), anyhow::Error> { // sov_demo_rollup::initialize_logging(); @@ -142,6 +239,7 @@ async fn test_delayed_sync_ten_blocks() -> Result<(), anyhow::Error> { NodeMode::SequencerNode, None, DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); @@ -172,6 +270,7 @@ async fn test_delayed_sync_ten_blocks() -> Result<(), anyhow::Error> { NodeMode::FullNode(seq_port), None, DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); @@ -233,6 +332,7 @@ async fn test_close_and_reopen_full_node() -> Result<(), anyhow::Error> { NodeMode::SequencerNode, None, DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); @@ -253,6 +353,7 @@ async fn test_close_and_reopen_full_node() -> Result<(), anyhow::Error> { NodeMode::FullNode(seq_port), Some("demo_data_test_close_and_reopen_full_node"), DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); @@ -332,6 +433,7 @@ async fn test_close_and_reopen_full_node() -> Result<(), anyhow::Error> { NodeMode::FullNode(seq_port), Some("demo_data_test_close_and_reopen_full_node_copy"), DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); @@ -384,6 +486,7 @@ async fn test_get_transaction_by_hash() -> Result<(), anyhow::Error> { NodeMode::SequencerNode, None, DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); @@ -403,6 +506,7 @@ async fn test_get_transaction_by_hash() -> Result<(), anyhow::Error> { NodeMode::FullNode(seq_port), None, DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); @@ -636,6 +740,7 @@ async fn test_reopen_sequencer() -> Result<(), anyhow::Error> { NodeMode::SequencerNode, Some("demo_data_test_reopen_sequencer"), DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); @@ -679,6 +784,7 @@ async fn test_reopen_sequencer() -> Result<(), anyhow::Error> { NodeMode::SequencerNode, Some("demo_data_test_reopen_sequencer_copy"), DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); diff --git a/examples/demo-rollup/tests/evm/archival_state.rs b/examples/demo-rollup/tests/evm/archival_state.rs index 6c19d8f19..738c05925 100644 --- a/examples/demo-rollup/tests/evm/archival_state.rs +++ b/examples/demo-rollup/tests/evm/archival_state.rs @@ -30,6 +30,7 @@ async fn test_archival_state() -> Result<(), anyhow::Error> { NodeMode::SequencerNode, None, DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); diff --git a/examples/demo-rollup/tests/evm/gas_price.rs b/examples/demo-rollup/tests/evm/gas_price.rs index ad46d1675..fef8e2170 100644 --- a/examples/demo-rollup/tests/evm/gas_price.rs +++ b/examples/demo-rollup/tests/evm/gas_price.rs @@ -33,6 +33,7 @@ async fn test_gas_price_increase() -> Result<(), anyhow::Error> { NodeMode::SequencerNode, None, DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); diff --git a/examples/demo-rollup/tests/evm/mod.rs b/examples/demo-rollup/tests/evm/mod.rs index d09d63c0e..33179d7cd 100644 --- a/examples/demo-rollup/tests/evm/mod.rs +++ b/examples/demo-rollup/tests/evm/mod.rs @@ -35,6 +35,7 @@ async fn web3_rpc_tests() -> Result<(), anyhow::Error> { NodeMode::SequencerNode, None, DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); @@ -80,6 +81,7 @@ async fn evm_tx_tests() -> Result<(), anyhow::Error> { NodeMode::SequencerNode, None, DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); @@ -114,6 +116,7 @@ async fn test_eth_get_logs() -> Result<(), anyhow::Error> { NodeMode::SequencerNode, None, DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); diff --git a/examples/demo-rollup/tests/evm/tracing.rs b/examples/demo-rollup/tests/evm/tracing.rs index ca5bf29fa..91b178428 100644 --- a/examples/demo-rollup/tests/evm/tracing.rs +++ b/examples/demo-rollup/tests/evm/tracing.rs @@ -33,6 +33,7 @@ async fn tracing_tests() -> Result<(), Box> { NodeMode::SequencerNode, None, DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); diff --git a/examples/demo-rollup/tests/mempool/mod.rs b/examples/demo-rollup/tests/mempool/mod.rs index 1479f652c..32129f2b3 100644 --- a/examples/demo-rollup/tests/mempool/mod.rs +++ b/examples/demo-rollup/tests/mempool/mod.rs @@ -27,6 +27,7 @@ async fn initialize_test() -> (JoinHandle<()>, Box) { NodeMode::SequencerNode, None, DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); diff --git a/examples/demo-rollup/tests/sequencer_commitments/mod.rs b/examples/demo-rollup/tests/sequencer_commitments/mod.rs index b18e6e482..3a76636c2 100644 --- a/examples/demo-rollup/tests/sequencer_commitments/mod.rs +++ b/examples/demo-rollup/tests/sequencer_commitments/mod.rs @@ -35,6 +35,7 @@ async fn sequencer_sends_commitments_to_da_layer() { NodeMode::SequencerNode, None, 4, + true, ) .await; }); diff --git a/examples/demo-rollup/tests/soft_confirmation_rule_enforcer/mod.rs b/examples/demo-rollup/tests/soft_confirmation_rule_enforcer/mod.rs index b6bb145be..157235fc3 100644 --- a/examples/demo-rollup/tests/soft_confirmation_rule_enforcer/mod.rs +++ b/examples/demo-rollup/tests/soft_confirmation_rule_enforcer/mod.rs @@ -28,6 +28,7 @@ async fn too_many_l2_block_per_l1_block() { NodeMode::SequencerNode, None, DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT, + true, ) .await; }); diff --git a/examples/demo-rollup/tests/test_helpers.rs b/examples/demo-rollup/tests/test_helpers.rs index ab4fc27dc..c4bf5346d 100644 --- a/examples/demo-rollup/tests/test_helpers.rs +++ b/examples/demo-rollup/tests/test_helpers.rs @@ -27,6 +27,7 @@ pub enum NodeMode { Prover(SocketAddr), } +#[allow(clippy::too_many_arguments)] pub async fn start_rollup( rpc_reporting_channel: oneshot::Sender, rt_genesis_paths: GenesisPaths, @@ -35,6 +36,7 @@ pub async fn start_rollup( node_mode: NodeMode, db_path: Option<&str>, min_soft_confirmations_per_commitment: u64, + include_tx_body: bool, ) { let mut path = db_path.map(Path::new); let mut temp_dir: Option = None; @@ -73,6 +75,7 @@ pub async fn start_rollup( } NodeMode::SequencerNode => None, }, + include_tx_body, }; let sequencer_config = SequencerConfig { diff --git a/full-node/chainway-sequencer/src/sequencer.rs b/full-node/chainway-sequencer/src/sequencer.rs index 067834e21..4cc28be54 100644 --- a/full-node/chainway-sequencer/src/sequencer.rs +++ b/full-node/chainway-sequencer/src/sequencer.rs @@ -443,8 +443,7 @@ where self.state_root = next_state_root; - self.ledger_db - .commit_soft_batch(soft_batch_receipt, false)?; + self.ledger_db.commit_soft_batch(soft_batch_receipt, true)?; self.mempool .remove_transactions(self.db_provider.last_block_tx_hashes()); diff --git a/full-node/db/sov-db/src/ledger_db/mod.rs b/full-node/db/sov-db/src/ledger_db/mod.rs index 722fe74d2..5430bb5eb 100644 --- a/full-node/db/sov-db/src/ledger_db/mod.rs +++ b/full-node/db/sov-db/src/ledger_db/mod.rs @@ -245,7 +245,7 @@ impl LedgerDB { pub fn commit_soft_batch( &self, batch_receipt: SoftBatchReceipt, - ignore_tx_body: bool, + include_tx_body: bool, ) -> Result<(), anyhow::Error> { // Create a scope to ensure that the lock is released before we commit to the db let mut current_item_numbers = { @@ -284,7 +284,7 @@ impl LedgerDB { // Rollup full nodes don't need to store the tx body as they already store evm body // Sequencer full nodes need to store the tx body as they are the only ones that have it - if ignore_tx_body { + if !include_tx_body { tx_to_store.body = None; } diff --git a/full-node/sov-stf-runner/src/config.rs b/full-node/sov-stf-runner/src/config.rs index f0b43764b..1f76f994c 100644 --- a/full-node/sov-stf-runner/src/config.rs +++ b/full-node/sov-stf-runner/src/config.rs @@ -61,6 +61,8 @@ pub struct RollupConfig { pub sequencer_public_key: Vec, /// Prover service configuration. pub prover_service: ProverServiceConfig, + /// Saves sequencer soft batches if set to true + pub include_tx_body: bool, } /// Reads toml file as a specific type. @@ -97,6 +99,7 @@ mod tests { fn test_correct_config() { let config = r#" sequencer_public_key = "0000000000000000000000000000000000000000000000000000000000000000" + include_tx_body = true [da] celestia_rpc_auth_token = "SECRET_RPC_TOKEN" celestia_rpc_address = "http://localhost:11111/" @@ -143,6 +146,7 @@ mod tests { prover_service: ProverServiceConfig { aggregated_proof_block_jump: 22, }, + include_tx_body: true, }; assert_eq!(config, expected); } diff --git a/full-node/sov-stf-runner/src/runner.rs b/full-node/sov-stf-runner/src/runner.rs index 46a3823ec..8a6d65808 100644 --- a/full-node/sov-stf-runner/src/runner.rs +++ b/full-node/sov-stf-runner/src/runner.rs @@ -60,6 +60,7 @@ where sequencer_client: Option, sequencer_pub_key: Vec, phantom: std::marker::PhantomData, + include_tx_body: bool, } /// Represents the possible modes of execution for a zkVM program @@ -122,6 +123,7 @@ where prover_service: Option, sequencer_client: Option, sequencer_pub_key: Vec, + include_tx_body: bool, ) -> Result { let rpc_config = runner_config.rpc_config; @@ -170,6 +172,7 @@ where sequencer_client, sequencer_pub_key, phantom: std::marker::PhantomData, + include_tx_body, }) } @@ -495,7 +498,8 @@ where l1_fee_rate: soft_batch.l1_fee_rate, }; - self.ledger_db.commit_soft_batch(soft_batch_receipt, true)?; + self.ledger_db + .commit_soft_batch(soft_batch_receipt, self.include_tx_body)?; self.ledger_db .extend_l2_range_of_l1_slot( SlotNumber(filtered_block.header().height()), diff --git a/full-node/sov-stf-runner/tests/runner_initialization_tests.rs b/full-node/sov-stf-runner/tests/runner_initialization_tests.rs index 6036d7024..1f369b6c2 100644 --- a/full-node/sov-stf-runner/tests/runner_initialization_tests.rs +++ b/full-node/sov-stf-runner/tests/runner_initialization_tests.rs @@ -83,6 +83,7 @@ fn initialize_runner( aggregated_proof_block_jump: 1, }, sequencer_client: None, + include_tx_body: true, }; let da_service = MockDaService::new(address); @@ -122,6 +123,7 @@ fn initialize_runner( Some(prover_service), None, vec![0u8; 32], + true, ) .unwrap() } diff --git a/full-node/sov-stf-runner/tests/runner_reorg_tests.rs b/full-node/sov-stf-runner/tests/runner_reorg_tests.rs index 9aac7bf1b..79cc11cbb 100644 --- a/full-node/sov-stf-runner/tests/runner_reorg_tests.rs +++ b/full-node/sov-stf-runner/tests/runner_reorg_tests.rs @@ -139,6 +139,7 @@ async fn runner_execution( aggregated_proof_block_jump: 1, }, sequencer_client: None, + include_tx_body: true, }; let ledger_db = LedgerDB::with_path(path).unwrap(); @@ -176,6 +177,7 @@ async fn runner_execution( Some(prover_service), None, vec![0u8; 32], + true, ) .unwrap(); diff --git a/module-system/sov-modules-rollup-blueprint/src/lib.rs b/module-system/sov-modules-rollup-blueprint/src/lib.rs index 424622720..2e6b2a126 100644 --- a/module-system/sov-modules-rollup-blueprint/src/lib.rs +++ b/module-system/sov-modules-rollup-blueprint/src/lib.rs @@ -294,6 +294,7 @@ pub trait RollupBlueprint: Sized + Send + Sync { prover_service, sequencer_client, rollup_config.sequencer_public_key, + rollup_config.include_tx_body, )?; Ok(Rollup { From bafd37210237c8b19fd029c8be008ca182b16407 Mon Sep 17 00:00:00 2001 From: okkothejawa <103260942+okkothejawa@users.noreply.github.com> Date: Mon, 25 Mar 2024 16:14:32 +0300 Subject: [PATCH 3/7] Add Hive CI (#290) * Add Hive CI * Remove unnecessary Hive CI check * Fix Hive CI runs on part * Fix Hive CI machines and client log typo --- .github/workflows/hive.yml | 114 +++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 .github/workflows/hive.yml diff --git a/.github/workflows/hive.yml b/.github/workflows/hive.yml new file mode 100644 index 000000000..4a9cba0ac --- /dev/null +++ b/.github/workflows/hive.yml @@ -0,0 +1,114 @@ +# Runs `ethereum/hive` tests. + +name: hive + +on: + workflow_dispatch: + schedule: + # every day + - cron: "13 21 * * *" # 21:13 UTC + +env: + CARGO_TERM_COLOR: always + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + # Except in `nightly` and `stable` branches! Any cancelled job will cause the + # CI run to fail, and we want to keep a clean history for major branches. + cancel-in-progress: ${{ (github.ref != 'refs/heads/nightly') && (github.ref != 'refs/heads/stable') }} + +jobs: + docker: + timeout-minutes: 60 + name: Build and publish Docker image + runs-on: ubicloud-standard-16 + steps: + - uses: actions/checkout@v4 + - name: Docker Setup Buildx + uses: docker/setup-buildx-action@v3.2.0 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5.3.0 + with: + context: . + file: ./hive/Dockerfile + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/citrea:latest + + prepare: + timeout-minutes: 45 + runs-on: ubicloud-standard-4 + steps: + - uses: actions/checkout@v4 + - run: mkdir artifacts + + - name: Checkout hive tests + uses: actions/checkout@v4 + with: + repository: chainwayxyz/hive + ref: main + path: hivetests + + - uses: actions/setup-go@v5 + with: + go-version: "^1.13.1" + - run: go version + - name: Build hive tool + run: | + cd hivetests + go build . + mv ./hive ../artifacts/ + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: artifacts + path: ./artifacts + + test: + timeout-minutes: 15 + strategy: + fail-fast: false + + needs: prepare + name: run + runs-on: ubicloud-standard-4 + permissions: + issues: write + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: artifacts + path: /tmp + + - name: Move hive binary + run: | + mv /tmp/hive /usr/local/bin + chmod +x /usr/local/bin/hive + + - name: Checkout hive tests + uses: actions/checkout@v4 + with: + repository: chainwayxyz/hive + ref: main + path: hivetests + + - name: Run ethereum/rpc simulator + run: | + cd hivetests + hive --sim "ethereum/rpc" --sim.limit "/http" --client citrea + + - name: Print simulator output + if: ${{ failure() }} + run: | + cat hivetests/workspace/logs/*simulator*.log + + - name: Print citrea client logs + if: ${{ failure() }} + run: | + cat hivetests/workspace/logs/citrea/client-*.log \ No newline at end of file From a2edd4680bf0057663b9debd2fbfab052375a4e8 Mon Sep 17 00:00:00 2001 From: okkothejawa <103260942+okkothejawa@users.noreply.github.com> Date: Mon, 25 Mar 2024 16:25:41 +0300 Subject: [PATCH 4/7] Add docker dependency to Hive test job in Hive CI (#292) --- .github/workflows/hive.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hive.yml b/.github/workflows/hive.yml index 4a9cba0ac..cb2d29a04 100644 --- a/.github/workflows/hive.yml +++ b/.github/workflows/hive.yml @@ -74,7 +74,7 @@ jobs: strategy: fail-fast: false - needs: prepare + needs: [docker, prepare] name: run runs-on: ubicloud-standard-4 permissions: From 2661f64ce82f904c9d87c7b2893480a3aadc1962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Talip=20Akal=C4=B1n?= <56600661+otaliptus@users.noreply.github.com> Date: Mon, 25 Mar 2024 16:58:17 +0300 Subject: [PATCH 5/7] Fix CI on soft batch save test (#294) * Init * Add test * Lint fix * PR Fixes * Change name * Add execute blocks * Increase sync time * Init second full node before execute blocks * Make it 10 --- examples/demo-rollup/tests/e2e/mod.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/demo-rollup/tests/e2e/mod.rs b/examples/demo-rollup/tests/e2e/mod.rs index fa625a96e..2ea1a62c7 100644 --- a/examples/demo-rollup/tests/e2e/mod.rs +++ b/examples/demo-rollup/tests/e2e/mod.rs @@ -139,10 +139,6 @@ async fn test_soft_batch_save() -> Result<(), anyhow::Error> { let full_node_port = full_node_port_rx.await.unwrap(); let full_node_test_client = make_test_client(full_node_port).await; - let _ = execute_blocks(&seq_test_client, &full_node_test_client).await; - - sleep(Duration::from_secs(10)).await; - let (full_node_port_tx_2, full_node_port_rx_2) = tokio::sync::oneshot::channel(); let full_node_task_2 = tokio::spawn(async move { @@ -164,7 +160,9 @@ async fn test_soft_batch_save() -> Result<(), anyhow::Error> { let full_node_port_2 = full_node_port_rx_2.await.unwrap(); let full_node_test_client_2 = make_test_client(full_node_port_2).await; - sleep(Duration::from_secs(20)).await; + let _ = execute_blocks(&seq_test_client, &full_node_test_client).await; + + sleep(Duration::from_secs(10)).await; let seq_block = seq_test_client .eth_get_block_by_number(Some(BlockNumberOrTag::Latest)) From 11d8d5542245ed8950094796970f7ce5d780396f Mon Sep 17 00:00:00 2001 From: okkothejawa <103260942+okkothejawa@users.noreply.github.com> Date: Mon, 25 Mar 2024 18:22:14 +0300 Subject: [PATCH 6/7] Split Hive CI to docker and hive test workflows (#295) --- .github/workflows/docker_hive.yml | 40 +++++++++++++++++++++++++++++++ .github/workflows/hive.yml | 30 ++++------------------- 2 files changed, 45 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/docker_hive.yml diff --git a/.github/workflows/docker_hive.yml b/.github/workflows/docker_hive.yml new file mode 100644 index 000000000..02c9ca72e --- /dev/null +++ b/.github/workflows/docker_hive.yml @@ -0,0 +1,40 @@ +# Makes a Docker build to be used in Hive tests. + +name: Docker for Hive + +on: + workflow_dispatch: + schedule: + # every day + - cron: "13 21 * * *" # 21:13 UTC + +env: + CARGO_TERM_COLOR: always + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + # Except in `nightly` and `stable` branches! Any cancelled job will cause the + # CI run to fail, and we want to keep a clean history for major branches. + cancel-in-progress: ${{ (github.ref != 'refs/heads/nightly') && (github.ref != 'refs/heads/stable') }} + +jobs: + docker: + timeout-minutes: 60 + name: Build and publish Docker image + runs-on: ubicloud-standard-16 + steps: + - uses: actions/checkout@v4 + - name: Docker Setup Buildx + uses: docker/setup-buildx-action@v3.2.0 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5.3.0 + with: + context: . + file: ./hive/Dockerfile + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/citrea:latest diff --git a/.github/workflows/hive.yml b/.github/workflows/hive.yml index cb2d29a04..084603cd4 100644 --- a/.github/workflows/hive.yml +++ b/.github/workflows/hive.yml @@ -1,12 +1,13 @@ # Runs `ethereum/hive` tests. -name: hive +name: Hive on: workflow_dispatch: - schedule: - # every day - - cron: "13 21 * * *" # 21:13 UTC + workflow_run: + workflows: ["Docker for Hive"] + types: + - completed env: CARGO_TERM_COLOR: always @@ -18,27 +19,6 @@ concurrency: cancel-in-progress: ${{ (github.ref != 'refs/heads/nightly') && (github.ref != 'refs/heads/stable') }} jobs: - docker: - timeout-minutes: 60 - name: Build and publish Docker image - runs-on: ubicloud-standard-16 - steps: - - uses: actions/checkout@v4 - - name: Docker Setup Buildx - uses: docker/setup-buildx-action@v3.2.0 - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v5.3.0 - with: - context: . - file: ./hive/Dockerfile - push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/citrea:latest - prepare: timeout-minutes: 45 runs-on: ubicloud-standard-4 From 0a8333db6c249583d2b9d287d052fe424f11e0ea Mon Sep 17 00:00:00 2001 From: okkothejawa <103260942+okkothejawa@users.noreply.github.com> Date: Mon, 25 Mar 2024 18:35:14 +0300 Subject: [PATCH 7/7] Fix hive CI (#296) --- .github/workflows/hive.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hive.yml b/.github/workflows/hive.yml index 084603cd4..603c5887c 100644 --- a/.github/workflows/hive.yml +++ b/.github/workflows/hive.yml @@ -54,7 +54,7 @@ jobs: strategy: fail-fast: false - needs: [docker, prepare] + needs: prepare name: run runs-on: ubicloud-standard-4 permissions: