Skip to content

Commit

Permalink
Fixed tests to pass CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Zyouell committed Dec 17, 2024
1 parent 04f6d13 commit 5a2f7e3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 28 deletions.
62 changes: 35 additions & 27 deletions mp2-test/src/mpt_sequential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,17 @@ pub fn generate_receipt_test_info<const NO_TOPICS: usize, const MAX_DATA: usize>
4 => event_contract.testTwoData().into_transaction_request(),
_ => unreachable!(),
};
let random_two = match (0..5).sample_single(&mut rng) {
0 => event_contract.testEmit().into_transaction_request(),
1 => event_contract.testTwoIndexed().into_transaction_request(),
2 => event_contract.testThreeIndexed().into_transaction_request(),
3 => event_contract.testOneData().into_transaction_request(),
4 => event_contract.testTwoData().into_transaction_request(),
_ => unreachable!(),
};
let tx_req = match i % 4 {
0 => random,
1 => event_contract
.twoEmits(U256::from((0..5).sample_single(&mut rng)))
.into_transaction_request(),
1 => random_two,
2 => other_contract.otherEmit().into_transaction_request(),
3 => other_contract.twoEmits().into_transaction_request(),
_ => unreachable!(),
Expand All @@ -219,31 +225,33 @@ pub fn generate_receipt_test_info<const NO_TOPICS: usize, const MAX_DATA: usize>
pending_tx_builders.push(rpc.send_transaction(tx_req_final).await.unwrap());
}

// Finally we guarantee at least one of the event we are going to query for
let queried_event_req = match (NO_TOPICS, MAX_DATA) {
(1, 0) => event_contract.testEmit().into_transaction_request(),
(2, 0) => event_contract.testTwoIndexed().into_transaction_request(),
(3, 0) => event_contract.testThreeIndexed().into_transaction_request(),
(3, 1) => event_contract.testOneData().into_transaction_request(),
(3, 2) => event_contract.testTwoData().into_transaction_request(),
_ => unreachable!(),
};
// Finally we guarantee at least three of the event we are going to query for
for _ in 0..3 {
let queried_event_req = match (NO_TOPICS, MAX_DATA) {
(1, 0) => event_contract.testEmit().into_transaction_request(),
(2, 0) => event_contract.testTwoIndexed().into_transaction_request(),
(3, 0) => event_contract.testThreeIndexed().into_transaction_request(),
(3, 1) => event_contract.testOneData().into_transaction_request(),
(3, 2) => event_contract.testTwoData().into_transaction_request(),
_ => unreachable!(),
};

let sender_address = Address::random();
let funding = U256::from(1e18 as u64);
rpc.anvil_set_balance(sender_address, funding)
.await
.unwrap();
rpc.anvil_auto_impersonate_account(true).await.unwrap();
let new_req = queried_event_req.with_from(sender_address);
let tx_req_final = rpc
.fill(new_req)
.await
.unwrap()
.as_builder()
.unwrap()
.clone();
pending_tx_builders.push(rpc.send_transaction(tx_req_final).await.unwrap());
let sender_address = Address::random();
let funding = U256::from(1e18 as u64);
rpc.anvil_set_balance(sender_address, funding)
.await
.unwrap();
rpc.anvil_auto_impersonate_account(true).await.unwrap();
let new_req = queried_event_req.with_from(sender_address);
let tx_req_final = rpc
.fill(new_req)
.await
.unwrap()
.as_builder()
.unwrap()
.clone();
pending_tx_builders.push(rpc.send_transaction(tx_req_final).await.unwrap());
}

// Mine a block, it should include all the transactions created above.
rpc.anvil_mine(Some(U256::from(1u8)), None).await.unwrap();
Expand Down
4 changes: 3 additions & 1 deletion mp2-v1/src/values_extraction/leaf_receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use rlp::Encodable;
use serde::{Deserialize, Serialize};
use std::{array::from_fn, iter};
/// Maximum number of logs per transaction we can process
const MAX_LOGS_PER_TX: usize = 2;
const MAX_LOGS_PER_TX: usize = 1;

/// The number of bytes that `gas_used` could take up in the receipt.
/// We set a max of 3 here because this would be over half the gas in the block for Ethereum.
Expand Down Expand Up @@ -243,6 +243,7 @@ impl EventWires {

// Pack the data and get the digest
let packed_data = data_bytes.arr.pack(b, Endianness::Big);

let data_digest = b.map_to_curve_point(
&std::iter::once(log_column.column_id)
.chain(packed_data)
Expand Down Expand Up @@ -764,6 +765,7 @@ mod tests {

let node = info.mpt_proof.last().unwrap().clone();

assert!(node.len() <= NODE_LEN);
let proof = run_circuit::<F, D, C, _>(test_circuit);
let pi = PublicInputs::new(&proof.public_inputs);

Expand Down

0 comments on commit 5a2f7e3

Please sign in to comment.