mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-07 00:03:10 +00:00
Remove intermediary block bloom filters (#1395)
* Remove intermediary block blooms * Update specs * Regenerate pdf * Apply comment, remove unneeded segment
This commit is contained in:
parent
30c944f778
commit
5572da30d7
@ -20,8 +20,6 @@ Those prover provided values are stored in memory prior to entering the kernel,
|
|||||||
\item the previous transaction number: $t_n$,
|
\item the previous transaction number: $t_n$,
|
||||||
\item the gas used before executing the current transaction: $g\_u_0$,
|
\item the gas used before executing the current transaction: $g\_u_0$,
|
||||||
\item the gas used after executing the current transaction: $g\_u_1$,
|
\item the gas used after executing the current transaction: $g\_u_1$,
|
||||||
\item the block bloom filter before executing the current transaction: $b\_f_0$
|
|
||||||
\item the block bloom filter after executing the current transaction: $b\_f_1$,
|
|
||||||
\item the state, transaction and receipts MPTs before executing the current transaction: $\texttt{tries}_0$,
|
\item the state, transaction and receipts MPTs before executing the current transaction: $\texttt{tries}_0$,
|
||||||
\item the hash of all MPTs before executing the current transaction: $\texttt{digests}_0$,
|
\item the hash of all MPTs before executing the current transaction: $\texttt{digests}_0$,
|
||||||
\item the hash of all MPTs after executing the current transaction: $\texttt{digests}_1$,
|
\item the hash of all MPTs after executing the current transaction: $\texttt{digests}_1$,
|
||||||
@ -31,7 +29,6 @@ Those prover provided values are stored in memory prior to entering the kernel,
|
|||||||
\paragraph*{Initialization:} The first step consists in initializing:
|
\paragraph*{Initialization:} The first step consists in initializing:
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item The shift table: it maps the number of bit shifts $s$ with its shifted value $1 << s$. Note that $0 \leq s \leq 255$.
|
\item The shift table: it maps the number of bit shifts $s$ with its shifted value $1 << s$. Note that $0 \leq s \leq 255$.
|
||||||
\item The block bloom filter: the current block bloom filter is initialized with $b\_f_0$.
|
|
||||||
\item The initial MPTs: the initial state, transaction and receipt tries $\texttt{tries}_0$ are loaded from memory and hashed. The hashes are then compared to $\texttt{digests}\_0$.
|
\item The initial MPTs: the initial state, transaction and receipt tries $\texttt{tries}_0$ are loaded from memory and hashed. The hashes are then compared to $\texttt{digests}\_0$.
|
||||||
\item We load the transaction number $t\_n$ and the current gas used $g\_u_0$ from memory.
|
\item We load the transaction number $t\_n$ and the current gas used $g\_u_0$ from memory.
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
@ -40,7 +37,7 @@ If no transaction is provided, we can halt after this initialization. Otherwise,
|
|||||||
|
|
||||||
The processing of the transaction returns a boolean ``success'' that indicates whether the transaction was executed successfully, along with the leftover gas.
|
The processing of the transaction returns a boolean ``success'' that indicates whether the transaction was executed successfully, along with the leftover gas.
|
||||||
|
|
||||||
The following step is then to update the receipts MPT. Here, we update the transaction's bloom filter and the block bloom filter. We store ``success'', the leftover gas, the transaction bloom filter and the logs in memory. We also store some additional information that facilitates the RLP encoding of the receipts later.
|
The following step is then to update the receipts MPT. Here, we update the transaction's bloom filter. We store ``success'', the leftover gas, the transaction bloom filter and the logs in memory. We also store some additional information that facilitates the RLP encoding of the receipts later.
|
||||||
|
|
||||||
If there are any withdrawals, they are performed at this stage.
|
If there are any withdrawals, they are performed at this stage.
|
||||||
|
|
||||||
@ -48,7 +45,6 @@ Finally, once the three MPTs have been updated, we need to carry out final check
|
|||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item the gas used after the execution is equal to $g\_u_1$,
|
\item the gas used after the execution is equal to $g\_u_1$,
|
||||||
\item the new transaction number is $n+1$ if there was a transaction,
|
\item the new transaction number is $n+1$ if there was a transaction,
|
||||||
\item the updated block bloom filter is equal to $b\_f_1$,
|
|
||||||
\item the three MPTs are hashed and checked against $\texttt{digests}_1$.
|
\item the three MPTs are hashed and checked against $\texttt{digests}_1$.
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
Once those final checks are performed, the program halts.
|
Once those final checks are performed, the program halts.
|
||||||
|
|||||||
Binary file not shown.
@ -147,26 +147,13 @@ logs_bloom_end:
|
|||||||
PUSH 7 SUB
|
PUSH 7 SUB
|
||||||
PUSH 1 SWAP1 SHL
|
PUSH 1 SWAP1 SHL
|
||||||
// Updates the current txn bloom filter.
|
// Updates the current txn bloom filter.
|
||||||
// stack: one_shifted_by_index, byte_index, byte_bit_index
|
|
||||||
DUP2 DUP1
|
|
||||||
// stack: byte_index, byte_index, one_shifted_by_index, byte_index, byte_bit_index
|
|
||||||
// load bloom_byte from current txn bloom filter
|
|
||||||
%mload_kernel(@SEGMENT_TXN_BLOOM)
|
|
||||||
%stack (old_bloom_byte, byte_index, one_shifted_by_index) -> (old_bloom_byte, one_shifted_by_index, byte_index, one_shifted_by_index)
|
|
||||||
OR
|
|
||||||
// stack: new_bloom_byte, byte_index, one_shifted_by_index, byte_index, byte_bit_index
|
|
||||||
SWAP1
|
|
||||||
%mstore_kernel(@SEGMENT_TXN_BLOOM)
|
|
||||||
// stack: one_shifted_by_index, byte_index, byte_bit_index
|
|
||||||
|
|
||||||
// Updates the block bloom filter.
|
|
||||||
SWAP2 POP DUP1
|
SWAP2 POP DUP1
|
||||||
%mload_kernel(@SEGMENT_BLOCK_BLOOM)
|
%mload_kernel(@SEGMENT_TXN_BLOOM)
|
||||||
// stack: old_bloom_byte, byte_index, one_shifted_by_index
|
// stack: old_bloom_byte, byte_index, one_shifted_by_index
|
||||||
DUP3 OR
|
DUP3 OR
|
||||||
// stack: new_bloom_byte, byte_index, one_shifted_by_index
|
// stack: new_bloom_byte, byte_index, one_shifted_by_index
|
||||||
SWAP1
|
SWAP1
|
||||||
%mstore_kernel(@SEGMENT_BLOCK_BLOOM)
|
%mstore_kernel(@SEGMENT_TXN_BLOOM)
|
||||||
// stack: one_shifted_by_index
|
// stack: one_shifted_by_index
|
||||||
POP
|
POP
|
||||||
// stack: empty
|
// stack: empty
|
||||||
|
|||||||
@ -14,9 +14,6 @@ global main:
|
|||||||
// Initialise the shift table
|
// Initialise the shift table
|
||||||
%shift_table_init
|
%shift_table_init
|
||||||
|
|
||||||
// Initialize the block bloom filter
|
|
||||||
%initialize_block_bloom
|
|
||||||
|
|
||||||
// Second, load all MPT data from the prover.
|
// Second, load all MPT data from the prover.
|
||||||
PUSH hash_initial_tries
|
PUSH hash_initial_tries
|
||||||
%jump(load_all_mpts)
|
%jump(load_all_mpts)
|
||||||
@ -67,68 +64,7 @@ global hash_final_tries:
|
|||||||
%mload_global_metadata(@GLOBAL_METADATA_BLOCK_GAS_USED_AFTER) %assert_eq
|
%mload_global_metadata(@GLOBAL_METADATA_BLOCK_GAS_USED_AFTER) %assert_eq
|
||||||
DUP3 %mload_global_metadata(@GLOBAL_METADATA_TXN_NUMBER_AFTER) %assert_eq
|
DUP3 %mload_global_metadata(@GLOBAL_METADATA_TXN_NUMBER_AFTER) %assert_eq
|
||||||
%pop3
|
%pop3
|
||||||
%check_metadata_block_bloom
|
|
||||||
%mpt_hash_state_trie %mload_global_metadata(@GLOBAL_METADATA_STATE_TRIE_DIGEST_AFTER) %assert_eq
|
%mpt_hash_state_trie %mload_global_metadata(@GLOBAL_METADATA_STATE_TRIE_DIGEST_AFTER) %assert_eq
|
||||||
%mpt_hash_txn_trie %mload_global_metadata(@GLOBAL_METADATA_TXN_TRIE_DIGEST_AFTER) %assert_eq
|
%mpt_hash_txn_trie %mload_global_metadata(@GLOBAL_METADATA_TXN_TRIE_DIGEST_AFTER) %assert_eq
|
||||||
%mpt_hash_receipt_trie %mload_global_metadata(@GLOBAL_METADATA_RECEIPT_TRIE_DIGEST_AFTER) %assert_eq
|
%mpt_hash_receipt_trie %mload_global_metadata(@GLOBAL_METADATA_RECEIPT_TRIE_DIGEST_AFTER) %assert_eq
|
||||||
%jump(halt)
|
%jump(halt)
|
||||||
|
|
||||||
initialize_block_bloom:
|
|
||||||
// stack: retdest
|
|
||||||
PUSH 0 PUSH 8 PUSH 0
|
|
||||||
|
|
||||||
initialize_bloom_loop:
|
|
||||||
// stack: i, len, offset, retdest
|
|
||||||
DUP2 DUP2 EQ %jumpi(initialize_bloom_loop_end)
|
|
||||||
PUSH 32 // Bloom word length
|
|
||||||
// stack: word_len, i, len, offset, retdest
|
|
||||||
// Load the next `block_bloom_before` word.
|
|
||||||
DUP2 %add_const(8) %mload_kernel(@SEGMENT_GLOBAL_BLOCK_BLOOM)
|
|
||||||
// stack: bloom_word, word_len, i, len, offset, retdest
|
|
||||||
DUP5 PUSH @SEGMENT_BLOCK_BLOOM PUSH 0 // Bloom word address in SEGMENT_BLOCK_BLOOM
|
|
||||||
%mstore_unpacking
|
|
||||||
// stack: new_offset, i, len, old_offset, retdest
|
|
||||||
SWAP3 POP %increment
|
|
||||||
// stack: i, len, new_offset, retdest
|
|
||||||
%jump(initialize_bloom_loop)
|
|
||||||
|
|
||||||
initialize_bloom_loop_end:
|
|
||||||
// stack: len, len, offset, retdest
|
|
||||||
%pop3
|
|
||||||
JUMP
|
|
||||||
|
|
||||||
%macro initialize_block_bloom
|
|
||||||
// stack: (empty)
|
|
||||||
PUSH %%after
|
|
||||||
%jump(initialize_block_bloom)
|
|
||||||
%%after:
|
|
||||||
%endmacro
|
|
||||||
|
|
||||||
check_metadata_block_bloom:
|
|
||||||
// stack: retdest
|
|
||||||
PUSH 0 PUSH 8 PUSH 0
|
|
||||||
|
|
||||||
check_bloom_loop:
|
|
||||||
// stack: i, len, offset, retdest
|
|
||||||
DUP2 DUP2 EQ %jumpi(check_bloom_loop_end)
|
|
||||||
PUSH 32 // Bloom word length
|
|
||||||
// stack: word_len, i, len, offset, retdest
|
|
||||||
DUP4 PUSH @SEGMENT_BLOCK_BLOOM PUSH 0
|
|
||||||
%mload_packing
|
|
||||||
// stack: bloom_word, i, len, offset, retdest
|
|
||||||
DUP2 %add_const(16) %mload_kernel(@SEGMENT_GLOBAL_BLOCK_BLOOM) %assert_eq
|
|
||||||
// stack: i, len, offset, retdest
|
|
||||||
%increment SWAP2 %add_const(32) SWAP2
|
|
||||||
// stack: i+1, len, new_offset, retdest
|
|
||||||
%jump(check_bloom_loop)
|
|
||||||
|
|
||||||
check_bloom_loop_end:
|
|
||||||
// stack: len, len, offset, retdest
|
|
||||||
%pop3
|
|
||||||
JUMP
|
|
||||||
|
|
||||||
%macro check_metadata_block_bloom
|
|
||||||
PUSH %%after
|
|
||||||
%jump(check_metadata_block_bloom)
|
|
||||||
%%after:
|
|
||||||
%endmacro
|
|
||||||
|
|||||||
@ -59,7 +59,6 @@ fn test_process_receipt() -> Result<()> {
|
|||||||
);
|
);
|
||||||
interpreter.set_txn_field(NormalizedTxnField::GasLimit, U256::from(5000));
|
interpreter.set_txn_field(NormalizedTxnField::GasLimit, U256::from(5000));
|
||||||
interpreter.set_memory_segment(Segment::TxnBloom, vec![0.into(); 256]);
|
interpreter.set_memory_segment(Segment::TxnBloom, vec![0.into(); 256]);
|
||||||
interpreter.set_memory_segment(Segment::BlockBloom, vec![0.into(); 256]);
|
|
||||||
interpreter.set_memory_segment(Segment::Logs, vec![0.into()]);
|
interpreter.set_memory_segment(Segment::Logs, vec![0.into()]);
|
||||||
interpreter.set_global_metadata_field(GlobalMetadata::LogsPayloadLen, 58.into());
|
interpreter.set_global_metadata_field(GlobalMetadata::LogsPayloadLen, 58.into());
|
||||||
interpreter.set_global_metadata_field(GlobalMetadata::LogsLen, U256::from(1));
|
interpreter.set_global_metadata_field(GlobalMetadata::LogsLen, U256::from(1));
|
||||||
@ -265,7 +264,6 @@ fn test_receipt_bloom_filter() -> Result<()> {
|
|||||||
logs.extend(cur_data);
|
logs.extend(cur_data);
|
||||||
// The Bloom filter initialization is required for this test to ensure we have the correct length for the filters. Otherwise, some trailing zeroes could be missing.
|
// The Bloom filter initialization is required for this test to ensure we have the correct length for the filters. Otherwise, some trailing zeroes could be missing.
|
||||||
interpreter.set_memory_segment(Segment::TxnBloom, vec![0.into(); 256]); // Initialize transaction Bloom filter.
|
interpreter.set_memory_segment(Segment::TxnBloom, vec![0.into(); 256]); // Initialize transaction Bloom filter.
|
||||||
interpreter.set_memory_segment(Segment::BlockBloom, vec![0.into(); 256]); // Initialize block Bloom filter.
|
|
||||||
interpreter.set_memory_segment(Segment::LogsData, logs);
|
interpreter.set_memory_segment(Segment::LogsData, logs);
|
||||||
interpreter.set_memory_segment(Segment::Logs, vec![0.into()]);
|
interpreter.set_memory_segment(Segment::Logs, vec![0.into()]);
|
||||||
interpreter.set_global_metadata_field(GlobalMetadata::LogsLen, U256::from(1));
|
interpreter.set_global_metadata_field(GlobalMetadata::LogsLen, U256::from(1));
|
||||||
@ -327,15 +325,6 @@ fn test_receipt_bloom_filter() -> Result<()> {
|
|||||||
|
|
||||||
assert_eq!(second_bloom_bytes, second_loaded_bloom);
|
assert_eq!(second_bloom_bytes, second_loaded_bloom);
|
||||||
|
|
||||||
// Check the final block Bloom.
|
|
||||||
let block_bloom = hex!("00000000000000000000000000000000000000000000000000800000000000000040000000005000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000008000000000000000000000000000000000000000001000000080008000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000500000000000000000000000000000002000040000000000000000000000000000000000000000000000008000000000000000000000100000000000000000000000000020000000000008000000000000000000000000").to_vec();
|
|
||||||
let loaded_block_bloom: Vec<u8> = interpreter
|
|
||||||
.get_memory_segment(Segment::BlockBloom)
|
|
||||||
.into_iter()
|
|
||||||
.map(|elt| elt.0[0] as u8)
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
assert_eq!(block_bloom, loaded_block_bloom);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,7 +559,6 @@ fn test_bloom_two_logs() -> Result<()> {
|
|||||||
];
|
];
|
||||||
let mut interpreter = Interpreter::new_with_kernel(logs_bloom, initial_stack);
|
let mut interpreter = Interpreter::new_with_kernel(logs_bloom, initial_stack);
|
||||||
interpreter.set_memory_segment(Segment::TxnBloom, vec![0.into(); 256]); // Initialize transaction Bloom filter.
|
interpreter.set_memory_segment(Segment::TxnBloom, vec![0.into(); 256]); // Initialize transaction Bloom filter.
|
||||||
interpreter.set_memory_segment(Segment::BlockBloom, vec![0.into(); 256]); // Initialize block Bloom filter.
|
|
||||||
interpreter.set_memory_segment(Segment::LogsData, logs);
|
interpreter.set_memory_segment(Segment::LogsData, logs);
|
||||||
interpreter.set_memory_segment(Segment::Logs, vec![0.into(), 4.into()]);
|
interpreter.set_memory_segment(Segment::Logs, vec![0.into(), 4.into()]);
|
||||||
interpreter.set_global_metadata_field(GlobalMetadata::LogsLen, U256::from(2));
|
interpreter.set_global_metadata_field(GlobalMetadata::LogsLen, U256::from(2));
|
||||||
|
|||||||
@ -744,19 +744,6 @@ where
|
|||||||
|
|
||||||
// Connect lhs `gas_used_after` with rhs `gas_used_before`.
|
// Connect lhs `gas_used_after` with rhs `gas_used_before`.
|
||||||
builder.connect(lhs.gas_used_after, rhs.gas_used_before);
|
builder.connect(lhs.gas_used_after, rhs.gas_used_before);
|
||||||
|
|
||||||
// Connect the `block_bloom` in public values to the lhs and rhs values correctly.
|
|
||||||
for (&limb0, &limb1) in pvs.block_bloom_after.iter().zip(&rhs.block_bloom_after) {
|
|
||||||
builder.connect(limb0, limb1);
|
|
||||||
}
|
|
||||||
for (&limb0, &limb1) in pvs.block_bloom_before.iter().zip(&lhs.block_bloom_before) {
|
|
||||||
builder.connect(limb0, limb1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Connect lhs `block_bloom_after` with rhs `block_bloom_before`.
|
|
||||||
for (&limb0, &limb1) in lhs.block_bloom_after.iter().zip(&rhs.block_bloom_before) {
|
|
||||||
builder.connect(limb0, limb1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_agg_child(
|
fn add_agg_child(
|
||||||
@ -928,15 +915,6 @@ where
|
|||||||
x.block_metadata.block_gas_used,
|
x.block_metadata.block_gas_used,
|
||||||
x.extra_block_data.gas_used_after,
|
x.extra_block_data.gas_used_after,
|
||||||
);
|
);
|
||||||
|
|
||||||
for (&limb0, &limb1) in x
|
|
||||||
.block_metadata
|
|
||||||
.block_bloom
|
|
||||||
.iter()
|
|
||||||
.zip(&x.extra_block_data.block_bloom_after)
|
|
||||||
{
|
|
||||||
builder.connect(limb0, limb1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn connect_initial_values_block(builder: &mut CircuitBuilder<F, D>, x: &PublicValuesTarget)
|
fn connect_initial_values_block(builder: &mut CircuitBuilder<F, D>, x: &PublicValuesTarget)
|
||||||
@ -948,11 +926,6 @@ where
|
|||||||
// The initial gas used is 0.
|
// The initial gas used is 0.
|
||||||
builder.assert_zero(x.extra_block_data.gas_used_before);
|
builder.assert_zero(x.extra_block_data.gas_used_before);
|
||||||
|
|
||||||
// The initial bloom filter is all zeroes.
|
|
||||||
for t in x.extra_block_data.block_bloom_before {
|
|
||||||
builder.assert_zero(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The transactions and receipts tries are empty at the beginning of the block.
|
// The transactions and receipts tries are empty at the beginning of the block.
|
||||||
let initial_trie = HashedPartialTrie::from(Node::Empty).hash();
|
let initial_trie = HashedPartialTrie::from(Node::Empty).hash();
|
||||||
|
|
||||||
@ -1058,8 +1031,6 @@ where
|
|||||||
txn_number_after: rhs_public_values.extra_block_data.txn_number_after,
|
txn_number_after: rhs_public_values.extra_block_data.txn_number_after,
|
||||||
gas_used_before: lhs_public_values.extra_block_data.gas_used_before,
|
gas_used_before: lhs_public_values.extra_block_data.gas_used_before,
|
||||||
gas_used_after: rhs_public_values.extra_block_data.gas_used_after,
|
gas_used_after: rhs_public_values.extra_block_data.gas_used_after,
|
||||||
block_bloom_before: lhs_public_values.extra_block_data.block_bloom_before,
|
|
||||||
block_bloom_after: rhs_public_values.extra_block_data.block_bloom_after,
|
|
||||||
},
|
},
|
||||||
block_metadata: rhs_public_values.block_metadata,
|
block_metadata: rhs_public_values.block_metadata,
|
||||||
block_hashes: rhs_public_values.block_hashes,
|
block_hashes: rhs_public_values.block_hashes,
|
||||||
|
|||||||
@ -42,9 +42,7 @@ use crate::witness::util::mem_write_log;
|
|||||||
pub struct GenerationInputs {
|
pub struct GenerationInputs {
|
||||||
pub txn_number_before: U256,
|
pub txn_number_before: U256,
|
||||||
pub gas_used_before: U256,
|
pub gas_used_before: U256,
|
||||||
pub block_bloom_before: [U256; 8],
|
|
||||||
pub gas_used_after: U256,
|
pub gas_used_after: U256,
|
||||||
pub block_bloom_after: [U256; 8],
|
|
||||||
|
|
||||||
// A None would yield an empty proof, otherwise this contains the encoding of a transaction.
|
// A None would yield an empty proof, otherwise this contains the encoding of a transaction.
|
||||||
pub signed_txn: Option<Vec<u8>>,
|
pub signed_txn: Option<Vec<u8>>,
|
||||||
@ -174,32 +172,7 @@ fn apply_metadata_and_tries_memops<F: RichField + Extendable<D>, const D: usize>
|
|||||||
metadata.block_bloom[i],
|
metadata.block_bloom[i],
|
||||||
)
|
)
|
||||||
}));
|
}));
|
||||||
// Write the block's bloom filter before the current transaction.
|
|
||||||
ops.extend(
|
|
||||||
(0..8)
|
|
||||||
.map(|i| {
|
|
||||||
mem_write_log(
|
|
||||||
channel,
|
|
||||||
MemoryAddress::new(0, Segment::GlobalBlockBloom, i + 8),
|
|
||||||
state,
|
|
||||||
inputs.block_bloom_before[i],
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
);
|
|
||||||
// Write the block's bloom filter after the current transaction.
|
|
||||||
ops.extend(
|
|
||||||
(0..8)
|
|
||||||
.map(|i| {
|
|
||||||
mem_write_log(
|
|
||||||
channel,
|
|
||||||
MemoryAddress::new(0, Segment::GlobalBlockBloom, i + 16),
|
|
||||||
state,
|
|
||||||
inputs.block_bloom_after[i],
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
);
|
|
||||||
// Write previous block hashes.
|
// Write previous block hashes.
|
||||||
ops.extend(
|
ops.extend(
|
||||||
(0..256)
|
(0..256)
|
||||||
@ -284,8 +257,6 @@ pub fn generate_traces<F: RichField + Extendable<D>, const D: usize>(
|
|||||||
txn_number_after,
|
txn_number_after,
|
||||||
gas_used_before: inputs.gas_used_before,
|
gas_used_before: inputs.gas_used_before,
|
||||||
gas_used_after,
|
gas_used_after,
|
||||||
block_bloom_before: inputs.block_bloom_before,
|
|
||||||
block_bloom_after: inputs.block_bloom_after,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let public_values = PublicValues {
|
let public_values = PublicValues {
|
||||||
|
|||||||
@ -109,12 +109,6 @@ fn observe_extra_block_data<
|
|||||||
challenger.observe_element(u256_to_u32(extra_data.txn_number_after)?);
|
challenger.observe_element(u256_to_u32(extra_data.txn_number_after)?);
|
||||||
challenger.observe_element(u256_to_u32(extra_data.gas_used_before)?);
|
challenger.observe_element(u256_to_u32(extra_data.gas_used_before)?);
|
||||||
challenger.observe_element(u256_to_u32(extra_data.gas_used_after)?);
|
challenger.observe_element(u256_to_u32(extra_data.gas_used_after)?);
|
||||||
for i in 0..8 {
|
|
||||||
challenger.observe_elements(&u256_limbs(extra_data.block_bloom_before[i]));
|
|
||||||
}
|
|
||||||
for i in 0..8 {
|
|
||||||
challenger.observe_elements(&u256_limbs(extra_data.block_bloom_after[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -134,8 +128,6 @@ fn observe_extra_block_data_target<
|
|||||||
challenger.observe_element(extra_data.txn_number_after);
|
challenger.observe_element(extra_data.txn_number_after);
|
||||||
challenger.observe_element(extra_data.gas_used_before);
|
challenger.observe_element(extra_data.gas_used_before);
|
||||||
challenger.observe_element(extra_data.gas_used_after);
|
challenger.observe_element(extra_data.gas_used_after);
|
||||||
challenger.observe_elements(&extra_data.block_bloom_before);
|
|
||||||
challenger.observe_elements(&extra_data.block_bloom_after);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn observe_block_hashes<
|
fn observe_block_hashes<
|
||||||
|
|||||||
@ -50,29 +50,25 @@ pub(crate) enum Segment {
|
|||||||
SelfDestructList = 25,
|
SelfDestructList = 25,
|
||||||
/// Contains the bloom filter of a transaction.
|
/// Contains the bloom filter of a transaction.
|
||||||
TxnBloom = 26,
|
TxnBloom = 26,
|
||||||
/// Contains the computed bloom filter of a block.
|
/// Contains the bloom filter present in the block header.
|
||||||
BlockBloom = 27,
|
GlobalBlockBloom = 27,
|
||||||
/// Contains the final block bloom, and the block bloom filters before and after the current transaction.
|
|
||||||
/// The first eight elements are `block_metadata.block_bloom`. The next eight are `block_bloom_before`,
|
|
||||||
/// and the last eight are `block_bloom_after.
|
|
||||||
GlobalBlockBloom = 28,
|
|
||||||
/// List of log pointers pointing to the LogsData segment.
|
/// List of log pointers pointing to the LogsData segment.
|
||||||
Logs = 29,
|
Logs = 28,
|
||||||
LogsData = 30,
|
LogsData = 29,
|
||||||
/// Journal of state changes. List of pointers to `JournalData`. Length in `GlobalMetadata`.
|
/// Journal of state changes. List of pointers to `JournalData`. Length in `GlobalMetadata`.
|
||||||
Journal = 31,
|
Journal = 30,
|
||||||
JournalData = 32,
|
JournalData = 31,
|
||||||
JournalCheckpoints = 33,
|
JournalCheckpoints = 32,
|
||||||
/// List of addresses that have been touched in the current transaction.
|
/// List of addresses that have been touched in the current transaction.
|
||||||
TouchedAddresses = 34,
|
TouchedAddresses = 33,
|
||||||
/// List of checkpoints for the current context. Length in `ContextMetadata`.
|
/// List of checkpoints for the current context. Length in `ContextMetadata`.
|
||||||
ContextCheckpoints = 35,
|
ContextCheckpoints = 34,
|
||||||
/// List of 256 previous block hashes.
|
/// List of 256 previous block hashes.
|
||||||
BlockHashes = 36,
|
BlockHashes = 35,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Segment {
|
impl Segment {
|
||||||
pub(crate) const COUNT: usize = 37;
|
pub(crate) const COUNT: usize = 36;
|
||||||
|
|
||||||
pub(crate) fn all() -> [Self; Self::COUNT] {
|
pub(crate) fn all() -> [Self; Self::COUNT] {
|
||||||
[
|
[
|
||||||
@ -103,7 +99,6 @@ impl Segment {
|
|||||||
Self::AccessedStorageKeys,
|
Self::AccessedStorageKeys,
|
||||||
Self::SelfDestructList,
|
Self::SelfDestructList,
|
||||||
Self::TxnBloom,
|
Self::TxnBloom,
|
||||||
Self::BlockBloom,
|
|
||||||
Self::GlobalBlockBloom,
|
Self::GlobalBlockBloom,
|
||||||
Self::Logs,
|
Self::Logs,
|
||||||
Self::LogsData,
|
Self::LogsData,
|
||||||
@ -146,7 +141,6 @@ impl Segment {
|
|||||||
Segment::AccessedStorageKeys => "SEGMENT_ACCESSED_STORAGE_KEYS",
|
Segment::AccessedStorageKeys => "SEGMENT_ACCESSED_STORAGE_KEYS",
|
||||||
Segment::SelfDestructList => "SEGMENT_SELFDESTRUCT_LIST",
|
Segment::SelfDestructList => "SEGMENT_SELFDESTRUCT_LIST",
|
||||||
Segment::TxnBloom => "SEGMENT_TXN_BLOOM",
|
Segment::TxnBloom => "SEGMENT_TXN_BLOOM",
|
||||||
Segment::BlockBloom => "SEGMENT_BLOCK_BLOOM",
|
|
||||||
Segment::GlobalBlockBloom => "SEGMENT_GLOBAL_BLOCK_BLOOM",
|
Segment::GlobalBlockBloom => "SEGMENT_GLOBAL_BLOCK_BLOOM",
|
||||||
Segment::Logs => "SEGMENT_LOGS",
|
Segment::Logs => "SEGMENT_LOGS",
|
||||||
Segment::LogsData => "SEGMENT_LOGS_DATA",
|
Segment::LogsData => "SEGMENT_LOGS_DATA",
|
||||||
@ -189,7 +183,6 @@ impl Segment {
|
|||||||
Segment::SelfDestructList => 256,
|
Segment::SelfDestructList => 256,
|
||||||
Segment::TxnBloom => 8,
|
Segment::TxnBloom => 8,
|
||||||
Segment::GlobalBlockBloom => 256,
|
Segment::GlobalBlockBloom => 256,
|
||||||
Segment::BlockBloom => 8,
|
|
||||||
Segment::Logs => 256,
|
Segment::Logs => 256,
|
||||||
Segment::LogsData => 256,
|
Segment::LogsData => 256,
|
||||||
Segment::Journal => 256,
|
Segment::Journal => 256,
|
||||||
|
|||||||
@ -140,12 +140,6 @@ pub struct ExtraBlockData {
|
|||||||
/// The accumulated gas used after execution of the local state transition. It should
|
/// The accumulated gas used after execution of the local state transition. It should
|
||||||
/// match the `block_gas_used` value after execution of the last transaction in a block.
|
/// match the `block_gas_used` value after execution of the last transaction in a block.
|
||||||
pub gas_used_after: U256,
|
pub gas_used_after: U256,
|
||||||
/// The accumulated bloom filter of this block prior execution of the local state transition,
|
|
||||||
/// starting with all zeros for the initial transaction of a block.
|
|
||||||
pub block_bloom_before: [U256; 8],
|
|
||||||
/// The accumulated bloom filter after execution of the local state transition. It should
|
|
||||||
/// match the `block_bloom` value after execution of the last transaction in a block.
|
|
||||||
pub block_bloom_after: [U256; 8],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Memory values which are public.
|
/// Memory values which are public.
|
||||||
@ -224,16 +218,12 @@ impl PublicValuesTarget {
|
|||||||
txn_number_after,
|
txn_number_after,
|
||||||
gas_used_before,
|
gas_used_before,
|
||||||
gas_used_after,
|
gas_used_after,
|
||||||
block_bloom_before,
|
|
||||||
block_bloom_after,
|
|
||||||
} = self.extra_block_data;
|
} = self.extra_block_data;
|
||||||
buffer.write_target_array(&genesis_state_root)?;
|
buffer.write_target_array(&genesis_state_root)?;
|
||||||
buffer.write_target(txn_number_before)?;
|
buffer.write_target(txn_number_before)?;
|
||||||
buffer.write_target(txn_number_after)?;
|
buffer.write_target(txn_number_after)?;
|
||||||
buffer.write_target(gas_used_before)?;
|
buffer.write_target(gas_used_before)?;
|
||||||
buffer.write_target(gas_used_after)?;
|
buffer.write_target(gas_used_after)?;
|
||||||
buffer.write_target_array(&block_bloom_before)?;
|
|
||||||
buffer.write_target_array(&block_bloom_after)?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -276,8 +266,6 @@ impl PublicValuesTarget {
|
|||||||
txn_number_after: buffer.read_target()?,
|
txn_number_after: buffer.read_target()?,
|
||||||
gas_used_before: buffer.read_target()?,
|
gas_used_before: buffer.read_target()?,
|
||||||
gas_used_after: buffer.read_target()?,
|
gas_used_after: buffer.read_target()?,
|
||||||
block_bloom_before: buffer.read_target_array()?,
|
|
||||||
block_bloom_after: buffer.read_target_array()?,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
@ -642,17 +630,11 @@ pub(crate) struct ExtraBlockDataTarget {
|
|||||||
/// `Target` for the accumulated gas used after execution of the local state transition. It should
|
/// `Target` for the accumulated gas used after execution of the local state transition. It should
|
||||||
/// match the `block_gas_used` value after execution of the last transaction in a block.
|
/// match the `block_gas_used` value after execution of the last transaction in a block.
|
||||||
pub gas_used_after: Target,
|
pub gas_used_after: Target,
|
||||||
/// `Target`s for the accumulated bloom filter of this block prior execution of the local state transition,
|
|
||||||
/// starting with all zeros for the initial transaction of a block.
|
|
||||||
pub block_bloom_before: [Target; 64],
|
|
||||||
/// `Target`s for the accumulated bloom filter after execution of the local state transition. It should
|
|
||||||
/// match the `block_bloom` value after execution of the last transaction in a block.
|
|
||||||
pub block_bloom_after: [Target; 64],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExtraBlockDataTarget {
|
impl ExtraBlockDataTarget {
|
||||||
/// Number of `Target`s required for the extra block data.
|
/// Number of `Target`s required for the extra block data.
|
||||||
const SIZE: usize = 140;
|
const SIZE: usize = 12;
|
||||||
|
|
||||||
/// Extracts the extra block data `Target`s from the public input `Target`s.
|
/// Extracts the extra block data `Target`s from the public input `Target`s.
|
||||||
/// The provided `pis` should start with the extra vblock data.
|
/// The provided `pis` should start with the extra vblock data.
|
||||||
@ -662,8 +644,6 @@ impl ExtraBlockDataTarget {
|
|||||||
let txn_number_after = pis[9];
|
let txn_number_after = pis[9];
|
||||||
let gas_used_before = pis[10];
|
let gas_used_before = pis[10];
|
||||||
let gas_used_after = pis[11];
|
let gas_used_after = pis[11];
|
||||||
let block_bloom_before = pis[12..76].try_into().unwrap();
|
|
||||||
let block_bloom_after = pis[76..140].try_into().unwrap();
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
genesis_state_trie_root,
|
genesis_state_trie_root,
|
||||||
@ -671,8 +651,6 @@ impl ExtraBlockDataTarget {
|
|||||||
txn_number_after,
|
txn_number_after,
|
||||||
gas_used_before,
|
gas_used_before,
|
||||||
gas_used_after,
|
gas_used_after,
|
||||||
block_bloom_before,
|
|
||||||
block_bloom_after,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -700,20 +678,6 @@ impl ExtraBlockDataTarget {
|
|||||||
txn_number_after: builder.select(condition, ed0.txn_number_after, ed1.txn_number_after),
|
txn_number_after: builder.select(condition, ed0.txn_number_after, ed1.txn_number_after),
|
||||||
gas_used_before: builder.select(condition, ed0.gas_used_before, ed1.gas_used_before),
|
gas_used_before: builder.select(condition, ed0.gas_used_before, ed1.gas_used_before),
|
||||||
gas_used_after: builder.select(condition, ed0.gas_used_after, ed1.gas_used_after),
|
gas_used_after: builder.select(condition, ed0.gas_used_after, ed1.gas_used_after),
|
||||||
block_bloom_before: core::array::from_fn(|i| {
|
|
||||||
builder.select(
|
|
||||||
condition,
|
|
||||||
ed0.block_bloom_before[i],
|
|
||||||
ed1.block_bloom_before[i],
|
|
||||||
)
|
|
||||||
}),
|
|
||||||
block_bloom_after: core::array::from_fn(|i| {
|
|
||||||
builder.select(
|
|
||||||
condition,
|
|
||||||
ed0.block_bloom_after[i],
|
|
||||||
ed1.block_bloom_after[i],
|
|
||||||
)
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -733,12 +697,6 @@ impl ExtraBlockDataTarget {
|
|||||||
builder.connect(ed0.txn_number_after, ed1.txn_number_after);
|
builder.connect(ed0.txn_number_after, ed1.txn_number_after);
|
||||||
builder.connect(ed0.gas_used_before, ed1.gas_used_before);
|
builder.connect(ed0.gas_used_before, ed1.gas_used_before);
|
||||||
builder.connect(ed1.gas_used_after, ed1.gas_used_after);
|
builder.connect(ed1.gas_used_after, ed1.gas_used_after);
|
||||||
for i in 0..64 {
|
|
||||||
builder.connect(ed0.block_bloom_before[i], ed1.block_bloom_before[i]);
|
|
||||||
}
|
|
||||||
for i in 0..64 {
|
|
||||||
builder.connect(ed0.block_bloom_after[i], ed1.block_bloom_after[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -543,27 +543,6 @@ pub(crate) fn get_memory_extra_looking_products_circuit<
|
|||||||
&public_values.block_metadata.block_bloom[i * 8..(i + 1) * 8],
|
&public_values.block_metadata.block_bloom[i * 8..(i + 1) * 8],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for i in 0..8 {
|
|
||||||
product = add_data_write(
|
|
||||||
builder,
|
|
||||||
challenge,
|
|
||||||
product,
|
|
||||||
bloom_segment,
|
|
||||||
i + 8,
|
|
||||||
&public_values.extra_block_data.block_bloom_before[i * 8..(i + 1) * 8],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for i in 0..8 {
|
|
||||||
product = add_data_write(
|
|
||||||
builder,
|
|
||||||
challenge,
|
|
||||||
product,
|
|
||||||
bloom_segment,
|
|
||||||
i + 16,
|
|
||||||
&public_values.extra_block_data.block_bloom_after[i * 8..(i + 1) * 8],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add trie roots writes.
|
// Add trie roots writes.
|
||||||
let trie_fields = [
|
let trie_fields = [
|
||||||
@ -761,16 +740,12 @@ pub(crate) fn add_virtual_extra_block_data<F: RichField + Extendable<D>, const D
|
|||||||
let txn_number_after = builder.add_virtual_public_input();
|
let txn_number_after = builder.add_virtual_public_input();
|
||||||
let gas_used_before = builder.add_virtual_public_input();
|
let gas_used_before = builder.add_virtual_public_input();
|
||||||
let gas_used_after = builder.add_virtual_public_input();
|
let gas_used_after = builder.add_virtual_public_input();
|
||||||
let block_bloom_before: [Target; 64] = builder.add_virtual_public_input_arr();
|
|
||||||
let block_bloom_after: [Target; 64] = builder.add_virtual_public_input_arr();
|
|
||||||
ExtraBlockDataTarget {
|
ExtraBlockDataTarget {
|
||||||
genesis_state_trie_root,
|
genesis_state_trie_root,
|
||||||
txn_number_before,
|
txn_number_before,
|
||||||
txn_number_after,
|
txn_number_after,
|
||||||
gas_used_before,
|
gas_used_before,
|
||||||
gas_used_after,
|
gas_used_after,
|
||||||
block_bloom_before,
|
|
||||||
block_bloom_after,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1041,21 +1016,5 @@ where
|
|||||||
witness.set_target(ed_target.gas_used_before, u256_to_u32(ed.gas_used_before)?);
|
witness.set_target(ed_target.gas_used_before, u256_to_u32(ed.gas_used_before)?);
|
||||||
witness.set_target(ed_target.gas_used_after, u256_to_u32(ed.gas_used_after)?);
|
witness.set_target(ed_target.gas_used_after, u256_to_u32(ed.gas_used_after)?);
|
||||||
|
|
||||||
let block_bloom_before = ed.block_bloom_before;
|
|
||||||
let mut block_bloom_limbs = [F::ZERO; 64];
|
|
||||||
for (i, limbs) in block_bloom_limbs.chunks_exact_mut(8).enumerate() {
|
|
||||||
limbs.copy_from_slice(&u256_limbs(block_bloom_before[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
witness.set_target_arr(&ed_target.block_bloom_before, &block_bloom_limbs);
|
|
||||||
|
|
||||||
let block_bloom_after = ed.block_bloom_after;
|
|
||||||
let mut block_bloom_limbs = [F::ZERO; 64];
|
|
||||||
for (i, limbs) in block_bloom_limbs.chunks_exact_mut(8).enumerate() {
|
|
||||||
limbs.copy_from_slice(&u256_limbs(block_bloom_after[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
witness.set_target_arr(&ed_target.block_bloom_after, &block_bloom_limbs);
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -250,15 +250,6 @@ where
|
|||||||
prod = add_data_write(challenge, bloom_segment, prod, index, val);
|
prod = add_data_write(challenge, bloom_segment, prod, index, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
for index in 0..8 {
|
|
||||||
let val = public_values.extra_block_data.block_bloom_before[index];
|
|
||||||
prod = add_data_write(challenge, bloom_segment, prod, index + 8, val);
|
|
||||||
}
|
|
||||||
for index in 0..8 {
|
|
||||||
let val = public_values.extra_block_data.block_bloom_after[index];
|
|
||||||
prod = add_data_write(challenge, bloom_segment, prod, index + 16, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add Blockhashes writes.
|
// Add Blockhashes writes.
|
||||||
let block_hashes_segment = F::from_canonical_u32(Segment::BlockHashes as u32);
|
let block_hashes_segment = F::from_canonical_u32(Segment::BlockHashes as u32);
|
||||||
for index in 0..256 {
|
for index in 0..256 {
|
||||||
@ -570,15 +561,6 @@ pub(crate) mod testutils {
|
|||||||
extra_looking_rows.push(add_extra_looking_row(bloom_segment, index, val));
|
extra_looking_rows.push(add_extra_looking_row(bloom_segment, index, val));
|
||||||
}
|
}
|
||||||
|
|
||||||
for index in 0..8 {
|
|
||||||
let val = public_values.extra_block_data.block_bloom_before[index];
|
|
||||||
extra_looking_rows.push(add_extra_looking_row(bloom_segment, index + 8, val));
|
|
||||||
}
|
|
||||||
for index in 0..8 {
|
|
||||||
let val = public_values.extra_block_data.block_bloom_after[index];
|
|
||||||
extra_looking_rows.push(add_extra_looking_row(bloom_segment, index + 16, val));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add Blockhashes writes.
|
// Add Blockhashes writes.
|
||||||
let block_hashes_segment = F::from_canonical_u32(Segment::BlockHashes as u32);
|
let block_hashes_segment = F::from_canonical_u32(Segment::BlockHashes as u32);
|
||||||
for index in 0..256 {
|
for index in 0..256 {
|
||||||
|
|||||||
@ -161,8 +161,6 @@ fn add11_yml() -> anyhow::Result<()> {
|
|||||||
txn_number_before: 0.into(),
|
txn_number_before: 0.into(),
|
||||||
gas_used_before: 0.into(),
|
gas_used_before: 0.into(),
|
||||||
gas_used_after: 0xa868u64.into(),
|
gas_used_after: 0xa868u64.into(),
|
||||||
block_bloom_before: [0.into(); 8],
|
|
||||||
block_bloom_after: [0.into(); 8],
|
|
||||||
block_hashes: BlockHashes {
|
block_hashes: BlockHashes {
|
||||||
prev_hashes: vec![H256::default(); 256],
|
prev_hashes: vec![H256::default(); 256],
|
||||||
cur_hash: H256::default(),
|
cur_hash: H256::default(),
|
||||||
|
|||||||
@ -193,8 +193,6 @@ fn test_basic_smart_contract() -> anyhow::Result<()> {
|
|||||||
txn_number_before: 0.into(),
|
txn_number_before: 0.into(),
|
||||||
gas_used_before: 0.into(),
|
gas_used_before: 0.into(),
|
||||||
gas_used_after: gas_used.into(),
|
gas_used_after: gas_used.into(),
|
||||||
block_bloom_before: [0.into(); 8],
|
|
||||||
block_bloom_after: [0.into(); 8],
|
|
||||||
block_hashes: BlockHashes {
|
block_hashes: BlockHashes {
|
||||||
prev_hashes: vec![H256::default(); 256],
|
prev_hashes: vec![H256::default(); 256],
|
||||||
cur_hash: H256::default(),
|
cur_hash: H256::default(),
|
||||||
|
|||||||
@ -68,8 +68,6 @@ fn test_empty_txn_list() -> anyhow::Result<()> {
|
|||||||
txn_number_before: 0.into(),
|
txn_number_before: 0.into(),
|
||||||
gas_used_before: 0.into(),
|
gas_used_before: 0.into(),
|
||||||
gas_used_after: 0.into(),
|
gas_used_after: 0.into(),
|
||||||
block_bloom_before: [0.into(); 8],
|
|
||||||
block_bloom_after: [0.into(); 8],
|
|
||||||
block_hashes: BlockHashes {
|
block_hashes: BlockHashes {
|
||||||
prev_hashes: initial_block_hashes,
|
prev_hashes: initial_block_hashes,
|
||||||
cur_hash: H256::default(),
|
cur_hash: H256::default(),
|
||||||
|
|||||||
@ -169,8 +169,6 @@ fn test_erc20() -> anyhow::Result<()> {
|
|||||||
txn_number_before: 0.into(),
|
txn_number_before: 0.into(),
|
||||||
gas_used_before: 0.into(),
|
gas_used_before: 0.into(),
|
||||||
gas_used_after: gas_used,
|
gas_used_after: gas_used,
|
||||||
block_bloom_before: [0.into(); 8],
|
|
||||||
block_bloom_after: bloom,
|
|
||||||
block_hashes: BlockHashes {
|
block_hashes: BlockHashes {
|
||||||
prev_hashes: vec![H256::default(); 256],
|
prev_hashes: vec![H256::default(); 256],
|
||||||
cur_hash: H256::default(),
|
cur_hash: H256::default(),
|
||||||
|
|||||||
@ -214,20 +214,7 @@ fn test_log_opcodes() -> anyhow::Result<()> {
|
|||||||
transactions_root: transactions_trie.hash(),
|
transactions_root: transactions_trie.hash(),
|
||||||
receipts_root: receipts_trie.hash(),
|
receipts_root: receipts_trie.hash(),
|
||||||
};
|
};
|
||||||
let block_bloom_after = [
|
|
||||||
U256::from_dec_str("392318858461667547739736838950479151006397215279002157056").unwrap(),
|
|
||||||
0.into(),
|
|
||||||
U256::from_dec_str(
|
|
||||||
"55213970774324510299478046898216203619608871777363092441300193790394368",
|
|
||||||
)
|
|
||||||
.unwrap(),
|
|
||||||
U256::from_dec_str("1361129467683753853853498429727072845824").unwrap(),
|
|
||||||
U256::from_dec_str("33554432").unwrap(),
|
|
||||||
U256::from_dec_str("98079714615416886934934209737619787760822675856605315072").unwrap(),
|
|
||||||
U256::from_dec_str("262144").unwrap(),
|
|
||||||
U256::from_dec_str("6739986666787659948666753771754908317446393422488596686587943714816")
|
|
||||||
.unwrap(),
|
|
||||||
];
|
|
||||||
let inputs = GenerationInputs {
|
let inputs = GenerationInputs {
|
||||||
signed_txn: Some(txn.to_vec()),
|
signed_txn: Some(txn.to_vec()),
|
||||||
withdrawals: vec![],
|
withdrawals: vec![],
|
||||||
@ -239,8 +226,6 @@ fn test_log_opcodes() -> anyhow::Result<()> {
|
|||||||
txn_number_before: 0.into(),
|
txn_number_before: 0.into(),
|
||||||
gas_used_before: 0.into(),
|
gas_used_before: 0.into(),
|
||||||
gas_used_after: gas_used.into(),
|
gas_used_after: gas_used.into(),
|
||||||
block_bloom_before: [0.into(); 8],
|
|
||||||
block_bloom_after,
|
|
||||||
|
|
||||||
block_hashes: BlockHashes {
|
block_hashes: BlockHashes {
|
||||||
prev_hashes: vec![H256::default(); 256],
|
prev_hashes: vec![H256::default(); 256],
|
||||||
@ -447,8 +432,6 @@ fn test_log_with_aggreg() -> anyhow::Result<()> {
|
|||||||
txn_number_before: 0.into(),
|
txn_number_before: 0.into(),
|
||||||
gas_used_before: 0.into(),
|
gas_used_before: 0.into(),
|
||||||
gas_used_after: 21000u64.into(),
|
gas_used_after: 21000u64.into(),
|
||||||
block_bloom_before: [0.into(); 8],
|
|
||||||
block_bloom_after: [0.into(); 8],
|
|
||||||
block_hashes: BlockHashes {
|
block_hashes: BlockHashes {
|
||||||
prev_hashes: vec![H256::default(); 256],
|
prev_hashes: vec![H256::default(); 256],
|
||||||
cur_hash: H256::default(),
|
cur_hash: H256::default(),
|
||||||
@ -459,7 +442,7 @@ fn test_log_with_aggreg() -> anyhow::Result<()> {
|
|||||||
// Preprocess all circuits.
|
// Preprocess all circuits.
|
||||||
let all_circuits = AllRecursiveCircuits::<F, C, D>::new(
|
let all_circuits = AllRecursiveCircuits::<F, C, D>::new(
|
||||||
&all_stark,
|
&all_stark,
|
||||||
&[16..17, 15..16, 17..18, 14..15, 10..11, 12..13, 19..20],
|
&[16..17, 14..16, 16..18, 14..15, 10..11, 12..13, 19..20],
|
||||||
&config,
|
&config,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -470,8 +453,7 @@ fn test_log_with_aggreg() -> anyhow::Result<()> {
|
|||||||
timing.filter(Duration::from_millis(100)).print();
|
timing.filter(Duration::from_millis(100)).print();
|
||||||
all_circuits.verify_root(root_proof_first.clone())?;
|
all_circuits.verify_root(root_proof_first.clone())?;
|
||||||
|
|
||||||
// The output bloom filter, gas used and transaction number are fed to the next transaction, so the two proofs can be correctly aggregated.
|
// The gas used and transaction number are fed to the next transaction, so the two proofs can be correctly aggregated.
|
||||||
let block_bloom_second = public_values_first.extra_block_data.block_bloom_after;
|
|
||||||
let gas_used_second = public_values_first.extra_block_data.gas_used_after;
|
let gas_used_second = public_values_first.extra_block_data.gas_used_after;
|
||||||
|
|
||||||
// Prove second transaction. In this second transaction, the code with logs is executed.
|
// Prove second transaction. In this second transaction, the code with logs is executed.
|
||||||
@ -565,22 +547,6 @@ fn test_log_with_aggreg() -> anyhow::Result<()> {
|
|||||||
receipts_root: receipts_trie.hash(),
|
receipts_root: receipts_trie.hash(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let block_bloom_final = [
|
|
||||||
0.into(),
|
|
||||||
0.into(),
|
|
||||||
U256::from_dec_str(
|
|
||||||
"55213970774324510299479508399853534522527075462195808724319849722937344",
|
|
||||||
)
|
|
||||||
.unwrap(),
|
|
||||||
U256::from_dec_str("1361129467683753853853498429727072845824").unwrap(),
|
|
||||||
U256::from_dec_str("33554432").unwrap(),
|
|
||||||
U256::from_dec_str("9223372036854775808").unwrap(),
|
|
||||||
U256::from_dec_str(
|
|
||||||
"3618502788666131106986593281521497120414687020801267626233049500247285563392",
|
|
||||||
)
|
|
||||||
.unwrap(),
|
|
||||||
U256::from_dec_str("2722259584404615024560450425766186844160").unwrap(),
|
|
||||||
];
|
|
||||||
let inputs = GenerationInputs {
|
let inputs = GenerationInputs {
|
||||||
signed_txn: Some(txn_2.to_vec()),
|
signed_txn: Some(txn_2.to_vec()),
|
||||||
withdrawals: vec![],
|
withdrawals: vec![],
|
||||||
@ -592,8 +558,6 @@ fn test_log_with_aggreg() -> anyhow::Result<()> {
|
|||||||
txn_number_before: 1.into(),
|
txn_number_before: 1.into(),
|
||||||
gas_used_before: gas_used_second,
|
gas_used_before: gas_used_second,
|
||||||
gas_used_after: receipt.cum_gas_used,
|
gas_used_after: receipt.cum_gas_used,
|
||||||
block_bloom_before: block_bloom_second,
|
|
||||||
block_bloom_after: block_bloom_final,
|
|
||||||
block_hashes: BlockHashes {
|
block_hashes: BlockHashes {
|
||||||
prev_hashes: vec![H256::default(); 256],
|
prev_hashes: vec![H256::default(); 256],
|
||||||
cur_hash: H256::default(),
|
cur_hash: H256::default(),
|
||||||
|
|||||||
@ -180,8 +180,6 @@ fn self_balance_gas_cost() -> anyhow::Result<()> {
|
|||||||
txn_number_before: 0.into(),
|
txn_number_before: 0.into(),
|
||||||
gas_used_before: 0.into(),
|
gas_used_before: 0.into(),
|
||||||
gas_used_after: gas_used.into(),
|
gas_used_after: gas_used.into(),
|
||||||
block_bloom_before: [0.into(); 8],
|
|
||||||
block_bloom_after: [0.into(); 8],
|
|
||||||
block_hashes: BlockHashes {
|
block_hashes: BlockHashes {
|
||||||
prev_hashes: vec![H256::default(); 256],
|
prev_hashes: vec![H256::default(); 256],
|
||||||
cur_hash: H256::default(),
|
cur_hash: H256::default(),
|
||||||
|
|||||||
@ -132,8 +132,6 @@ fn test_selfdestruct() -> anyhow::Result<()> {
|
|||||||
txn_number_before: 0.into(),
|
txn_number_before: 0.into(),
|
||||||
gas_used_before: 0.into(),
|
gas_used_before: 0.into(),
|
||||||
gas_used_after: 26002.into(),
|
gas_used_after: 26002.into(),
|
||||||
block_bloom_before: [0.into(); 8],
|
|
||||||
block_bloom_after: [0.into(); 8],
|
|
||||||
block_hashes: BlockHashes {
|
block_hashes: BlockHashes {
|
||||||
prev_hashes: vec![H256::default(); 256],
|
prev_hashes: vec![H256::default(); 256],
|
||||||
cur_hash: H256::default(),
|
cur_hash: H256::default(),
|
||||||
|
|||||||
@ -148,8 +148,6 @@ fn test_simple_transfer() -> anyhow::Result<()> {
|
|||||||
txn_number_before: 0.into(),
|
txn_number_before: 0.into(),
|
||||||
gas_used_before: 0.into(),
|
gas_used_before: 0.into(),
|
||||||
gas_used_after: 21032.into(),
|
gas_used_after: 21032.into(),
|
||||||
block_bloom_before: [0.into(); 8],
|
|
||||||
block_bloom_after: [0.into(); 8],
|
|
||||||
block_hashes: BlockHashes {
|
block_hashes: BlockHashes {
|
||||||
prev_hashes: vec![H256::default(); 256],
|
prev_hashes: vec![H256::default(); 256],
|
||||||
cur_hash: H256::default(),
|
cur_hash: H256::default(),
|
||||||
|
|||||||
@ -78,8 +78,6 @@ fn test_withdrawals() -> anyhow::Result<()> {
|
|||||||
txn_number_before: 0.into(),
|
txn_number_before: 0.into(),
|
||||||
gas_used_before: 0.into(),
|
gas_used_before: 0.into(),
|
||||||
gas_used_after: 0.into(),
|
gas_used_after: 0.into(),
|
||||||
block_bloom_before: [0.into(); 8],
|
|
||||||
block_bloom_after: [0.into(); 8],
|
|
||||||
block_hashes: BlockHashes {
|
block_hashes: BlockHashes {
|
||||||
prev_hashes: vec![H256::default(); 256],
|
prev_hashes: vec![H256::default(); 256],
|
||||||
cur_hash: H256::default(),
|
cur_hash: H256::default(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user