Skip to content

Commit

Permalink
reactivate pre_eip_155 test (#1406)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored Sep 26, 2024
1 parent ff372ce commit b2058bb
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 10 deletions.
13 changes: 11 additions & 2 deletions src/pool/validate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#![allow(unused_variables, clippy::struct_excessive_bools)]

use crate::providers::eth_provider::{database::state::EthDatabase, provider::EthereumProvider};
use crate::providers::eth_provider::{
database::state::EthDatabase, provider::EthereumProvider,
starknet::kakarot_core::get_white_listed_eip_155_transaction_hashes,
};
use reth_chainspec::ChainSpec;
use reth_primitives::{
BlockId, GotExpected, InvalidTransactionError, SealedBlock, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID,
Expand Down Expand Up @@ -222,11 +225,17 @@ where
Tx: EthPoolTransaction,
{
/// Validates a single transaction.
#[allow(clippy::too_many_lines)]
fn validate_one(&self, transaction: Tx) -> TransactionValidationOutcome<Tx> {
// Checks for tx_type
match transaction.tx_type() {
LEGACY_TX_TYPE_ID => {
// Accept legacy transactions
if !get_white_listed_eip_155_transaction_hashes().contains(transaction.hash()) {
return TransactionValidationOutcome::Invalid(
transaction,
InvalidTransactionError::TxTypeNotSupported.into(),
);
}
}
EIP2930_TX_TYPE_ID => {
// Accept only legacy transactions until EIP-2718/2930 activates
Expand Down
48 changes: 40 additions & 8 deletions tests/tests/eth_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,9 +971,9 @@ async fn test_send_raw_transaction_exceed_gas_limit(#[future] katana: Katana, _s
#[rstest]
#[awt]
#[tokio::test(flavor = "multi_thread")]
#[ignore = "failing because of relayer change"]
async fn test_send_raw_transaction_pre_eip_155(#[future] katana: Katana, _setup: ()) {
async fn test_send_raw_transaction_pre_eip_155(#[future] katana_empty: Katana, _setup: ()) {
// Given
let katana = katana_empty;
let eth_provider = katana.eth_provider();
let eth_client = katana.eth_client();
let nonce: u64 = katana.eoa().nonce().await.unwrap().try_into().expect("Failed to convert nonce");
Expand All @@ -998,22 +998,54 @@ async fn test_send_raw_transaction_pre_eip_155(#[future] katana: Katana, _setup:
assert_eq!(mempool_size.total, 0);

// Send the transaction
let tx_hash = eth_client
let _ = eth_client
.send_raw_transaction(transaction_signed.envelope_encoded())
.await
.expect("failed to send transaction");

let bytes = tx_hash.0;
let starknet_tx_hash = Felt::from_bytes_be(&bytes);

let mempool_size_after_send = eth_client.mempool().pool_size();
// Assert that the number of pending transactions in the mempool is 1
assert_eq!(mempool_size_after_send.pending, 1);
assert_eq!(mempool_size_after_send.total, 1);

watch_tx(eth_provider.starknet_provider_inner(), starknet_tx_hash, std::time::Duration::from_millis(300), 60)
// Prepare the relayer
let relayer_balance = katana
.eth_client
.starknet_provider()
.balance_at(katana.eoa.relayer.address(), BlockId::Tag(BlockTag::Latest))
.await
.expect("Failed to get relayer balance");
let relayer_balance = into_via_try_wrapper!(relayer_balance).expect("Failed to convert balance");

let nonce = katana
.eth_client
.starknet_provider()
.get_nonce(BlockId::Tag(BlockTag::Latest), katana.eoa.relayer.address())
.await
.expect("Tx polling failed");
.unwrap_or_default();

let current_nonce = Mutex::new(nonce);

// Relay the transaction
let starknet_transaction_hash = LockedRelayer::new(
current_nonce.lock().await,
katana.eoa.relayer.address(),
relayer_balance,
&(*(*katana.eth_client.starknet_provider())),
katana.eth_client.starknet_provider().chain_id().await.expect("Failed to get chain id"),
)
.relay_transaction(&transaction_signed)
.await
.expect("Failed to relay transaction");

watch_tx(
eth_provider.starknet_provider_inner(),
starknet_transaction_hash,
std::time::Duration::from_millis(300),
60,
)
.await
.expect("Tx polling failed");

// Then
// Check that the Arachnid deployer contract was deployed
Expand Down

0 comments on commit b2058bb

Please sign in to comment.