From 6a6b5b9c06f32bdac671bbaa537e5605bcd7ab32 Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Fri, 18 Oct 2024 17:17:31 +0200 Subject: [PATCH 01/24] Add test for eip1559 and eip2930 transaction types. --- crates/telos/node/tests/live_test_runner.rs | 76 ++++++++++++++++++--- 1 file changed, 68 insertions(+), 8 deletions(-) diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index 7c0012991087..93157a1f5f99 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -1,16 +1,23 @@ -use alloy_network::{ReceiptResponse, TransactionBuilder}; -use alloy_primitives::U256; +use std::fmt::Debug; +use std::str::FromStr; +use alloy_contract::private::Transport; +use alloy_network::{Ethereum, Network, ReceiptResponse, TransactionBuilder}; +use alloy_primitives::{Address, B256, U256}; +use alloy_primitives::private::proptest::collection::vec; use alloy_provider::network::EthereumWallet; use alloy_provider::{Provider, ProviderBuilder}; -use alloy_rpc_types::TransactionRequest; +use alloy_rpc_types::{TransactionRequest}; use alloy_signer_local::PrivateKeySigner; -use alloy_sol_types::private::primitives::TxKind::Create; +use alloy_sol_types::private::primitives::TxKind::{Create}; use alloy_sol_types::{sol, SolEvent}; -use reqwest::Url; -use reth::primitives::BlockId; + use reth::rpc::types::{BlockTransactionsKind, TransactionInput}; -use std::str::FromStr; +use reqwest::{Url}; + use tracing::info; +use reth::primitives::BlockId; +use reth::revm::primitives::{AccessList, AccessListItem}; + #[tokio::test] pub async fn run_local() { @@ -92,7 +99,7 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { ..Default::default() }; - let deploy_result = provider.send_transaction(legacy_tx_request).await.unwrap(); + let deploy_result = provider.send_transaction(legacy_tx_request.clone()).await.unwrap(); let deploy_tx_hash = deploy_result.tx_hash(); info!("Deployed contract with tx hash: {deploy_tx_hash}"); @@ -125,10 +132,63 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { assert_eq!(U256::from(rpc_block_num), block_num_event.number); info!("Block numbers match inside transaction event"); + // test eip1559 transaction which is not supported + test_1559_tx(provider.clone(), address).await; + // test eip2930 transaction which is not supported + test_2930_tx(provider.clone(), address).await; + // The below needs to be done using LegacyTransaction style call... with the current code it's including base_fee_per_gas and being rejected by reth // let block_num_latest = block_num_checker.getBlockNum().call().await.unwrap(); // assert!(block_num_latest._0 > U256::from(rpc_block_num), "Latest block number via call to getBlockNum is not greater than the block number in the previous log event"); // // let block_num_five_back = block_num_checker.getBlockNum().call().block(BlockId::number(rpc_block_num - 5)).await.unwrap(); // assert!(block_num_five_back._0 == U256::from(rpc_block_num - 5), "Block number 5 blocks back via historical eth_call is not correct"); + +} + +// test_1559_tx tests sending eip1559 transaction that has max_priority_fee_per_gas and max_fee_per_gas set +pub async fn test_1559_tx(provider: impl Provider + Send + Sync, sender_address: Address) +where + T: Transport + Clone + Debug, +{ + let nonce = provider.get_transaction_count(sender_address).await.unwrap(); + let chain_id = provider.get_chain_id().await.unwrap(); + let to_address: Address = Address::from_str("0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4").unwrap(); + + let tx = TransactionRequest::default() + .with_to(to_address) + .with_nonce(nonce) + .with_chain_id(chain_id) + .with_value(U256::from(100)) + .with_gas_limit(21_000) + .with_max_priority_fee_per_gas(1_000_000_000) + .with_max_fee_per_gas(20_000_000_000); + + let tx_result = provider.send_transaction(tx).await; + assert!(tx_result.is_err()); +} + +// test_2930_tx tests sending eip2930 transaction which has access_list provided +pub async fn test_2930_tx(provider: impl Provider + Send + Sync, sender_address: Address) +where + T: Transport + Clone + Debug, + +{ + let nonce = provider.get_transaction_count(sender_address).await.unwrap(); + let chain_id = provider.get_chain_id().await.unwrap(); + let gas_price = provider.get_gas_price().await.unwrap(); + + let to_address: Address = Address::from_str("0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4").unwrap(); + let tx = TransactionRequest::default() + .to(to_address) + .nonce(nonce) + .value(U256::from(1e17)) + .with_chain_id(chain_id) + .with_gas_price(gas_price) + .with_gas_limit(20_000_000) + .max_priority_fee_per_gas(1e11 as u128) + .with_access_list(AccessList::from(vec![AccessListItem { address: to_address, storage_keys: vec![B256::ZERO] }])) + .max_fee_per_gas(2e9 as u128); + let tx_result = provider.send_transaction(tx).await; + assert!(tx_result.is_err()); } From 51ef536cd6cec5b2a5f3cf754088763a8fb3c2b7 Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Wed, 23 Oct 2024 14:02:48 +0200 Subject: [PATCH 02/24] Add double approve test. --- crates/telos/node/tests/live_test_runner.rs | 54 ++++++++++++++++++--- 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index 93157a1f5f99..558f544fe77d 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -1,23 +1,21 @@ use std::fmt::Debug; use std::str::FromStr; use alloy_contract::private::Transport; -use alloy_network::{Ethereum, Network, ReceiptResponse, TransactionBuilder}; -use alloy_primitives::{Address, B256, U256}; -use alloy_primitives::private::proptest::collection::vec; +use alloy_network::{Ethereum, ReceiptResponse, TransactionBuilder}; +use alloy_primitives::{keccak256, Address, B256, U256}; use alloy_provider::network::EthereumWallet; use alloy_provider::{Provider, ProviderBuilder}; use alloy_rpc_types::{TransactionRequest}; use alloy_signer_local::PrivateKeySigner; use alloy_sol_types::private::primitives::TxKind::{Create}; use alloy_sol_types::{sol, SolEvent}; - use reth::rpc::types::{BlockTransactionsKind, TransactionInput}; use reqwest::{Url}; - use tracing::info; use reth::primitives::BlockId; -use reth::revm::primitives::{AccessList, AccessListItem}; +use reth::primitives::revm_primitives::bytes::Bytes; +use reth::revm::primitives::{AccessList, AccessListItem}; #[tokio::test] pub async fn run_local() { @@ -136,7 +134,8 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { test_1559_tx(provider.clone(), address).await; // test eip2930 transaction which is not supported test_2930_tx(provider.clone(), address).await; - + // test double approve erc20 call + test_double_approve_erc20(provider.clone(), address).await; // The below needs to be done using LegacyTransaction style call... with the current code it's including base_fee_per_gas and being rejected by reth // let block_num_latest = block_num_checker.getBlockNum().call().await.unwrap(); // assert!(block_num_latest._0 > U256::from(rpc_block_num), "Latest block number via call to getBlockNum is not greater than the block number in the previous log event"); @@ -192,3 +191,44 @@ where let tx_result = provider.send_transaction(tx).await; assert!(tx_result.is_err()); } + +// test_double_approve_erc20 sends 2 transactions for approve on the ERC20 token and asserts that only once it is success +pub async fn test_double_approve_erc20(provider: impl Provider + Send + Sync, sender_address: Address) +where + T: Transport + Clone + Debug, + +{ + let nonce = provider.get_transaction_count(sender_address).await.unwrap(); + let chain_id = provider.get_chain_id().await.unwrap(); + let gas_price = provider.get_gas_price().await.unwrap(); + + let erc20_contract_address: Address = "0x49f54c5e2301eb9256438123e80762470c2c7ec2".parse().unwrap(); + let spender: Address = "0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4".parse().unwrap(); + let function_signature = "approve(address,uint256)"; + let amount: U256 = U256::from(0); + let selector = &keccak256(function_signature.as_bytes())[..4]; + let amount_bytes: [u8; 32] = amount.to_be_bytes(); + let mut encoded_data = Vec::new(); + encoded_data.extend_from_slice(selector); + encoded_data.extend_from_slice(spender.as_ref()); + encoded_data.extend_from_slice(&amount_bytes); + let input_data = Bytes::from(encoded_data); + + // Build approve transaction + let tx = TransactionRequest::default() + .to(erc20_contract_address) + .with_input(input_data) + .nonce(nonce) + .value(U256::from(10)) + .with_chain_id(chain_id) + .with_gas_price(gas_price) + .with_gas_limit(20_000_000); + + // call approve + let tx_result = provider.send_transaction(tx.clone()).await; + assert!(tx_result.is_ok()); + + // repeat approve + let tx_result = provider.send_transaction(tx.clone()).await; + assert!(tx_result.is_err()); +} From 6e4d94fb241642a348408f0bb4e2a86df4d6ef0e Mon Sep 17 00:00:00 2001 From: Coa Date: Thu, 24 Oct 2024 14:58:01 +0200 Subject: [PATCH 03/24] Add RLP tests --- Cargo.lock | 2 +- crates/telos/node/Cargo.toml | 6 +- crates/telos/node/tests/live_test_runner.rs | 103 +++++++++++++++----- 3 files changed, 85 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aaba2eec5fe3..fc3cda637e7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9381,7 +9381,7 @@ dependencies = [ name = "reth-node-telos" version = "1.0.8" dependencies = [ - "alloy-consensus 0.4.2", + "alloy-consensus 0.3.6", "alloy-contract", "alloy-network 0.4.2", "alloy-primitives", diff --git a/crates/telos/node/Cargo.toml b/crates/telos/node/Cargo.toml index 3d7b8e01117d..bcb19efcc267 100644 --- a/crates/telos/node/Cargo.toml +++ b/crates/telos/node/Cargo.toml @@ -60,7 +60,9 @@ telos = [ ] [dev-dependencies] -alloy-consensus.workspace = true +# Translator and reth versions doesn't match, causing missing implementation of a TelosTxDecodable trait +alloy-consensus = "0.3.6" + alloy-contract = "0.4.2" alloy-primitives.workspace = true alloy-provider.workspace = true @@ -72,8 +74,6 @@ alloy-sol-types.workspace = true alloy-transport-http.workspace = true reqwest.workspace = true -reth.workspace = true -reth-chainspec.workspace = true reth-e2e-test-utils.workspace = true eyre.workspace = true diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index 558f544fe77d..64969d3f306f 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -1,18 +1,20 @@ -use std::fmt::Debug; -use std::str::FromStr; +use alloy_consensus::{Signed, TxLegacy}; use alloy_contract::private::Transport; use alloy_network::{Ethereum, ReceiptResponse, TransactionBuilder}; -use alloy_primitives::{keccak256, Address, B256, U256}; +use alloy_primitives::{keccak256, Address, Signature, B256, U256}; use alloy_provider::network::EthereumWallet; use alloy_provider::{Provider, ProviderBuilder}; -use alloy_rpc_types::{TransactionRequest}; +use alloy_rpc_types::TransactionRequest; use alloy_signer_local::PrivateKeySigner; -use alloy_sol_types::private::primitives::TxKind::{Create}; +use alloy_sol_types::private::primitives::TxKind::Create; use alloy_sol_types::{sol, SolEvent}; +use reqwest::Url; +use reth::primitives::BlockId; use reth::rpc::types::{BlockTransactionsKind, TransactionInput}; -use reqwest::{Url}; +use std::fmt::Debug; +use std::str::FromStr; +use telos_translator_rs::rlp::telos_rlp_decode::TelosTxDecodable; use tracing::info; -use reth::primitives::BlockId; use reth::primitives::revm_primitives::bytes::Bytes; use reth::revm::primitives::{AccessList, AccessListItem}; @@ -88,7 +90,7 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { let legacy_tx_request = TransactionRequest { from: Some(address), to: Some(legacy_tx.to), - gas: Some(legacy_tx.gas_limit), + gas: Some(legacy_tx.gas_limit as u64), gas_price: Some(legacy_tx.gas_price), value: Some(legacy_tx.value), input: TransactionInput::from(legacy_tx.input), @@ -134,25 +136,30 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { test_1559_tx(provider.clone(), address).await; // test eip2930 transaction which is not supported test_2930_tx(provider.clone(), address).await; - // test double approve erc20 call + // test double approve erc20 call test_double_approve_erc20(provider.clone(), address).await; + // test incorrect rlp call + test_incorrect_rlp(provider.clone(), address).await; + // The below needs to be done using LegacyTransaction style call... with the current code it's including base_fee_per_gas and being rejected by reth // let block_num_latest = block_num_checker.getBlockNum().call().await.unwrap(); // assert!(block_num_latest._0 > U256::from(rpc_block_num), "Latest block number via call to getBlockNum is not greater than the block number in the previous log event"); // // let block_num_five_back = block_num_checker.getBlockNum().call().block(BlockId::number(rpc_block_num - 5)).await.unwrap(); // assert!(block_num_five_back._0 == U256::from(rpc_block_num - 5), "Block number 5 blocks back via historical eth_call is not correct"); - } // test_1559_tx tests sending eip1559 transaction that has max_priority_fee_per_gas and max_fee_per_gas set -pub async fn test_1559_tx(provider: impl Provider + Send + Sync, sender_address: Address) -where +pub async fn test_1559_tx( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where T: Transport + Clone + Debug, { let nonce = provider.get_transaction_count(sender_address).await.unwrap(); let chain_id = provider.get_chain_id().await.unwrap(); - let to_address: Address = Address::from_str("0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4").unwrap(); + let to_address: Address = + Address::from_str("0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4").unwrap(); let tx = TransactionRequest::default() .with_to(to_address) @@ -168,16 +175,18 @@ where } // test_2930_tx tests sending eip2930 transaction which has access_list provided -pub async fn test_2930_tx(provider: impl Provider + Send + Sync, sender_address: Address) -where +pub async fn test_2930_tx( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where T: Transport + Clone + Debug, - { let nonce = provider.get_transaction_count(sender_address).await.unwrap(); let chain_id = provider.get_chain_id().await.unwrap(); let gas_price = provider.get_gas_price().await.unwrap(); - let to_address: Address = Address::from_str("0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4").unwrap(); + let to_address: Address = + Address::from_str("0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4").unwrap(); let tx = TransactionRequest::default() .to(to_address) .nonce(nonce) @@ -186,23 +195,28 @@ where .with_gas_price(gas_price) .with_gas_limit(20_000_000) .max_priority_fee_per_gas(1e11 as u128) - .with_access_list(AccessList::from(vec![AccessListItem { address: to_address, storage_keys: vec![B256::ZERO] }])) + .with_access_list(AccessList::from(vec![AccessListItem { + address: to_address, + storage_keys: vec![B256::ZERO], + }])) .max_fee_per_gas(2e9 as u128); let tx_result = provider.send_transaction(tx).await; assert!(tx_result.is_err()); } // test_double_approve_erc20 sends 2 transactions for approve on the ERC20 token and asserts that only once it is success -pub async fn test_double_approve_erc20(provider: impl Provider + Send + Sync, sender_address: Address) -where +pub async fn test_double_approve_erc20( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where T: Transport + Clone + Debug, - { let nonce = provider.get_transaction_count(sender_address).await.unwrap(); let chain_id = provider.get_chain_id().await.unwrap(); let gas_price = provider.get_gas_price().await.unwrap(); - let erc20_contract_address: Address = "0x49f54c5e2301eb9256438123e80762470c2c7ec2".parse().unwrap(); + let erc20_contract_address: Address = + "0x49f54c5e2301eb9256438123e80762470c2c7ec2".parse().unwrap(); let spender: Address = "0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4".parse().unwrap(); let function_signature = "approve(address,uint256)"; let amount: U256 = U256::from(0); @@ -232,3 +246,48 @@ where let tx_result = provider.send_transaction(tx.clone()).await; assert!(tx_result.is_err()); } + +pub async fn test_incorrect_rlp( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where + T: Transport + Clone + Debug, +{ + let chain_id = Some(provider.get_chain_id().await.unwrap()); + let nonce = Some(provider.get_transaction_count(sender_address).await.unwrap()); + let legacy_tx = tx_trailing_empty_values().unwrap().tx().clone(); + + let legacy_tx_request = TransactionRequest { + from: Some(sender_address), + to: Some(legacy_tx.to), + gas: Some(legacy_tx.gas_limit as u64), + gas_price: Some(legacy_tx.gas_price), + value: Some(legacy_tx.value), + input: TransactionInput::from(legacy_tx.input), + nonce, + chain_id, + ..Default::default() + }; + + let tx_result = provider.send_transaction(legacy_tx_request).await; + assert!(tx_result.is_err()); +} + +fn tx_trailing_empty_values() -> eyre::Result> { + let byte_array: [u8; 43] = [ + 234, 21, 133, 117, 98, 209, 251, 63, 131, 30, 132, 128, 148, 221, 124, 155, 23, 110, 221, + 57, 225, 22, 88, 115, 0, 111, 245, 56, 10, 44, 0, 51, 174, 130, 39, 16, 130, 0, 0, 128, + 128, 128, 128, + ]; + + let r = U256::from_str( + "7478307613393818857995123362551696556625819847066981460737539381080402549198", + )?; + let s = U256::from_str( + "93208746529385687702128536437164864077231874732405909428462768306792425324544", + )?; + let v = 42u64; + + let sig = Signature::from_rs_and_parity(r, s, v)?; + Ok(TxLegacy::decode_telos_signed_fields(&mut &byte_array[..], Some(sig))?) +} From 542060181a915fa82153b37b914495c7b31827c2 Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Thu, 24 Oct 2024 15:40:51 +0200 Subject: [PATCH 04/24] Add contract deployment history blocks check. --- crates/telos/node/tests/integration.rs | 2 +- crates/telos/node/tests/live_test_runner.rs | 22 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/crates/telos/node/tests/integration.rs b/crates/telos/node/tests/integration.rs index 268fde39928c..1fc3d6e572ab 100644 --- a/crates/telos/node/tests/integration.rs +++ b/crates/telos/node/tests/integration.rs @@ -112,7 +112,7 @@ async fn build_consensus_and_translator( jwt_secret: reth_handle.jwt_secret, ship_endpoint: format!("ws://localhost:{ship_port}"), chain_endpoint: format!("http://localhost:{chain_port}"), - batch_size: 1, + batch_size: 100, prev_hash: "b25034033c9ca7a40e879ddcc29cf69071a22df06688b5fe8cc2d68b4e0528f9".to_string(), validate_hash: None, evm_start_block: 1, diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index 64969d3f306f..cb88ac03388b 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -1,10 +1,13 @@ use alloy_consensus::{Signed, TxLegacy}; +use std::thread::sleep; +use std::time::Duration; use alloy_contract::private::Transport; use alloy_network::{Ethereum, ReceiptResponse, TransactionBuilder}; use alloy_primitives::{keccak256, Address, Signature, B256, U256}; use alloy_provider::network::EthereumWallet; use alloy_provider::{Provider, ProviderBuilder}; -use alloy_rpc_types::TransactionRequest; +use alloy_rpc_types::{TransactionRequest}; +use alloy_rpc_types::BlockNumberOrTag::Latest; use alloy_signer_local::PrivateKeySigner; use alloy_sol_types::private::primitives::TxKind::Create; use alloy_sol_types::{sol, SolEvent}; @@ -132,6 +135,23 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { assert_eq!(U256::from(rpc_block_num), block_num_event.number); info!("Block numbers match inside transaction event"); + // wait for some blocks + while let Some(block) = provider.get_block_by_number(Latest, false).await.unwrap() { + if block.header.number == block_num_event.number.as_limbs()[0] + 8 { + break; + } + } + // test latest block and call get block from the contract + let latest_block = provider.get_block_by_number(Latest, false).await.unwrap().unwrap(); + let contract = BlockNumChecker::new(contract_address, provider.clone()); + let block_number = contract.getBlockNum().call().await.unwrap(); + assert_eq!(U256::from(latest_block.header.number), block_number._0); + assert!(latest_block.header.number > rpc_block_num); + + // call for history blocks + let block_num_five_back = block_num_checker.getBlockNum().call().block(BlockId::number(latest_block.header.number - 5)).await.unwrap(); + assert_eq!(block_num_five_back._0, U256::from(latest_block.header.number - 5), "Block number 5 blocks back via historical eth_call is not correct"); + // test eip1559 transaction which is not supported test_1559_tx(provider.clone(), address).await; // test eip2930 transaction which is not supported From 08a79b1d0e7d865405f72568a3dc9253b22a0709 Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Mon, 28 Oct 2024 21:13:00 +0100 Subject: [PATCH 05/24] Check tx receipt when calling approve. --- crates/telos/node/tests/live_test_runner.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index cb88ac03388b..b61ddee940b5 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -249,7 +249,7 @@ pub async fn test_double_approve_erc20( let input_data = Bytes::from(encoded_data); // Build approve transaction - let tx = TransactionRequest::default() + let mut tx = TransactionRequest::default() .to(erc20_contract_address) .with_input(input_data) .nonce(nonce) @@ -261,10 +261,27 @@ pub async fn test_double_approve_erc20( // call approve let tx_result = provider.send_transaction(tx.clone()).await; assert!(tx_result.is_ok()); + let receipt1 = tx_result.unwrap().get_receipt().await; + assert!(receipt1.is_ok()); + + let nonce = provider.get_transaction_count(sender_address).await.unwrap(); + tx.nonce = Some(nonce); // repeat approve let tx_result = provider.send_transaction(tx.clone()).await; - assert!(tx_result.is_err()); + assert!(tx_result.is_ok()); + + let receipt2 = tx_result.unwrap().get_receipt().await; + assert!(receipt2.is_ok()); + + let block_number = receipt2.unwrap().block_number.unwrap(); + + // make sure the block is included + while let Some(block) = provider.get_block_by_number(Latest, false).await.unwrap() { + if block.header.number == block_number { + break; + } + } } pub async fn test_incorrect_rlp( From 5da4f14a50d7fde015ab8d7d7fdeb828debbb0a0 Mon Sep 17 00:00:00 2001 From: Coa Date: Tue, 29 Oct 2024 14:20:49 +0100 Subject: [PATCH 06/24] Add signed and unsigned txs tests --- Cargo.lock | 1 + crates/telos/node/Cargo.toml | 1 + crates/telos/node/tests/live_test_runner.rs | 169 +++++++++++++++++++- 3 files changed, 164 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fc3cda637e7a..4c3432c2841b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9396,6 +9396,7 @@ dependencies = [ "derive_more 1.0.0", "env_logger 0.11.5", "eyre", + "num-bigint", "reqwest 0.12.8", "reth", "reth-auto-seal-consensus", diff --git a/crates/telos/node/Cargo.toml b/crates/telos/node/Cargo.toml index bcb19efcc267..a8bdaf3c33bc 100644 --- a/crates/telos/node/Cargo.toml +++ b/crates/telos/node/Cargo.toml @@ -85,4 +85,5 @@ telos-translator-rs = { git = "https://github.com/telosnetwork/telos-consensus-c env_logger = "0.11.5" testcontainers = "0.21.1" derive_more.workspace = true +num-bigint = "0.4.5" diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index b61ddee940b5..1d47e75a340f 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -1,21 +1,23 @@ use alloy_consensus::{Signed, TxLegacy}; -use std::thread::sleep; -use std::time::Duration; use alloy_contract::private::Transport; use alloy_network::{Ethereum, ReceiptResponse, TransactionBuilder}; -use alloy_primitives::{keccak256, Address, Signature, B256, U256}; +use alloy_primitives::{hex, keccak256, Address, Signature, B256, U256}; use alloy_provider::network::EthereumWallet; use alloy_provider::{Provider, ProviderBuilder}; -use alloy_rpc_types::{TransactionRequest}; use alloy_rpc_types::BlockNumberOrTag::Latest; +use alloy_rpc_types::TransactionRequest; use alloy_signer_local::PrivateKeySigner; use alloy_sol_types::private::primitives::TxKind::Create; use alloy_sol_types::{sol, SolEvent}; +use antelope::chain::checksum::Checksum256; +use num_bigint::{BigUint, ToBigUint}; use reqwest::Url; use reth::primitives::BlockId; use reth::rpc::types::{BlockTransactionsKind, TransactionInput}; use std::fmt::Debug; use std::str::FromStr; +use std::thread::sleep; +use std::time::Duration; use telos_translator_rs::rlp::telos_rlp_decode::TelosTxDecodable; use tracing::info; @@ -149,8 +151,17 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { assert!(latest_block.header.number > rpc_block_num); // call for history blocks - let block_num_five_back = block_num_checker.getBlockNum().call().block(BlockId::number(latest_block.header.number - 5)).await.unwrap(); - assert_eq!(block_num_five_back._0, U256::from(latest_block.header.number - 5), "Block number 5 blocks back via historical eth_call is not correct"); + let block_num_five_back = block_num_checker + .getBlockNum() + .call() + .block(BlockId::number(latest_block.header.number - 5)) + .await + .unwrap(); + assert_eq!( + block_num_five_back._0, + U256::from(latest_block.header.number - 5), + "Block number 5 blocks back via historical eth_call is not correct" + ); // test eip1559 transaction which is not supported test_1559_tx(provider.clone(), address).await; @@ -160,6 +171,9 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { test_double_approve_erc20(provider.clone(), address).await; // test incorrect rlp call test_incorrect_rlp(provider.clone(), address).await; + test_unsigned_trx(provider.clone(), address).await; + test_unsigned_trx2(provider.clone(), address).await; + test_signed_trx(provider.clone(), address).await; // The below needs to be done using LegacyTransaction style call... with the current code it's including base_fee_per_gas and being rejected by reth // let block_num_latest = block_num_checker.getBlockNum().call().await.unwrap(); @@ -307,7 +321,7 @@ pub async fn test_incorrect_rlp( }; let tx_result = provider.send_transaction(legacy_tx_request).await; - assert!(tx_result.is_err()); + assert!(tx_result.is_ok()); } fn tx_trailing_empty_values() -> eyre::Result> { @@ -328,3 +342,144 @@ fn tx_trailing_empty_values() -> eyre::Result> { let sig = Signature::from_rs_and_parity(r, s, v)?; Ok(TxLegacy::decode_telos_signed_fields(&mut &byte_array[..], Some(sig))?) } + +pub async fn test_unsigned_trx( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where + T: Transport + Clone + Debug, +{ + let chain_id = Some(provider.get_chain_id().await.unwrap()); + let nonce = Some(provider.get_transaction_count(sender_address).await.unwrap()); + let legacy_tx = tx_unsigned_trx().unwrap().tx().clone(); + + let legacy_tx_request = TransactionRequest { + from: Some(sender_address), + to: Some(legacy_tx.to), + gas: Some(legacy_tx.gas_limit as u64), + gas_price: Some(113378400387), + value: Some(legacy_tx.value), + input: TransactionInput::from(legacy_tx.input), + nonce, + chain_id, + ..Default::default() + }; + + let tx_result = provider.send_transaction(legacy_tx_request).await; + assert!(tx_result.is_ok()); +} + +fn tx_unsigned_trx() -> eyre::Result> { + let raw = hex::decode( + "e7808082520894d80744e16d62c62c5fa2a04b92da3fe6b9efb5238b52e00fde054bb73290000080", + ) + .unwrap(); + + Ok(TxLegacy::decode_telos_signed_fields( + &mut raw.as_slice(), + Some(make_unique_vrs( + Checksum256::from_hex( + "00000032f9ff3095950dbef8701acc5f0eb193e3c2d089da0e2237659048d62b", + ) + .unwrap(), + Address::ZERO, + 0, + )), + )?) +} + +pub async fn test_unsigned_trx2( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where + T: Transport + Clone + Debug, +{ + let chain_id = Some(provider.get_chain_id().await.unwrap()); + let nonce = Some(provider.get_transaction_count(sender_address).await.unwrap()); + let legacy_tx = tx_unsigned_trx2().unwrap().tx().clone(); + + let legacy_tx_request = TransactionRequest { + from: Some(sender_address), + to: Some(legacy_tx.to), + gas: Some(legacy_tx.gas_limit as u64), + gas_price: Some(113378400387), + value: Some(legacy_tx.value), + input: TransactionInput::from(legacy_tx.input), + nonce, + chain_id, + ..Default::default() + }; + + let tx_result = provider.send_transaction(legacy_tx_request).await; + assert!(tx_result.is_ok()); +} + +fn tx_unsigned_trx2() -> eyre::Result> { + let raw = hex::decode( + "f78212aa8575a1c379a28307a120947282835cf78a5e88a52fc701f09d1614635be4b8900000000000000000000000000000000080808080", + ) + .unwrap(); + + Ok(TxLegacy::decode_telos_signed_fields( + &mut raw.as_slice(), + Some(make_unique_vrs( + Checksum256::from_hex( + "00000032f9ff3095950dbef8701acc5f0eb193e3c2d089da0e2237659048d62b", + ) + .unwrap(), + Address::ZERO, + 0, + )), + )?) +} + +pub async fn test_signed_trx( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where + T: Transport + Clone + Debug, +{ + let chain_id = Some(provider.get_chain_id().await.unwrap()); + let nonce = Some(provider.get_transaction_count(sender_address).await.unwrap()); + let legacy_tx = tx_signed_trx().unwrap().tx().clone(); + + let legacy_tx_request = TransactionRequest { + from: Some(sender_address), + to: Some(legacy_tx.to), + gas: Some(legacy_tx.gas_limit as u64), + gas_price: Some(113378400387), + value: Some(legacy_tx.value), + input: TransactionInput::from(legacy_tx.input), + nonce, + chain_id, + ..Default::default() + }; + + let tx_result = provider.send_transaction(legacy_tx_request).await; + assert!(tx_result.is_ok()); +} + +fn tx_signed_trx() -> eyre::Result> { + let raw = hex::decode( + "f8aa11857a307efa8083023fa09479f5a8bd0d6a00a41ea62cda426cef0115117a6180b844e2bbb1580000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000073a0b40ec08b01a351dcbf5e86eeb15262bf7033dc7b99a054dfb198487636a79c5fa000b64d6775ba737738ccff7f1c0a29c287cbb91f2eb17e1d0b74ffb73d9daa85", + ).unwrap(); + + Ok(TxLegacy::decode_telos_signed_fields(&mut raw.as_slice(), None)?) +} + +pub fn make_unique_vrs( + block_hash_native: Checksum256, + sender_address: Address, + trx_index: usize, +) -> Signature { + let v = 42u64; + let hash_biguint = BigUint::from_bytes_be(&block_hash_native.data); + let trx_index_biguint: BigUint = trx_index.to_biguint().unwrap(); + let r_biguint = hash_biguint + trx_index_biguint; + + let mut s_bytes = [0x00u8; 32]; + s_bytes[..20].copy_from_slice(sender_address.as_slice()); + let r = U256::from_be_slice(r_biguint.to_bytes_be().as_slice()); + let s = U256::from_be_slice(&s_bytes); + Signature::from_rs_and_parity(r, s, v).expect("Failed to create signature") +} From db1476927977bcd6eaa54a136bd5e822affe7795 Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Mon, 4 Nov 2024 16:27:37 +0100 Subject: [PATCH 07/24] Do not send to reth tx pool. --- crates/telos/rpc/src/eth/transaction.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/crates/telos/rpc/src/eth/transaction.rs b/crates/telos/rpc/src/eth/transaction.rs index e22f31c39f41..722199d5e760 100644 --- a/crates/telos/rpc/src/eth/transaction.rs +++ b/crates/telos/rpc/src/eth/transaction.rs @@ -1,15 +1,19 @@ //! Loads and formats OP transaction RPC response. +use std::str::FromStr; use alloy_primitives::{Bytes, B256}; +use alloy_primitives::private::proptest::collection::vec; +use antelope::api::v1::structs::SendTransactionResponse; +use log::info; use reth_node_api::FullNodeComponents; use reth_provider::{BlockReaderIdExt, TransactionsProvider}; use reth_rpc_eth_api::{ helpers::{EthSigner, EthTransactions, LoadTransaction, SpawnBlocking}, FromEthApiError, FullEthApiTypes, }; -use reth_rpc_eth_types::{utils::recover_raw_transaction, EthStateCache}; +use reth_rpc_eth_types::{utils::recover_raw_transaction, EthApiError, EthStateCache}; use reth_transaction_pool::{PoolTransaction, TransactionOrigin, TransactionPool}; - +use crate::error::TelosEthApiError; use crate::eth::TelosClient; use crate::eth::TelosEthApi; @@ -37,8 +41,8 @@ where if let Some(client) = self.raw_tx_forwarder().as_ref() { tracing::debug!( target: "rpc::eth", "forwarding raw transaction to Telos native"); let result = client.send_to_telos(&tx).await.inspect_err(|err| { - tracing::debug!(target: "rpc::eth", %err, hash=% *pool_transaction.hash(), "failed to forward raw transaction"); - }); + tracing::debug!(target: "rpc::eth", %err, hash=% *pool_transaction.hash(), "failed to forward raw transaction"); + }); // TODO: Retry here if it's a network error, parse errors from Telos and try to return appropriate error to client if let Err(err) = result { @@ -46,13 +50,7 @@ where } } - // submit the transaction to the pool with a `Local` origin - let hash = self - .pool() - .add_transaction(TransactionOrigin::Local, pool_transaction) - .await - .map_err(Self::Error::from_eth_err)?; - + let hash = *pool_transaction.hash(); Ok(hash) } } From 1b9a322cee787348fb342f14925fedaeef259bf7 Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Mon, 4 Nov 2024 17:30:23 +0100 Subject: [PATCH 08/24] Wait for receipt. --- crates/telos/node/tests/live_test_runner.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index 1d47e75a340f..f2f35351b262 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -248,7 +248,7 @@ pub async fn test_double_approve_erc20( let nonce = provider.get_transaction_count(sender_address).await.unwrap(); let chain_id = provider.get_chain_id().await.unwrap(); let gas_price = provider.get_gas_price().await.unwrap(); - + info!("Nonce: {}", nonce); let erc20_contract_address: Address = "0x49f54c5e2301eb9256438123e80762470c2c7ec2".parse().unwrap(); let spender: Address = "0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4".parse().unwrap(); @@ -280,7 +280,7 @@ pub async fn test_double_approve_erc20( let nonce = provider.get_transaction_count(sender_address).await.unwrap(); tx.nonce = Some(nonce); - + info!("Nonce: {}", nonce); // repeat approve let tx_result = provider.send_transaction(tx.clone()).await; assert!(tx_result.is_ok()); @@ -307,7 +307,6 @@ pub async fn test_incorrect_rlp( let chain_id = Some(provider.get_chain_id().await.unwrap()); let nonce = Some(provider.get_transaction_count(sender_address).await.unwrap()); let legacy_tx = tx_trailing_empty_values().unwrap().tx().clone(); - let legacy_tx_request = TransactionRequest { from: Some(sender_address), to: Some(legacy_tx.to), @@ -321,7 +320,9 @@ pub async fn test_incorrect_rlp( }; let tx_result = provider.send_transaction(legacy_tx_request).await; + assert!(tx_result.is_ok()); + let _ = tx_result.unwrap().get_receipt().await.unwrap(); } fn tx_trailing_empty_values() -> eyre::Result> { @@ -352,13 +353,12 @@ pub async fn test_unsigned_trx( let chain_id = Some(provider.get_chain_id().await.unwrap()); let nonce = Some(provider.get_transaction_count(sender_address).await.unwrap()); let legacy_tx = tx_unsigned_trx().unwrap().tx().clone(); - let legacy_tx_request = TransactionRequest { from: Some(sender_address), to: Some(legacy_tx.to), gas: Some(legacy_tx.gas_limit as u64), gas_price: Some(113378400387), - value: Some(legacy_tx.value), + value: Some(U256::from(1)), // update balance to 0 since there is not enough from decoded data on the account input: TransactionInput::from(legacy_tx.input), nonce, chain_id, @@ -366,7 +366,9 @@ pub async fn test_unsigned_trx( }; let tx_result = provider.send_transaction(legacy_tx_request).await; + assert!(tx_result.is_ok()); + let _ = tx_result.unwrap().get_receipt().await.unwrap(); } fn tx_unsigned_trx() -> eyre::Result> { @@ -397,7 +399,6 @@ pub async fn test_unsigned_trx2( let chain_id = Some(provider.get_chain_id().await.unwrap()); let nonce = Some(provider.get_transaction_count(sender_address).await.unwrap()); let legacy_tx = tx_unsigned_trx2().unwrap().tx().clone(); - let legacy_tx_request = TransactionRequest { from: Some(sender_address), to: Some(legacy_tx.to), @@ -411,7 +412,9 @@ pub async fn test_unsigned_trx2( }; let tx_result = provider.send_transaction(legacy_tx_request).await; + assert!(tx_result.is_ok()); + let _ = tx_result.unwrap().get_receipt().await.unwrap(); } fn tx_unsigned_trx2() -> eyre::Result> { @@ -442,7 +445,6 @@ pub async fn test_signed_trx( let chain_id = Some(provider.get_chain_id().await.unwrap()); let nonce = Some(provider.get_transaction_count(sender_address).await.unwrap()); let legacy_tx = tx_signed_trx().unwrap().tx().clone(); - let legacy_tx_request = TransactionRequest { from: Some(sender_address), to: Some(legacy_tx.to), @@ -456,7 +458,9 @@ pub async fn test_signed_trx( }; let tx_result = provider.send_transaction(legacy_tx_request).await; + assert!(tx_result.is_ok()); + let _ = tx_result.unwrap().get_receipt().await.unwrap(); } fn tx_signed_trx() -> eyre::Result> { From 0d5fb63386bf3c0125022444bbf2df00ddc75f0a Mon Sep 17 00:00:00 2001 From: Coa Date: Thu, 7 Nov 2024 16:37:28 +0100 Subject: [PATCH 09/24] Read nonce from the node --- crates/telos/node/tests/integration.rs | 1 + crates/telos/node/tests/live_test_runner.rs | 62 ++++++++++++++++++--- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/crates/telos/node/tests/integration.rs b/crates/telos/node/tests/integration.rs index 1fc3d6e572ab..92dd72c69c66 100644 --- a/crates/telos/node/tests/integration.rs +++ b/crates/telos/node/tests/integration.rs @@ -213,6 +213,7 @@ async fn testing_chain_sync() { } live_test_runner::run_tests( + format!("http://localhost:{chain_port}"), &rpc_url.clone().to_string(), "87ef69a835f8cd0c44ab99b7609a20b2ca7f1c8470af4f0e5b44db927d542084", ) diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index f2f35351b262..bb2ea8bc837f 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -9,30 +9,67 @@ use alloy_rpc_types::TransactionRequest; use alloy_signer_local::PrivateKeySigner; use alloy_sol_types::private::primitives::TxKind::Create; use alloy_sol_types::{sol, SolEvent}; -use antelope::chain::checksum::Checksum256; +use antelope::chain::checksum::Checksum160; +use antelope::{name, StructPacker}; +use antelope::api::{ + client::{APIClient, DefaultProvider}, + v1::structs::{ + GetTableRowsParams, IndexPosition, TableIndexType, + } +}; +use antelope::chain::{ + name::Name, + checksum::Checksum256, + Packer +}; +use antelope::serializer::{Encoder, Decoder}; use num_bigint::{BigUint, ToBigUint}; use reqwest::Url; use reth::primitives::BlockId; use reth::rpc::types::{BlockTransactionsKind, TransactionInput}; +use serde::{Deserialize, Serialize}; use std::fmt::Debug; use std::str::FromStr; -use std::thread::sleep; -use std::time::Duration; use telos_translator_rs::rlp::telos_rlp_decode::TelosTxDecodable; use tracing::info; use reth::primitives::revm_primitives::bytes::Bytes; use reth::revm::primitives::{AccessList, AccessListItem}; +#[derive(Debug, Clone, Default, Serialize, Deserialize, StructPacker)] +pub struct AccountRow { + pub index: u64, + pub address: Checksum160, + pub account: Name, + pub nonce: u64, + pub code: Vec, + pub balance: Checksum256, +} + +fn account_params(account: &str) -> GetTableRowsParams { + GetTableRowsParams { + code: name!("eosio.evm"), + table: name!("account"), + scope: Some(name!("eosio.evm")), + lower_bound: Some(TableIndexType::NAME(name!(account))), + upper_bound: Some(TableIndexType::NAME(name!(account))), + limit: Some(1), + reverse: None, + index_position: Some(IndexPosition::TERTIARY), + show_payer: None, + } +} + #[tokio::test] pub async fn run_local() { env_logger::builder().is_test(true).try_init().unwrap(); + let api_url = "http://localhost:8888".to_string(); let url = "http://localhost:8545"; let private_key = "26e86e45f6fc45ec6e2ecd128cec80fa1d1505e5507dcd2ae58c3130a7a97b48"; - run_tests(url, private_key).await; + run_tests(api_url, url, private_key).await; } -pub async fn run_tests(url: &str, private_key: &str) { +pub async fn run_tests(api_url: String, url: &str, private_key: &str) { let signer = PrivateKeySigner::from_str(private_key).unwrap(); let wallet = EthereumWallet::from(signer.clone()); @@ -49,10 +86,10 @@ pub async fn run_tests(url: &str, private_key: &str) { let block = provider.get_block(BlockId::latest(), BlockTransactionsKind::Full).await; info!("Latest block:\n {:?}", block); - test_blocknum_onchain(url, private_key).await; + test_blocknum_onchain(api_url, url, private_key).await; } -pub async fn test_blocknum_onchain(url: &str, private_key: &str) { +pub async fn test_blocknum_onchain(api_url: String, url: &str, private_key: &str) { sol! { #[sol(rpc, bytecode="6080604052348015600e575f80fd5b5060ef8061001b5f395ff3fe6080604052348015600e575f80fd5b50600436106030575f3560e01c80637f6c6f101460345780638fb82b0214604e575b5f80fd5b603a6056565b6040516045919060a2565b60405180910390f35b6054605d565b005b5f43905090565b437fc04eeb4cfe0799838abac8fa75bca975bff679179886c80c84a7b93229a1a61860405160405180910390a2565b5f819050919050565b609c81608c565b82525050565b5f60208201905060b35f8301846095565b9291505056fea264697066735822122003482ecf0ea4d820deb6b5ebd2755b67c3c8d4fb9ed50a8b4e0bce59613552df64736f6c634300081a0033")] contract BlockNumChecker { @@ -76,9 +113,8 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { let provider = ProviderBuilder::new().wallet(wallet.clone()).on_http(Url::from_str(url).unwrap()); - info!("Deploying contract using address {address}"); - let nonce = provider.get_transaction_count(address).await.unwrap(); + let chain_id = provider.get_chain_id().await.unwrap(); let gas_price = provider.get_gas_price().await.unwrap(); @@ -163,6 +199,14 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { "Block number 5 blocks back via historical eth_call is not correct" ); + info!("Deploying contract using address {address}"); + + let params = account_params("evmuser"); + let api_client = APIClient::::default_provider(api_url, Some(1)).unwrap(); + let row: &AccountRow = &api_client.v1_chain.get_table_rows(params).await.unwrap().rows[0]; + + info!("Account nonce: {}", row.nonce); + // test eip1559 transaction which is not supported test_1559_tx(provider.clone(), address).await; // test eip2930 transaction which is not supported From 3147a2e5b1a932fa2ac144e9cca7eefd37989740 Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Thu, 7 Nov 2024 17:26:50 +0100 Subject: [PATCH 10/24] Assert nonce for the account after the reth is synced with blocks in container. --- Cargo.lock | 43 ++++++++++++++++++--- crates/telos/node/Cargo.toml | 8 ++-- crates/telos/node/tests/integration.rs | 26 +++++++++++-- crates/telos/node/tests/live_test_runner.rs | 20 +++------- crates/telos/rpc/src/eth/transaction.rs | 8 +--- 5 files changed, 72 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4c3432c2841b..04eee602bbe3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1255,6 +1255,39 @@ dependencies = [ "tokio", ] +[[package]] +name = "antelope-client" +version = "0.3.0" +source = "git+https://github.com/telosnetwork/antelope-rs#fea2203b2edb5cfcedd5365031e5286b47dc5c66" +dependencies = [ + "antelope-client-macros", + "async-trait", + "base64 0.21.7", + "bs58", + "chrono", + "digest 0.10.7", + "ecdsa", + "flate2", + "hex", + "hmac 0.12.1", + "k256", + "log", + "once_cell", + "p256", + "rand 0.8.5", + "rand_core 0.6.4", + "reqwest 0.11.27", + "ripemd", + "serde", + "serde-big-array", + "serde_json", + "sha2 0.10.8", + "signature", + "thiserror", + "tokio", + "tracing", +] + [[package]] name = "antelope-client-macros" version = "0.2.0" @@ -9391,7 +9424,7 @@ dependencies = [ "alloy-signer-local", "alloy-sol-types", "alloy-transport-http 0.4.2", - "antelope-client", + "antelope-client 0.2.1", "clap", "derive_more 1.0.0", "env_logger 0.11.5", @@ -10574,7 +10607,7 @@ dependencies = [ "alloy-network 0.4.2", "alloy-primitives", "alloy-rpc-types 0.4.2", - "antelope-client", + "antelope-client 0.2.1", "async-trait", "derive_more 1.0.0", "jsonrpsee-types", @@ -12041,12 +12074,11 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "telos-consensus-client" version = "0.1.0" -source = "git+https://github.com/telosnetwork/telos-consensus-client?rev=f8ecbe1aeea57911c9fbefdddf49efa92d8472ce#f8ecbe1aeea57911c9fbefdddf49efa92d8472ce" dependencies = [ "alloy", "alloy-consensus 0.3.6", "alloy-rlp", - "antelope-client", + "antelope-client 0.3.0", "arrowbatch", "base64 0.22.1", "bytes", @@ -12092,13 +12124,12 @@ dependencies = [ [[package]] name = "telos-translator-rs" version = "0.1.0" -source = "git+https://github.com/telosnetwork/telos-consensus-client?rev=f8ecbe1aeea57911c9fbefdddf49efa92d8472ce#f8ecbe1aeea57911c9fbefdddf49efa92d8472ce" dependencies = [ "alloy", "alloy-consensus 0.3.6", "alloy-eips 0.3.6", "alloy-rlp", - "antelope-client", + "antelope-client 0.3.0", "bytes", "clap", "dashmap 5.5.3", diff --git a/crates/telos/node/Cargo.toml b/crates/telos/node/Cargo.toml index a8bdaf3c33bc..5b2ac57e8554 100644 --- a/crates/telos/node/Cargo.toml +++ b/crates/telos/node/Cargo.toml @@ -77,10 +77,10 @@ reqwest.workspace = true reth-e2e-test-utils.workspace = true eyre.workspace = true -telos-consensus-client = { git = "https://github.com/telosnetwork/telos-consensus-client", rev = "f8ecbe1aeea57911c9fbefdddf49efa92d8472ce" } -telos-translator-rs = { git = "https://github.com/telosnetwork/telos-consensus-client", rev = "f8ecbe1aeea57911c9fbefdddf49efa92d8472ce" } -#telos-consensus-client = { path = "../../../../telos-consensus-client/client" } -#telos-translator-rs = { path = "../../../../telos-consensus-client/translator" } +#telos-consensus-client = { git = "https://github.com/telosnetwork/telos-consensus-client", rev = "f8ecbe1aeea57911c9fbefdddf49efa92d8472ce" } +#telos-translator-rs = { git = "https://github.com/telosnetwork/telos-consensus-client", rev = "f8ecbe1aeea57911c9fbefdddf49efa92d8472ce" } +telos-consensus-client = { path = "../../../../telos-consensus-client/client" } +telos-translator-rs = { path = "../../../../telos-consensus-client/translator" } env_logger = "0.11.5" testcontainers = "0.21.1" diff --git a/crates/telos/node/tests/integration.rs b/crates/telos/node/tests/integration.rs index 92dd72c69c66..da856b2e9ee4 100644 --- a/crates/telos/node/tests/integration.rs +++ b/crates/telos/node/tests/integration.rs @@ -1,4 +1,4 @@ -use alloy_provider::{Provider, ProviderBuilder}; +use alloy_provider::{Provider, ProviderBuilder, ReqwestProvider}; use antelope::api::client::{APIClient, DefaultProvider}; use reqwest::Url; use reth::{ @@ -11,6 +11,8 @@ use reth_e2e_test_utils::node::NodeTestContext; use reth_node_telos::{TelosArgs, TelosNode}; use reth_telos_rpc::TelosClient; use std::{fs, path::PathBuf, sync::Arc, time::Duration}; +use std::str::FromStr; +use alloy_primitives::Address; use telos_consensus_client::{ client::ConsensusClient, config::{AppConfig, CliArgs}, @@ -37,6 +39,10 @@ const CONTAINER_TAG: &str = // This is the last block in the container, after this block the node is done syncing and is running live const CONTAINER_LAST_EVM_BLOCK: u64 = 1010; +// evmuser address from the container +const EVM_USER_ADDRESS: &str = "0x4c641f9b61809fadeef2ec64f54ea2bcb398e4f3"; +const EVM_USER: &str = "evmuser"; + async fn start_ship() -> ContainerAsync { // Change this container to a local image if using new ship data, // then make sure to update the ship data in the testcontainer-nodeos-evm repo and build a new version @@ -198,6 +204,7 @@ async fn testing_chain_sync() { let rpc_url = Url::from(format!("http://localhost:{}", rpc_port).parse().unwrap()); let provider = ProviderBuilder::new().on_http(rpc_url.clone()); + let api_client = APIClient::::default_provider(format!("http://localhost:{chain_port}").to_string(), Some(1)).unwrap(); loop { tokio::time::sleep(Duration::from_secs(1)).await; @@ -208,16 +215,17 @@ async fn testing_chain_sync() { break; } if latest_block > CONTAINER_LAST_EVM_BLOCK { + // test account nonce after successful reth sync from the container + test_evm_address_nonce(provider, api_client).await; break; } } live_test_runner::run_tests( - format!("http://localhost:{chain_port}"), &rpc_url.clone().to_string(), "87ef69a835f8cd0c44ab99b7609a20b2ca7f1c8470af4f0e5b44db927d542084", ) - .await; + .await; _ = translator_shutdown.shutdown().await.unwrap(); _ = consensus_shutdown.shutdown().await.unwrap(); @@ -227,3 +235,15 @@ async fn testing_chain_sync() { _ = tokio::join!(client_handle, translator_handle); println!("Translator shutdown done."); } + +async fn test_evm_address_nonce(provider: ReqwestProvider, api_client: APIClient) { + let params = live_test_runner::account_params(EVM_USER); + let row: &live_test_runner::AccountRow = &api_client.v1_chain.get_table_rows(params).await.unwrap().rows[0]; + + let account = provider.get_account(Address::from_str(EVM_USER_ADDRESS).unwrap()).await.unwrap(); + let tx_count = provider.get_transaction_count(Address::from_str(EVM_USER_ADDRESS).unwrap()).await.unwrap(); + // assert nonce of the account that has sent transactions in the container blocks + assert_eq!(account.nonce, 2); + assert_eq!(account.nonce, tx_count); + assert_eq!(account.nonce, row.nonce); +} diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index bb2ea8bc837f..5813bf25c512 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -12,7 +12,6 @@ use alloy_sol_types::{sol, SolEvent}; use antelope::chain::checksum::Checksum160; use antelope::{name, StructPacker}; use antelope::api::{ - client::{APIClient, DefaultProvider}, v1::structs::{ GetTableRowsParams, IndexPosition, TableIndexType, } @@ -46,7 +45,7 @@ pub struct AccountRow { pub balance: Checksum256, } -fn account_params(account: &str) -> GetTableRowsParams { +pub(crate) fn account_params(account: &str) -> GetTableRowsParams { GetTableRowsParams { code: name!("eosio.evm"), table: name!("account"), @@ -63,13 +62,12 @@ fn account_params(account: &str) -> GetTableRowsParams { #[tokio::test] pub async fn run_local() { env_logger::builder().is_test(true).try_init().unwrap(); - let api_url = "http://localhost:8888".to_string(); let url = "http://localhost:8545"; let private_key = "26e86e45f6fc45ec6e2ecd128cec80fa1d1505e5507dcd2ae58c3130a7a97b48"; - run_tests(api_url, url, private_key).await; + run_tests(url, private_key).await; } -pub async fn run_tests(api_url: String, url: &str, private_key: &str) { +pub async fn run_tests(url: &str, private_key: &str) { let signer = PrivateKeySigner::from_str(private_key).unwrap(); let wallet = EthereumWallet::from(signer.clone()); @@ -86,10 +84,10 @@ pub async fn run_tests(api_url: String, url: &str, private_key: &str) { let block = provider.get_block(BlockId::latest(), BlockTransactionsKind::Full).await; info!("Latest block:\n {:?}", block); - test_blocknum_onchain(api_url, url, private_key).await; + test_blocknum_onchain(url, private_key).await; } -pub async fn test_blocknum_onchain(api_url: String, url: &str, private_key: &str) { +pub async fn test_blocknum_onchain(url: &str, private_key: &str) { sol! { #[sol(rpc, bytecode="6080604052348015600e575f80fd5b5060ef8061001b5f395ff3fe6080604052348015600e575f80fd5b50600436106030575f3560e01c80637f6c6f101460345780638fb82b0214604e575b5f80fd5b603a6056565b6040516045919060a2565b60405180910390f35b6054605d565b005b5f43905090565b437fc04eeb4cfe0799838abac8fa75bca975bff679179886c80c84a7b93229a1a61860405160405180910390a2565b5f819050919050565b609c81608c565b82525050565b5f60208201905060b35f8301846095565b9291505056fea264697066735822122003482ecf0ea4d820deb6b5ebd2755b67c3c8d4fb9ed50a8b4e0bce59613552df64736f6c634300081a0033")] contract BlockNumChecker { @@ -201,12 +199,6 @@ pub async fn test_blocknum_onchain(api_url: String, url: &str, private_key: &str info!("Deploying contract using address {address}"); - let params = account_params("evmuser"); - let api_client = APIClient::::default_provider(api_url, Some(1)).unwrap(); - let row: &AccountRow = &api_client.v1_chain.get_table_rows(params).await.unwrap().rows[0]; - - info!("Account nonce: {}", row.nonce); - // test eip1559 transaction which is not supported test_1559_tx(provider.clone(), address).await; // test eip2930 transaction which is not supported @@ -218,7 +210,6 @@ pub async fn test_blocknum_onchain(api_url: String, url: &str, private_key: &str test_unsigned_trx(provider.clone(), address).await; test_unsigned_trx2(provider.clone(), address).await; test_signed_trx(provider.clone(), address).await; - // The below needs to be done using LegacyTransaction style call... with the current code it's including base_fee_per_gas and being rejected by reth // let block_num_latest = block_num_checker.getBlockNum().call().await.unwrap(); // assert!(block_num_latest._0 > U256::from(rpc_block_num), "Latest block number via call to getBlockNum is not greater than the block number in the previous log event"); @@ -227,6 +218,7 @@ pub async fn test_blocknum_onchain(api_url: String, url: &str, private_key: &str // assert!(block_num_five_back._0 == U256::from(rpc_block_num - 5), "Block number 5 blocks back via historical eth_call is not correct"); } + // test_1559_tx tests sending eip1559 transaction that has max_priority_fee_per_gas and max_fee_per_gas set pub async fn test_1559_tx( provider: impl Provider + Send + Sync, diff --git a/crates/telos/rpc/src/eth/transaction.rs b/crates/telos/rpc/src/eth/transaction.rs index 722199d5e760..18319c389691 100644 --- a/crates/telos/rpc/src/eth/transaction.rs +++ b/crates/telos/rpc/src/eth/transaction.rs @@ -1,19 +1,15 @@ //! Loads and formats OP transaction RPC response. -use std::str::FromStr; use alloy_primitives::{Bytes, B256}; -use alloy_primitives::private::proptest::collection::vec; use antelope::api::v1::structs::SendTransactionResponse; -use log::info; use reth_node_api::FullNodeComponents; use reth_provider::{BlockReaderIdExt, TransactionsProvider}; use reth_rpc_eth_api::{ helpers::{EthSigner, EthTransactions, LoadTransaction, SpawnBlocking}, FromEthApiError, FullEthApiTypes, }; -use reth_rpc_eth_types::{utils::recover_raw_transaction, EthApiError, EthStateCache}; -use reth_transaction_pool::{PoolTransaction, TransactionOrigin, TransactionPool}; -use crate::error::TelosEthApiError; +use reth_rpc_eth_types::{utils::recover_raw_transaction, EthStateCache}; +use reth_transaction_pool::{PoolTransaction, TransactionPool}; use crate::eth::TelosClient; use crate::eth::TelosEthApi; From f0c8a43af6d801477aed46c63e1d8157581c12ea Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Fri, 15 Nov 2024 15:41:52 +0100 Subject: [PATCH 11/24] Add a revision test check. --- Cargo.lock | 245 +++----------------- Cargo.toml | 2 +- crates/telos/node/tests/integration.rs | 42 +++- crates/telos/node/tests/live_test_runner.rs | 43 ++-- crates/telos/node/tests/main.rs | 2 +- 5 files changed, 96 insertions(+), 238 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 04eee602bbe3..6aec1c65c07f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -501,7 +501,7 @@ dependencies = [ "alloy-primitives", "alloy-pubsub", "alloy-rpc-client 0.4.2", - "alloy-rpc-types-admin 0.4.2", + "alloy-rpc-types-admin", "alloy-rpc-types-engine 0.4.2", "alloy-rpc-types-eth 0.4.2", "alloy-transport 0.4.2", @@ -635,18 +635,6 @@ dependencies = [ "serde", ] -[[package]] -name = "alloy-rpc-types-admin" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fefd12e99dd6b7de387ed13ad047ce2c90d8950ca62fc48b8a457ebb8f936c61" -dependencies = [ - "alloy-genesis 0.3.6", - "alloy-primitives", - "serde", - "serde_json", -] - [[package]] name = "alloy-rpc-types-admin" version = "0.4.2" @@ -659,17 +647,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "alloy-rpc-types-anvil" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d25cb45ad7c0930dd62eecf164d2afe4c3d2dd2c82af85680ad1f118e1e5cb83" -dependencies = [ - "alloy-primitives", - "alloy-serde 0.3.6", - "serde", -] - [[package]] name = "alloy-rpc-types-anvil" version = "0.4.2" @@ -681,20 +658,6 @@ dependencies = [ "serde", ] -[[package]] -name = "alloy-rpc-types-beacon" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7081d2206dca51ce23a06338d78d9b536931cc3f15134fc1c6535eb2b77f18" -dependencies = [ - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-rpc-types-engine 0.3.6", - "serde", - "serde_with", - "thiserror", -] - [[package]] name = "alloy-rpc-types-beacon" version = "0.4.2" @@ -731,7 +694,8 @@ dependencies = [ "alloy-rlp", "alloy-serde 0.3.6", "derive_more 1.0.0", - "jsonrpsee-types", + "jsonwebtoken", + "rand 0.8.5", "serde", ] @@ -771,7 +735,6 @@ dependencies = [ "derive_more 1.0.0", "hashbrown 0.14.5", "itertools 0.13.0", - "jsonrpsee-types", "serde", "serde_json", ] @@ -796,19 +759,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "alloy-rpc-types-mev" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "922d92389e5022650c4c60ffd2f9b2467c3f853764f0f74ff16a23106f9017d5" -dependencies = [ - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-serde 0.3.6", - "serde", - "serde_json", -] - [[package]] name = "alloy-rpc-types-mev" version = "0.4.2" @@ -822,20 +772,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "alloy-rpc-types-trace" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98db35cd42c90b484377e6bc44d95377a7a38a5ebee996e67754ac0446d542ab" -dependencies = [ - "alloy-primitives", - "alloy-rpc-types-eth 0.3.6", - "alloy-serde 0.3.6", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "alloy-rpc-types-trace" version = "0.4.2" @@ -850,18 +786,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "alloy-rpc-types-txpool" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bac37082c3b21283b3faf5cc0e08974272aee2f756ce1adeb26db56a5fce0d5" -dependencies = [ - "alloy-primitives", - "alloy-rpc-types-eth 0.3.6", - "alloy-serde 0.3.6", - "serde", -] - [[package]] name = "alloy-rpc-types-txpool" version = "0.4.2" @@ -1223,42 +1147,10 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "antelope-client" -version = "0.2.1" -source = "git+https://github.com/telosnetwork/antelope-rs?branch=development#ed53c75b6b9ce14aa72002ddd491a6697ae563d9" -dependencies = [ - "antelope-client-macros", - "async-trait", - "base64 0.21.7", - "bs58", - "chrono", - "digest 0.10.7", - "ecdsa", - "flate2", - "hex", - "hmac 0.12.1", - "k256", - "log", - "once_cell", - "p256", - "rand 0.8.5", - "rand_core 0.6.4", - "reqwest 0.11.27", - "ripemd", - "serde", - "serde-big-array", - "serde_json", - "sha2 0.10.8", - "signature", - "thiserror", - "tokio", -] - [[package]] name = "antelope-client" version = "0.3.0" -source = "git+https://github.com/telosnetwork/antelope-rs#fea2203b2edb5cfcedd5365031e5286b47dc5c66" +source = "git+https://github.com/telosnetwork/antelope-rs?branch=master#fea2203b2edb5cfcedd5365031e5286b47dc5c66" dependencies = [ "antelope-client-macros", "async-trait", @@ -3545,7 +3437,7 @@ name = "example-beacon-api-sidecar-fetcher" version = "0.1.0" dependencies = [ "alloy-primitives", - "alloy-rpc-types-beacon 0.4.2", + "alloy-rpc-types-beacon", "clap", "eyre", "futures-util", @@ -3561,7 +3453,7 @@ dependencies = [ name = "example-beacon-api-sse" version = "0.0.0" dependencies = [ - "alloy-rpc-types-beacon 0.4.2", + "alloy-rpc-types-beacon", "clap", "futures-util", "mev-share-sse", @@ -3837,7 +3729,7 @@ name = "example-txpool-tracing" version = "0.0.0" dependencies = [ "alloy-primitives", - "alloy-rpc-types-trace 0.4.2", + "alloy-rpc-types-trace", "clap", "futures-util", "reth", @@ -6365,20 +6257,6 @@ dependencies = [ "spin", ] -[[package]] -name = "op-alloy-genesis" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e1b8a9b70da0e027242ec1762f0f3a386278b6291d00d12ff5a64929dc19f68" -dependencies = [ - "alloy-consensus 0.3.6", - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-sol-types", - "serde", - "serde_repr", -] - [[package]] name = "op-alloy-genesis" version = "0.3.3" @@ -6407,23 +6285,6 @@ dependencies = [ "op-alloy-rpc-types 0.3.3", ] -[[package]] -name = "op-alloy-protocol" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf300a82ae2d30e2255bfea87a2259da49f63a25a44db561ae64cc9e3084139f" -dependencies = [ - "alloy-consensus 0.3.6", - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.3.6", - "hashbrown 0.14.5", - "op-alloy-consensus 0.2.12", - "op-alloy-genesis 0.2.12", - "serde", -] - [[package]] name = "op-alloy-protocol" version = "0.3.3" @@ -6437,7 +6298,7 @@ dependencies = [ "alloy-serde 0.4.2", "derive_more 1.0.0", "op-alloy-consensus 0.3.3", - "op-alloy-genesis 0.3.3", + "op-alloy-genesis", "serde", ] @@ -6476,23 +6337,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "op-alloy-rpc-types-engine" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2947272a81ebf988f4804b6f0f6a7c0b2f6f89a908cb410e36f8f3828f81c778" -dependencies = [ - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-rpc-types-engine 0.3.6", - "alloy-serde 0.3.6", - "derive_more 1.0.0", - "op-alloy-consensus 0.2.12", - "op-alloy-genesis 0.2.12", - "op-alloy-protocol 0.2.12", - "serde", -] - [[package]] name = "op-alloy-rpc-types-engine" version = "0.3.3" @@ -6503,7 +6347,7 @@ dependencies = [ "alloy-rpc-types-engine 0.4.2", "alloy-serde 0.4.2", "derive_more 1.0.0", - "op-alloy-protocol 0.3.3", + "op-alloy-protocol", "serde", ] @@ -8354,7 +8198,7 @@ dependencies = [ "futures-util", "jsonrpsee", "jsonrpsee-types", - "op-alloy-rpc-types-engine 0.3.3", + "op-alloy-rpc-types-engine", "reth", "reth-chainspec", "reth-db", @@ -9106,7 +8950,7 @@ name = "reth-network-api" version = "1.0.8" dependencies = [ "alloy-primitives", - "alloy-rpc-types-admin 0.4.2", + "alloy-rpc-types-admin", "auto_impl", "derive_more 1.0.0", "enr", @@ -9424,7 +9268,7 @@ dependencies = [ "alloy-signer-local", "alloy-sol-types", "alloy-transport-http 0.4.2", - "antelope-client 0.2.1", + "antelope-client", "clap", "derive_more 1.0.0", "env_logger 0.11.5", @@ -9599,7 +9443,7 @@ dependencies = [ "jsonrpsee", "jsonrpsee-types", "op-alloy-consensus 0.3.3", - "op-alloy-rpc-types-engine 0.3.3", + "op-alloy-rpc-types-engine", "parking_lot 0.12.3", "reqwest 0.12.8", "reth", @@ -9646,7 +9490,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-rpc-types-engine 0.4.2", - "op-alloy-rpc-types-engine 0.3.3", + "op-alloy-rpc-types-engine", "reth-basic-payload-builder", "reth-chain-state", "reth-chainspec", @@ -9758,7 +9602,7 @@ dependencies = [ "alloy-primitives", "alloy-rpc-types 0.4.2", "async-trait", - "op-alloy-rpc-types-engine 0.3.3", + "op-alloy-rpc-types-engine", "pin-project", "reth-chain-state", "reth-chainspec", @@ -10040,12 +9884,12 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-rpc-types 0.4.2", - "alloy-rpc-types-admin 0.4.2", + "alloy-rpc-types-admin", "alloy-rpc-types-debug", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-mev 0.4.2", - "alloy-rpc-types-trace 0.4.2", - "alloy-rpc-types-txpool 0.4.2", + "alloy-rpc-types-mev", + "alloy-rpc-types-trace", + "alloy-rpc-types-txpool", "alloy-serde 0.4.2", "alloy-signer 0.4.2", "alloy-signer-local", @@ -10105,15 +9949,15 @@ dependencies = [ "alloy-json-rpc 0.4.2", "alloy-primitives", "alloy-rpc-types 0.4.2", - "alloy-rpc-types-admin 0.4.2", - "alloy-rpc-types-anvil 0.4.2", - "alloy-rpc-types-beacon 0.4.2", + "alloy-rpc-types-admin", + "alloy-rpc-types-anvil", + "alloy-rpc-types-beacon", "alloy-rpc-types-debug", "alloy-rpc-types-engine 0.4.2", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-mev 0.4.2", - "alloy-rpc-types-trace 0.4.2", - "alloy-rpc-types-txpool 0.4.2", + "alloy-rpc-types-mev", + "alloy-rpc-types-trace", + "alloy-rpc-types-txpool", "alloy-serde 0.4.2", "jsonrpsee", "reth-engine-primitives", @@ -10131,7 +9975,7 @@ dependencies = [ "alloy-primitives", "alloy-rpc-types 0.4.2", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-trace 0.4.2", + "alloy-rpc-types-trace", "futures", "jsonrpsee", "jsonrpsee-http-client", @@ -10152,7 +9996,7 @@ dependencies = [ "alloy-rpc-types 0.4.2", "alloy-rpc-types-engine 0.4.2", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-trace 0.4.2", + "alloy-rpc-types-trace", "alloy-serde 0.4.2", "clap", "http 1.1.0", @@ -10243,7 +10087,7 @@ dependencies = [ "alloy-primitives", "alloy-rpc-types 0.4.2", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-mev 0.4.2", + "alloy-rpc-types-mev", "async-trait", "auto_impl", "dyn-clone", @@ -10346,26 +10190,6 @@ dependencies = [ "strum", ] -[[package]] -name = "reth-rpc-types" -version = "1.0.6" -source = "git+https://github.com/telosnetwork/telos-reth?branch=telos-main#63d23e00982a0ab7704a6dff97b3f5d355e11d56" -dependencies = [ - "alloy-primitives", - "alloy-rpc-types 0.3.6", - "alloy-rpc-types-admin 0.3.6", - "alloy-rpc-types-anvil 0.3.6", - "alloy-rpc-types-beacon 0.3.6", - "alloy-rpc-types-engine 0.3.6", - "alloy-rpc-types-mev 0.3.6", - "alloy-rpc-types-trace 0.3.6", - "alloy-rpc-types-txpool 0.3.6", - "alloy-serde 0.3.6", - "jsonrpsee-types", - "op-alloy-rpc-types 0.2.12", - "op-alloy-rpc-types-engine 0.2.12", -] - [[package]] name = "reth-rpc-types-compat" version = "1.0.8" @@ -10607,7 +10431,7 @@ dependencies = [ "alloy-network 0.4.2", "alloy-primitives", "alloy-rpc-types 0.4.2", - "antelope-client 0.2.1", + "antelope-client", "async-trait", "derive_more 1.0.0", "jsonrpsee-types", @@ -10895,7 +10719,7 @@ source = "git+https://github.com/telosnetwork/telos-evm-inspectors?branch=telos- dependencies = [ "alloy-primitives", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-trace 0.4.2", + "alloy-rpc-types-trace", "alloy-sol-types", "anstyle", "boa_engine", @@ -12078,7 +11902,9 @@ dependencies = [ "alloy", "alloy-consensus 0.3.6", "alloy-rlp", - "antelope-client 0.3.0", + "alloy-rpc-types 0.3.6", + "alloy-rpc-types-engine 0.3.6", + "antelope-client", "arrowbatch", "base64 0.22.1", "bytes", @@ -12092,7 +11918,6 @@ dependencies = [ "rand 0.8.5", "reqwest 0.11.27", "reth-primitives 1.0.6", - "reth-rpc-types", "rocksdb", "serde", "serde_json", @@ -12129,7 +11954,8 @@ dependencies = [ "alloy-consensus 0.3.6", "alloy-eips 0.3.6", "alloy-rlp", - "antelope-client 0.3.0", + "alloy-rpc-types-engine 0.3.6", + "antelope-client", "bytes", "clap", "dashmap 5.5.3", @@ -12141,7 +11967,6 @@ dependencies = [ "moka", "num-bigint", "reth-primitives 1.0.6", - "reth-rpc-types", "reth-telos-rpc-engine-api 1.0.6", "reth-trie-common 1.0.6", "rlp", diff --git a/Cargo.toml b/Cargo.toml index 710e36b25017..62025e2ea230 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -601,7 +601,7 @@ reth-node-telos = { path = "crates/telos/node" } reth-telos-rpc = { path = "crates/telos/rpc" } reth-telos-primitives-traits = { path = "crates/telos/primitives-traits" } reth-telos-rpc-engine-api = { path = "crates/telos/rpc-engine-api" } -antelope-client = { git = "https://github.com/telosnetwork/antelope-rs", branch = "development" } +antelope-client = { git = "https://github.com/telosnetwork/antelope-rs", branch = "master" } [patch.crates-io] #alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} diff --git a/crates/telos/node/tests/integration.rs b/crates/telos/node/tests/integration.rs index da856b2e9ee4..45266875cd70 100644 --- a/crates/telos/node/tests/integration.rs +++ b/crates/telos/node/tests/integration.rs @@ -1,5 +1,11 @@ +use crate::live_test_runner::ConfigRow; +use alloy_primitives::Address; use alloy_provider::{Provider, ProviderBuilder, ReqwestProvider}; use antelope::api::client::{APIClient, DefaultProvider}; +use antelope::chain::binary_extension::BinaryExtension; +use antelope::chain::checksum::Checksum256; +use antelope::serializer::Decoder; +use antelope::StructPacker; use reqwest::Url; use reth::{ args::RpcServerArgs, @@ -10,14 +16,16 @@ use reth_chainspec::{ChainSpec, ChainSpecBuilder, TEVMTESTNET}; use reth_e2e_test_utils::node::NodeTestContext; use reth_node_telos::{TelosArgs, TelosNode}; use reth_telos_rpc::TelosClient; -use std::{fs, path::PathBuf, sync::Arc, time::Duration}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; use std::str::FromStr; -use alloy_primitives::Address; +use std::{fs, path::PathBuf, sync::Arc, time::Duration}; use telos_consensus_client::{ client::ConsensusClient, config::{AppConfig, CliArgs}, main_utils::build_consensus_client, }; +use telos_translator_rs::types::evm_types::{AccountRow, EvmContractConfigRow}; use telos_translator_rs::{ block::TelosEVMBlock, translator::Translator, types::translator_types::ChainId, }; @@ -25,6 +33,7 @@ use testcontainers::{ core::ContainerPort::Tcp, runners::AsyncRunner, ContainerAsync, GenericImage, }; use tokio::sync::mpsc; +use tracing::info; pub mod live_test_runner; @@ -204,7 +213,14 @@ async fn testing_chain_sync() { let rpc_url = Url::from(format!("http://localhost:{}", rpc_port).parse().unwrap()); let provider = ProviderBuilder::new().on_http(rpc_url.clone()); - let api_client = APIClient::::default_provider(format!("http://localhost:{chain_port}").to_string(), Some(1)).unwrap(); + + info!("Client URL {:?}", format!("http://localhost:{chain_port}")); + + let api_client = APIClient::::default_provider( + format!("http://localhost:{chain_port}").to_string(), + Some(1), + ) + .unwrap(); loop { tokio::time::sleep(Duration::from_secs(1)).await; @@ -216,7 +232,9 @@ async fn testing_chain_sync() { } if latest_block > CONTAINER_LAST_EVM_BLOCK { // test account nonce after successful reth sync from the container - test_evm_address_nonce(provider, api_client).await; + test_evm_address_nonce(provider, api_client.clone()).await; + // test current revision from the transactions in the container + test_revision(api_client).await; break; } } @@ -225,7 +243,7 @@ async fn testing_chain_sync() { &rpc_url.clone().to_string(), "87ef69a835f8cd0c44ab99b7609a20b2ca7f1c8470af4f0e5b44db927d542084", ) - .await; + .await; _ = translator_shutdown.shutdown().await.unwrap(); _ = consensus_shutdown.shutdown().await.unwrap(); @@ -238,12 +256,22 @@ async fn testing_chain_sync() { async fn test_evm_address_nonce(provider: ReqwestProvider, api_client: APIClient) { let params = live_test_runner::account_params(EVM_USER); - let row: &live_test_runner::AccountRow = &api_client.v1_chain.get_table_rows(params).await.unwrap().rows[0]; + let row: &AccountRow = &api_client.v1_chain.get_table_rows(params).await.unwrap().rows[0]; let account = provider.get_account(Address::from_str(EVM_USER_ADDRESS).unwrap()).await.unwrap(); - let tx_count = provider.get_transaction_count(Address::from_str(EVM_USER_ADDRESS).unwrap()).await.unwrap(); + let tx_count = + provider.get_transaction_count(Address::from_str(EVM_USER_ADDRESS).unwrap()).await.unwrap(); // assert nonce of the account that has sent transactions in the container blocks assert_eq!(account.nonce, 2); assert_eq!(account.nonce, tx_count); assert_eq!(account.nonce, row.nonce); } + +async fn test_revision(api_client: APIClient) { + // revision in the container transaction is set to 1 + let expected_revision = 1u32; + let params = live_test_runner::config_params(); + let row: &ConfigRow = &api_client.v1_chain.get_table_rows(params).await.unwrap().rows[0]; + + assert_eq!(*row.revision.value().unwrap(), expected_revision); +} diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index 5813bf25c512..fdaebd6c37c3 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -9,19 +9,12 @@ use alloy_rpc_types::TransactionRequest; use alloy_signer_local::PrivateKeySigner; use alloy_sol_types::private::primitives::TxKind::Create; use alloy_sol_types::{sol, SolEvent}; +use antelope::api::v1::structs::{GetTableRowsParams, IndexPosition, TableIndexType}; +use antelope::chain::binary_extension::BinaryExtension; use antelope::chain::checksum::Checksum160; +use antelope::chain::{checksum::Checksum256, name::Name, Packer}; +use antelope::serializer::{Decoder, Encoder}; use antelope::{name, StructPacker}; -use antelope::api::{ - v1::structs::{ - GetTableRowsParams, IndexPosition, TableIndexType, - } -}; -use antelope::chain::{ - name::Name, - checksum::Checksum256, - Packer -}; -use antelope::serializer::{Encoder, Decoder}; use num_bigint::{BigUint, ToBigUint}; use reqwest::Url; use reth::primitives::BlockId; @@ -36,13 +29,12 @@ use reth::primitives::revm_primitives::bytes::Bytes; use reth::revm::primitives::{AccessList, AccessListItem}; #[derive(Debug, Clone, Default, Serialize, Deserialize, StructPacker)] -pub struct AccountRow { - pub index: u64, - pub address: Checksum160, - pub account: Name, - pub nonce: u64, - pub code: Vec, - pub balance: Checksum256, +pub struct ConfigRow { + pub trx_index: u32, + pub last_block: u32, + pub gas_used_block: Checksum256, + pub gas_price: Checksum256, + pub revision: BinaryExtension, } pub(crate) fn account_params(account: &str) -> GetTableRowsParams { @@ -59,6 +51,20 @@ pub(crate) fn account_params(account: &str) -> GetTableRowsParams { } } +pub(crate) fn config_params() -> GetTableRowsParams { + GetTableRowsParams { + code: name!("eosio.evm"), + table: name!("config"), + scope: Some(name!("eosio.evm")), + lower_bound: None, + upper_bound: None, + limit: Some(1), + reverse: None, + index_position: None, + show_payer: None, + } +} + #[tokio::test] pub async fn run_local() { env_logger::builder().is_test(true).try_init().unwrap(); @@ -218,7 +224,6 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { // assert!(block_num_five_back._0 == U256::from(rpc_block_num - 5), "Block number 5 blocks back via historical eth_call is not correct"); } - // test_1559_tx tests sending eip1559 transaction that has max_priority_fee_per_gas and max_fee_per_gas set pub async fn test_1559_tx( provider: impl Provider + Send + Sync, diff --git a/crates/telos/node/tests/main.rs b/crates/telos/node/tests/main.rs index 43614c668a2c..c5818b75ca1a 100644 --- a/crates/telos/node/tests/main.rs +++ b/crates/telos/node/tests/main.rs @@ -1,4 +1,4 @@ mod integration; pub mod live_test_runner; -const fn main() {} \ No newline at end of file +const fn main() {} From 20ba9a43b8ac13aee2d62ff4e7d4a4deed4b9bb0 Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Fri, 15 Nov 2024 16:07:21 +0100 Subject: [PATCH 12/24] Remove unused config struct. --- crates/telos/node/tests/integration.rs | 3 +-- crates/telos/node/tests/live_test_runner.rs | 9 --------- crates/telos/rpc/src/eth/transaction.rs | 1 - 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/crates/telos/node/tests/integration.rs b/crates/telos/node/tests/integration.rs index 45266875cd70..bb2b54ca2d4b 100644 --- a/crates/telos/node/tests/integration.rs +++ b/crates/telos/node/tests/integration.rs @@ -1,4 +1,3 @@ -use crate::live_test_runner::ConfigRow; use alloy_primitives::Address; use alloy_provider::{Provider, ProviderBuilder, ReqwestProvider}; use antelope::api::client::{APIClient, DefaultProvider}; @@ -271,7 +270,7 @@ async fn test_revision(api_client: APIClient) { // revision in the container transaction is set to 1 let expected_revision = 1u32; let params = live_test_runner::config_params(); - let row: &ConfigRow = &api_client.v1_chain.get_table_rows(params).await.unwrap().rows[0]; + let row: &EvmContractConfigRow = &api_client.v1_chain.get_table_rows(params).await.unwrap().rows[0]; assert_eq!(*row.revision.value().unwrap(), expected_revision); } diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index fdaebd6c37c3..8b8bf4ac924a 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -28,15 +28,6 @@ use tracing::info; use reth::primitives::revm_primitives::bytes::Bytes; use reth::revm::primitives::{AccessList, AccessListItem}; -#[derive(Debug, Clone, Default, Serialize, Deserialize, StructPacker)] -pub struct ConfigRow { - pub trx_index: u32, - pub last_block: u32, - pub gas_used_block: Checksum256, - pub gas_price: Checksum256, - pub revision: BinaryExtension, -} - pub(crate) fn account_params(account: &str) -> GetTableRowsParams { GetTableRowsParams { code: name!("eosio.evm"), diff --git a/crates/telos/rpc/src/eth/transaction.rs b/crates/telos/rpc/src/eth/transaction.rs index 18319c389691..20a60e2572cb 100644 --- a/crates/telos/rpc/src/eth/transaction.rs +++ b/crates/telos/rpc/src/eth/transaction.rs @@ -1,7 +1,6 @@ //! Loads and formats OP transaction RPC response. use alloy_primitives::{Bytes, B256}; -use antelope::api::v1::structs::SendTransactionResponse; use reth_node_api::FullNodeComponents; use reth_provider::{BlockReaderIdExt, TransactionsProvider}; use reth_rpc_eth_api::{ From 79ddc0962d03c869f6bddd0c0ba0373ade01e99f Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Wed, 27 Nov 2024 17:17:45 +0100 Subject: [PATCH 13/24] Use send2 in tests. --- Cargo.lock | 1 - Cargo.toml | 3 ++- crates/telos/node/tests/live_test_runner.rs | 25 ------------------ crates/telos/rpc/src/eth/telos_client.rs | 29 +++++++++++---------- crates/telos/rpc/src/eth/transaction.rs | 2 +- 5 files changed, 18 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6aec1c65c07f..09c2564d66f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1150,7 +1150,6 @@ dependencies = [ [[package]] name = "antelope-client" version = "0.3.0" -source = "git+https://github.com/telosnetwork/antelope-rs?branch=master#fea2203b2edb5cfcedd5365031e5286b47dc5c66" dependencies = [ "antelope-client-macros", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 62025e2ea230..3b68e8e3c153 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -601,7 +601,8 @@ reth-node-telos = { path = "crates/telos/node" } reth-telos-rpc = { path = "crates/telos/rpc" } reth-telos-primitives-traits = { path = "crates/telos/primitives-traits" } reth-telos-rpc-engine-api = { path = "crates/telos/rpc-engine-api" } -antelope-client = { git = "https://github.com/telosnetwork/antelope-rs", branch = "master" } +antelope-client = { path = "../antelope-rs/crates/antelope" } + [patch.crates-io] #alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index f8e1530e61c7..eeffa93894e5 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -238,31 +238,6 @@ where assert!(tx_result.is_err()); } -// test_1559_tx tests sending eip1559 transaction that has max_priority_fee_per_gas and max_fee_per_gas set -pub async fn test_1559_tx( - provider: impl Provider + Send + Sync, - sender_address: Address, -) where - T: Transport + Clone + Debug, -{ - let nonce = provider.get_transaction_count(sender_address).await.unwrap(); - let chain_id = provider.get_chain_id().await.unwrap(); - let to_address: Address = - Address::from_str("0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4").unwrap(); - - let tx = TransactionRequest::default() - .with_to(to_address) - .with_nonce(nonce) - .with_chain_id(chain_id) - .with_value(U256::from(100)) - .with_gas_limit(21_000) - .with_max_priority_fee_per_gas(1_000_000_000) - .with_max_fee_per_gas(20_000_000_000); - - let tx_result = provider.send_transaction(tx).await; - assert!(tx_result.is_err()); -} - // test_2930_tx tests sending eip2930 transaction which has access_list provided pub async fn test_2930_tx( provider: impl Provider + Send + Sync, diff --git a/crates/telos/rpc/src/eth/telos_client.rs b/crates/telos/rpc/src/eth/telos_client.rs index 7531da71f65e..13c5267cdac6 100644 --- a/crates/telos/rpc/src/eth/telos_client.rs +++ b/crates/telos/rpc/src/eth/telos_client.rs @@ -1,16 +1,19 @@ +use std::future::Future; use std::sync::Arc; -use reth_rpc_eth_types::error::EthResult; + +use antelope::{chain::Packer, name, StructPacker}; use antelope::api::client::{APIClient, DefaultProvider}; -use antelope::chain::name::Name; -use antelope::chain::private_key::PrivateKey; -use antelope::{chain::{Packer, Encoder, Decoder}, name, StructPacker}; use antelope::chain::action::{Action, PermissionLevel}; use antelope::chain::checksum::Checksum160; +use antelope::chain::name::Name; +use antelope::chain::private_key::PrivateKey; use antelope::chain::transaction::{SignedTransaction, Transaction}; +use tracing::{debug, error, warn}; +use antelope::serializer::Decoder; +use antelope::serializer::Encoder; use backoff::Exponential; +use reth_rpc_eth_types::error::EthResult; use reth_rpc_eth_types::EthApiError; -use std::future::Future; -use tracing::{debug, error, warn}; /// A client to interact with a Telos node #[derive(Debug, Clone)] @@ -74,9 +77,9 @@ mod backoff { } async fn retry(mut call: F) -> Result -where - F: FnMut() -> Fut, - Fut: Future>, + where + F: FnMut() -> Fut, + Fut: Future>, { const RETRIES: usize = 12; let mut backoff = Exponential::default().take(RETRIES - 1); @@ -150,18 +153,16 @@ impl TelosClient { context_free_data: vec![], }; - let tx_response = retry(|| async { + let tx_response = self.inner .api_client .v1_chain - .send_transaction(signed_telos_transaction.clone()) + .send_transaction2(signed_telos_transaction.clone(), None) .await .map_err(|error| { warn!("{error:?}"); format!("{error:?}") - }) - }) - .await; + }); let tx = match tx_response { Ok(value) => value, diff --git a/crates/telos/rpc/src/eth/transaction.rs b/crates/telos/rpc/src/eth/transaction.rs index 20a60e2572cb..ee222436ccff 100644 --- a/crates/telos/rpc/src/eth/transaction.rs +++ b/crates/telos/rpc/src/eth/transaction.rs @@ -86,4 +86,4 @@ where pub fn raw_tx_forwarder(&self) -> Option { self.telos_client.get().cloned() } -} \ No newline at end of file +} From 21ded288bd4c9906db06a4669c075eabe33f760e Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Fri, 29 Nov 2024 17:11:53 +0100 Subject: [PATCH 14/24] Add custom errors. --- Cargo.lock | 1 + crates/rpc/rpc-eth-types/src/error.rs | 1 + crates/telos/node/tests/live_test_runner.rs | 58 +++++++++++++++- crates/telos/rpc/Cargo.toml | 1 + crates/telos/rpc/src/eth/telos_client.rs | 73 +++++++++++++++++---- 5 files changed, 122 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 09c2564d66f2..d468560af4ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10436,6 +10436,7 @@ dependencies = [ "jsonrpsee-types", "log", "parking_lot 0.12.3", + "regex", "reth-chainspec", "reth-evm", "reth-network-api", diff --git a/crates/rpc/rpc-eth-types/src/error.rs b/crates/rpc/rpc-eth-types/src/error.rs index 10fa3b716021..7a46327b038e 100644 --- a/crates/rpc/rpc-eth-types/src/error.rs +++ b/crates/rpc/rpc-eth-types/src/error.rs @@ -5,6 +5,7 @@ use std::time::Duration; use alloy_primitives::{Address, Bytes, U256}; use alloy_rpc_types::{error::EthRpcErrorCode, request::TransactionInputError, BlockError}; use alloy_sol_types::decode_revert_reason; +use jsonrpsee_core::ClientError; use reth_errors::RethError; use reth_primitives::{revm_primitives::InvalidHeader, BlockId}; use reth_rpc_server_types::result::{ diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index eeffa93894e5..04d91caefb5b 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -28,6 +28,7 @@ use reth::primitives::BlockNumberOrTag::Latest; use reth::primitives::revm_primitives::bytes::Bytes; use reth::revm::primitives::{AccessList, AccessListItem}; +use reth::rpc::server_types::eth::{EthApiError, RpcInvalidTransactionError}; pub(crate) fn account_params(account: &str) -> GetTableRowsParams { GetTableRowsParams { @@ -207,6 +208,9 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { test_unsigned_trx(provider.clone(), address).await; test_unsigned_trx2(provider.clone(), address).await; test_signed_trx(provider.clone(), address).await; + test_wrong_nonce(provider.clone(), address).await; + test_high_nonce(provider.clone(), address).await; + // The below needs to be done using LegacyTransaction style call... with the current code it's including base_fee_per_gas and being rejected by reth // let block_num_latest = block_num_checker.getBlockNum().call().await.unwrap(); // assert!(block_num_latest._0 > U256::from(rpc_block_num), "Latest block number via call to getBlockNum is not greater than the block number in the previous log event"); @@ -310,7 +314,6 @@ pub async fn test_double_approve_erc20( let nonce = provider.get_transaction_count(sender_address).await.unwrap(); tx.nonce = Some(nonce); - info!("Nonce: {}", nonce); // repeat approve let tx_result = provider.send_transaction(tx.clone()).await; assert!(tx_result.is_ok()); @@ -328,6 +331,59 @@ pub async fn test_double_approve_erc20( } } +pub async fn test_wrong_nonce( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where + T: Transport + Clone + Debug, +{ + let chain_id = Some(provider.get_chain_id().await.unwrap()); + let nonce = Some(0); + let legacy_tx = tx_trailing_empty_values().unwrap().tx().clone(); + let legacy_tx_request = TransactionRequest { + from: Some(sender_address), + to: Some(legacy_tx.to), + gas: Some(legacy_tx.gas_limit as u64), + gas_price: Some(legacy_tx.gas_price), + value: Some(legacy_tx.value), + input: TransactionInput::from(legacy_tx.input), + nonce, + chain_id, + ..Default::default() + }; + + let tx_result = provider.send_transaction(legacy_tx_request).await; + + assert!(tx_result.is_err()); + +} + +pub async fn test_high_nonce( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where + T: Transport + Clone + Debug, +{ + let chain_id = Some(provider.get_chain_id().await.unwrap()); + let nonce = Some(500); + let legacy_tx = tx_trailing_empty_values().unwrap().tx().clone(); + let legacy_tx_request = TransactionRequest { + from: Some(sender_address), + to: Some(legacy_tx.to), + gas: Some(legacy_tx.gas_limit as u64), + gas_price: Some(legacy_tx.gas_price), + value: Some(legacy_tx.value), + input: TransactionInput::from(legacy_tx.input), + nonce, + chain_id, + ..Default::default() + }; + + let tx_result = provider.send_transaction(legacy_tx_request).await; + + assert!(tx_result.is_err()); +} + pub async fn test_incorrect_rlp( provider: impl Provider + Send + Sync, sender_address: Address, diff --git a/crates/telos/rpc/Cargo.toml b/crates/telos/rpc/Cargo.toml index f0023d2c01bf..7e919063562f 100644 --- a/crates/telos/rpc/Cargo.toml +++ b/crates/telos/rpc/Cargo.toml @@ -31,6 +31,7 @@ reth-rpc-eth-api.workspace = true reth-rpc-eth-types.workspace = true thiserror = "1.0.63" +regex = "1.10.5" tracing.workspace = true antelope-client.workspace = true diff --git a/crates/telos/rpc/src/eth/telos_client.rs b/crates/telos/rpc/src/eth/telos_client.rs index 13c5267cdac6..fc1b968fd21d 100644 --- a/crates/telos/rpc/src/eth/telos_client.rs +++ b/crates/telos/rpc/src/eth/telos_client.rs @@ -1,19 +1,71 @@ +use std::fmt; use std::future::Future; use std::sync::Arc; use antelope::{chain::Packer, name, StructPacker}; use antelope::api::client::{APIClient, DefaultProvider}; +use antelope::api::v1::structs::{ClientError, SendTransactionResponseError}; use antelope::chain::action::{Action, PermissionLevel}; use antelope::chain::checksum::Checksum160; use antelope::chain::name::Name; use antelope::chain::private_key::PrivateKey; use antelope::chain::transaction::{SignedTransaction, Transaction}; -use tracing::{debug, error, warn}; +use regex::Regex; +use tracing::{debug, error}; use antelope::serializer::Decoder; use antelope::serializer::Encoder; +use derive_more::Display; + use backoff::Exponential; +use reth_rpc_eth_types::{EthApiError, RpcInvalidTransactionError}; use reth_rpc_eth_types::error::EthResult; -use reth_rpc_eth_types::EthApiError; + +#[derive(Debug)] +struct TelosError(ClientError); + +impl fmt::Display for TelosError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?}", self) + } +} + +impl From for EthApiError { + fn from(err: TelosError) -> Self { + match err.0 { + ClientError::SERVER(server_error) => { + return parse_server_error(server_error.error); + } + // ClientError::SIMPLE(client_error) => {} + // ClientError::HTTP(http_error) => {} + // ClientError::ENCODING(encoding_error) => {} + // ClientError::NETWORK(network_error) => {} + _ => EthApiError::EvmCustom(err.to_string()) + } + } +} + +fn parse_server_error(error: SendTransactionResponseError) -> EthApiError { + for detail in error.details { + if detail.message.contains("Calling from_big_endian with oversized array") { + return EthApiError::EvmCustom(detail.message); + } else if detail.message.contains("Transaction gas price") { // TODO gas to high + return EthApiError::InvalidTransaction(RpcInvalidTransactionError::GasTooLow); + } else if detail.message.contains("incorrect nonce") { + let re = Regex::new(r"received (\d+) expected (\d+)").unwrap(); + if let Some(captures) = re.captures(detail.message.as_str()) { + let received: u64 = captures.get(1).unwrap().as_str().parse().ok().unwrap(); + let expected: u64 = captures.get(2).unwrap().as_str().parse().ok().unwrap(); + if received < expected { + return EthApiError::InvalidTransaction(RpcInvalidTransactionError::NonceTooLow { tx: received, state: expected }); + } else { + return EthApiError::InvalidTransaction(RpcInvalidTransactionError::NonceTooHigh); + } + } + } + } + EthApiError::EvmCustom("".to_string()) +} + /// A client to interact with a Telos node #[derive(Debug, Clone)] @@ -157,20 +209,19 @@ impl TelosClient { self.inner .api_client .v1_chain - .send_transaction2(signed_telos_transaction.clone(), None) - .await - .map_err(|error| { - warn!("{error:?}"); - format!("{error:?}") - }); + .send_transaction(signed_telos_transaction.clone()) + .await; + // + // .map_err(|error| { + // warn!("{error:?}"); + // format!("{error:?}") + // }); let tx = match tx_response { Ok(value) => value, Err(err) => { error!("Error sending transaction to Telos: {:?}", err); - return Err(EthApiError::EvmCustom( - "Error sending transaction to Telos".to_string(), - )); + return Err(EthApiError::from(TelosError(err))); } }; From 9ec1938151102e2865dafa246206de9d35a6f50f Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Mon, 2 Dec 2024 10:26:22 +0100 Subject: [PATCH 15/24] Update tests. --- crates/telos/node/tests/live_test_runner.rs | 27 +++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index 04d91caefb5b..630c9155863d 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -5,9 +5,10 @@ use alloy_primitives::{hex, keccak256, Address, Signature, B256, U256}; use alloy_provider::network::EthereumWallet; use alloy_provider::{Provider, ProviderBuilder}; use alloy_rpc_types::TransactionRequest; +use std::error::Error; use alloy_signer_local::PrivateKeySigner; -use alloy_sol_types::private::primitives::TxKind::{Create}; +use alloy_sol_types::private::primitives::TxKind::Create; use alloy_sol_types::{sol, SolEvent}; use antelope::api::v1::structs::{GetTableRowsParams, IndexPosition, TableIndexType}; use antelope::chain::binary_extension::BinaryExtension; @@ -18,13 +19,13 @@ use antelope::{name, StructPacker}; use num_bigint::{BigUint, ToBigUint}; use reqwest::Url; use reth::primitives::BlockId; +use reth::primitives::BlockNumberOrTag::Latest; use reth::rpc::types::{BlockTransactionsKind, TransactionInput}; use serde::{Deserialize, Serialize}; use std::fmt::Debug; use std::str::FromStr; use telos_translator_rs::rlp::telos_rlp_decode::TelosTxDecodable; use tracing::info; -use reth::primitives::BlockNumberOrTag::Latest; use reth::primitives::revm_primitives::bytes::Bytes; use reth::revm::primitives::{AccessList, AccessListItem}; @@ -217,17 +218,19 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { // // let block_num_five_back = block_num_checker.getBlockNum().call().block(BlockId::number(rpc_block_num - 5)).await.unwrap(); // assert!(block_num_five_back._0 == U256::from(rpc_block_num - 5), "Block number 5 blocks back via historical eth_call is not correct"); - } // test_1559_tx tests sending eip1559 transaction that has max_priority_fee_per_gas and max_fee_per_gas set -pub async fn test_1559_tx(provider: impl Provider + Send + Sync, sender_address: Address) -where +pub async fn test_1559_tx( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where T: Transport + Clone + Debug, { let nonce = provider.get_transaction_count(sender_address).await.unwrap(); let chain_id = provider.get_chain_id().await.unwrap(); - let to_address: Address = Address::from_str("0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4").unwrap(); + let to_address: Address = + Address::from_str("0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4").unwrap(); let tx = TransactionRequest::default() .with_to(to_address) @@ -355,7 +358,11 @@ pub async fn test_wrong_nonce( let tx_result = provider.send_transaction(legacy_tx_request).await; assert!(tx_result.is_err()); - + let err = tx_result.unwrap_err(); + assert_eq!( + err.to_string(), + "server returned an error response: error code -32003: nonce too low: next nonce 9, tx nonce 0" + ) } pub async fn test_high_nonce( @@ -382,6 +389,12 @@ pub async fn test_high_nonce( let tx_result = provider.send_transaction(legacy_tx_request).await; assert!(tx_result.is_err()); + + let err = tx_result.unwrap_err(); + assert_eq!( + err.to_string(), + "server returned an error response: error code -32003: nonce too high" + ) } pub async fn test_incorrect_rlp( From fcecc32fee4e4cc8f2c1c32d2f00cd0c6682e771 Mon Sep 17 00:00:00 2001 From: Coa Date: Mon, 2 Dec 2024 16:05:36 +0100 Subject: [PATCH 16/24] Handle more errors --- crates/telos/rpc/src/eth/telos_client.rs | 86 +++++++++++++----------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/crates/telos/rpc/src/eth/telos_client.rs b/crates/telos/rpc/src/eth/telos_client.rs index fc1b968fd21d..a540892fe095 100644 --- a/crates/telos/rpc/src/eth/telos_client.rs +++ b/crates/telos/rpc/src/eth/telos_client.rs @@ -2,23 +2,25 @@ use std::fmt; use std::future::Future; use std::sync::Arc; -use antelope::{chain::Packer, name, StructPacker}; use antelope::api::client::{APIClient, DefaultProvider}; -use antelope::api::v1::structs::{ClientError, SendTransactionResponseError}; +use antelope::api::v1::structs::{ + ClientError, EncodingError, HTTPError, SendTransactionResponseError, SimpleError, +}; use antelope::chain::action::{Action, PermissionLevel}; use antelope::chain::checksum::Checksum160; use antelope::chain::name::Name; use antelope::chain::private_key::PrivateKey; use antelope::chain::transaction::{SignedTransaction, Transaction}; -use regex::Regex; -use tracing::{debug, error}; use antelope::serializer::Decoder; use antelope::serializer::Encoder; +use antelope::{chain::Packer, name, StructPacker}; use derive_more::Display; +use regex::Regex; +use tracing::{debug, error}; use backoff::Exponential; -use reth_rpc_eth_types::{EthApiError, RpcInvalidTransactionError}; use reth_rpc_eth_types::error::EthResult; +use reth_rpc_eth_types::{EthApiError, RpcInvalidTransactionError}; #[derive(Debug)] struct TelosError(ClientError); @@ -32,41 +34,45 @@ impl fmt::Display for TelosError { impl From for EthApiError { fn from(err: TelosError) -> Self { match err.0 { - ClientError::SERVER(server_error) => { - return parse_server_error(server_error.error); - } - // ClientError::SIMPLE(client_error) => {} - // ClientError::HTTP(http_error) => {} - // ClientError::ENCODING(encoding_error) => {} - // ClientError::NETWORK(network_error) => {} - _ => EthApiError::EvmCustom(err.to_string()) + ClientError::SERVER(server_error) => parse_server_error(server_error.error), + ClientError::SIMPLE(client_error) => EthApiError::EvmCustom(client_error.message), + ClientError::HTTP(http_error) => EthApiError::EvmCustom(http_error.message), + ClientError::ENCODING(encoding_error) => EthApiError::EvmCustom(encoding_error.message), + ClientError::NETWORK(network_error) => EthApiError::EvmCustom(network_error), + _ => EthApiError::EvmCustom(err.to_string()), } } } -fn parse_server_error(error: SendTransactionResponseError) -> EthApiError { - for detail in error.details { - if detail.message.contains("Calling from_big_endian with oversized array") { - return EthApiError::EvmCustom(detail.message); - } else if detail.message.contains("Transaction gas price") { // TODO gas to high +fn parse_server_error(server_error: SendTransactionResponseError) -> EthApiError { + for message in server_error.details.iter().map(|details| &details.message) { + if message.contains("Calling from_big_endian with oversized array") { + return EthApiError::FailedToDecodeSignedTransaction; + } + if message.contains("Transaction gas price") { + // TODO: gas to high return EthApiError::InvalidTransaction(RpcInvalidTransactionError::GasTooLow); - } else if detail.message.contains("incorrect nonce") { - let re = Regex::new(r"received (\d+) expected (\d+)").unwrap(); - if let Some(captures) = re.captures(detail.message.as_str()) { - let received: u64 = captures.get(1).unwrap().as_str().parse().ok().unwrap(); - let expected: u64 = captures.get(2).unwrap().as_str().parse().ok().unwrap(); - if received < expected { - return EthApiError::InvalidTransaction(RpcInvalidTransactionError::NonceTooLow { tx: received, state: expected }); - } else { - return EthApiError::InvalidTransaction(RpcInvalidTransactionError::NonceTooHigh); - } - } } + if !message.contains("incorrect nonce") { + return EthApiError::EvmCustom(message.to_string()); + } + let re = Regex::new(r"received (\d+) expected (\d+)").unwrap(); + let Some(captures) = re.captures(&message) else { + return EthApiError::EvmCustom(message.to_string()); + }; + let received: u64 = captures.get(1).unwrap().as_str().parse().ok().unwrap(); + let expected: u64 = captures.get(2).unwrap().as_str().parse().ok().unwrap(); + if received < expected { + return EthApiError::InvalidTransaction(RpcInvalidTransactionError::NonceTooLow { + tx: received, + state: expected, + }); + } + return EthApiError::InvalidTransaction(RpcInvalidTransactionError::NonceTooHigh); } - EthApiError::EvmCustom("".to_string()) + EthApiError::EvmCustom(server_error.what) } - /// A client to interact with a Telos node #[derive(Debug, Clone)] pub struct TelosClient { @@ -129,9 +135,9 @@ mod backoff { } async fn retry(mut call: F) -> Result - where - F: FnMut() -> Fut, - Fut: Future>, +where + F: FnMut() -> Fut, + Fut: Future>, { const RETRIES: usize = 12; let mut backoff = Exponential::default().take(RETRIES - 1); @@ -157,7 +163,11 @@ impl TelosClient { { panic!("Should not construct TelosClient without proper TelosArgs with telos_endpoint and signer args"); } - let api_client = APIClient::::default_provider(telos_client_args.telos_endpoint.unwrap().into(), Some(3)).unwrap(); + let api_client = APIClient::::default_provider( + telos_client_args.telos_endpoint.unwrap().into(), + Some(3), + ) + .unwrap(); let inner = TelosClientInner { api_client, signer_account: name!(&telos_client_args.signer_account.unwrap()), @@ -206,11 +216,7 @@ impl TelosClient { }; let tx_response = - self.inner - .api_client - .v1_chain - .send_transaction(signed_telos_transaction.clone()) - .await; + self.inner.api_client.v1_chain.send_transaction(signed_telos_transaction.clone()).await; // // .map_err(|error| { // warn!("{error:?}"); From 6288bd0bcfbd3addc7f5896a911b69cd7ff128ff Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Tue, 3 Dec 2024 13:09:01 +0100 Subject: [PATCH 17/24] Handle http error. --- crates/telos/rpc/src/eth/telos_client.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/telos/rpc/src/eth/telos_client.rs b/crates/telos/rpc/src/eth/telos_client.rs index a540892fe095..b882c69fac18 100644 --- a/crates/telos/rpc/src/eth/telos_client.rs +++ b/crates/telos/rpc/src/eth/telos_client.rs @@ -15,10 +15,12 @@ use antelope::serializer::Decoder; use antelope::serializer::Encoder; use antelope::{chain::Packer, name, StructPacker}; use derive_more::Display; +use jsonrpsee_types::ErrorObject; use regex::Regex; use tracing::{debug, error}; use backoff::Exponential; +use reth_primitives::revm_primitives::bitvec::macros::internal::funty::Fundamental; use reth_rpc_eth_types::error::EthResult; use reth_rpc_eth_types::{EthApiError, RpcInvalidTransactionError}; @@ -36,7 +38,11 @@ impl From for EthApiError { match err.0 { ClientError::SERVER(server_error) => parse_server_error(server_error.error), ClientError::SIMPLE(client_error) => EthApiError::EvmCustom(client_error.message), - ClientError::HTTP(http_error) => EthApiError::EvmCustom(http_error.message), + ClientError::HTTP(http_error) => { + let http_error = + ErrorObject::owned(http_error.code.as_i32(), http_error.message, None::<()>); + EthApiError::Other(Box::new(http_error)) + } ClientError::ENCODING(encoding_error) => EthApiError::EvmCustom(encoding_error.message), ClientError::NETWORK(network_error) => EthApiError::EvmCustom(network_error), _ => EthApiError::EvmCustom(err.to_string()), @@ -46,7 +52,9 @@ impl From for EthApiError { fn parse_server_error(server_error: SendTransactionResponseError) -> EthApiError { for message in server_error.details.iter().map(|details| &details.message) { - if message.contains("Calling from_big_endian with oversized array") { + if message.contains("Calling from_big_endian with oversized array") + || message.contains("Invalid packed transaction") + { return EthApiError::FailedToDecodeSignedTransaction; } if message.contains("Transaction gas price") { From 7054f9a2ad6af4a1db0bb62fb317167fe418b50d Mon Sep 17 00:00:00 2001 From: Coa Date: Tue, 3 Dec 2024 16:18:04 +0100 Subject: [PATCH 18/24] Warn on every serer error --- crates/telos/rpc/src/eth/telos_client.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/telos/rpc/src/eth/telos_client.rs b/crates/telos/rpc/src/eth/telos_client.rs index b882c69fac18..8127a29b0ec9 100644 --- a/crates/telos/rpc/src/eth/telos_client.rs +++ b/crates/telos/rpc/src/eth/telos_client.rs @@ -17,7 +17,7 @@ use antelope::{chain::Packer, name, StructPacker}; use derive_more::Display; use jsonrpsee_types::ErrorObject; use regex::Regex; -use tracing::{debug, error}; +use tracing::{debug, error, warn}; use backoff::Exponential; use reth_primitives::revm_primitives::bitvec::macros::internal::funty::Fundamental; @@ -52,6 +52,7 @@ impl From for EthApiError { fn parse_server_error(server_error: SendTransactionResponseError) -> EthApiError { for message in server_error.details.iter().map(|details| &details.message) { + warn!("{message:?}"); if message.contains("Calling from_big_endian with oversized array") || message.contains("Invalid packed transaction") { From 7a7cd303a7555e4dc922072d08918213c0ec876d Mon Sep 17 00:00:00 2001 From: Coa Date: Wed, 4 Dec 2024 10:07:48 +0100 Subject: [PATCH 19/24] Handle send_transaction2 error --- Cargo.toml | 1 + crates/telos/rpc/src/eth/telos_client.rs | 33 +++++++++++++----------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3b68e8e3c153..ea91df55e746 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -601,6 +601,7 @@ reth-node-telos = { path = "crates/telos/node" } reth-telos-rpc = { path = "crates/telos/rpc" } reth-telos-primitives-traits = { path = "crates/telos/primitives-traits" } reth-telos-rpc-engine-api = { path = "crates/telos/rpc-engine-api" } +# antelope-client = { git = "https://github.com/telosnetwork/antelope-rs", rev = "e0d3c4a" } antelope-client = { path = "../antelope-rs/crates/antelope" } diff --git a/crates/telos/rpc/src/eth/telos_client.rs b/crates/telos/rpc/src/eth/telos_client.rs index 8127a29b0ec9..f26de05c0c6c 100644 --- a/crates/telos/rpc/src/eth/telos_client.rs +++ b/crates/telos/rpc/src/eth/telos_client.rs @@ -4,7 +4,8 @@ use std::sync::Arc; use antelope::api::client::{APIClient, DefaultProvider}; use antelope::api::v1::structs::{ - ClientError, EncodingError, HTTPError, SendTransactionResponseError, SimpleError, + ClientError, EncodingError, HTTPError, SendTransactionResponse2Error, + SendTransactionResponseError, SimpleError, }; use antelope::chain::action::{Action, PermissionLevel}; use antelope::chain::checksum::Checksum160; @@ -25,7 +26,7 @@ use reth_rpc_eth_types::error::EthResult; use reth_rpc_eth_types::{EthApiError, RpcInvalidTransactionError}; #[derive(Debug)] -struct TelosError(ClientError); +struct TelosError(ClientError); impl fmt::Display for TelosError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -50,9 +51,10 @@ impl From for EthApiError { } } -fn parse_server_error(server_error: SendTransactionResponseError) -> EthApiError { - for message in server_error.details.iter().map(|details| &details.message) { - warn!("{message:?}"); +fn parse_server_error(server_error: SendTransactionResponse2Error) -> EthApiError { + let mut error_message = server_error.message; + for error in server_error.stack { + let message = error.data.to_string(); if message.contains("Calling from_big_endian with oversized array") || message.contains("Invalid packed transaction") { @@ -67,7 +69,8 @@ fn parse_server_error(server_error: SendTransactionResponseError) -> EthApiError } let re = Regex::new(r"received (\d+) expected (\d+)").unwrap(); let Some(captures) = re.captures(&message) else { - return EthApiError::EvmCustom(message.to_string()); + warn!("{message:?}"); + continue; }; let received: u64 = captures.get(1).unwrap().as_str().parse().ok().unwrap(); let expected: u64 = captures.get(2).unwrap().as_str().parse().ok().unwrap(); @@ -76,10 +79,11 @@ fn parse_server_error(server_error: SendTransactionResponseError) -> EthApiError tx: received, state: expected, }); + } else { + return EthApiError::InvalidTransaction(RpcInvalidTransactionError::NonceTooHigh); } - return EthApiError::InvalidTransaction(RpcInvalidTransactionError::NonceTooHigh); } - EthApiError::EvmCustom(server_error.what) + EthApiError::EvmCustom(error_message) } /// A client to interact with a Telos node @@ -224,13 +228,12 @@ impl TelosClient { context_free_data: vec![], }; - let tx_response = - self.inner.api_client.v1_chain.send_transaction(signed_telos_transaction.clone()).await; - // - // .map_err(|error| { - // warn!("{error:?}"); - // format!("{error:?}") - // }); + let tx_response = self + .inner + .api_client + .v1_chain + .send_transaction2(signed_telos_transaction.clone(), None) + .await; let tx = match tx_response { Ok(value) => value, From 939b670088be9e214f54062c48f4398d00b31fa4 Mon Sep 17 00:00:00 2001 From: Coa Date: Fri, 6 Dec 2024 15:14:02 +0100 Subject: [PATCH 20/24] Update antelope and consensus client --- Cargo.lock | 406 +------------------------ Cargo.toml | 4 +- crates/telos/node/Cargo.toml | 8 +- crates/telos/node/tests/integration.rs | 1 + 4 files changed, 11 insertions(+), 408 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d468560af4ba..1b4a4798f6e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,7 +59,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", - "const-random", "getrandom 0.2.15", "once_cell", "version_check", @@ -1150,6 +1149,7 @@ dependencies = [ [[package]] name = "antelope-client" version = "0.3.0" +source = "git+https://github.com/telosnetwork/antelope-rs?branch=master#b585d1813df1d02218126e5b26fb3d120c14562a" dependencies = [ "antelope-client-macros", "async-trait", @@ -1354,248 +1354,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" -[[package]] -name = "arrow" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "219d05930b81663fd3b32e3bde8ce5bff3c4d23052a99f11a8fa50a3b47b2658" -dependencies = [ - "arrow-arith", - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-csv", - "arrow-data", - "arrow-ipc", - "arrow-json", - "arrow-ord", - "arrow-row", - "arrow-schema", - "arrow-select", - "arrow-string", -] - -[[package]] -name = "arrow-arith" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0272150200c07a86a390be651abdd320a2d12e84535f0837566ca87ecd8f95e0" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "chrono", - "half", - "num", -] - -[[package]] -name = "arrow-array" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8010572cf8c745e242d1b632bd97bd6d4f40fefed5ed1290a8f433abaa686fea" -dependencies = [ - "ahash", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "chrono", - "half", - "hashbrown 0.14.5", - "num", -] - -[[package]] -name = "arrow-buffer" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d0a2432f0cba5692bf4cb757469c66791394bac9ec7ce63c1afe74744c37b27" -dependencies = [ - "bytes", - "half", - "num", -] - -[[package]] -name = "arrow-cast" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9abc10cd7995e83505cc290df9384d6e5412b207b79ce6bdff89a10505ed2cba" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "arrow-select", - "atoi", - "base64 0.22.1", - "chrono", - "half", - "lexical-core", - "num", - "ryu", -] - -[[package]] -name = "arrow-csv" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95cbcba196b862270bf2a5edb75927380a7f3a163622c61d40cbba416a6305f2" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-data", - "arrow-schema", - "chrono", - "csv", - "csv-core", - "lazy_static", - "lexical-core", - "regex", -] - -[[package]] -name = "arrow-data" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2742ac1f6650696ab08c88f6dd3f0eb68ce10f8c253958a18c943a68cd04aec5" -dependencies = [ - "arrow-buffer", - "arrow-schema", - "half", - "num", -] - -[[package]] -name = "arrow-ipc" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a42ea853130f7e78b9b9d178cb4cd01dee0f78e64d96c2949dc0a915d6d9e19d" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-data", - "arrow-schema", - "flatbuffers", -] - -[[package]] -name = "arrow-json" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaafb5714d4e59feae964714d724f880511500e3569cc2a94d02456b403a2a49" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-data", - "arrow-schema", - "chrono", - "half", - "indexmap 2.6.0", - "lexical-core", - "num", - "serde", - "serde_json", -] - -[[package]] -name = "arrow-ord" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3e6b61e3dc468f503181dccc2fc705bdcc5f2f146755fa5b56d0a6c5943f412" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "arrow-select", - "half", - "num", -] - -[[package]] -name = "arrow-row" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "848ee52bb92eb459b811fb471175ea3afcf620157674c8794f539838920f9228" -dependencies = [ - "ahash", - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "half", - "hashbrown 0.14.5", -] - -[[package]] -name = "arrow-schema" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d9483aaabe910c4781153ae1b6ae0393f72d9ef757d38d09d450070cf2e528" - -[[package]] -name = "arrow-select" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "849524fa70e0e3c5ab58394c770cb8f514d0122d20de08475f7b472ed8075830" -dependencies = [ - "ahash", - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "num", -] - -[[package]] -name = "arrow-string" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9373cb5a021aee58863498c37eb484998ef13377f69989c6c5ccfbd258236cdb" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "arrow-select", - "memchr", - "num", - "regex", - "regex-syntax 0.8.5", -] - -[[package]] -name = "arrowbatch" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e304bae8e33446c64842dba444042ce65cb23e2b1e439fa2f4abb7591db562c5" -dependencies = [ - "arrow", - "base64 0.22.1", - "chrono", - "env_logger 0.10.2", - "futures", - "futures-util", - "hex", - "log", - "moka", - "num", - "num-bigint", - "rlp", - "serde", - "serde_json", - "tokio", - "tokio-tungstenite 0.21.0", - "tungstenite 0.21.0", - "uuid", - "zstd", -] - [[package]] name = "asn1_der" version = "0.7.6" @@ -1693,15 +1451,6 @@ dependencies = [ "rustc_version 0.4.1", ] -[[package]] -name = "atoi" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" -dependencies = [ - "num-traits", -] - [[package]] name = "atomic-waker" version = "1.1.2" @@ -2569,26 +2318,6 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "const-random" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" -dependencies = [ - "const-random-macro", -] - -[[package]] -name = "const-random-macro" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" -dependencies = [ - "getrandom 0.2.15", - "once_cell", - "tiny-keccak", -] - [[package]] name = "const_format" version = "0.2.33" @@ -3383,19 +3112,6 @@ dependencies = [ "regex", ] -[[package]] -name = "env_logger" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - [[package]] name = "env_logger" version = "0.11.5" @@ -3839,16 +3555,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "flatbuffers" -version = "23.5.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dac53e22462d78c16d64a1cd22371b54cc3fe94aa15e7886a2fa6e5d1ab8640" -dependencies = [ - "bitflags 1.3.2", - "rustc_version 0.4.1", -] - [[package]] name = "flate2" version = "1.0.34" @@ -4209,7 +3915,6 @@ checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ "cfg-if", "crunchy", - "num-traits", ] [[package]] @@ -5386,70 +5091,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" -[[package]] -name = "lexical-core" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cde5de06e8d4c2faabc400238f9ae1c74d5412d03a7bd067645ccbc47070e46" -dependencies = [ - "lexical-parse-float", - "lexical-parse-integer", - "lexical-util", - "lexical-write-float", - "lexical-write-integer", -] - -[[package]] -name = "lexical-parse-float" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683b3a5ebd0130b8fb52ba0bdc718cc56815b6a097e28ae5a6997d0ad17dc05f" -dependencies = [ - "lexical-parse-integer", - "lexical-util", - "static_assertions", -] - -[[package]] -name = "lexical-parse-integer" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d0994485ed0c312f6d965766754ea177d07f9c00c9b82a5ee62ed5b47945ee9" -dependencies = [ - "lexical-util", - "static_assertions", -] - -[[package]] -name = "lexical-util" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5255b9ff16ff898710eb9eb63cb39248ea8a5bb036bea8085b1a767ff6c4e3fc" -dependencies = [ - "static_assertions", -] - -[[package]] -name = "lexical-write-float" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accabaa1c4581f05a3923d1b4cfd124c329352288b7b9da09e766b0668116862" -dependencies = [ - "lexical-util", - "lexical-write-integer", - "static_assertions", -] - -[[package]] -name = "lexical-write-integer" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1b6f3d1f4422866b68192d62f77bc5c700bee84f3069f2469d7bc8c77852446" -dependencies = [ - "lexical-util", - "static_assertions", -] - [[package]] name = "libc" version = "0.2.159" @@ -9270,7 +8911,7 @@ dependencies = [ "antelope-client", "clap", "derive_more 1.0.0", - "env_logger 0.11.5", + "env_logger", "eyre", "num-bigint", "reqwest 0.12.8", @@ -11898,6 +11539,7 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "telos-consensus-client" version = "0.1.0" +source = "git+https://github.com/telosnetwork/telos-consensus-client?rev=db63c0f5ae372ea2f05c663c9063dfa4b7e65f03#db63c0f5ae372ea2f05c663c9063dfa4b7e65f03" dependencies = [ "alloy", "alloy-consensus 0.3.6", @@ -11905,7 +11547,6 @@ dependencies = [ "alloy-rpc-types 0.3.6", "alloy-rpc-types-engine 0.3.6", "antelope-client", - "arrowbatch", "base64 0.22.1", "bytes", "chrono", @@ -11949,6 +11590,7 @@ dependencies = [ [[package]] name = "telos-translator-rs" version = "0.1.0" +source = "git+https://github.com/telosnetwork/telos-consensus-client?rev=db63c0f5ae372ea2f05c663c9063dfa4b7e65f03#db63c0f5ae372ea2f05c663c9063dfa4b7e65f03" dependencies = [ "alloy", "alloy-consensus 0.3.6", @@ -11993,15 +11635,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "termtree" version = "0.4.1" @@ -12335,18 +11968,6 @@ dependencies = [ "tokio-util", ] -[[package]] -name = "tokio-tungstenite" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" -dependencies = [ - "futures-util", - "log", - "tokio", - "tungstenite 0.21.0", -] - [[package]] name = "tokio-tungstenite" version = "0.23.1" @@ -12711,25 +12332,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "tungstenite" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http 1.1.0", - "httparse", - "log", - "rand 0.8.5", - "sha1", - "thiserror", - "url", - "utf-8", -] - [[package]] name = "tungstenite" version = "0.23.0" diff --git a/Cargo.toml b/Cargo.toml index ea91df55e746..dae953a2d776 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -601,8 +601,8 @@ reth-node-telos = { path = "crates/telos/node" } reth-telos-rpc = { path = "crates/telos/rpc" } reth-telos-primitives-traits = { path = "crates/telos/primitives-traits" } reth-telos-rpc-engine-api = { path = "crates/telos/rpc-engine-api" } -# antelope-client = { git = "https://github.com/telosnetwork/antelope-rs", rev = "e0d3c4a" } -antelope-client = { path = "../antelope-rs/crates/antelope" } +antelope-client = { git = "https://github.com/telosnetwork/antelope-rs", branch = "master" } +# antelope-client = { path = "../antelope-rs/crates/antelope" } [patch.crates-io] diff --git a/crates/telos/node/Cargo.toml b/crates/telos/node/Cargo.toml index 5b2ac57e8554..309a00bd02c5 100644 --- a/crates/telos/node/Cargo.toml +++ b/crates/telos/node/Cargo.toml @@ -77,10 +77,10 @@ reqwest.workspace = true reth-e2e-test-utils.workspace = true eyre.workspace = true -#telos-consensus-client = { git = "https://github.com/telosnetwork/telos-consensus-client", rev = "f8ecbe1aeea57911c9fbefdddf49efa92d8472ce" } -#telos-translator-rs = { git = "https://github.com/telosnetwork/telos-consensus-client", rev = "f8ecbe1aeea57911c9fbefdddf49efa92d8472ce" } -telos-consensus-client = { path = "../../../../telos-consensus-client/client" } -telos-translator-rs = { path = "../../../../telos-consensus-client/translator" } +telos-consensus-client = { git = "https://github.com/telosnetwork/telos-consensus-client", rev = "db63c0f5ae372ea2f05c663c9063dfa4b7e65f03" } +telos-translator-rs = { git = "https://github.com/telosnetwork/telos-consensus-client", rev = "db63c0f5ae372ea2f05c663c9063dfa4b7e65f03" } +# telos-consensus-client = { path = "../../../../telos-consensus-client/client" } +# telos-translator-rs = { path = "../../../../telos-consensus-client/translator" } env_logger = "0.11.5" testcontainers = "0.21.1" diff --git a/crates/telos/node/tests/integration.rs b/crates/telos/node/tests/integration.rs index bb2b54ca2d4b..4cb3d4f36cac 100644 --- a/crates/telos/node/tests/integration.rs +++ b/crates/telos/node/tests/integration.rs @@ -132,6 +132,7 @@ async fn build_consensus_and_translator( evm_start_block: 1, // TODO: Determine a good stop block and test it here evm_stop_block: None, + evm_deploy_block: None, data_path: "temp/db".to_string(), block_checkpoint_interval: 1000, maximum_sync_range: 100000, From 3c3362e33cddfccc532f4e110aae099a96ffdf84 Mon Sep 17 00:00:00 2001 From: Coa Date: Mon, 9 Dec 2024 09:36:05 +0100 Subject: [PATCH 21/24] Update antelope client and handle details on error --- Cargo.lock | 6 +-- Cargo.toml | 2 +- crates/telos/node/Cargo.toml | 4 +- crates/telos/rpc/src/eth/telos_client.rs | 63 ++++++++++++++---------- 4 files changed, 42 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1b4a4798f6e0..502a94bc253e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1149,7 +1149,7 @@ dependencies = [ [[package]] name = "antelope-client" version = "0.3.0" -source = "git+https://github.com/telosnetwork/antelope-rs?branch=master#b585d1813df1d02218126e5b26fb3d120c14562a" +source = "git+https://github.com/telosnetwork/antelope-rs?rev=d701cd9ca2e87e8e0fd99746f9c672cb3536e5ec#d701cd9ca2e87e8e0fd99746f9c672cb3536e5ec" dependencies = [ "antelope-client-macros", "async-trait", @@ -11539,7 +11539,7 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "telos-consensus-client" version = "0.1.0" -source = "git+https://github.com/telosnetwork/telos-consensus-client?rev=db63c0f5ae372ea2f05c663c9063dfa4b7e65f03#db63c0f5ae372ea2f05c663c9063dfa4b7e65f03" +source = "git+https://github.com/telosnetwork/telos-consensus-client?rev=9fadee1fd565e3a7ad51c1142e2673df52bd9028#9fadee1fd565e3a7ad51c1142e2673df52bd9028" dependencies = [ "alloy", "alloy-consensus 0.3.6", @@ -11590,7 +11590,7 @@ dependencies = [ [[package]] name = "telos-translator-rs" version = "0.1.0" -source = "git+https://github.com/telosnetwork/telos-consensus-client?rev=db63c0f5ae372ea2f05c663c9063dfa4b7e65f03#db63c0f5ae372ea2f05c663c9063dfa4b7e65f03" +source = "git+https://github.com/telosnetwork/telos-consensus-client?rev=9fadee1fd565e3a7ad51c1142e2673df52bd9028#9fadee1fd565e3a7ad51c1142e2673df52bd9028" dependencies = [ "alloy", "alloy-consensus 0.3.6", diff --git a/Cargo.toml b/Cargo.toml index dae953a2d776..2938dfffdb71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -601,7 +601,7 @@ reth-node-telos = { path = "crates/telos/node" } reth-telos-rpc = { path = "crates/telos/rpc" } reth-telos-primitives-traits = { path = "crates/telos/primitives-traits" } reth-telos-rpc-engine-api = { path = "crates/telos/rpc-engine-api" } -antelope-client = { git = "https://github.com/telosnetwork/antelope-rs", branch = "master" } +antelope-client = { git = "https://github.com/telosnetwork/antelope-rs", rev = "d701cd9ca2e87e8e0fd99746f9c672cb3536e5ec" } # antelope-client = { path = "../antelope-rs/crates/antelope" } diff --git a/crates/telos/node/Cargo.toml b/crates/telos/node/Cargo.toml index 309a00bd02c5..b86cfe4183dd 100644 --- a/crates/telos/node/Cargo.toml +++ b/crates/telos/node/Cargo.toml @@ -77,8 +77,8 @@ reqwest.workspace = true reth-e2e-test-utils.workspace = true eyre.workspace = true -telos-consensus-client = { git = "https://github.com/telosnetwork/telos-consensus-client", rev = "db63c0f5ae372ea2f05c663c9063dfa4b7e65f03" } -telos-translator-rs = { git = "https://github.com/telosnetwork/telos-consensus-client", rev = "db63c0f5ae372ea2f05c663c9063dfa4b7e65f03" } +telos-consensus-client = { git = "https://github.com/telosnetwork/telos-consensus-client", rev = "9fadee1fd565e3a7ad51c1142e2673df52bd9028" } +telos-translator-rs = { git = "https://github.com/telosnetwork/telos-consensus-client", rev = "9fadee1fd565e3a7ad51c1142e2673df52bd9028" } # telos-consensus-client = { path = "../../../../telos-consensus-client/client" } # telos-translator-rs = { path = "../../../../telos-consensus-client/translator" } diff --git a/crates/telos/rpc/src/eth/telos_client.rs b/crates/telos/rpc/src/eth/telos_client.rs index f26de05c0c6c..2a982ff15e5b 100644 --- a/crates/telos/rpc/src/eth/telos_client.rs +++ b/crates/telos/rpc/src/eth/telos_client.rs @@ -51,36 +51,45 @@ impl From for EthApiError { } } +fn parse_error_message(message: String) -> Option { + if message.contains("Calling from_big_endian with oversized array") + || message.contains("Invalid packed transaction") + { + return Some(EthApiError::FailedToDecodeSignedTransaction); + } + if message.contains("Transaction gas price") { + // TODO: gas to high + return Some(EthApiError::InvalidTransaction(RpcInvalidTransactionError::GasTooLow)); + } + if !message.contains("incorrect nonce") { + return Some(EthApiError::EvmCustom(message.to_string())); + } + let re = Regex::new(r"received (\d+) expected (\d+)").unwrap(); + let Some(captures) = re.captures(&message) else { + warn!("{message:?}"); + return None; + }; + let received: u64 = captures.get(1).unwrap().as_str().parse().ok().unwrap(); + let expected: u64 = captures.get(2).unwrap().as_str().parse().ok().unwrap(); + if received < expected { + return Some(EthApiError::InvalidTransaction(RpcInvalidTransactionError::NonceTooLow { + tx: received, + state: expected, + })); + } + Some(EthApiError::InvalidTransaction(RpcInvalidTransactionError::NonceTooHigh)) +} + fn parse_server_error(server_error: SendTransactionResponse2Error) -> EthApiError { let mut error_message = server_error.message; - for error in server_error.stack { - let message = error.data.to_string(); - if message.contains("Calling from_big_endian with oversized array") - || message.contains("Invalid packed transaction") - { - return EthApiError::FailedToDecodeSignedTransaction; - } - if message.contains("Transaction gas price") { - // TODO: gas to high - return EthApiError::InvalidTransaction(RpcInvalidTransactionError::GasTooLow); - } - if !message.contains("incorrect nonce") { - return EthApiError::EvmCustom(message.to_string()); + for detail in server_error.details.unwrap_or_default() { + if let Some(error) = parse_error_message(detail.message) { + return error; } - let re = Regex::new(r"received (\d+) expected (\d+)").unwrap(); - let Some(captures) = re.captures(&message) else { - warn!("{message:?}"); - continue; - }; - let received: u64 = captures.get(1).unwrap().as_str().parse().ok().unwrap(); - let expected: u64 = captures.get(2).unwrap().as_str().parse().ok().unwrap(); - if received < expected { - return EthApiError::InvalidTransaction(RpcInvalidTransactionError::NonceTooLow { - tx: received, - state: expected, - }); - } else { - return EthApiError::InvalidTransaction(RpcInvalidTransactionError::NonceTooHigh); + } + for error in server_error.stack { + if let Some(error) = parse_error_message(error.data.to_string()) { + return error; } } EthApiError::EvmCustom(error_message) From 6d351d935b412697029d1e50f35d58eda0e92f34 Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Mon, 9 Dec 2024 14:58:46 +0100 Subject: [PATCH 22/24] Clean imports. --- crates/telos/node/tests/integration.rs | 6 ------ crates/telos/node/tests/live_test_runner.rs | 10 ++-------- crates/telos/rpc/src/eth/telos_client.rs | 7 +------ 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/crates/telos/node/tests/integration.rs b/crates/telos/node/tests/integration.rs index 4cb3d4f36cac..0ad846523a07 100644 --- a/crates/telos/node/tests/integration.rs +++ b/crates/telos/node/tests/integration.rs @@ -1,10 +1,6 @@ use alloy_primitives::Address; use alloy_provider::{Provider, ProviderBuilder, ReqwestProvider}; use antelope::api::client::{APIClient, DefaultProvider}; -use antelope::chain::binary_extension::BinaryExtension; -use antelope::chain::checksum::Checksum256; -use antelope::serializer::Decoder; -use antelope::StructPacker; use reqwest::Url; use reth::{ args::RpcServerArgs, @@ -15,8 +11,6 @@ use reth_chainspec::{ChainSpec, ChainSpecBuilder, TEVMTESTNET}; use reth_e2e_test_utils::node::NodeTestContext; use reth_node_telos::{TelosArgs, TelosNode}; use reth_telos_rpc::TelosClient; -use serde::{Deserialize, Serialize}; -use std::collections::HashMap; use std::str::FromStr; use std::{fs, path::PathBuf, sync::Arc, time::Duration}; use telos_consensus_client::{ diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index 630c9155863d..e3e6834ef262 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -5,23 +5,18 @@ use alloy_primitives::{hex, keccak256, Address, Signature, B256, U256}; use alloy_provider::network::EthereumWallet; use alloy_provider::{Provider, ProviderBuilder}; use alloy_rpc_types::TransactionRequest; -use std::error::Error; use alloy_signer_local::PrivateKeySigner; use alloy_sol_types::private::primitives::TxKind::Create; use alloy_sol_types::{sol, SolEvent}; use antelope::api::v1::structs::{GetTableRowsParams, IndexPosition, TableIndexType}; -use antelope::chain::binary_extension::BinaryExtension; -use antelope::chain::checksum::Checksum160; -use antelope::chain::{checksum::Checksum256, name::Name, Packer}; -use antelope::serializer::{Decoder, Encoder}; -use antelope::{name, StructPacker}; +use antelope::chain::{checksum::Checksum256, name::Name}; +use antelope::{name}; use num_bigint::{BigUint, ToBigUint}; use reqwest::Url; use reth::primitives::BlockId; use reth::primitives::BlockNumberOrTag::Latest; use reth::rpc::types::{BlockTransactionsKind, TransactionInput}; -use serde::{Deserialize, Serialize}; use std::fmt::Debug; use std::str::FromStr; use telos_translator_rs::rlp::telos_rlp_decode::TelosTxDecodable; @@ -29,7 +24,6 @@ use tracing::info; use reth::primitives::revm_primitives::bytes::Bytes; use reth::revm::primitives::{AccessList, AccessListItem}; -use reth::rpc::server_types::eth::{EthApiError, RpcInvalidTransactionError}; pub(crate) fn account_params(account: &str) -> GetTableRowsParams { GetTableRowsParams { diff --git a/crates/telos/rpc/src/eth/telos_client.rs b/crates/telos/rpc/src/eth/telos_client.rs index 2a982ff15e5b..33c33f015409 100644 --- a/crates/telos/rpc/src/eth/telos_client.rs +++ b/crates/telos/rpc/src/eth/telos_client.rs @@ -3,10 +3,7 @@ use std::future::Future; use std::sync::Arc; use antelope::api::client::{APIClient, DefaultProvider}; -use antelope::api::v1::structs::{ - ClientError, EncodingError, HTTPError, SendTransactionResponse2Error, - SendTransactionResponseError, SimpleError, -}; +use antelope::api::v1::structs::{ClientError, SendTransaction2Options, SendTransactionResponse2Error}; use antelope::chain::action::{Action, PermissionLevel}; use antelope::chain::checksum::Checksum160; use antelope::chain::name::Name; @@ -15,7 +12,6 @@ use antelope::chain::transaction::{SignedTransaction, Transaction}; use antelope::serializer::Decoder; use antelope::serializer::Encoder; use antelope::{chain::Packer, name, StructPacker}; -use derive_more::Display; use jsonrpsee_types::ErrorObject; use regex::Regex; use tracing::{debug, error, warn}; @@ -46,7 +42,6 @@ impl From for EthApiError { } ClientError::ENCODING(encoding_error) => EthApiError::EvmCustom(encoding_error.message), ClientError::NETWORK(network_error) => EthApiError::EvmCustom(network_error), - _ => EthApiError::EvmCustom(err.to_string()), } } } From 1b21d2d6dacf0ca81c4b027b8d03d8d2898bdc81 Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Mon, 9 Dec 2024 15:31:27 +0100 Subject: [PATCH 23/24] Add options when sending tx with retry. --- crates/rpc/rpc-eth-types/src/error.rs | 1 - crates/telos/node/tests/live_test_runner.rs | 11 +++++++++-- crates/telos/rpc/src/eth/telos_client.rs | 10 ++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/crates/rpc/rpc-eth-types/src/error.rs b/crates/rpc/rpc-eth-types/src/error.rs index 7a46327b038e..10fa3b716021 100644 --- a/crates/rpc/rpc-eth-types/src/error.rs +++ b/crates/rpc/rpc-eth-types/src/error.rs @@ -5,7 +5,6 @@ use std::time::Duration; use alloy_primitives::{Address, Bytes, U256}; use alloy_rpc_types::{error::EthRpcErrorCode, request::TransactionInputError, BlockError}; use alloy_sol_types::decode_revert_reason; -use jsonrpsee_core::ClientError; use reth_errors::RethError; use reth_primitives::{revm_primitives::InvalidHeader, BlockId}; use reth_rpc_server_types::result::{ diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index e3e6834ef262..6f21e4452875 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -236,6 +236,11 @@ pub async fn test_1559_tx( .with_max_fee_per_gas(20_000_000_000); let tx_result = provider.send_transaction(tx).await; + + info!("test_1559_tx"); + + + assert!(tx_result.is_err()); } @@ -266,6 +271,8 @@ pub async fn test_2930_tx( }])) .max_fee_per_gas(2e9 as u128); let tx_result = provider.send_transaction(tx).await; + info!("test_2930_tx"); + assert!(tx_result.is_err()); } @@ -320,9 +327,9 @@ pub async fn test_double_approve_erc20( let block_number = receipt2.unwrap().block_number.unwrap(); - // make sure the block is included + // make sure the block is included and there is a progress while let Some(block) = provider.get_block_by_number(Latest, false).await.unwrap() { - if block.header.number == block_number { + if block.header.number >= block_number { break; } } diff --git a/crates/telos/rpc/src/eth/telos_client.rs b/crates/telos/rpc/src/eth/telos_client.rs index 33c33f015409..2ad014b76337 100644 --- a/crates/telos/rpc/src/eth/telos_client.rs +++ b/crates/telos/rpc/src/eth/telos_client.rs @@ -76,7 +76,7 @@ fn parse_error_message(message: String) -> Option { } fn parse_server_error(server_error: SendTransactionResponse2Error) -> EthApiError { - let mut error_message = server_error.message; + let error_message = server_error.message; for detail in server_error.details.unwrap_or_default() { if let Some(error) = parse_error_message(detail.message) { return error; @@ -232,11 +232,17 @@ impl TelosClient { context_free_data: vec![], }; + let options = SendTransaction2Options{ + return_failure_trace: true, + retry_trx: true, + retry_trx_num_blocks: 2, + }; + let tx_response = self .inner .api_client .v1_chain - .send_transaction2(signed_telos_transaction.clone(), None) + .send_transaction2(signed_telos_transaction.clone(), Some(options)) .await; let tx = match tx_response { From 41bf1f52695e710526f4b81f8fc5628d473133f3 Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Mon, 9 Dec 2024 15:59:00 +0100 Subject: [PATCH 24/24] Update Cargo.lock --- Cargo.lock | 656 ++++------------------------------------------------- 1 file changed, 41 insertions(+), 615 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b351a18ece36..695e93c7feb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,7 +59,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", - "const-random", "getrandom 0.2.15", "once_cell", "version_check", @@ -501,7 +500,7 @@ dependencies = [ "alloy-primitives", "alloy-pubsub", "alloy-rpc-client 0.4.2", - "alloy-rpc-types-admin 0.4.2", + "alloy-rpc-types-admin", "alloy-rpc-types-engine 0.4.2", "alloy-rpc-types-eth 0.4.2", "alloy-transport 0.4.2", @@ -635,18 +634,6 @@ dependencies = [ "serde", ] -[[package]] -name = "alloy-rpc-types-admin" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fefd12e99dd6b7de387ed13ad047ce2c90d8950ca62fc48b8a457ebb8f936c61" -dependencies = [ - "alloy-genesis 0.3.6", - "alloy-primitives", - "serde", - "serde_json", -] - [[package]] name = "alloy-rpc-types-admin" version = "0.4.2" @@ -659,17 +646,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "alloy-rpc-types-anvil" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d25cb45ad7c0930dd62eecf164d2afe4c3d2dd2c82af85680ad1f118e1e5cb83" -dependencies = [ - "alloy-primitives", - "alloy-serde 0.3.6", - "serde", -] - [[package]] name = "alloy-rpc-types-anvil" version = "0.4.2" @@ -681,20 +657,6 @@ dependencies = [ "serde", ] -[[package]] -name = "alloy-rpc-types-beacon" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7081d2206dca51ce23a06338d78d9b536931cc3f15134fc1c6535eb2b77f18" -dependencies = [ - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-rpc-types-engine 0.3.6", - "serde", - "serde_with", - "thiserror", -] - [[package]] name = "alloy-rpc-types-beacon" version = "0.4.2" @@ -731,7 +693,8 @@ dependencies = [ "alloy-rlp", "alloy-serde 0.3.6", "derive_more 1.0.0", - "jsonrpsee-types", + "jsonwebtoken", + "rand 0.8.5", "serde", ] @@ -771,7 +734,6 @@ dependencies = [ "derive_more 1.0.0", "hashbrown 0.14.5", "itertools 0.13.0", - "jsonrpsee-types", "serde", "serde_json", ] @@ -796,19 +758,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "alloy-rpc-types-mev" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "922d92389e5022650c4c60ffd2f9b2467c3f853764f0f74ff16a23106f9017d5" -dependencies = [ - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-serde 0.3.6", - "serde", - "serde_json", -] - [[package]] name = "alloy-rpc-types-mev" version = "0.4.2" @@ -822,20 +771,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "alloy-rpc-types-trace" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98db35cd42c90b484377e6bc44d95377a7a38a5ebee996e67754ac0446d542ab" -dependencies = [ - "alloy-primitives", - "alloy-rpc-types-eth 0.3.6", - "alloy-serde 0.3.6", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "alloy-rpc-types-trace" version = "0.4.2" @@ -850,18 +785,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "alloy-rpc-types-txpool" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bac37082c3b21283b3faf5cc0e08974272aee2f756ce1adeb26db56a5fce0d5" -dependencies = [ - "alloy-primitives", - "alloy-rpc-types-eth 0.3.6", - "alloy-serde 0.3.6", - "serde", -] - [[package]] name = "alloy-rpc-types-txpool" version = "0.4.2" @@ -1223,42 +1146,10 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "antelope-client" -version = "0.2.1" -source = "git+https://github.com/telosnetwork/antelope-rs?branch=development#ed53c75b6b9ce14aa72002ddd491a6697ae563d9" -dependencies = [ - "antelope-client-macros", - "async-trait", - "base64 0.21.7", - "bs58", - "chrono", - "digest 0.10.7", - "ecdsa", - "flate2", - "hex", - "hmac 0.12.1", - "k256", - "log", - "once_cell", - "p256", - "rand 0.8.5", - "rand_core 0.6.4", - "reqwest 0.11.27", - "ripemd", - "serde", - "serde-big-array", - "serde_json", - "sha2 0.10.8", - "signature", - "thiserror", - "tokio", -] - [[package]] name = "antelope-client" version = "0.3.0" -source = "git+https://github.com/telosnetwork/antelope-rs?branch=master#fea2203b2edb5cfcedd5365031e5286b47dc5c66" +source = "git+https://github.com/telosnetwork/antelope-rs?rev=d701cd9ca2e87e8e0fd99746f9c672cb3536e5ec#d701cd9ca2e87e8e0fd99746f9c672cb3536e5ec" dependencies = [ "antelope-client-macros", "async-trait", @@ -1463,248 +1354,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" -[[package]] -name = "arrow" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "219d05930b81663fd3b32e3bde8ce5bff3c4d23052a99f11a8fa50a3b47b2658" -dependencies = [ - "arrow-arith", - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-csv", - "arrow-data", - "arrow-ipc", - "arrow-json", - "arrow-ord", - "arrow-row", - "arrow-schema", - "arrow-select", - "arrow-string", -] - -[[package]] -name = "arrow-arith" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0272150200c07a86a390be651abdd320a2d12e84535f0837566ca87ecd8f95e0" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "chrono", - "half", - "num", -] - -[[package]] -name = "arrow-array" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8010572cf8c745e242d1b632bd97bd6d4f40fefed5ed1290a8f433abaa686fea" -dependencies = [ - "ahash", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "chrono", - "half", - "hashbrown 0.14.5", - "num", -] - -[[package]] -name = "arrow-buffer" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d0a2432f0cba5692bf4cb757469c66791394bac9ec7ce63c1afe74744c37b27" -dependencies = [ - "bytes", - "half", - "num", -] - -[[package]] -name = "arrow-cast" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9abc10cd7995e83505cc290df9384d6e5412b207b79ce6bdff89a10505ed2cba" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "arrow-select", - "atoi", - "base64 0.22.1", - "chrono", - "half", - "lexical-core", - "num", - "ryu", -] - -[[package]] -name = "arrow-csv" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95cbcba196b862270bf2a5edb75927380a7f3a163622c61d40cbba416a6305f2" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-data", - "arrow-schema", - "chrono", - "csv", - "csv-core", - "lazy_static", - "lexical-core", - "regex", -] - -[[package]] -name = "arrow-data" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2742ac1f6650696ab08c88f6dd3f0eb68ce10f8c253958a18c943a68cd04aec5" -dependencies = [ - "arrow-buffer", - "arrow-schema", - "half", - "num", -] - -[[package]] -name = "arrow-ipc" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a42ea853130f7e78b9b9d178cb4cd01dee0f78e64d96c2949dc0a915d6d9e19d" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-data", - "arrow-schema", - "flatbuffers", -] - -[[package]] -name = "arrow-json" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaafb5714d4e59feae964714d724f880511500e3569cc2a94d02456b403a2a49" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-data", - "arrow-schema", - "chrono", - "half", - "indexmap 2.6.0", - "lexical-core", - "num", - "serde", - "serde_json", -] - -[[package]] -name = "arrow-ord" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3e6b61e3dc468f503181dccc2fc705bdcc5f2f146755fa5b56d0a6c5943f412" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "arrow-select", - "half", - "num", -] - -[[package]] -name = "arrow-row" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "848ee52bb92eb459b811fb471175ea3afcf620157674c8794f539838920f9228" -dependencies = [ - "ahash", - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "half", - "hashbrown 0.14.5", -] - -[[package]] -name = "arrow-schema" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d9483aaabe910c4781153ae1b6ae0393f72d9ef757d38d09d450070cf2e528" - -[[package]] -name = "arrow-select" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "849524fa70e0e3c5ab58394c770cb8f514d0122d20de08475f7b472ed8075830" -dependencies = [ - "ahash", - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "num", -] - -[[package]] -name = "arrow-string" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9373cb5a021aee58863498c37eb484998ef13377f69989c6c5ccfbd258236cdb" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "arrow-select", - "memchr", - "num", - "regex", - "regex-syntax 0.8.5", -] - -[[package]] -name = "arrowbatch" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e304bae8e33446c64842dba444042ce65cb23e2b1e439fa2f4abb7591db562c5" -dependencies = [ - "arrow", - "base64 0.22.1", - "chrono", - "env_logger 0.10.2", - "futures", - "futures-util", - "hex", - "log", - "moka", - "num", - "num-bigint", - "rlp", - "serde", - "serde_json", - "tokio", - "tokio-tungstenite 0.21.0", - "tungstenite 0.21.0", - "uuid", - "zstd", -] - [[package]] name = "asn1_der" version = "0.7.6" @@ -1802,15 +1451,6 @@ dependencies = [ "rustc_version 0.4.1", ] -[[package]] -name = "atoi" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" -dependencies = [ - "num-traits", -] - [[package]] name = "atomic-waker" version = "1.1.2" @@ -2678,26 +2318,6 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "const-random" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" -dependencies = [ - "const-random-macro", -] - -[[package]] -name = "const-random-macro" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" -dependencies = [ - "getrandom 0.2.15", - "once_cell", - "tiny-keccak", -] - [[package]] name = "const_format" version = "0.2.33" @@ -3492,19 +3112,6 @@ dependencies = [ "regex", ] -[[package]] -name = "env_logger" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - [[package]] name = "env_logger" version = "0.11.5" @@ -3545,7 +3152,7 @@ name = "example-beacon-api-sidecar-fetcher" version = "0.1.0" dependencies = [ "alloy-primitives", - "alloy-rpc-types-beacon 0.4.2", + "alloy-rpc-types-beacon", "clap", "eyre", "futures-util", @@ -3561,7 +3168,7 @@ dependencies = [ name = "example-beacon-api-sse" version = "0.0.0" dependencies = [ - "alloy-rpc-types-beacon 0.4.2", + "alloy-rpc-types-beacon", "clap", "futures-util", "mev-share-sse", @@ -3837,7 +3444,7 @@ name = "example-txpool-tracing" version = "0.0.0" dependencies = [ "alloy-primitives", - "alloy-rpc-types-trace 0.4.2", + "alloy-rpc-types-trace", "clap", "futures-util", "reth", @@ -3948,16 +3555,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "flatbuffers" -version = "23.5.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dac53e22462d78c16d64a1cd22371b54cc3fe94aa15e7886a2fa6e5d1ab8640" -dependencies = [ - "bitflags 1.3.2", - "rustc_version 0.4.1", -] - [[package]] name = "flate2" version = "1.0.34" @@ -4318,7 +3915,6 @@ checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ "cfg-if", "crunchy", - "num-traits", ] [[package]] @@ -5495,70 +5091,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" -[[package]] -name = "lexical-core" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cde5de06e8d4c2faabc400238f9ae1c74d5412d03a7bd067645ccbc47070e46" -dependencies = [ - "lexical-parse-float", - "lexical-parse-integer", - "lexical-util", - "lexical-write-float", - "lexical-write-integer", -] - -[[package]] -name = "lexical-parse-float" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683b3a5ebd0130b8fb52ba0bdc718cc56815b6a097e28ae5a6997d0ad17dc05f" -dependencies = [ - "lexical-parse-integer", - "lexical-util", - "static_assertions", -] - -[[package]] -name = "lexical-parse-integer" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d0994485ed0c312f6d965766754ea177d07f9c00c9b82a5ee62ed5b47945ee9" -dependencies = [ - "lexical-util", - "static_assertions", -] - -[[package]] -name = "lexical-util" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5255b9ff16ff898710eb9eb63cb39248ea8a5bb036bea8085b1a767ff6c4e3fc" -dependencies = [ - "static_assertions", -] - -[[package]] -name = "lexical-write-float" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accabaa1c4581f05a3923d1b4cfd124c329352288b7b9da09e766b0668116862" -dependencies = [ - "lexical-util", - "lexical-write-integer", - "static_assertions", -] - -[[package]] -name = "lexical-write-integer" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1b6f3d1f4422866b68192d62f77bc5c700bee84f3069f2469d7bc8c77852446" -dependencies = [ - "lexical-util", - "static_assertions", -] - [[package]] name = "libc" version = "0.2.159" @@ -6365,20 +5897,6 @@ dependencies = [ "spin", ] -[[package]] -name = "op-alloy-genesis" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e1b8a9b70da0e027242ec1762f0f3a386278b6291d00d12ff5a64929dc19f68" -dependencies = [ - "alloy-consensus 0.3.6", - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-sol-types", - "serde", - "serde_repr", -] - [[package]] name = "op-alloy-genesis" version = "0.3.3" @@ -6407,23 +5925,6 @@ dependencies = [ "op-alloy-rpc-types 0.3.3", ] -[[package]] -name = "op-alloy-protocol" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf300a82ae2d30e2255bfea87a2259da49f63a25a44db561ae64cc9e3084139f" -dependencies = [ - "alloy-consensus 0.3.6", - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.3.6", - "hashbrown 0.14.5", - "op-alloy-consensus 0.2.12", - "op-alloy-genesis 0.2.12", - "serde", -] - [[package]] name = "op-alloy-protocol" version = "0.3.3" @@ -6437,7 +5938,7 @@ dependencies = [ "alloy-serde 0.4.2", "derive_more 1.0.0", "op-alloy-consensus 0.3.3", - "op-alloy-genesis 0.3.3", + "op-alloy-genesis", "serde", ] @@ -6476,23 +5977,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "op-alloy-rpc-types-engine" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2947272a81ebf988f4804b6f0f6a7c0b2f6f89a908cb410e36f8f3828f81c778" -dependencies = [ - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-rpc-types-engine 0.3.6", - "alloy-serde 0.3.6", - "derive_more 1.0.0", - "op-alloy-consensus 0.2.12", - "op-alloy-genesis 0.2.12", - "op-alloy-protocol 0.2.12", - "serde", -] - [[package]] name = "op-alloy-rpc-types-engine" version = "0.3.3" @@ -6503,7 +5987,7 @@ dependencies = [ "alloy-rpc-types-engine 0.4.2", "alloy-serde 0.4.2", "derive_more 1.0.0", - "op-alloy-protocol 0.3.3", + "op-alloy-protocol", "serde", ] @@ -8354,7 +7838,7 @@ dependencies = [ "futures-util", "jsonrpsee", "jsonrpsee-types", - "op-alloy-rpc-types-engine 0.3.3", + "op-alloy-rpc-types-engine", "reth", "reth-chainspec", "reth-db", @@ -9107,7 +8591,7 @@ name = "reth-network-api" version = "1.0.8" dependencies = [ "alloy-primitives", - "alloy-rpc-types-admin 0.4.2", + "alloy-rpc-types-admin", "auto_impl", "derive_more 1.0.0", "enr", @@ -9415,7 +8899,7 @@ dependencies = [ name = "reth-node-telos" version = "1.0.8" dependencies = [ - "alloy-consensus 0.4.2", + "alloy-consensus 0.3.6", "alloy-contract", "alloy-network 0.4.2", "alloy-primitives", @@ -9425,11 +8909,12 @@ dependencies = [ "alloy-signer-local", "alloy-sol-types", "alloy-transport-http 0.4.2", - "antelope-client 0.3.0", + "antelope-client", "clap", "derive_more 1.0.0", - "env_logger 0.11.5", + "env_logger", "eyre", + "num-bigint", "reqwest 0.12.8", "reth", "reth-auto-seal-consensus", @@ -9601,7 +9086,7 @@ dependencies = [ "jsonrpsee", "jsonrpsee-types", "op-alloy-consensus 0.3.3", - "op-alloy-rpc-types-engine 0.3.3", + "op-alloy-rpc-types-engine", "parking_lot 0.12.3", "reqwest 0.12.8", "reth", @@ -9648,7 +9133,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-rpc-types-engine 0.4.2", - "op-alloy-rpc-types-engine 0.3.3", + "op-alloy-rpc-types-engine", "reth-basic-payload-builder", "reth-chain-state", "reth-chainspec", @@ -9760,7 +9245,7 @@ dependencies = [ "alloy-primitives", "alloy-rpc-types 0.4.2", "async-trait", - "op-alloy-rpc-types-engine 0.3.3", + "op-alloy-rpc-types-engine", "pin-project", "reth-chain-state", "reth-chainspec", @@ -10042,12 +9527,12 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-rpc-types 0.4.2", - "alloy-rpc-types-admin 0.4.2", + "alloy-rpc-types-admin", "alloy-rpc-types-debug", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-mev 0.4.2", - "alloy-rpc-types-trace 0.4.2", - "alloy-rpc-types-txpool 0.4.2", + "alloy-rpc-types-mev", + "alloy-rpc-types-trace", + "alloy-rpc-types-txpool", "alloy-serde 0.4.2", "alloy-signer 0.4.2", "alloy-signer-local", @@ -10107,15 +9592,15 @@ dependencies = [ "alloy-json-rpc 0.4.2", "alloy-primitives", "alloy-rpc-types 0.4.2", - "alloy-rpc-types-admin 0.4.2", - "alloy-rpc-types-anvil 0.4.2", - "alloy-rpc-types-beacon 0.4.2", + "alloy-rpc-types-admin", + "alloy-rpc-types-anvil", + "alloy-rpc-types-beacon", "alloy-rpc-types-debug", "alloy-rpc-types-engine 0.4.2", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-mev 0.4.2", - "alloy-rpc-types-trace 0.4.2", - "alloy-rpc-types-txpool 0.4.2", + "alloy-rpc-types-mev", + "alloy-rpc-types-trace", + "alloy-rpc-types-txpool", "alloy-serde 0.4.2", "jsonrpsee", "reth-engine-primitives", @@ -10133,7 +9618,7 @@ dependencies = [ "alloy-primitives", "alloy-rpc-types 0.4.2", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-trace 0.4.2", + "alloy-rpc-types-trace", "futures", "jsonrpsee", "jsonrpsee-http-client", @@ -10154,7 +9639,7 @@ dependencies = [ "alloy-rpc-types 0.4.2", "alloy-rpc-types-engine 0.4.2", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-trace 0.4.2", + "alloy-rpc-types-trace", "alloy-serde 0.4.2", "clap", "http 1.1.0", @@ -10245,7 +9730,7 @@ dependencies = [ "alloy-primitives", "alloy-rpc-types 0.4.2", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-mev 0.4.2", + "alloy-rpc-types-mev", "async-trait", "auto_impl", "dyn-clone", @@ -10348,26 +9833,6 @@ dependencies = [ "strum", ] -[[package]] -name = "reth-rpc-types" -version = "1.0.6" -source = "git+https://github.com/telosnetwork/telos-reth?branch=telos-main#63d23e00982a0ab7704a6dff97b3f5d355e11d56" -dependencies = [ - "alloy-primitives", - "alloy-rpc-types 0.3.6", - "alloy-rpc-types-admin 0.3.6", - "alloy-rpc-types-anvil 0.3.6", - "alloy-rpc-types-beacon 0.3.6", - "alloy-rpc-types-engine 0.3.6", - "alloy-rpc-types-mev 0.3.6", - "alloy-rpc-types-trace 0.3.6", - "alloy-rpc-types-txpool 0.3.6", - "alloy-serde 0.3.6", - "jsonrpsee-types", - "op-alloy-rpc-types 0.2.12", - "op-alloy-rpc-types-engine 0.2.12", -] - [[package]] name = "reth-rpc-types-compat" version = "1.0.8" @@ -10610,12 +10075,13 @@ dependencies = [ "alloy-network 0.4.2", "alloy-primitives", "alloy-rpc-types 0.4.2", - "antelope-client 0.3.0", + "antelope-client", "async-trait", "derive_more 1.0.0", "jsonrpsee-types", "log", "parking_lot 0.12.3", + "regex", "reth-chainspec", "reth-evm", "reth-network-api", @@ -10899,7 +10365,7 @@ source = "git+https://github.com/telosnetwork/telos-evm-inspectors?branch=telos- dependencies = [ "alloy-primitives", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-trace 0.4.2", + "alloy-rpc-types-trace", "alloy-sol-types", "anstyle", "boa_engine", @@ -12078,13 +11544,14 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "telos-consensus-client" version = "0.1.0" -source = "git+https://github.com/telosnetwork/telos-consensus-client?rev=f8ecbe1aeea57911c9fbefdddf49efa92d8472ce#f8ecbe1aeea57911c9fbefdddf49efa92d8472ce" +source = "git+https://github.com/telosnetwork/telos-consensus-client?rev=9fadee1fd565e3a7ad51c1142e2673df52bd9028#9fadee1fd565e3a7ad51c1142e2673df52bd9028" dependencies = [ "alloy", "alloy-consensus 0.3.6", "alloy-rlp", - "antelope-client 0.2.1", - "arrowbatch", + "alloy-rpc-types 0.3.6", + "alloy-rpc-types-engine 0.3.6", + "antelope-client", "base64 0.22.1", "bytes", "chrono", @@ -12097,7 +11564,6 @@ dependencies = [ "rand 0.8.5", "reqwest 0.11.27", "reth-primitives 1.0.6", - "reth-rpc-types", "rocksdb", "serde", "serde_json", @@ -12131,13 +11597,14 @@ dependencies = [ [[package]] name = "telos-translator-rs" version = "0.1.0" -source = "git+https://github.com/telosnetwork/telos-consensus-client?rev=f8ecbe1aeea57911c9fbefdddf49efa92d8472ce#f8ecbe1aeea57911c9fbefdddf49efa92d8472ce" +source = "git+https://github.com/telosnetwork/telos-consensus-client?rev=9fadee1fd565e3a7ad51c1142e2673df52bd9028#9fadee1fd565e3a7ad51c1142e2673df52bd9028" dependencies = [ "alloy", "alloy-consensus 0.3.6", "alloy-eips 0.3.6", "alloy-rlp", - "antelope-client 0.2.1", + "alloy-rpc-types-engine 0.3.6", + "antelope-client", "bytes", "clap", "dashmap 5.5.3", @@ -12149,7 +11616,6 @@ dependencies = [ "moka", "num-bigint", "reth-primitives 1.0.6", - "reth-rpc-types", "reth-telos-rpc-engine-api 1.0.6", "reth-trie-common 1.0.6", "rlp", @@ -12176,15 +11642,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "termtree" version = "0.4.1" @@ -12518,18 +11975,6 @@ dependencies = [ "tokio-util", ] -[[package]] -name = "tokio-tungstenite" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" -dependencies = [ - "futures-util", - "log", - "tokio", - "tungstenite 0.21.0", -] - [[package]] name = "tokio-tungstenite" version = "0.23.1" @@ -12894,25 +12339,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "tungstenite" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http 1.1.0", - "httparse", - "log", - "rand 0.8.5", - "sha1", - "thiserror", - "url", - "utf-8", -] - [[package]] name = "tungstenite" version = "0.23.0"