Skip to content

Commit

Permalink
[action] defer access list tx enabling (#4129)
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinxie authored Feb 4, 2024
1 parent 1e98841 commit 56714b3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 33 deletions.
7 changes: 1 addition & 6 deletions action/rlp_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func NewEthSigner(txType iotextypes.Encoding, chainID uint32) (types.Signer, err
case iotextypes.Encoding_IOTEX_PROTOBUF, iotextypes.Encoding_ETHEREUM_UNPROTECTED:
// native tx use same signature format as that of Homestead (for pre-EIP155 unprotected tx)
return types.HomesteadSigner{}, nil
case iotextypes.Encoding_ETHEREUM_EIP155, iotextypes.Encoding_ETHEREUM_ACCESSLIST:
case iotextypes.Encoding_ETHEREUM_EIP155:
return types.NewEIP2930Signer(big.NewInt(int64(chainID))), nil
default:
return nil, ErrInvalidAct
Expand Down Expand Up @@ -131,11 +131,6 @@ func ExtractTypeSigPubkey(tx *types.Transaction) (iotextypes.Encoding, []byte, c
encoding = iotextypes.Encoding_ETHEREUM_UNPROTECTED
signer = types.HomesteadSigner{}
}
case types.AccessListTxType:
// AL txs are defined to use 0 and 1 as their recovery
// id, add 27 to become equivalent to unprotected Homestead signatures.
V = new(big.Int).Add(V, big.NewInt(27))
encoding = iotextypes.Encoding_ETHEREUM_ACCESSLIST
default:
return encoding, nil, nil, ErrNotSupported
}
Expand Down
24 changes: 1 addition & 23 deletions action/rlp_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestGenerateRlp(t *testing.T) {
func TestRlpDecodeVerify(t *testing.T) {
require := require.New(t)

oldTests := rlpTests[:len(rlpTests)-2]
oldTests := rlpTests[:len(rlpTests)-1]
for _, v := range oldTests {
// decode received RLP tx
tx, sig, pubkey, err := DecodeRawTx(v.raw, _evmNetworkID)
Expand Down Expand Up @@ -396,21 +396,6 @@ var (
"040a98b1acb38ed9cd8d0e8f1f03b1588bae140586f8a8049197b65013a3c17690151ae422e3fdfb26be2e6a4465b1f9cf5c26a5635109929a0d0a11734124d50a",
"3fab184622dc19b6109349b94811493bf2a45362",
},
{
"accesslist",
"0x01f8a0827a690184ee6b280082520894a0ee7a142d267c1f36714e4a8f75612f20a797206480f838f794a0ee7a142d267c1f36714e4a8f75612f20a79720e1a0000000000000000000000000000000000000000000000000000000000000000001a0eb211dfd353d76d43ea31a130ff36ac4eb7b379eae4d49fa2376741daf32f9ffa07ab673241d75e103f81ddd4aa34dd6849faf2f0f593eebe61a68fed74490a348",
1,
21000,
"4000000000",
"100",
"0xa0Ee7A142d267C1f36714E4a8F75612F20a79720",
31337,
iotextypes.Encoding_ETHEREUM_ACCESSLIST,
0,
"a57cf9e47beede973c5725a92176c631e51d96bcec41310c6371a4cc72b0658d",
"048318535b54105d4a7aae60c08fc45f9687181b4fdfc625bd1a753fa7397fed753547f11ca8696646f2f3acb08e31016afac23e630c5d11f59f61fef57b0d2aa5",
"f39fd6e51aad88f6f4ce6ab8827279cfffb92266",
},
}
)

Expand All @@ -436,13 +421,6 @@ func TestEthTxDecodeVerify(t *testing.T) {
// unprotected tx has V = 27, 28
require.True(27 == recID || 28 == recID)
require.True(27 == sig[64] || 28 == sig[64])
} else if encoding == iotextypes.Encoding_ETHEREUM_ACCESSLIST {
require.EqualValues(types.AccessListTxType, tx.Type())
require.True(tx.Protected())
// // accesslist tx has V = 0, 1
require.LessOrEqual(recID, uint64(1))
require.True(27 == sig[64] || 28 == sig[64])
require.Equal(1, len(tx.AccessList()))
}
require.EqualValues(v.chainID, tx.ChainId().Uint64())
require.Equal(v.pubkey, pubkey.HexString())
Expand Down
6 changes: 3 additions & 3 deletions action/sealedenvelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type SealedEnvelope struct {
// an all-0 return value means the transaction is invalid
func (sealed *SealedEnvelope) envelopeHash() (hash.Hash256, error) {
switch sealed.encoding {
case iotextypes.Encoding_ETHEREUM_EIP155, iotextypes.Encoding_ETHEREUM_UNPROTECTED, iotextypes.Encoding_ETHEREUM_ACCESSLIST:
case iotextypes.Encoding_ETHEREUM_EIP155, iotextypes.Encoding_ETHEREUM_UNPROTECTED:
act, ok := sealed.Action().(EthCompatibleAction)
if !ok {
return hash.ZeroHash256, ErrInvalidAct
Expand Down Expand Up @@ -66,7 +66,7 @@ func (sealed *SealedEnvelope) Hash() (hash.Hash256, error) {

func (sealed *SealedEnvelope) calcHash() (hash.Hash256, error) {
switch sealed.encoding {
case iotextypes.Encoding_ETHEREUM_EIP155, iotextypes.Encoding_ETHEREUM_UNPROTECTED, iotextypes.Encoding_ETHEREUM_ACCESSLIST:
case iotextypes.Encoding_ETHEREUM_EIP155, iotextypes.Encoding_ETHEREUM_UNPROTECTED:
act, ok := sealed.Action().(EthCompatibleAction)
if !ok {
return hash.ZeroHash256, ErrInvalidAct
Expand Down Expand Up @@ -144,7 +144,7 @@ func (sealed *SealedEnvelope) loadProto(pbAct *iotextypes.Action, evmID uint32)
}
encoding := pbAct.GetEncoding()
switch encoding {
case iotextypes.Encoding_ETHEREUM_EIP155, iotextypes.Encoding_ETHEREUM_UNPROTECTED, iotextypes.Encoding_ETHEREUM_ACCESSLIST:
case iotextypes.Encoding_ETHEREUM_EIP155, iotextypes.Encoding_ETHEREUM_UNPROTECTED:
// verify action type can support RLP-encoding
act, ok := elp.Action().(EthCompatibleAction)
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion action/sealedenvelope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func TestSealedEnvelope_Proto(t *testing.T) {
err string
}{
{0, _signByte, "invalid signature length ="},
{iotextypes.Encoding_ETHEREUM_ACCESSLIST + 1, _validSig, "unknown encoding type"},
{iotextypes.Encoding_ETHEREUM_UNPROTECTED + 1, _validSig, "unknown encoding type"},
} {
se.encoding = v.encoding
se.signature = v.sig
Expand Down

0 comments on commit 56714b3

Please sign in to comment.