From efdfbc314da0c9a72abc440fe3f9bd1966975a5d Mon Sep 17 00:00:00 2001 From: Shoham Chakraborty Date: Thu, 20 Apr 2023 17:42:27 +0800 Subject: [PATCH 1/3] Rename finalize_block --- lib/ain-evm/src/handler.rs | 2 +- lib/ain-evm/tests/block.rs | 12 ++++++------ lib/ain-grpc/src/tests.rs | 2 +- lib/ain-rs-exports/src/lib.rs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/ain-evm/src/handler.rs b/lib/ain-evm/src/handler.rs index d674422a73..0c24a3dcb9 100644 --- a/lib/ain-evm/src/handler.rs +++ b/lib/ain-evm/src/handler.rs @@ -30,7 +30,7 @@ impl Handlers { } } - pub fn finalize_block( + pub fn finalise_block( &self, context: u64, update_state: bool, diff --git a/lib/ain-evm/tests/block.rs b/lib/ain-evm/tests/block.rs index 7ae9b67e77..f869565f0f 100644 --- a/lib/ain-evm/tests/block.rs +++ b/lib/ain-evm/tests/block.rs @@ -6,7 +6,7 @@ use primitive_types::{H160, H256, U256}; use ain_evm::handler::Handlers; #[test] -fn test_finalize_block_and_do_not_update_state() { +fn test_finalise_block_and_do_not_update_state() { let handler = Handlers::new(); let context = handler.evm.get_context(); handler.evm.add_balance( @@ -21,14 +21,14 @@ fn test_finalize_block_and_do_not_update_state() { handler.evm.tx_queues.add_signed_tx(context, tx1); let old_state = handler.evm.state.read().unwrap(); - let _ = handler.finalize_block(context, false, None).unwrap(); + let _ = handler.finalise_block(context, false, None).unwrap(); let new_state = handler.evm.state.read().unwrap(); assert_eq!(*new_state, *old_state); } #[test] -fn test_finalize_block_and_update_state() { +fn test_finalise_block_and_update_state() { let handler = Handlers::new(); let context = handler.evm.get_context(); handler.evm.add_balance( @@ -58,7 +58,7 @@ fn test_finalize_block_and_update_state() { assert_eq!(handler.evm.tx_queues.len(context), 3); assert_eq!(handler.evm.tx_queues.len(handler.evm.get_context()), 0); - let (block, failed_txs) = handler.finalize_block(context, true, None).unwrap(); + let (block, failed_txs) = handler.finalise_block(context, true, None).unwrap(); assert_eq!( block.transactions, vec![tx1, tx2, tx3.clone()] @@ -131,7 +131,7 @@ fn test_deploy_and_call_smart_contract() { .tx_queues .add_signed_tx(context, create_smart_contract_tx); - handler.finalize_block(context, true, None).unwrap(); + handler.finalise_block(context, true, None).unwrap(); // Fund caller address handler.evm.add_balance( @@ -150,7 +150,7 @@ fn test_deploy_and_call_smart_contract() { .tx_queues .add_signed_tx(context, call_smart_contract_tx); - handler.finalize_block(context, true, None).unwrap(); + handler.finalise_block(context, true, None).unwrap(); let smart_contract_storage = handler.evm.get_storage(smart_contract_address); assert_eq!( diff --git a/lib/ain-grpc/src/tests.rs b/lib/ain-grpc/src/tests.rs index 91b0ca3914..2141a2f3d8 100644 --- a/lib/ain-grpc/src/tests.rs +++ b/lib/ain-grpc/src/tests.rs @@ -54,7 +54,7 @@ fn should_get_balance() { .evm .add_balance(ctx, H160::from_str(ALICE).unwrap(), U256::from(1337)); - let _ = handler.finalize_block(ctx, true, None); + let _ = handler.finalise_block(ctx, true, None); let res2 = EthService::Eth_GetBalance(handler, input.into()); assert_eq!(res2.unwrap().balance, "1337"); diff --git a/lib/ain-rs-exports/src/lib.rs b/lib/ain-rs-exports/src/lib.rs index e90838576f..34d478dadc 100644 --- a/lib/ain-rs-exports/src/lib.rs +++ b/lib/ain-rs-exports/src/lib.rs @@ -113,6 +113,6 @@ fn evm_finalise( let (block, _failed_tx) = RUNTIME .handlers - .finalize_block(context, update_state, Some(eth_address))?; + .finalise_block(context, update_state, Some(eth_address))?; Ok(block.header.rlp_bytes().into()) } From 5e0694ee55415cfc87118e5aa7c5bcfefad0a671 Mon Sep 17 00:00:00 2001 From: Shoham Chakraborty Date: Thu, 20 Apr 2023 17:54:28 +0800 Subject: [PATCH 2/3] Revert "Rename finalize_block" This reverts commit efdfbc314da0c9a72abc440fe3f9bd1966975a5d. --- lib/ain-evm/src/handler.rs | 2 +- lib/ain-evm/tests/block.rs | 12 ++++++------ lib/ain-grpc/src/tests.rs | 2 +- lib/ain-rs-exports/src/lib.rs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/ain-evm/src/handler.rs b/lib/ain-evm/src/handler.rs index 0c24a3dcb9..d674422a73 100644 --- a/lib/ain-evm/src/handler.rs +++ b/lib/ain-evm/src/handler.rs @@ -30,7 +30,7 @@ impl Handlers { } } - pub fn finalise_block( + pub fn finalize_block( &self, context: u64, update_state: bool, diff --git a/lib/ain-evm/tests/block.rs b/lib/ain-evm/tests/block.rs index f869565f0f..7ae9b67e77 100644 --- a/lib/ain-evm/tests/block.rs +++ b/lib/ain-evm/tests/block.rs @@ -6,7 +6,7 @@ use primitive_types::{H160, H256, U256}; use ain_evm::handler::Handlers; #[test] -fn test_finalise_block_and_do_not_update_state() { +fn test_finalize_block_and_do_not_update_state() { let handler = Handlers::new(); let context = handler.evm.get_context(); handler.evm.add_balance( @@ -21,14 +21,14 @@ fn test_finalise_block_and_do_not_update_state() { handler.evm.tx_queues.add_signed_tx(context, tx1); let old_state = handler.evm.state.read().unwrap(); - let _ = handler.finalise_block(context, false, None).unwrap(); + let _ = handler.finalize_block(context, false, None).unwrap(); let new_state = handler.evm.state.read().unwrap(); assert_eq!(*new_state, *old_state); } #[test] -fn test_finalise_block_and_update_state() { +fn test_finalize_block_and_update_state() { let handler = Handlers::new(); let context = handler.evm.get_context(); handler.evm.add_balance( @@ -58,7 +58,7 @@ fn test_finalise_block_and_update_state() { assert_eq!(handler.evm.tx_queues.len(context), 3); assert_eq!(handler.evm.tx_queues.len(handler.evm.get_context()), 0); - let (block, failed_txs) = handler.finalise_block(context, true, None).unwrap(); + let (block, failed_txs) = handler.finalize_block(context, true, None).unwrap(); assert_eq!( block.transactions, vec![tx1, tx2, tx3.clone()] @@ -131,7 +131,7 @@ fn test_deploy_and_call_smart_contract() { .tx_queues .add_signed_tx(context, create_smart_contract_tx); - handler.finalise_block(context, true, None).unwrap(); + handler.finalize_block(context, true, None).unwrap(); // Fund caller address handler.evm.add_balance( @@ -150,7 +150,7 @@ fn test_deploy_and_call_smart_contract() { .tx_queues .add_signed_tx(context, call_smart_contract_tx); - handler.finalise_block(context, true, None).unwrap(); + handler.finalize_block(context, true, None).unwrap(); let smart_contract_storage = handler.evm.get_storage(smart_contract_address); assert_eq!( diff --git a/lib/ain-grpc/src/tests.rs b/lib/ain-grpc/src/tests.rs index 2141a2f3d8..91b0ca3914 100644 --- a/lib/ain-grpc/src/tests.rs +++ b/lib/ain-grpc/src/tests.rs @@ -54,7 +54,7 @@ fn should_get_balance() { .evm .add_balance(ctx, H160::from_str(ALICE).unwrap(), U256::from(1337)); - let _ = handler.finalise_block(ctx, true, None); + let _ = handler.finalize_block(ctx, true, None); let res2 = EthService::Eth_GetBalance(handler, input.into()); assert_eq!(res2.unwrap().balance, "1337"); diff --git a/lib/ain-rs-exports/src/lib.rs b/lib/ain-rs-exports/src/lib.rs index 34d478dadc..e90838576f 100644 --- a/lib/ain-rs-exports/src/lib.rs +++ b/lib/ain-rs-exports/src/lib.rs @@ -113,6 +113,6 @@ fn evm_finalise( let (block, _failed_tx) = RUNTIME .handlers - .finalise_block(context, update_state, Some(eth_address))?; + .finalize_block(context, update_state, Some(eth_address))?; Ok(block.header.rlp_bytes().into()) } From c486562151a2ef7274a1a992dc511e59118cf0fd Mon Sep 17 00:00:00 2001 From: Shoham Chakraborty Date: Thu, 20 Apr 2023 17:55:59 +0800 Subject: [PATCH 3/3] Rename FFI call --- lib/ain-rs-exports/src/lib.rs | 4 ++-- src/miner.cpp | 2 +- src/validation.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ain-rs-exports/src/lib.rs b/lib/ain-rs-exports/src/lib.rs index e90838576f..6a10334352 100644 --- a/lib/ain-rs-exports/src/lib.rs +++ b/lib/ain-rs-exports/src/lib.rs @@ -20,7 +20,7 @@ mod ffi { fn evm_get_context() -> u64; fn evm_discard_context(context: u64); fn evm_queue_tx(context: u64, raw_tx: &str) -> Result; - fn evm_finalise( + fn evm_finalize( context: u64, update_state: bool, miner_address: [u8; 20], @@ -104,7 +104,7 @@ fn evm_queue_tx(context: u64, raw_tx: &str) -> Result> { } use rlp::Encodable; -fn evm_finalise( +fn evm_finalize( context: u64, update_state: bool, miner_address: [u8; 20], diff --git a/src/miner.cpp b/src/miner.cpp index 064c3ff769..7e96033a31 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -245,7 +245,7 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc // TODO Get failed TXs and try to restore to mempool std::array dummyAddress{}; - const auto rustHeader = evm_finalise(evmContext, false, dummyAddress); + const auto rustHeader = evm_finalize(evmContext, false, dummyAddress); std::vector evmHeader{}; evmHeader.resize(rustHeader.size()); diff --git a/src/validation.cpp b/src/validation.cpp index c6857845e9..88e3b4029d 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2873,7 +2873,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl std::copy(minter.begin(), minter.end(), minerAddress.begin()); } - evm_finalise(evmContext, true, minerAddress); + evm_finalize(evmContext, true, minerAddress); } auto &checkpoints = chainparams.Checkpoints().mapCheckpoints;