Skip to content

Commit

Permalink
core/tx: remove txid, replace with l1blocknumber (ethereum#78)
Browse files Browse the repository at this point in the history
* core/tx: remove txid, replace with l1blocknumber

* txmeta/test: remove dead code

* tx: remove dead code

* tmeta: allow for dynamic origin

* rollup: properly assign l1blocknumber
  • Loading branch information
tynes authored Nov 4, 2020
1 parent c424513 commit 5670f82
Show file tree
Hide file tree
Showing 17 changed files with 201 additions and 240 deletions.
3 changes: 1 addition & 2 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
Expand Down Expand Up @@ -602,7 +601,7 @@ 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) L1RollupTxId() *hexutil.Uint64 { return m.CallMsg.L1RollupTxId }
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
Expand Down
13 changes: 6 additions & 7 deletions core/rawdb/accessors_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
Expand Down Expand Up @@ -437,8 +436,8 @@ func TestBlockMetaStorage(t *testing.T) {
if meta.L1MessageSender != nil {
t.Fatalf("Could not recover L1MessageSender")
}
if meta.L1RollupTxId != nil {
t.Fatalf("Could not recover L1RollupTxId")
if meta.L1BlockNumber != nil {
t.Fatalf("Could not recover L1BlockNumber")
}

if meta.SignatureHashType != types.SighashEIP155 {
Expand All @@ -453,9 +452,9 @@ func TestBlockMetaStorage(t *testing.T) {
}

addr := common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87")
txid := hexutil.Uint64(777)
l1BlockNumber := big.NewInt(777)

tx2 := types.NewTransaction(2, common.HexToAddress("0x02"), big.NewInt(2), 2, big.NewInt(2), nil, &addr, &txid, types.QueueOriginSequencer, types.SighashEthSign)
tx2 := types.NewTransaction(2, common.HexToAddress("0x02"), big.NewInt(2), 2, big.NewInt(2), nil, &addr, l1BlockNumber, types.QueueOriginSequencer, types.SighashEthSign)

WriteTransactionMeta(db, tx2.Hash(), tx2.GetMeta())
meta2 := ReadTransactionMeta(db, tx2.Hash())
Expand All @@ -464,8 +463,8 @@ func TestBlockMetaStorage(t *testing.T) {
t.Fatalf("Could not recover L1MessageSender")
}

if *meta2.L1RollupTxId != txid {
t.Fatalf("Could not recover L1RollupTxId")
if meta2.L1BlockNumber.Cmp(l1BlockNumber) != 0 {
t.Fatalf("Could not recover L1BlockNumber")
}
if meta2.SignatureHashType != types.SighashEthSign {
t.Fatalf("Could not recover sighash type")
Expand Down
12 changes: 5 additions & 7 deletions core/rawdb/accessors_indexes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import (
"math/big"
"testing"

"github.com/ethereum/go-ethereum/common/hexutil"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
Expand Down Expand Up @@ -71,12 +69,12 @@ func TestLookupStorage(t *testing.T) {
sender1 := common.BytesToAddress([]byte{0x44})
sender2 := common.BytesToAddress([]byte{0x55})

l1RollupTxId1 := hexutil.Uint64(1)
l1RollupTxId2 := hexutil.Uint64(2)
l1BlockNumber1 := big.NewInt(1)
l1BlockNumber2 := big.NewInt(2)

tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}, &sender1, &l1RollupTxId1, types.QueueOriginSequencer, types.SighashEIP155)
tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}, &sender2, &l1RollupTxId2, types.QueueOriginSequencer, types.SighashEIP155)
tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}, nil, &l1RollupTxId1, types.QueueOriginSequencer, types.SighashEIP155)
tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}, &sender1, l1BlockNumber1, types.QueueOriginSequencer, types.SighashEIP155)
tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}, &sender2, l1BlockNumber2, types.QueueOriginSequencer, types.SighashEIP155)
tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}, nil, l1BlockNumber1, types.QueueOriginSequencer, types.SighashEIP155)
txs := []*types.Transaction{tx1, tx2, tx3}

block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, nil)
Expand Down
2 changes: 1 addition & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ type Message interface {
CheckNonce() bool
Data() []byte
L1MessageSender() *common.Address
L1RollupTxId() *hexutil.Uint64
L1BlockNumber() *big.Int
QueueOrigin() *big.Int
}

Expand Down
136 changes: 57 additions & 79 deletions core/types/gen_tx_json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions core/types/gen_tx_meta_json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5670f82

Please sign in to comment.