Commit 25a5dbdd authored by Mark Tyneway's avatar Mark Tyneway Committed by Kelvin Fichter

l2geth: remove `SignatureHashType` (#752)

* l2geth: remove tx type

* l2geth: no longer parse type in rollup client

* chore: add changeset

* chore: remove extra sighash params

* fix: do not check txtype in integration tests
Co-authored-by: default avatarGeorgios Konstantopoulos <me@gakonst.com>
parent 6b46c8ba
---
'@eth-optimism/l2geth': patch
---
Removes the SignatureHashType from l2geth as it is deprecated and no longer required.
......@@ -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
......
......@@ -249,7 +249,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))
......@@ -270,7 +269,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)
})
......
......@@ -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.
......
......@@ -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")
}
}
......@@ -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}
......
......@@ -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.
......
......@@ -156,7 +156,6 @@ func modMessage(
msg.L1MessageSender(),
msg.L1BlockNumber(),
queueOrigin,
msg.SignatureHashType(),
)
return outmsg, nil
......
......@@ -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")
}
......
......@@ -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
......@@ -85,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)
}
......@@ -95,7 +85,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,
......@@ -231,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.
......@@ -318,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
......@@ -534,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,
......@@ -551,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)),
}
}
......@@ -567,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 }
......@@ -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())
......
......@@ -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 {
......
......@@ -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())
}
}
......@@ -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
......
......@@ -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"]
......@@ -1375,15 +1375,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
}
......@@ -1616,9 +1607,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.
......@@ -1691,13 +1681,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
}
......@@ -1794,7 +1784,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)
}
......@@ -2151,7 +2141,6 @@ func (api *PrivateDebugAPI) IngestTransactions(txs []*RPCTransaction) error {
l1Timestamp := uint64(tx.L1Timestamp)
rawTransaction := tx.RawTransaction
sighashType := types.SighashEIP155
var queueOrigin types.QueueOrigin
switch tx.QueueOrigin {
case "sequencer":
......@@ -2170,14 +2159,13 @@ func (api *PrivateDebugAPI) IngestTransactions(txs []*RPCTransaction) error {
}
meta := types.TransactionMeta{
L1BlockNumber: l1BlockNumber,
L1Timestamp: l1Timestamp,
L1MessageSender: tx.L1TxOrigin,
SignatureHashType: sighashType,
QueueOrigin: big.NewInt(int64(queueOrigin)),
Index: (*uint64)(tx.Index),
QueueIndex: (*uint64)(tx.QueueIndex),
RawTransaction: rawTransaction,
L1BlockNumber: l1BlockNumber,
L1Timestamp: l1Timestamp,
L1MessageSender: tx.L1TxOrigin,
QueueOrigin: big.NewInt(int64(queueOrigin)),
Index: (*uint64)(tx.Index),
QueueIndex: (*uint64)(tx.QueueIndex),
RawTransaction: rawTransaction,
}
transaction.SetTransactionMeta(&meta)
transactions[i] = transaction
......
......@@ -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)
......
......@@ -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)
......
......@@ -1073,7 +1073,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")
......
......@@ -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"`
}
......@@ -241,7 +240,6 @@ func enqueueToTransaction(enqueue *Enqueue) (*types.Transaction, error) {
blockNumber,
timestamp,
&origin,
types.SighashEIP155,
types.QueueOriginL1ToL2,
enqueue.Index,
enqueue.QueueIndex,
......@@ -327,7 +325,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 {
......@@ -352,7 +349,6 @@ func batchedTransactionToTransaction(res *transaction, signer *types.EIP155Signe
new(big.Int).SetUint64(res.BlockNumber),
res.Timestamp,
res.Origin,
sighashType,
queueOrigin,
&res.Index,
res.QueueIndex,
......@@ -393,7 +389,6 @@ func batchedTransactionToTransaction(res *transaction, signer *types.EIP155Signe
new(big.Int).SetUint64(res.BlockNumber),
res.Timestamp,
origin,
sighashType,
queueOrigin,
&res.Index,
res.QueueIndex,
......
......@@ -121,7 +121,6 @@ func TestSyncServiceTransactionEnqueued(t *testing.T) {
l1BlockNumber,
timestamp,
&l1TxOrigin,
types.SighashEIP155,
types.QueueOriginL1ToL2,
&index,
&queueIndex,
......@@ -570,7 +569,6 @@ func TestSyncServiceSync(t *testing.T) {
l1BlockNumber,
timestamp,
&l1TxOrigin,
types.SighashEIP155,
types.QueueOriginL1ToL2,
&index,
&queueIndex,
......@@ -622,7 +620,6 @@ func TestInitializeL1ContextPostGenesis(t *testing.T) {
l1BlockNumber,
timestamp,
&l1TxOrigin,
types.SighashEIP155,
types.QueueOriginL1ToL2,
&index,
&queueIndex,
......
......@@ -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
}
......@@ -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
}
......
......@@ -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
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment