terminology

This commit is contained in:
Daniel Lubarov 2022-07-26 16:12:21 -07:00
parent 0ba6078984
commit d1cb854cf2
3 changed files with 25 additions and 26 deletions

View File

@ -1,5 +1,5 @@
// Type 0 transactions, aka legacy transaction, have the format // Type 0 transactions, aka legacy transaction, have the format
// rlp([nonce, gas_price, gas_limit, destination, amount, data, v, r, s]) // rlp([nonce, gas_price, gas_limit, to, value, data, v, r, s])
// //
// The field v was originally encoded as // The field v was originally encoded as
// 27 + y_parity // 27 + y_parity
@ -7,9 +7,9 @@
// 35 + 2 * chain_id + y_parity // 35 + 2 * chain_id + y_parity
// //
// If a chain_id is present in v, the signed data is // If a chain_id is present in v, the signed data is
// keccak256(rlp([nonce, gas_price, gas_limit, destination, amount, data, chain_id, 0, 0])) // keccak256(rlp([nonce, gas_price, gas_limit, to, value, data, chain_id, 0, 0]))
// otherwise, it is // otherwise, it is
// keccak256(rlp([nonce, gas_price, gas_limit, destination, amount, data])) // keccak256(rlp([nonce, gas_price, gas_limit, to, value, data]))
global process_type_0_txn: global process_type_0_txn:
JUMPDEST JUMPDEST
@ -58,34 +58,34 @@ store_gas_limit:
%mstore_current(@SEGMENT_NORMALIZED_TXN) %mstore_current(@SEGMENT_NORMALIZED_TXN)
// Peak at the RLP to see if the next byte is zero. // Peak at the RLP to see if the next byte is zero.
// If so, there is no destination field, so skip the store_destination step. // If so, there is no value field, so skip the store_to step.
// stack: pos // stack: pos
DUP1 DUP1
%mload_current(@SEGMENT_RLP_RAW) %mload_current(@SEGMENT_RLP_RAW)
ISZERO ISZERO
// stack: destination_empty, pos // stack: to_empty, pos
%jumpi(parse_amount) %jumpi(parse_value)
// If we got here, there is a destination field. // If we got here, there is a "to" field.
PUSH store_destination PUSH store_to
SWAP1 SWAP1
// stack: pos, store_destination // stack: pos, store_to
%jump(decode_rlp_scalar) %jump(decode_rlp_scalar)
store_destination: store_to:
%stack (pos, destination) -> (@TXN_FIELD_DESTINATION, destination, pos) %stack (pos, to) -> (@TXN_FIELD_TO, to, pos)
%mstore_current(@SEGMENT_NORMALIZED_TXN) %mstore_current(@SEGMENT_NORMALIZED_TXN)
// stack: pos // stack: pos
parse_amount: parse_value:
// stack: pos // stack: pos
PUSH store_amount PUSH store_value
SWAP1 SWAP1
// stack: pos, store_amount // stack: pos, store_value
%jump(decode_rlp_scalar) %jump(decode_rlp_scalar)
store_amount: store_value:
%stack (pos, amount) -> (@TXN_FIELD_AMOUNT, amount, pos) %stack (pos, value) -> (@TXN_FIELD_VALUE, value, pos)
%mstore_current(@SEGMENT_NORMALIZED_TXN) %mstore_current(@SEGMENT_NORMALIZED_TXN)
// stack: pos // stack: pos

View File

@ -1,12 +1,11 @@
// Type 2 transactions, introduced by EIP 1559, have the format // Type 2 transactions, introduced by EIP 1559, have the format
// 0x02 || rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, // 0x02 || rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas,
// gas_limit, destination, amount, data, access_list, y_parity, // gas_limit, to, value, data, access_list, y_parity, r, s])
// r, s])
// //
// The signed data is // The signed data is
// keccak256(0x02 || rlp([chain_id, nonce, max_priority_fee_per_gas, // keccak256(0x02 || rlp([chain_id, nonce, max_priority_fee_per_gas,
// max_fee_per_gas, gas_limit, destination, amount, // max_fee_per_gas, gas_limit, to, value, data,
// data, access_list])) // access_list]))
global process_type_2_txn: global process_type_2_txn:
JUMPDEST JUMPDEST

View File

@ -10,8 +10,8 @@ pub(crate) enum NormalizedTxnField {
MaxPriorityFeePerGas = 3, MaxPriorityFeePerGas = 3,
MaxFeePerGas = 4, MaxFeePerGas = 4,
GasLimit = 5, GasLimit = 5,
Destination = 6, To = 6,
Amount = 7, Value = 7,
/// The length of the data field. The data itself is stored in another segment. /// The length of the data field. The data itself is stored in another segment.
DataLen = 8, DataLen = 8,
YParity = 9, YParity = 9,
@ -30,8 +30,8 @@ impl NormalizedTxnField {
Self::MaxPriorityFeePerGas, Self::MaxPriorityFeePerGas,
Self::MaxFeePerGas, Self::MaxFeePerGas,
Self::GasLimit, Self::GasLimit,
Self::Destination, Self::To,
Self::Amount, Self::Value,
Self::DataLen, Self::DataLen,
Self::YParity, Self::YParity,
Self::R, Self::R,
@ -48,8 +48,8 @@ impl NormalizedTxnField {
NormalizedTxnField::MaxPriorityFeePerGas => "TXN_FIELD_MAX_PRIORITY_FEE_PER_GAS", NormalizedTxnField::MaxPriorityFeePerGas => "TXN_FIELD_MAX_PRIORITY_FEE_PER_GAS",
NormalizedTxnField::MaxFeePerGas => "TXN_FIELD_MAX_FEE_PER_GAS", NormalizedTxnField::MaxFeePerGas => "TXN_FIELD_MAX_FEE_PER_GAS",
NormalizedTxnField::GasLimit => "TXN_FIELD_GAS_LIMIT", NormalizedTxnField::GasLimit => "TXN_FIELD_GAS_LIMIT",
NormalizedTxnField::Destination => "TXN_FIELD_DESTINATION", NormalizedTxnField::To => "TXN_FIELD_TO",
NormalizedTxnField::Amount => "TXN_FIELD_AMOUNT", NormalizedTxnField::Value => "TXN_FIELD_VALUE",
NormalizedTxnField::DataLen => "TXN_FIELD_DATA_LEN", NormalizedTxnField::DataLen => "TXN_FIELD_DATA_LEN",
NormalizedTxnField::YParity => "TXN_FIELD_Y_PARITY", NormalizedTxnField::YParity => "TXN_FIELD_Y_PARITY",
NormalizedTxnField::R => "TXN_FIELD_R", NormalizedTxnField::R => "TXN_FIELD_R",