From 1f7bb0e833e668b523b40bd01fd0481940e42950 Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Tue, 4 May 2021 14:58:53 -0700 Subject: [PATCH 1/5] l2geth: remove tx type --- .../accounts/abi/bind/backends/simulated.go | 7 ++- l2geth/core/rawdb/accessors_chain_test.go | 10 +--- l2geth/core/state_transition.go | 1 - l2geth/core/state_transition_ovm.go | 1 - l2geth/core/types/gen_tx_meta_json.go | 23 +++------ l2geth/core/types/transaction.go | 50 ++++++------------- l2geth/core/types/transaction_meta.go | 39 +++++---------- l2geth/core/types/transaction_meta_test.go | 43 +--------------- l2geth/core/types/transaction_test.go | 4 -- l2geth/interfaces.go | 7 ++- l2geth/internal/ethapi/api.go | 22 +++----- l2geth/miner/worker.go | 2 +- l2geth/rollup/client.go | 4 -- l2geth/signer/core/types.go | 9 ++-- 14 files changed, 55 insertions(+), 167 deletions(-) diff --git a/l2geth/accounts/abi/bind/backends/simulated.go b/l2geth/accounts/abi/bind/backends/simulated.go index 243491799533..f00cad5055e6 100644 --- a/l2geth/accounts/abi/bind/backends/simulated.go +++ b/l2geth/accounts/abi/bind/backends/simulated.go @@ -601,10 +601,9 @@ func (m callmsg) Gas() uint64 { return m.CallMsg.Gas } func (m callmsg) Value() *big.Int { return m.CallMsg.Value } func (m callmsg) Data() []byte { return m.CallMsg.Data } -func (m callmsg) L1MessageSender() *common.Address { return m.CallMsg.L1MessageSender } -func (m callmsg) L1BlockNumber() *big.Int { return m.CallMsg.L1BlockNumber } -func (m callmsg) QueueOrigin() *big.Int { return m.CallMsg.QueueOrigin } -func (m callmsg) SignatureHashType() types.SignatureHashType { return m.CallMsg.SignatureHashType } +func (m callmsg) L1MessageSender() *common.Address { return m.CallMsg.L1MessageSender } +func (m callmsg) L1BlockNumber() *big.Int { return m.CallMsg.L1BlockNumber } +func (m callmsg) QueueOrigin() *big.Int { return m.CallMsg.QueueOrigin } // filterBackend implements filters.Backend to support filtering for logs without // taking bloom-bits acceleration structures into account. diff --git a/l2geth/core/rawdb/accessors_chain_test.go b/l2geth/core/rawdb/accessors_chain_test.go index 3c1ffa065ec2..6d81deb3be79 100644 --- a/l2geth/core/rawdb/accessors_chain_test.go +++ b/l2geth/core/rawdb/accessors_chain_test.go @@ -430,7 +430,7 @@ func TestBlockMetaStorage(t *testing.T) { index1 := uint64(1) tx1 := types.NewTransaction(1, common.HexToAddress("0x1"), big.NewInt(1), 1, big.NewInt(1), nil) - tx1Meta := types.NewTransactionMeta(nil, 0, nil, types.SighashEIP155, types.QueueOriginSequencer, &index1, nil, nil) + tx1Meta := types.NewTransactionMeta(nil, 0, nil, types.QueueOriginSequencer, &index1, nil, nil) tx1.SetTransactionMeta(tx1Meta) WriteTransactionMeta(db, index1, tx1.GetMeta()) @@ -442,9 +442,6 @@ func TestBlockMetaStorage(t *testing.T) { if meta.L1BlockNumber != nil { t.Fatalf("Could not recover L1BlockNumber") } - if meta.SignatureHashType != types.SighashEIP155 { - t.Fatalf("Could not recover sighash type") - } if meta.Index == nil { t.Fatalf("Could not recover index") } @@ -464,7 +461,7 @@ func TestBlockMetaStorage(t *testing.T) { index2 := uint64(2) tx2 := types.NewTransaction(2, common.HexToAddress("0x02"), big.NewInt(2), 2, big.NewInt(2), nil) - tx2Meta := types.NewTransactionMeta(l1BlockNumber, 0, &addr, types.SighashEthSign, types.QueueOriginSequencer, nil, nil, nil) + tx2Meta := types.NewTransactionMeta(l1BlockNumber, 0, &addr, types.QueueOriginSequencer, nil, nil, nil) tx2.SetTransactionMeta(tx2Meta) WriteTransactionMeta(db, index2, tx2.GetMeta()) @@ -477,7 +474,4 @@ func TestBlockMetaStorage(t *testing.T) { if meta2.L1BlockNumber.Cmp(l1BlockNumber) != 0 { t.Fatalf("Could not recover L1BlockNumber") } - if meta2.SignatureHashType != types.SighashEthSign { - t.Fatalf("Could not recover sighash type") - } } diff --git a/l2geth/core/state_transition.go b/l2geth/core/state_transition.go index d5e839a757dc..933b0f8aa7a8 100644 --- a/l2geth/core/state_transition.go +++ b/l2geth/core/state_transition.go @@ -78,7 +78,6 @@ type Message interface { L1MessageSender() *common.Address L1BlockNumber() *big.Int QueueOrigin() *big.Int - SignatureHashType() types.SignatureHashType } // IntrinsicGas computes the 'intrinsic gas' for a message with the given data. diff --git a/l2geth/core/state_transition_ovm.go b/l2geth/core/state_transition_ovm.go index adba0fb257df..5da13437adba 100644 --- a/l2geth/core/state_transition_ovm.go +++ b/l2geth/core/state_transition_ovm.go @@ -156,7 +156,6 @@ func modMessage( msg.L1MessageSender(), msg.L1BlockNumber(), queueOrigin, - msg.SignatureHashType(), ) return outmsg, nil diff --git a/l2geth/core/types/gen_tx_meta_json.go b/l2geth/core/types/gen_tx_meta_json.go index 5bf2f763f36e..13a57551050f 100644 --- a/l2geth/core/types/gen_tx_meta_json.go +++ b/l2geth/core/types/gen_tx_meta_json.go @@ -13,16 +13,14 @@ import ( // MarshalJSON marshals as JSON. func (t TransactionMeta) MarshalJSON() ([]byte, error) { type TransactionMeta struct { - L1BlockNumber *big.Int `json:"l1BlockNumber"` - L1MessageSender *common.Address `json:"l1MessageSender" gencodec:"required"` - SignatureHashType SignatureHashType `json:"signatureHashType" gencodec:"required"` - QueueOrigin *big.Int `json:"queueOrigin" gencodec:"required"` - Index *uint64 `json:"index" gencodec:"required"` + L1BlockNumber *big.Int `json:"l1BlockNumber"` + L1MessageSender *common.Address `json:"l1MessageSender" gencodec:"required"` + QueueOrigin *big.Int `json:"queueOrigin" gencodec:"required"` + Index *uint64 `json:"index" gencodec:"required"` } var enc TransactionMeta enc.L1BlockNumber = t.L1BlockNumber enc.L1MessageSender = t.L1MessageSender - enc.SignatureHashType = t.SignatureHashType enc.QueueOrigin = t.QueueOrigin enc.Index = t.Index return json.Marshal(&enc) @@ -31,11 +29,10 @@ func (t TransactionMeta) MarshalJSON() ([]byte, error) { // UnmarshalJSON unmarshals from JSON. func (t *TransactionMeta) UnmarshalJSON(input []byte) error { type TransactionMeta struct { - L1BlockNumber *big.Int `json:"l1BlockNumber"` - L1MessageSender *common.Address `json:"l1MessageSender" gencodec:"required"` - SignatureHashType *SignatureHashType `json:"signatureHashType" gencodec:"required"` - QueueOrigin *big.Int `json:"queueOrigin" gencodec:"required"` - Index *uint64 `json:"index" gencodec:"required"` + L1BlockNumber *big.Int `json:"l1BlockNumber"` + L1MessageSender *common.Address `json:"l1MessageSender" gencodec:"required"` + QueueOrigin *big.Int `json:"queueOrigin" gencodec:"required"` + Index *uint64 `json:"index" gencodec:"required"` } var dec TransactionMeta if err := json.Unmarshal(input, &dec); err != nil { @@ -48,10 +45,6 @@ func (t *TransactionMeta) UnmarshalJSON(input []byte) error { return errors.New("missing required field 'l1MessageSender' for TransactionMeta") } t.L1MessageSender = dec.L1MessageSender - if dec.SignatureHashType == nil { - return errors.New("missing required field 'signatureHashType' for TransactionMeta") - } - t.SignatureHashType = *dec.SignatureHashType if dec.QueueOrigin == nil { return errors.New("missing required field 'queueOrigin' for TransactionMeta") } diff --git a/l2geth/core/types/transaction.go b/l2geth/core/types/transaction.go index 3aaf1c3c2590..57b4d4834da4 100644 --- a/l2geth/core/types/transaction.go +++ b/l2geth/core/types/transaction.go @@ -35,15 +35,6 @@ var ( ErrInvalidSig = errors.New("invalid transaction v, r, s values") ) -// TODO(mark): migrate from sighash type to type -type SignatureHashType uint8 - -const ( - SighashEIP155 SignatureHashType = 0 - SighashEthSign SignatureHashType = 1 - CreateEOA SignatureHashType = 2 -) - type Transaction struct { data txdata meta TransactionMeta @@ -95,7 +86,7 @@ func newTransaction(nonce uint64, to *common.Address, amount *big.Int, gasLimit data = common.CopyBytes(data) } - meta := NewTransactionMeta(nil, 0, nil, SighashEIP155, QueueOriginSequencer, nil, nil, nil) + meta := NewTransactionMeta(nil, 0, nil, QueueOriginSequencer, nil, nil, nil) d := txdata{ AccountNonce: nonce, @@ -230,14 +221,7 @@ func (tx *Transaction) Value() *big.Int { return new(big.Int).Set(tx.data.Amo func (tx *Transaction) Nonce() uint64 { return tx.data.AccountNonce } func (tx *Transaction) CheckNonce() bool { return true } -func (tx *Transaction) SetNonce(nonce uint64) { tx.data.AccountNonce = nonce } -func (tx *Transaction) SignatureHashType() SignatureHashType { return tx.meta.SignatureHashType } -func (tx *Transaction) SetSignatureHashType(sighashType SignatureHashType) { - tx.meta.SignatureHashType = sighashType -} -func (tx *Transaction) IsEthSignSighash() bool { - return tx.SignatureHashType() == SighashEthSign -} +func (tx *Transaction) SetNonce(nonce uint64) { tx.data.AccountNonce = nonce } // To returns the recipient address of the transaction. // It returns nil if the transaction is a contract creation. @@ -317,10 +301,9 @@ func (tx *Transaction) AsMessage(s Signer) (Message, error) { data: tx.data.Payload, checkNonce: true, - l1MessageSender: tx.meta.L1MessageSender, - l1BlockNumber: tx.meta.L1BlockNumber, - signatureHashType: tx.meta.SignatureHashType, - queueOrigin: tx.meta.QueueOrigin, + l1MessageSender: tx.meta.L1MessageSender, + l1BlockNumber: tx.meta.L1BlockNumber, + queueOrigin: tx.meta.QueueOrigin, } var err error @@ -533,13 +516,12 @@ type Message struct { data []byte checkNonce bool - l1MessageSender *common.Address - l1BlockNumber *big.Int - signatureHashType SignatureHashType - queueOrigin *big.Int + l1MessageSender *common.Address + l1BlockNumber *big.Int + queueOrigin *big.Int } -func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, checkNonce bool, l1MessageSender *common.Address, l1BlockNumber *big.Int, queueOrigin QueueOrigin, signatureHashType SignatureHashType) Message { +func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, checkNonce bool, l1MessageSender *common.Address, l1BlockNumber *big.Int, queueOrigin QueueOrigin) Message { return Message{ from: from, to: to, @@ -550,10 +532,9 @@ func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *b data: data, checkNonce: checkNonce, - l1BlockNumber: l1BlockNumber, - l1MessageSender: l1MessageSender, - signatureHashType: signatureHashType, - queueOrigin: big.NewInt(int64(queueOrigin)), + l1BlockNumber: l1BlockNumber, + l1MessageSender: l1MessageSender, + queueOrigin: big.NewInt(int64(queueOrigin)), } } @@ -566,7 +547,6 @@ func (m Message) Nonce() uint64 { return m.nonce } func (m Message) Data() []byte { return m.data } func (m Message) CheckNonce() bool { return m.checkNonce } -func (m Message) L1MessageSender() *common.Address { return m.l1MessageSender } -func (m Message) L1BlockNumber() *big.Int { return m.l1BlockNumber } -func (m Message) SignatureHashType() SignatureHashType { return m.signatureHashType } -func (m Message) QueueOrigin() *big.Int { return m.queueOrigin } +func (m Message) L1MessageSender() *common.Address { return m.l1MessageSender } +func (m Message) L1BlockNumber() *big.Int { return m.l1BlockNumber } +func (m Message) QueueOrigin() *big.Int { return m.queueOrigin } diff --git a/l2geth/core/types/transaction_meta.go b/l2geth/core/types/transaction_meta.go index a475c53decc7..3d09cbd69bff 100644 --- a/l2geth/core/types/transaction_meta.go +++ b/l2geth/core/types/transaction_meta.go @@ -23,11 +23,10 @@ const ( //go:generate gencodec -type TransactionMeta -out gen_tx_meta_json.go type TransactionMeta struct { - L1BlockNumber *big.Int `json:"l1BlockNumber"` - L1Timestamp uint64 `json:"l1Timestamp"` - L1MessageSender *common.Address `json:"l1MessageSender" gencodec:"required"` - SignatureHashType SignatureHashType `json:"signatureHashType" gencodec:"required"` - QueueOrigin *big.Int `json:"queueOrigin" gencodec:"required"` + L1BlockNumber *big.Int `json:"l1BlockNumber"` + L1Timestamp uint64 `json:"l1Timestamp"` + L1MessageSender *common.Address `json:"l1MessageSender" gencodec:"required"` + QueueOrigin *big.Int `json:"queueOrigin" gencodec:"required"` // The canonical transaction chain index Index *uint64 `json:"index" gencodec:"required"` // The queue index, nil for queue origin sequencer transactions @@ -36,22 +35,20 @@ type TransactionMeta struct { } // NewTransactionMeta creates a TransactionMeta -func NewTransactionMeta(l1BlockNumber *big.Int, l1timestamp uint64, l1MessageSender *common.Address, sighashType SignatureHashType, queueOrigin QueueOrigin, index *uint64, queueIndex *uint64, rawTransaction []byte) *TransactionMeta { +func NewTransactionMeta(l1BlockNumber *big.Int, l1timestamp uint64, l1MessageSender *common.Address, queueOrigin QueueOrigin, index *uint64, queueIndex *uint64, rawTransaction []byte) *TransactionMeta { return &TransactionMeta{ - L1BlockNumber: l1BlockNumber, - L1Timestamp: l1timestamp, - L1MessageSender: l1MessageSender, - SignatureHashType: sighashType, - QueueOrigin: big.NewInt(int64(queueOrigin)), - Index: index, - QueueIndex: queueIndex, - RawTransaction: rawTransaction, + L1BlockNumber: l1BlockNumber, + L1Timestamp: l1timestamp, + L1MessageSender: l1MessageSender, + QueueOrigin: big.NewInt(int64(queueOrigin)), + Index: index, + QueueIndex: queueIndex, + RawTransaction: rawTransaction, } } // TxMetaDecode deserializes bytes as a TransactionMeta struct. // The schema is: -// varbytes(SignatureHashType) || // varbytes(L1BlockNumber) || // varbytes(L1MessageSender) || // varbytes(QueueOrigin) || @@ -61,14 +58,6 @@ func TxMetaDecode(input []byte) (*TransactionMeta, error) { meta := TransactionMeta{} b := bytes.NewReader(input) - sb, err := common.ReadVarBytes(b, 0, 1024, "SignatureHashType") - if err != nil { - return nil, err - } - var sighashType SignatureHashType - binary.Read(bytes.NewReader(sb), binary.LittleEndian, &sighashType) - meta.SignatureHashType = sighashType - lb, err := common.ReadVarBytes(b, 0, 1024, "l1BlockNumber") if err != nil { return nil, err @@ -138,10 +127,6 @@ func TxMetaDecode(input []byte) (*TransactionMeta, error) { func TxMetaEncode(meta *TransactionMeta) []byte { b := new(bytes.Buffer) - s := new(bytes.Buffer) - binary.Write(s, binary.LittleEndian, &meta.SignatureHashType) - common.WriteVarBytes(b, 0, s.Bytes()) - L1BlockNumber := meta.L1BlockNumber if L1BlockNumber == nil { common.WriteVarBytes(b, 0, getNullValue()) diff --git a/l2geth/core/types/transaction_meta_test.go b/l2geth/core/types/transaction_meta_test.go index 6471b5f77614..546d3cb99369 100644 --- a/l2geth/core/types/transaction_meta_test.go +++ b/l2geth/core/types/transaction_meta_test.go @@ -17,7 +17,6 @@ var ( l1BlockNumber *big.Int l1Timestamp uint64 msgSender *common.Address - sighashType SignatureHashType queueOrigin QueueOrigin rawTransaction []byte }{ @@ -25,7 +24,6 @@ var ( l1BlockNumber: l1BlockNumber, l1Timestamp: 100, msgSender: &addr, - sighashType: SighashEthSign, queueOrigin: QueueOriginL1ToL2, rawTransaction: []byte{255, 255, 255, 255}, }, @@ -33,7 +31,6 @@ var ( l1BlockNumber: nil, l1Timestamp: 45, msgSender: &addr, - sighashType: SighashEthSign, queueOrigin: QueueOriginL1ToL2, rawTransaction: []byte{42, 69, 42, 69}, }, @@ -41,7 +38,6 @@ var ( l1BlockNumber: l1BlockNumber, l1Timestamp: 0, msgSender: nil, - sighashType: SighashEthSign, queueOrigin: QueueOriginSequencer, rawTransaction: []byte{0, 0, 0, 0}, }, @@ -49,7 +45,6 @@ var ( l1BlockNumber: l1BlockNumber, l1Timestamp: 0, msgSender: &addr, - sighashType: SighashEthSign, queueOrigin: QueueOriginSequencer, rawTransaction: []byte{0, 0, 0, 0}, }, @@ -57,7 +52,6 @@ var ( l1BlockNumber: nil, l1Timestamp: 0, msgSender: nil, - sighashType: SighashEthSign, queueOrigin: QueueOriginL1ToL2, rawTransaction: []byte{0, 0, 0, 0}, }, @@ -65,30 +59,15 @@ var ( l1BlockNumber: l1BlockNumber, l1Timestamp: 0, msgSender: &addr, - sighashType: SighashEthSign, queueOrigin: QueueOriginL1ToL2, rawTransaction: []byte{0, 0, 0, 0}, }, } - - txMetaSighashEncodeTests = []struct { - input SignatureHashType - output SignatureHashType - }{ - { - input: SighashEIP155, - output: SighashEIP155, - }, - { - input: SighashEthSign, - output: SighashEthSign, - }, - } ) func TestTransactionMetaEncode(t *testing.T) { for _, test := range txMetaSerializationTests { - txmeta := NewTransactionMeta(test.l1BlockNumber, test.l1Timestamp, test.msgSender, test.sighashType, test.queueOrigin, nil, nil, test.rawTransaction) + txmeta := NewTransactionMeta(test.l1BlockNumber, test.l1Timestamp, test.msgSender, test.queueOrigin, nil, nil, test.rawTransaction) encoded := TxMetaEncode(txmeta) decoded, err := TxMetaDecode(encoded) @@ -103,22 +82,6 @@ func TestTransactionMetaEncode(t *testing.T) { } } -func TestTransactionSighashEncode(t *testing.T) { - for _, test := range txMetaSighashEncodeTests { - txmeta := NewTransactionMeta(l1BlockNumber, 0, &addr, test.input, QueueOriginSequencer, nil, nil, nil) - encoded := TxMetaEncode(txmeta) - decoded, err := TxMetaDecode(encoded) - - if err != nil { - t.Fatal(err) - } - - if decoded.SignatureHashType != test.output { - t.Fatal("SighashTypes do not match") - } - } -} - func isTxMetaEqual(meta1 *TransactionMeta, meta2 *TransactionMeta) bool { // Maybe can just return this if !reflect.DeepEqual(meta1, meta2) { @@ -149,10 +112,6 @@ func isTxMetaEqual(meta1 *TransactionMeta, meta2 *TransactionMeta) bool { } } - if meta1.SignatureHashType != meta2.SignatureHashType { - return false - } - if meta1.QueueOrigin == nil || meta2.QueueOrigin == nil { // Note: this only works because it is the final comparison if meta1.QueueOrigin == nil && meta2.QueueOrigin == nil { diff --git a/l2geth/core/types/transaction_test.go b/l2geth/core/types/transaction_test.go index f7d108379b67..6106362f4bf1 100644 --- a/l2geth/core/types/transaction_test.go +++ b/l2geth/core/types/transaction_test.go @@ -263,8 +263,4 @@ func TestOVMMetaDataHash(t *testing.T) { if emptyTx.Hash() != emptyTxEmptyL1Sender.Hash() { t.Errorf("L1MessageSender, should not affect the hash, want %x, got %x with L1MessageSender", emptyTx.Hash(), emptyTxEmptyL1Sender.Hash()) } - - if emptyTx.Hash() != emptyTxSighashEthSign.Hash() { - t.Errorf("SignatureHashType, should not affect the hash, want %x, got %x with SighashEthSign", emptyTx.Hash(), emptyTxSighashEthSign.Hash()) - } } diff --git a/l2geth/interfaces.go b/l2geth/interfaces.go index 50bde19ddf8c..ab3f44eb86fc 100644 --- a/l2geth/interfaces.go +++ b/l2geth/interfaces.go @@ -120,10 +120,9 @@ type CallMsg struct { Value *big.Int // amount of wei sent along with the call Data []byte // input data, usually an ABI-encoded contract method invocation - L1MessageSender *common.Address - L1BlockNumber *big.Int - QueueOrigin *big.Int - SignatureHashType types.SignatureHashType + L1MessageSender *common.Address + L1BlockNumber *big.Int + QueueOrigin *big.Int } // A ContractCaller provides contract calls, essentially transactions that are executed by diff --git a/l2geth/internal/ethapi/api.go b/l2geth/internal/ethapi/api.go index 64dc1b9d3814..35ff8e676a29 100644 --- a/l2geth/internal/ethapi/api.go +++ b/l2geth/internal/ethapi/api.go @@ -931,7 +931,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo // Create new call message var msg core.Message - msg = types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, false, &addr, nil, types.QueueOriginSequencer, 0) + msg = types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, false, &addr, nil, types.QueueOriginSequencer) if vm.UsingOVM { cfg := b.ChainConfig() executionManager := cfg.StateDump.Accounts["OVM_ExecutionManager"] @@ -1353,15 +1353,6 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber queueIndex := (hexutil.Uint64)(*meta.QueueIndex) result.QueueIndex = &queueIndex } - - switch meta.SignatureHashType { - case types.SighashEthSign: - result.TxType = "EthSign" - case types.SighashEIP155: - result.TxType = "EIP155" - case types.CreateEOA: - result.TxType = "CreateEOA" - } } return result } @@ -1594,9 +1585,8 @@ type SendTxArgs struct { Data *hexutil.Bytes `json:"data"` Input *hexutil.Bytes `json:"input"` - L1BlockNumber *big.Int `json:"l1BlockNumber"` - L1MessageSender *common.Address `json:"l1MessageSender"` - SignatureHashType types.SignatureHashType `json:"signatureHashType"` + L1BlockNumber *big.Int `json:"l1BlockNumber"` + L1MessageSender *common.Address `json:"l1MessageSender"` } // setDefaults is a helper function that fills in default values for unspecified tx fields. @@ -1669,13 +1659,13 @@ func (args *SendTxArgs) toTransaction() *types.Transaction { if args.To == nil { tx := types.NewContractCreation(uint64(*args.Nonce), (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input) raw, _ := rlp.EncodeToBytes(tx) - txMeta := types.NewTransactionMeta(args.L1BlockNumber, 0, nil, types.SighashEIP155, types.QueueOriginSequencer, nil, nil, raw) + txMeta := types.NewTransactionMeta(args.L1BlockNumber, 0, nil, types.QueueOriginSequencer, nil, nil, raw) tx.SetTransactionMeta(txMeta) return tx } tx := types.NewTransaction(uint64(*args.Nonce), *args.To, (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input) raw, _ := rlp.EncodeToBytes(tx) - txMeta := types.NewTransactionMeta(args.L1BlockNumber, 0, args.L1MessageSender, args.SignatureHashType, types.QueueOriginSequencer, nil, nil, raw) + txMeta := types.NewTransactionMeta(args.L1BlockNumber, 0, args.L1MessageSender, types.QueueOriginSequencer, nil, nil, raw) tx.SetTransactionMeta(txMeta) return tx } @@ -1772,7 +1762,7 @@ func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encod return common.Hash{}, err } // L1Timestamp and L1BlockNumber will be set right before execution - txMeta := types.NewTransactionMeta(nil, 0, nil, types.SighashEIP155, types.QueueOriginSequencer, nil, nil, encodedTx) + txMeta := types.NewTransactionMeta(nil, 0, nil, types.QueueOriginSequencer, nil, nil, encodedTx) tx.SetTransactionMeta(txMeta) return SubmitTransaction(ctx, s.b, tx) } diff --git a/l2geth/miner/worker.go b/l2geth/miner/worker.go index 8221e5afa57d..c3c35e6c3042 100644 --- a/l2geth/miner/worker.go +++ b/l2geth/miner/worker.go @@ -1072,7 +1072,7 @@ func (w *worker) commit(uncles []*types.Header, interval func(), update bool, st bn = new(big.Int) } log.Info("New block", "index", block.Number().Uint64()-uint64(1), "l1-timestamp", tx.L1Timestamp(), "l1-blocknumber", bn.Uint64(), "tx-hash", tx.Hash().Hex(), - "queue-orign", tx.QueueOrigin(), "type", tx.SignatureHashType(), "gas", block.GasUsed(), "fees", feesEth, "elapsed", common.PrettyDuration(time.Since(start))) + "queue-orign", tx.QueueOrigin(), "gas", block.GasUsed(), "fees", feesEth, "elapsed", common.PrettyDuration(time.Since(start))) case <-w.exitCh: log.Info("Worker has exited") diff --git a/l2geth/rollup/client.go b/l2geth/rollup/client.go index 6d2913eec12d..6daa260a8acc 100644 --- a/l2geth/rollup/client.go +++ b/l2geth/rollup/client.go @@ -238,7 +238,6 @@ func enqueueToTransaction(enqueue *Enqueue) (*types.Transaction, error) { blockNumber, timestamp, &origin, - types.SighashEIP155, types.QueueOriginL1ToL2, enqueue.Index, enqueue.QueueIndex, @@ -287,7 +286,6 @@ func batchedTransactionToTransaction(res *transaction, signer *types.EIP155Signe } else { return nil, fmt.Errorf("Unknown queue origin: %s", res.QueueOrigin) } - sighashType := types.SighashEIP155 // Transactions that have been decoded are // Queue Origin Sequencer transactions if res.Decoded != nil { @@ -312,7 +310,6 @@ func batchedTransactionToTransaction(res *transaction, signer *types.EIP155Signe new(big.Int).SetUint64(res.BlockNumber), res.Timestamp, res.Origin, - sighashType, queueOrigin, &res.Index, res.QueueIndex, @@ -353,7 +350,6 @@ func batchedTransactionToTransaction(res *transaction, signer *types.EIP155Signe new(big.Int).SetUint64(res.BlockNumber), res.Timestamp, origin, - sighashType, queueOrigin, &res.Index, res.QueueIndex, diff --git a/l2geth/signer/core/types.go b/l2geth/signer/core/types.go index 28ccea210c34..c9f2b2eb3128 100644 --- a/l2geth/signer/core/types.go +++ b/l2geth/signer/core/types.go @@ -78,10 +78,9 @@ type SendTxArgs struct { Data *hexutil.Bytes `json:"data"` Input *hexutil.Bytes `json:"input"` - L1MessageSender *common.MixedcaseAddress `json:"l1MessageSender"` - L1BlockNumber *big.Int `json:"l1BlockNumber"` - SignatureHashType types.SignatureHashType `json:"signatureHashType"` - QueueOrigin types.QueueOrigin `json:"queueOrigin"` + L1MessageSender *common.MixedcaseAddress `json:"l1MessageSender"` + L1BlockNumber *big.Int `json:"l1BlockNumber"` + QueueOrigin types.QueueOrigin `json:"queueOrigin"` } func (args SendTxArgs) String() string { @@ -111,7 +110,7 @@ func (args *SendTxArgs) toTransaction() *types.Transaction { } tx := types.NewTransaction(uint64(args.Nonce), args.To.Address(), (*big.Int)(&args.Value), (uint64)(args.Gas), (*big.Int)(&args.GasPrice), input) - txMeta := types.NewTransactionMeta(l1BlockNumber, 0, l1MessageSender, args.SignatureHashType, args.QueueOrigin, nil, nil, nil) + txMeta := types.NewTransactionMeta(l1BlockNumber, 0, l1MessageSender, args.QueueOrigin, nil, nil, nil) tx.SetTransactionMeta(txMeta) return tx } From 3be16c5bbc59613253f8cd0a397e2f9e2344adfe Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Tue, 4 May 2021 15:00:34 -0700 Subject: [PATCH 2/5] l2geth: no longer parse type in rollup client --- l2geth/rollup/client.go | 1 - 1 file changed, 1 deletion(-) diff --git a/l2geth/rollup/client.go b/l2geth/rollup/client.go index 6daa260a8acc..23c2bc9fff5f 100644 --- a/l2geth/rollup/client.go +++ b/l2geth/rollup/client.go @@ -74,7 +74,6 @@ type transaction struct { Origin *common.Address `json:"origin"` Data hexutil.Bytes `json:"data"` QueueOrigin string `json:"queueOrigin"` - Type string `json:"type"` QueueIndex *uint64 `json:"queueIndex"` Decoded *decoded `json:"decoded"` } From cf21eea0775cf03fe5233497ccd8db375dae3765 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Thu, 20 May 2021 11:47:37 +0300 Subject: [PATCH 3/5] chore: add changeset --- .changeset/six-seals-eat.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/six-seals-eat.md diff --git a/.changeset/six-seals-eat.md b/.changeset/six-seals-eat.md new file mode 100644 index 000000000000..89854eed54dc --- /dev/null +++ b/.changeset/six-seals-eat.md @@ -0,0 +1,5 @@ +--- +'@eth-optimism/l2geth': patch +--- + +Removes the SignatureHashType from l2geth as it is deprecated and no longer required. From af62a0c2fa399ce7d22356fd993826295f64271e Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Thu, 20 May 2021 12:00:57 +0300 Subject: [PATCH 4/5] chore: remove extra sighash params --- l2geth/core/rawdb/accessors_indexes_test.go | 6 +++--- l2geth/les/odr_test.go | 4 ++-- l2geth/light/odr_test.go | 2 +- l2geth/rollup/sync_service_test.go | 3 --- l2geth/tests/state_test_util.go | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/l2geth/core/rawdb/accessors_indexes_test.go b/l2geth/core/rawdb/accessors_indexes_test.go index f980bcf20976..74b3f08a71b8 100644 --- a/l2geth/core/rawdb/accessors_indexes_test.go +++ b/l2geth/core/rawdb/accessors_indexes_test.go @@ -73,15 +73,15 @@ func TestLookupStorage(t *testing.T) { l1BlockNumber2 := big.NewInt(2) tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) - tx1Meta := types.NewTransactionMeta(l1BlockNumber1, 0, &sender1, types.SighashEIP155, types.QueueOriginSequencer, nil, nil, nil) + tx1Meta := types.NewTransactionMeta(l1BlockNumber1, 0, &sender1, types.QueueOriginSequencer, nil, nil, nil) tx1.SetTransactionMeta(tx1Meta) tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) - tx2Meta := types.NewTransactionMeta(l1BlockNumber2, 0, &sender2, types.SighashEIP155, types.QueueOriginSequencer, nil, nil, nil) + tx2Meta := types.NewTransactionMeta(l1BlockNumber2, 0, &sender2, types.QueueOriginSequencer, nil, nil, nil) tx2.SetTransactionMeta(tx2Meta) tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) - tx3Meta := types.NewTransactionMeta(l1BlockNumber1, 0, nil, types.SighashEIP155, types.QueueOriginSequencer, nil, nil, nil) + tx3Meta := types.NewTransactionMeta(l1BlockNumber1, 0, nil, types.QueueOriginSequencer, nil, nil, nil) tx3.SetTransactionMeta(tx3Meta) txs := []*types.Transaction{tx1, tx2, tx3} diff --git a/l2geth/les/odr_test.go b/l2geth/les/odr_test.go index c1004326d093..42df067ac92e 100644 --- a/l2geth/les/odr_test.go +++ b/l2geth/les/odr_test.go @@ -128,7 +128,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai from := statedb.GetOrNewStateObject(bankAddr) from.SetBalance(math.MaxBig256) - msg := callmsg{types.NewMessage(from.Address(), &testContractAddr, 0, new(big.Int), 100000, new(big.Int), data, false, nil, nil, types.QueueOriginSequencer, 0)} + msg := callmsg{types.NewMessage(from.Address(), &testContractAddr, 0, new(big.Int), 100000, new(big.Int), data, false, nil, nil, types.QueueOriginSequencer)} context := core.NewEVMContext(msg, header, bc, nil) vmenv := vm.NewEVM(context, statedb, config, vm.Config{}) @@ -142,7 +142,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai header := lc.GetHeaderByHash(bhash) state := light.NewState(ctx, header, lc.Odr()) state.SetBalance(bankAddr, math.MaxBig256) - msg := callmsg{types.NewMessage(bankAddr, &testContractAddr, 0, new(big.Int), 100000, new(big.Int), data, false, nil, nil, types.QueueOriginSequencer, 0)} + msg := callmsg{types.NewMessage(bankAddr, &testContractAddr, 0, new(big.Int), 100000, new(big.Int), data, false, nil, nil, types.QueueOriginSequencer)} context := core.NewEVMContext(msg, header, lc, nil) vmenv := vm.NewEVM(context, state, config, vm.Config{}) gp := new(core.GasPool).AddGas(math.MaxUint64) diff --git a/l2geth/light/odr_test.go b/l2geth/light/odr_test.go index 387f705b0315..70873e74f9e2 100644 --- a/l2geth/light/odr_test.go +++ b/l2geth/light/odr_test.go @@ -194,7 +194,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, bc *core.BlockChain // Perform read-only call. st.SetBalance(testBankAddress, math.MaxBig256) - msg := callmsg{types.NewMessage(testBankAddress, &testContractAddr, 0, new(big.Int), 1000000, new(big.Int), data, false, nil, nil, types.QueueOriginSequencer, 0)} + msg := callmsg{types.NewMessage(testBankAddress, &testContractAddr, 0, new(big.Int), 1000000, new(big.Int), data, false, nil, nil, types.QueueOriginSequencer)} context := core.NewEVMContext(msg, header, chain, nil) vmenv := vm.NewEVM(context, st, config, vm.Config{}) gp := new(core.GasPool).AddGas(math.MaxUint64) diff --git a/l2geth/rollup/sync_service_test.go b/l2geth/rollup/sync_service_test.go index f5e2ea175bfa..3f55f7d2b68a 100644 --- a/l2geth/rollup/sync_service_test.go +++ b/l2geth/rollup/sync_service_test.go @@ -118,7 +118,6 @@ func TestSyncServiceTransactionEnqueued(t *testing.T) { l1BlockNumber, timestamp, &l1TxOrigin, - types.SighashEIP155, types.QueueOriginL1ToL2, &index, &queueIndex, @@ -203,7 +202,6 @@ func TestSyncServiceSync(t *testing.T) { l1BlockNumber, timestamp, &l1TxOrigin, - types.SighashEIP155, types.QueueOriginL1ToL2, &index, &queueIndex, @@ -252,7 +250,6 @@ func TestInitializeL1ContextPostGenesis(t *testing.T) { l1BlockNumber, timestamp, &l1TxOrigin, - types.SighashEIP155, types.QueueOriginL1ToL2, &index, &queueIndex, diff --git a/l2geth/tests/state_test_util.go b/l2geth/tests/state_test_util.go index fd1e679ae44d..26e6607ef241 100644 --- a/l2geth/tests/state_test_util.go +++ b/l2geth/tests/state_test_util.go @@ -279,7 +279,7 @@ func (tx *stTransaction) toMessage(ps stPostState) (core.Message, error) { return nil, fmt.Errorf("invalid tx data %q", dataHex) } - msg := types.NewMessage(from, to, tx.Nonce, value, gasLimit, tx.GasPrice, data, true, nil, nil, types.QueueOriginSequencer, 0) + msg := types.NewMessage(from, to, tx.Nonce, value, gasLimit, tx.GasPrice, data, true, nil, nil, types.QueueOriginSequencer) return msg, nil } From 0d396311765cd96d68ffb53572d38c37f12959c3 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Thu, 20 May 2021 12:35:37 +0300 Subject: [PATCH 5/5] fix: do not check txtype in integration tests --- integration-tests/test/queue-ingestion.spec.ts | 2 -- integration-tests/test/rpc.spec.ts | 2 -- l2geth/core/types/transaction.go | 1 - packages/core-utils/src/l2context.ts | 1 - 4 files changed, 6 deletions(-) diff --git a/integration-tests/test/queue-ingestion.spec.ts b/integration-tests/test/queue-ingestion.spec.ts index bf252fcf0f0d..11dd4289677a 100644 --- a/integration-tests/test/queue-ingestion.spec.ts +++ b/integration-tests/test/queue-ingestion.spec.ts @@ -86,8 +86,6 @@ describe('Queue Ingestion', () => { // The `to` addresses are defined in the previous test and // increment sequentially. expect(tx.to).to.be.equal('0x' + `${i}`.repeat(40)) - // The transaction type is EIP155 - expect(tx.txType).to.be.equal('EIP155') // The queue origin is Layer 1 expect(tx.queueOrigin).to.be.equal('l1') // the L1TxOrigin is equal to the Layer one from diff --git a/integration-tests/test/rpc.spec.ts b/integration-tests/test/rpc.spec.ts index b0e0a3222ffe..164b31c4079e 100644 --- a/integration-tests/test/rpc.spec.ts +++ b/integration-tests/test/rpc.spec.ts @@ -238,7 +238,6 @@ describe('Basic RPC tests', () => { await result.wait() const transaction = (await provider.getTransaction(result.hash)) as any - expect(transaction.txType).to.equal('EIP155') expect(transaction.queueOrigin).to.equal('sequencer') expect(transaction.transactionIndex).to.be.eq(0) expect(transaction.gasLimit).to.be.deep.eq(BigNumber.from(tx.gasLimit)) @@ -259,7 +258,6 @@ describe('Basic RPC tests', () => { expect(block.number).to.not.equal(0) expect(typeof block.stateRoot).to.equal('string') expect(block.transactions.length).to.equal(1) - expect(block.transactions[0].txType).to.equal('EIP155') expect(block.transactions[0].queueOrigin).to.equal('sequencer') expect(block.transactions[0].l1TxOrigin).to.equal(null) }) diff --git a/l2geth/core/types/transaction.go b/l2geth/core/types/transaction.go index 57b4d4834da4..ffcc2aa08d7c 100644 --- a/l2geth/core/types/transaction.go +++ b/l2geth/core/types/transaction.go @@ -76,7 +76,6 @@ func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit u return newTransaction(nonce, &to, amount, gasLimit, gasPrice, data) } -// TODO: cannot deploy contracts with SighashEthSign right until SighashEIP155 is no longer hardcoded func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { return newTransaction(nonce, nil, amount, gasLimit, gasPrice, data) } diff --git a/packages/core-utils/src/l2context.ts b/packages/core-utils/src/l2context.ts index 0fe7f771b7eb..18e526ba2e10 100644 --- a/packages/core-utils/src/l2context.ts +++ b/packages/core-utils/src/l2context.ts @@ -31,7 +31,6 @@ export const injectL2Context = (l1Provider: providers.JsonRpcProvider) => { ) } b.transactions[i].l1TxOrigin = block.transactions[i].l1TxOrigin - b.transactions[i].txType = block.transactions[i].txType b.transactions[i].queueOrigin = block.transactions[i].queueOrigin b.transactions[i].rawTransaction = block.transactions[i].rawTransaction }