From bf21b278d812ef1212d1367e526dbd2033034ef5 Mon Sep 17 00:00:00 2001 From: Linda Guiga Date: Tue, 5 Sep 2023 08:22:53 +0100 Subject: [PATCH] Apply comments --- evm/src/cpu/kernel/asm/core/create_receipt.asm | 5 ++--- .../cpu/kernel/asm/mpt/hash/hash_trie_specific.asm | 12 +++++------- .../cpu/kernel/asm/mpt/load/load_trie_specific.asm | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/evm/src/cpu/kernel/asm/core/create_receipt.asm b/evm/src/cpu/kernel/asm/core/create_receipt.asm index 32f64494..586ea5bb 100644 --- a/evm/src/cpu/kernel/asm/core/create_receipt.asm +++ b/evm/src/cpu/kernel/asm/core/create_receipt.asm @@ -57,9 +57,8 @@ process_receipt_after_bloom: // Write transaction type if necessary. RLP_RAW contains, at index 0, the current transaction type. PUSH 0 %mload_kernel(@SEGMENT_RLP_RAW) - DUP1 - // stack: first_txn_byte, first_txn_byte, receipt_ptr, payload_len, status, new_cum_gas, txn_nb, new_cum_gas, txn_nb, retdest - %eq_const(1) %jumpi(receipt_nonzero_type) + // stack: first_txn_byte, receipt_ptr, payload_len, status, new_cum_gas, txn_nb, new_cum_gas, txn_nb, retdest + DUP1 %eq_const(1) %jumpi(receipt_nonzero_type) DUP1 %eq_const(2) %jumpi(receipt_nonzero_type) // If we are here, we are dealing with a legacy transaction, and we do not need to write the type. POP diff --git a/evm/src/cpu/kernel/asm/mpt/hash/hash_trie_specific.asm b/evm/src/cpu/kernel/asm/mpt/hash/hash_trie_specific.asm index 5b40225c..6b057a49 100644 --- a/evm/src/cpu/kernel/asm/mpt/hash/hash_trie_specific.asm +++ b/evm/src/cpu/kernel/asm/mpt/hash/hash_trie_specific.asm @@ -108,9 +108,10 @@ global encode_receipt: // either RLP(RLP(receipt)) for Legacy transactions or RLP(txn_type||RLP(receipt)) for transactions of type 1 or 2. // First encode the wrapper prefix. DUP2 %mload_trie_data - // stack: first_byte, rlp_pos, value_ptr, retdest - // The first byte is either the transaction type or the first byte of the RLP encoding. - DUP1 PUSH 3 GT %jumpi(encode_nonzero_receipt_type) + // stack: first_value, rlp_pos, value_ptr, retdest + // The first value is either the transaction type or the payload length. + // Since the receipt contains at least the 256-bytes long bloom filter, payload_len > 3. + DUP1 %lt_const(3) %jumpi(encode_nonzero_receipt_type) // If we are here, then the first byte is the payload length. %rlp_list_len // stack: rlp_receipt_len, rlp_pos, value_ptr, retdest @@ -254,10 +255,7 @@ encode_nonzero_receipt_type: %mstore_rlp %increment // stack: rlp_pos, txn_type, old_rlp_pos, value_ptr, retdest - SWAP1 POP - // stack: rlp_pos, old_rlp_pos, value_ptr, retdest - SWAP1 POP - // stack: rlp_pos, value_ptr, retdest + %stack (rlp_pos, txn_type, old_rlp_pos, value_ptr, retdest) -> (rlp_pos, value_ptr, retdest) // We replace `value_ptr` with `paylaod_len_ptr` so we can encode the rest of the data more easily SWAP1 %increment SWAP1 // stack: rlp_pos, payload_len_ptr, retdest diff --git a/evm/src/cpu/kernel/asm/mpt/load/load_trie_specific.asm b/evm/src/cpu/kernel/asm/mpt/load/load_trie_specific.asm index 213469cc..9ac51773 100644 --- a/evm/src/cpu/kernel/asm/mpt/load/load_trie_specific.asm +++ b/evm/src/cpu/kernel/asm/mpt/load/load_trie_specific.asm @@ -37,7 +37,7 @@ global mpt_load_receipt_trie_value: PROVER_INPUT(mpt) DUP1 %append_to_trie_data // If the first byte is less than 3, then it is the transaction type, equal to either 1 or 2. // In that case, we still need to load the payload length. - PUSH 3 GT %jumpi(mpt_load_payload_len) + %lt_const(3) %jumpi(mpt_load_payload_len) mpt_load_after_type: // Load status.