-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update EIP-6404: Split RLP conversions from EIP-6493 for clarity
EIP-6493 mixes the introduction of SSZ transactions converted from RLP with native SSZ transactions, implying that the corresponding Receipt definition and engine API changes also must be part of EIP-6493. Splitting the RLP converted transactions into the other SSZ transaction EIP-6404 achieves a clearer balance, and is also closer to practical implementation order where an EL initially may choose to support only RLP converted transactions before adding the native SSZ profiles.
- Loading branch information
1 parent
226b17b
commit 1fb768e
Showing
12 changed files
with
856 additions
and
1,127 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
from rlp import decode | ||
from rlp_types import * | ||
from ssz_types import * | ||
|
||
def upgrade_rlp_transaction_to_ssz(pre_bytes: bytes): | ||
type_ = pre_bytes[0] | ||
|
||
if type_ == 0x03: # EIP-4844 | ||
pre = decode(pre_bytes[1:], BlobRlpTransaction) | ||
assert pre.y_parity in (0, 1) | ||
ecdsa_signature = ecdsa_pack_signature( | ||
pre.y_parity != 0, | ||
pre.r, | ||
pre.s, | ||
) | ||
from_ = ecdsa_recover_from_address(ecdsa_signature, compute_blob_sig_hash(pre)) | ||
|
||
return RlpBlobTransaction( | ||
payload=RlpBlobTransactionPayload( | ||
type_=BLOB_TX_TYPE, | ||
chain_id=pre.chain_id, | ||
nonce=pre.nonce, | ||
max_fees_per_gas=BlobFeesPerGas( | ||
regular=pre.max_fee_per_gas, | ||
blob=pre.max_fee_per_blob_gas, | ||
), | ||
gas=pre.gas, | ||
to=ExecutionAddress(pre.to), | ||
value=pre.value, | ||
input_=pre.data, | ||
access_list=[AccessTuple( | ||
address=access_tuple[0], | ||
storage_keys=access_tuple[1] | ||
) for access_tuple in pre.access_list], | ||
max_priority_fees_per_gas=BlobFeesPerGas( | ||
regular=pre.max_priority_fee_per_gas, | ||
blob=FeePerGas(0), | ||
), | ||
blob_versioned_hashes=pre.blob_versioned_hashes, | ||
), | ||
signature=EcdsaExecutionSignature( | ||
from_=from_, | ||
ecdsa_signature=ecdsa_signature, | ||
), | ||
) | ||
|
||
if type_ == 0x02: # EIP-1559 | ||
pre = decode(pre_bytes[1:], FeeMarketRlpTransaction) | ||
assert pre.y_parity in (0, 1) | ||
ecdsa_signature = ecdsa_pack_signature( | ||
pre.y_parity != 0, | ||
pre.r, | ||
pre.s, | ||
) | ||
from_ = ecdsa_recover_from_address(ecdsa_signature, compute_fee_market_sig_hash(pre)) | ||
|
||
return RlpFeeMarketTransaction( | ||
payload=RlpFeeMarketTransactionPayload( | ||
type_=FEE_MARKET_TX_TYPE, | ||
chain_id=pre.chain_id, | ||
nonce=pre.nonce, | ||
max_fees_per_gas=BasicFeesPerGas( | ||
regular=pre.max_fee_per_gas, | ||
), | ||
gas=pre.gas, | ||
to=ExecutionAddress(pre.to) if len(pre.to) > 0 else None, | ||
value=pre.value, | ||
input_=pre.data, | ||
access_list=[AccessTuple( | ||
address=access_tuple[0], | ||
storage_keys=access_tuple[1] | ||
) for access_tuple in pre.access_list], | ||
max_priority_fees_per_gas=BasicFeesPerGas( | ||
regular=pre.max_priority_fee_per_gas, | ||
), | ||
), | ||
signature=EcdsaExecutionSignature( | ||
from_=from_, | ||
ecdsa_signature=ecdsa_signature, | ||
), | ||
) | ||
|
||
if type_ == 0x01: # EIP-2930 | ||
pre = decode(pre_bytes[1:], AccessListRlpTransaction) | ||
assert pre.y_parity in (0, 1) | ||
ecdsa_signature = ecdsa_pack_signature( | ||
pre.y_parity != 0, | ||
pre.r, | ||
pre.s | ||
) | ||
from_ = ecdsa_recover_from_address(ecdsa_signature, compute_access_list_sig_hash(pre)) | ||
|
||
return RlpAccessListTransaction( | ||
payload=RlpAccessListTransactionPayload( | ||
type_=ACCESS_LIST_TX_TYPE, | ||
chain_id=pre.chain_id, | ||
nonce=pre.nonce, | ||
max_fees_per_gas=BasicFeesPerGas( | ||
regular=pre.gas_price, | ||
), | ||
gas=pre.gas, | ||
to=ExecutionAddress(pre.to) if len(pre.to) > 0 else None, | ||
value=pre.value, | ||
input_=pre.data, | ||
access_list=[AccessTuple( | ||
address=access_tuple[0], | ||
storage_keys=access_tuple[1] | ||
) for access_tuple in pre.access_list], | ||
), | ||
signature=EcdsaExecutionSignature( | ||
from_=from_, | ||
ecdsa_signature=ecdsa_signature, | ||
), | ||
) | ||
|
||
if 0xc0 <= type_ <= 0xfe: # Legacy | ||
pre = decode(pre_bytes, LegacyRlpTransaction) | ||
ecdsa_signature = ecdsa_pack_signature( | ||
(pre.v & 0x1) == 0, | ||
pre.r, | ||
pre.s, | ||
) | ||
from_ = ecdsa_recover_from_address(ecdsa_signature, compute_legacy_sig_hash(pre)) | ||
|
||
if (pre.v not in (27, 28)): # EIP-155 | ||
chain_id = ((pre.v - 35) >> 1) | ||
else: | ||
chain_id = None | ||
|
||
return RlpLegacyTransaction( | ||
payload=RlpLegacyTransactionPayload( | ||
type_=LEGACY_TX_TYPE, | ||
chain_id=chain_id, | ||
nonce=pre.nonce, | ||
max_fees_per_gas=BasicFeesPerGas( | ||
regular=pre.gas_price, | ||
), | ||
gas=pre.gas, | ||
to=ExecutionAddress(pre.to) if len(pre.to) > 0 else None, | ||
value=pre.value, | ||
input_=pre.data, | ||
), | ||
signature=EcdsaExecutionSignature( | ||
from_=from_, | ||
ecdsa_signature=ecdsa_signature, | ||
), | ||
) | ||
|
||
assert False |
Oops, something went wrong.