Commit 8ae39154 authored by Joshua Gutow's avatar Joshua Gutow Committed by GitHub

op-node: Use unmetered L1 Attributes Transaction (#3157)

* op-node: Use unmetered L1 Attributes Transaction

This enables the IsSystemTransaction flag in the L1 Attributes
deposit & updates to the latest version of geth.

* specs updates

* Update specs/deposits.md

* feat: bedrock deposit transaction type update

* bedrock: update geth dependency

* fix(core-utils): bedrock deposit tx encode/decode typescript fixes

* feat(packages/contracts-bedrock): update UserDepositTransaction type and encoding to handle isSystemTransaction bool

* contracts-bedrock: update differential deposit tx solidity <> js fuzzing

* core-utils

* contracts-bedrock

* contracts-bedrock: fix test

* contracts-bedrock: fix differential tests

* contracts-bedrock: fix broken test

* contracts-bedrock: gas snapshot
Co-authored-by: default avatarprotolambda <proto@protolambda.com>
Co-authored-by: default avatarMark Tyneway <mark.tyneway@gmail.com>
parent acdea79d
---
'@eth-optimism/contracts-bedrock': patch
'@eth-optimism/core-utils': patch
---
Update deposit transaction type
...@@ -18,7 +18,7 @@ use ( ...@@ -18,7 +18,7 @@ use (
./state-surgery ./state-surgery
) )
replace github.com/ethereum/go-ethereum v1.10.20 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d replace github.com/ethereum/go-ethereum v1.10.21 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220803173305-1c9d4cc76a6e
// For local debugging: // For local debugging:
//replace github.com/ethereum/go-ethereum v1.10.20 => ../go-ethereum //replace github.com/ethereum/go-ethereum v1.10.21 => ../go-ethereum
...@@ -5,7 +5,7 @@ go 1.18 ...@@ -5,7 +5,7 @@ go 1.18
require ( require (
github.com/ethereum-optimism/optimism/op-node v0.3.0 github.com/ethereum-optimism/optimism/op-node v0.3.0
github.com/ethereum-optimism/optimism/op-proposer v0.3.0 github.com/ethereum-optimism/optimism/op-proposer v0.3.0
github.com/ethereum/go-ethereum v1.10.20 github.com/ethereum/go-ethereum v1.10.21
github.com/miguelmota/go-ethereum-hdwallet v0.1.1 github.com/miguelmota/go-ethereum-hdwallet v0.1.1
github.com/urfave/cli v1.22.5 github.com/urfave/cli v1.22.5
) )
...@@ -54,4 +54,4 @@ require ( ...@@ -54,4 +54,4 @@ require (
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
) )
replace github.com/ethereum/go-ethereum v1.10.20 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d replace github.com/ethereum/go-ethereum v1.10.21 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220803173305-1c9d4cc76a6e
...@@ -153,8 +153,8 @@ github.com/ethereum-optimism/optimism/op-node v0.3.0 h1:jep/cbIbP7fjBSAR48yk5NJV ...@@ -153,8 +153,8 @@ github.com/ethereum-optimism/optimism/op-node v0.3.0 h1:jep/cbIbP7fjBSAR48yk5NJV
github.com/ethereum-optimism/optimism/op-node v0.3.0/go.mod h1:iF9AhYjr8jNeoCDNP/Vs/ywQ2USZU5L66AxZbSAUi0E= github.com/ethereum-optimism/optimism/op-node v0.3.0/go.mod h1:iF9AhYjr8jNeoCDNP/Vs/ywQ2USZU5L66AxZbSAUi0E=
github.com/ethereum-optimism/optimism/op-proposer v0.3.0 h1:K1ipZt3TLD0BJi7tKOmx8tCLXj9i4f4baBIhbPmUxk4= github.com/ethereum-optimism/optimism/op-proposer v0.3.0 h1:K1ipZt3TLD0BJi7tKOmx8tCLXj9i4f4baBIhbPmUxk4=
github.com/ethereum-optimism/optimism/op-proposer v0.3.0/go.mod h1:GcQ9VCWz2zEVexecq5IYo/2eadK/y7IBOEfx4YV1QJk= github.com/ethereum-optimism/optimism/op-proposer v0.3.0/go.mod h1:GcQ9VCWz2zEVexecq5IYo/2eadK/y7IBOEfx4YV1QJk=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d h1:w0DBXhp0sv0bWRDOCA/Y6yHOALU7qLLLf5/kE3YfFr4= github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220803173305-1c9d4cc76a6e h1:hz+iywXjnqz6xA3lTLvtNL9OZyX76pS5SER4kZBmQLs=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d/go.mod h1:m2m08SAQ8XB0VcVBoDg9n74Dw5PUMl3hzv1NXVBFPfg= github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220803173305-1c9d4cc76a6e/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg=
github.com/ethereum/go-ethereum v1.10.4/go.mod h1:nEE0TP5MtxGzOMd7egIrbPJMQBnhVU3ELNxhBglIzhg= github.com/ethereum/go-ethereum v1.10.4/go.mod h1:nEE0TP5MtxGzOMd7egIrbPJMQBnhVU3ELNxhBglIzhg=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
......
...@@ -3,7 +3,7 @@ module github.com/ethereum-optimism/optimism/op-bindings ...@@ -3,7 +3,7 @@ module github.com/ethereum-optimism/optimism/op-bindings
go 1.18 go 1.18
require ( require (
github.com/ethereum/go-ethereum v1.10.20 github.com/ethereum/go-ethereum v1.10.21
github.com/stretchr/testify v1.7.2 github.com/stretchr/testify v1.7.2
) )
...@@ -41,4 +41,4 @@ require ( ...@@ -41,4 +41,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )
replace github.com/ethereum/go-ethereum v1.10.20 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d replace github.com/ethereum/go-ethereum v1.10.21 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220803173305-1c9d4cc76a6e
...@@ -28,8 +28,8 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1 ...@@ -28,8 +28,8 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw= github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d h1:w0DBXhp0sv0bWRDOCA/Y6yHOALU7qLLLf5/kE3YfFr4= github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220803173305-1c9d4cc76a6e h1:hz+iywXjnqz6xA3lTLvtNL9OZyX76pS5SER4kZBmQLs=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d/go.mod h1:m2m08SAQ8XB0VcVBoDg9n74Dw5PUMl3hzv1NXVBFPfg= github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220803173305-1c9d4cc76a6e/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
......
...@@ -7,7 +7,7 @@ require ( ...@@ -7,7 +7,7 @@ require (
github.com/ethereum-optimism/optimism/op-bindings v0.3.0 github.com/ethereum-optimism/optimism/op-bindings v0.3.0
github.com/ethereum-optimism/optimism/op-node v0.3.0 github.com/ethereum-optimism/optimism/op-node v0.3.0
github.com/ethereum-optimism/optimism/op-proposer v0.3.0 github.com/ethereum-optimism/optimism/op-proposer v0.3.0
github.com/ethereum/go-ethereum v1.10.20 github.com/ethereum/go-ethereum v1.10.21
github.com/libp2p/go-libp2p v0.18.1 github.com/libp2p/go-libp2p v0.18.1
github.com/libp2p/go-libp2p-core v0.15.0 github.com/libp2p/go-libp2p-core v0.15.0
github.com/miguelmota/go-ethereum-hdwallet v0.1.1 github.com/miguelmota/go-ethereum-hdwallet v0.1.1
...@@ -161,4 +161,4 @@ require ( ...@@ -161,4 +161,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )
replace github.com/ethereum/go-ethereum v1.10.20 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d replace github.com/ethereum/go-ethereum v1.10.21 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220803173305-1c9d4cc76a6e
...@@ -245,8 +245,8 @@ github.com/ethereum-optimism/optimism/op-node v0.3.0 h1:jep/cbIbP7fjBSAR48yk5NJV ...@@ -245,8 +245,8 @@ github.com/ethereum-optimism/optimism/op-node v0.3.0 h1:jep/cbIbP7fjBSAR48yk5NJV
github.com/ethereum-optimism/optimism/op-node v0.3.0/go.mod h1:iF9AhYjr8jNeoCDNP/Vs/ywQ2USZU5L66AxZbSAUi0E= github.com/ethereum-optimism/optimism/op-node v0.3.0/go.mod h1:iF9AhYjr8jNeoCDNP/Vs/ywQ2USZU5L66AxZbSAUi0E=
github.com/ethereum-optimism/optimism/op-proposer v0.3.0 h1:K1ipZt3TLD0BJi7tKOmx8tCLXj9i4f4baBIhbPmUxk4= github.com/ethereum-optimism/optimism/op-proposer v0.3.0 h1:K1ipZt3TLD0BJi7tKOmx8tCLXj9i4f4baBIhbPmUxk4=
github.com/ethereum-optimism/optimism/op-proposer v0.3.0/go.mod h1:GcQ9VCWz2zEVexecq5IYo/2eadK/y7IBOEfx4YV1QJk= github.com/ethereum-optimism/optimism/op-proposer v0.3.0/go.mod h1:GcQ9VCWz2zEVexecq5IYo/2eadK/y7IBOEfx4YV1QJk=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d h1:w0DBXhp0sv0bWRDOCA/Y6yHOALU7qLLLf5/kE3YfFr4= github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220803173305-1c9d4cc76a6e h1:hz+iywXjnqz6xA3lTLvtNL9OZyX76pS5SER4kZBmQLs=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d/go.mod h1:m2m08SAQ8XB0VcVBoDg9n74Dw5PUMl3hzv1NXVBFPfg= github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220803173305-1c9d4cc76a6e/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg=
github.com/ethereum/go-ethereum v1.10.4/go.mod h1:nEE0TP5MtxGzOMd7egIrbPJMQBnhVU3ELNxhBglIzhg= github.com/ethereum/go-ethereum v1.10.4/go.mod h1:nEE0TP5MtxGzOMd7egIrbPJMQBnhVU3ELNxhBglIzhg=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
......
...@@ -4,7 +4,7 @@ go 1.18 ...@@ -4,7 +4,7 @@ go 1.18
require ( require (
github.com/ethereum-optimism/optimism/op-bindings v0.3.0 github.com/ethereum-optimism/optimism/op-bindings v0.3.0
github.com/ethereum/go-ethereum v1.10.20 github.com/ethereum/go-ethereum v1.10.21
github.com/golang/snappy v0.0.4 github.com/golang/snappy v0.0.4
github.com/google/go-cmp v0.5.8 github.com/google/go-cmp v0.5.8
github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/go-multierror v1.1.1
...@@ -173,7 +173,4 @@ require ( ...@@ -173,7 +173,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )
replace github.com/ethereum/go-ethereum v1.10.20 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d replace github.com/ethereum/go-ethereum v1.10.21 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220803173305-1c9d4cc76a6e
// For local debugging:
// replace github.com/ethereum/go-ethereum v1.10.17 => ../go-ethereum
...@@ -193,8 +193,8 @@ github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go. ...@@ -193,8 +193,8 @@ github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum-optimism/optimism/op-bindings v0.3.0 h1:d2Mwb8FzR2zuhW0sS5xFKWz/6VFPTEIE+XINqZj0Rv4= github.com/ethereum-optimism/optimism/op-bindings v0.3.0 h1:d2Mwb8FzR2zuhW0sS5xFKWz/6VFPTEIE+XINqZj0Rv4=
github.com/ethereum-optimism/optimism/op-bindings v0.3.0/go.mod h1:CrvUVIISKcyJ7o27ub/HY4Kq9wEJQxrGmWthTqxPSGo= github.com/ethereum-optimism/optimism/op-bindings v0.3.0/go.mod h1:CrvUVIISKcyJ7o27ub/HY4Kq9wEJQxrGmWthTqxPSGo=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d h1:w0DBXhp0sv0bWRDOCA/Y6yHOALU7qLLLf5/kE3YfFr4= github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220803173305-1c9d4cc76a6e h1:hz+iywXjnqz6xA3lTLvtNL9OZyX76pS5SER4kZBmQLs=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d/go.mod h1:m2m08SAQ8XB0VcVBoDg9n74Dw5PUMl3hzv1NXVBFPfg= github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220803173305-1c9d4cc76a6e/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fjl/memsize v0.0.1 h1:+zhkb+dhUgx0/e+M8sF0QqiouvMQUiKR+QYvdxIOKcQ= github.com/fjl/memsize v0.0.1 h1:+zhkb+dhUgx0/e+M8sF0QqiouvMQUiKR+QYvdxIOKcQ=
github.com/fjl/memsize v0.0.1/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fjl/memsize v0.0.1/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
......
...@@ -77,6 +77,7 @@ func UnmarshalDepositLogEvent(ev *types.Log) (*types.DepositTx, error) { ...@@ -77,6 +77,7 @@ func UnmarshalDepositLogEvent(ev *types.Log) (*types.DepositTx, error) {
} }
dep.SourceHash = source.SourceHash() dep.SourceHash = source.SourceHash()
dep.From = from dep.From = from
dep.IsSystemTransaction = false
var err error var err error
switch version { switch version {
......
...@@ -102,17 +102,17 @@ func L1InfoDeposit(seqNumber uint64, block eth.L1Info) (*types.DepositTx, error) ...@@ -102,17 +102,17 @@ func L1InfoDeposit(seqNumber uint64, block eth.L1Info) (*types.DepositTx, error)
L1BlockHash: block.Hash(), L1BlockHash: block.Hash(),
SeqNumber: seqNumber, SeqNumber: seqNumber,
} }
// Uses ~30k normal case // Set a very large gas limit with `IsSystemTransaction` to ensure
// Uses ~70k on first transaction // that the L1 Attributes Transaction does not run out of gas.
// Round up to 75k to ensure that we always have enough gas.
return &types.DepositTx{ return &types.DepositTx{
SourceHash: source.SourceHash(), SourceHash: source.SourceHash(),
From: L1InfoDepositerAddress, From: L1InfoDepositerAddress,
To: &L1BlockAddress, To: &L1BlockAddress,
Mint: nil, Mint: nil,
Value: big.NewInt(0), Value: big.NewInt(0),
Gas: 150_000, // TODO: temporary work around. Block 1 seems to require more gas than specced. Gas: 150_000_000,
Data: data, IsSystemTransaction: true,
Data: data,
}, nil }, nil
} }
......
...@@ -25,13 +25,14 @@ func GenerateDeposit(sourceHash common.Hash, rng *rand.Rand) *types.DepositTx { ...@@ -25,13 +25,14 @@ func GenerateDeposit(sourceHash common.Hash, rng *rand.Rand) *types.DepositTx {
} }
dep := &types.DepositTx{ dep := &types.DepositTx{
SourceHash: sourceHash, SourceHash: sourceHash,
From: RandomAddress(rng), From: RandomAddress(rng),
To: to, To: to,
Value: RandomETH(rng, 200), Value: RandomETH(rng, 200),
Gas: uint64(rng.Int63n(10 * 1e6)), // 10 M gas max Gas: uint64(rng.Int63n(10 * 1e6)), // 10 M gas max
Data: data, Data: data,
Mint: mint, Mint: mint,
IsSystemTransaction: false,
} }
return dep return dep
} }
......
...@@ -5,7 +5,7 @@ go 1.18 ...@@ -5,7 +5,7 @@ go 1.18
require ( require (
github.com/ethereum-optimism/optimism/op-bindings v0.3.0 github.com/ethereum-optimism/optimism/op-bindings v0.3.0
github.com/ethereum-optimism/optimism/op-node v0.3.0 github.com/ethereum-optimism/optimism/op-node v0.3.0
github.com/ethereum/go-ethereum v1.10.20 github.com/ethereum/go-ethereum v1.10.21
github.com/miguelmota/go-ethereum-hdwallet v0.1.1 github.com/miguelmota/go-ethereum-hdwallet v0.1.1
github.com/stretchr/testify v1.8.0 github.com/stretchr/testify v1.8.0
github.com/urfave/cli v1.22.5 github.com/urfave/cli v1.22.5
...@@ -60,4 +60,4 @@ require ( ...@@ -60,4 +60,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )
replace github.com/ethereum/go-ethereum v1.10.20 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d replace github.com/ethereum/go-ethereum v1.10.21 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220803173305-1c9d4cc76a6e
...@@ -181,8 +181,8 @@ github.com/ethereum-optimism/optimism/op-bindings v0.3.0 h1:d2Mwb8FzR2zuhW0sS5xF ...@@ -181,8 +181,8 @@ github.com/ethereum-optimism/optimism/op-bindings v0.3.0 h1:d2Mwb8FzR2zuhW0sS5xF
github.com/ethereum-optimism/optimism/op-bindings v0.3.0/go.mod h1:CrvUVIISKcyJ7o27ub/HY4Kq9wEJQxrGmWthTqxPSGo= github.com/ethereum-optimism/optimism/op-bindings v0.3.0/go.mod h1:CrvUVIISKcyJ7o27ub/HY4Kq9wEJQxrGmWthTqxPSGo=
github.com/ethereum-optimism/optimism/op-node v0.3.0 h1:jep/cbIbP7fjBSAR48yk5NJVEoGYvoNlYI00KpBI6Mw= github.com/ethereum-optimism/optimism/op-node v0.3.0 h1:jep/cbIbP7fjBSAR48yk5NJVEoGYvoNlYI00KpBI6Mw=
github.com/ethereum-optimism/optimism/op-node v0.3.0/go.mod h1:iF9AhYjr8jNeoCDNP/Vs/ywQ2USZU5L66AxZbSAUi0E= github.com/ethereum-optimism/optimism/op-node v0.3.0/go.mod h1:iF9AhYjr8jNeoCDNP/Vs/ywQ2USZU5L66AxZbSAUi0E=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d h1:w0DBXhp0sv0bWRDOCA/Y6yHOALU7qLLLf5/kE3YfFr4= github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220803173305-1c9d4cc76a6e h1:hz+iywXjnqz6xA3lTLvtNL9OZyX76pS5SER4kZBmQLs=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d/go.mod h1:m2m08SAQ8XB0VcVBoDg9n74Dw5PUMl3hzv1NXVBFPfg= github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220803173305-1c9d4cc76a6e/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg=
github.com/ethereum/go-ethereum v1.10.4/go.mod h1:nEE0TP5MtxGzOMd7egIrbPJMQBnhVU3ELNxhBglIzhg= github.com/ethereum/go-ethereum v1.10.4/go.mod h1:nEE0TP5MtxGzOMd7egIrbPJMQBnhVU3ELNxhBglIzhg=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
......
...@@ -135,10 +135,10 @@ OptimismPortalUpgradeable_Test:test_cannotInitImpl() (gas: 10813) ...@@ -135,10 +135,10 @@ OptimismPortalUpgradeable_Test:test_cannotInitImpl() (gas: 10813)
OptimismPortalUpgradeable_Test:test_cannotInitProxy() (gas: 15789) OptimismPortalUpgradeable_Test:test_cannotInitProxy() (gas: 15789)
OptimismPortalUpgradeable_Test:test_initValuesOnProxy() (gas: 15967) OptimismPortalUpgradeable_Test:test_initValuesOnProxy() (gas: 15967)
OptimismPortalUpgradeable_Test:test_upgrading() (gas: 180632) OptimismPortalUpgradeable_Test:test_upgrading() (gas: 180632)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_revertsOnInsufficientGas() (gas: 160743) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_revertsOnInsufficientGas() (gas: 160788)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_revertsOnInvalidOutputRootProof() (gas: 81241) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_revertsOnInvalidOutputRootProof() (gas: 81241)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_revertsOnRecentWithdrawal() (gas: 53001) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_revertsOnRecentWithdrawal() (gas: 53001)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_revertsOnReentrancy() (gas: 205521) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_revertsOnReentrancy() (gas: 205566)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_revertsOnReplay() (gas: 278941) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_revertsOnReplay() (gas: 278941)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_revertsOnSelfCall() (gas: 50539) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_revertsOnSelfCall() (gas: 50539)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_revertsOninvalidWithdrawalProof() (gas: 148562) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_revertsOninvalidWithdrawalProof() (gas: 148562)
......
...@@ -13,6 +13,8 @@ library Encoding { ...@@ -13,6 +13,8 @@ library Encoding {
/** /**
* @notice RLP encodes the L2 transaction that would be generated when a given deposit is sent * @notice RLP encodes the L2 transaction that would be generated when a given deposit is sent
* to the L2 system. Useful for searching for a deposit in the L2 system. * to the L2 system. Useful for searching for a deposit in the L2 system.
* This currently only supports user deposits and not system
* transactions.
* *
* @param _tx User deposit transaction to encode. * @param _tx User deposit transaction to encode.
* *
...@@ -24,14 +26,15 @@ library Encoding { ...@@ -24,14 +26,15 @@ library Encoding {
returns (bytes memory) returns (bytes memory)
{ {
bytes32 source = Hashing.hashDepositSource(_tx.l1BlockHash, _tx.logIndex); bytes32 source = Hashing.hashDepositSource(_tx.l1BlockHash, _tx.logIndex);
bytes[] memory raw = new bytes[](7); bytes[] memory raw = new bytes[](8);
raw[0] = RLPWriter.writeBytes(abi.encodePacked(source)); raw[0] = RLPWriter.writeBytes(abi.encodePacked(source));
raw[1] = RLPWriter.writeAddress(_tx.from); raw[1] = RLPWriter.writeAddress(_tx.from);
raw[2] = _tx.isCreation ? RLPWriter.writeBytes("") : RLPWriter.writeAddress(_tx.to); raw[2] = _tx.isCreation ? RLPWriter.writeBytes("") : RLPWriter.writeAddress(_tx.to);
raw[3] = RLPWriter.writeUint(_tx.mint); raw[3] = RLPWriter.writeUint(_tx.mint);
raw[4] = RLPWriter.writeUint(_tx.value); raw[4] = RLPWriter.writeUint(_tx.value);
raw[5] = RLPWriter.writeUint(uint256(_tx.gasLimit)); raw[5] = RLPWriter.writeUint(uint256(_tx.gasLimit));
raw[6] = RLPWriter.writeBytes(_tx.data); raw[6] = RLPWriter.writeBool(false);
raw[7] = RLPWriter.writeBytes(_tx.data);
return abi.encodePacked(uint8(0x7e), RLPWriter.writeList(raw)); return abi.encodePacked(uint8(0x7e), RLPWriter.writeList(raw));
} }
......
...@@ -34,10 +34,10 @@ library Types { ...@@ -34,10 +34,10 @@ library Types {
struct UserDepositTransaction { struct UserDepositTransaction {
address from; address from;
address to; address to;
bool isCreation;
uint256 value; uint256 value;
uint256 mint; uint256 mint;
uint64 gasLimit; uint64 gasLimit;
bool isCreation;
bytes data; bytes data;
bytes32 l1BlockHash; bytes32 l1BlockHash;
uint256 logIndex; uint256 logIndex;
......
...@@ -576,11 +576,32 @@ contract FFIInterface is Test { ...@@ -576,11 +576,32 @@ contract FFIInterface is Test {
cmds[8] = vm.toString(_value); cmds[8] = vm.toString(_value);
cmds[9] = vm.toString(_gas); cmds[9] = vm.toString(_gas);
cmds[10] = vm.toString(_data); cmds[10] = vm.toString(_data);
bytes memory result = vm.ffi(cmds);
bytes memory result = vm.ffi(cmds);
return abi.decode(result, (bytes32)); return abi.decode(result, (bytes32));
} }
function encodeDepositTransaction(
Types.UserDepositTransaction calldata txn
) external returns (bytes memory) {
string[] memory cmds = new string[](12);
cmds[0] = "node";
cmds[1] = "dist/scripts/differential-testing.js";
cmds[2] = "encodeDepositTransaction";
cmds[3] = vm.toString(txn.from);
cmds[4] = vm.toString(txn.to);
cmds[5] = vm.toString(txn.value);
cmds[6] = vm.toString(txn.mint);
cmds[7] = vm.toString(txn.gasLimit);
cmds[8] = vm.toString(txn.isCreation);
cmds[9] = vm.toString(txn.data);
cmds[10] = vm.toString(txn.l1BlockHash);
cmds[11] = vm.toString(txn.logIndex);
bytes memory result = vm.ffi(cmds);
return abi.decode(result, (bytes));
}
function encodeCrossDomainMessage( function encodeCrossDomainMessage(
uint256 _nonce, uint256 _nonce,
address _sender, address _sender,
......
...@@ -65,4 +65,35 @@ contract Encoding_Test is CommonTest { ...@@ -65,4 +65,35 @@ contract Encoding_Test is CommonTest {
assertEq(encoding, _encoding); assertEq(encoding, _encoding);
} }
function test_encodeDepositTransaction_differential(
address _from,
address _to,
uint256 _mint,
uint256 _value,
uint64 _gas,
bool isCreate,
bytes memory _data,
uint256 _logIndex
) external {
Types.UserDepositTransaction memory t = Types.UserDepositTransaction(
_from,
_to,
isCreate,
_value,
_mint,
_gas,
_data,
bytes32(uint256(0)),
_logIndex
);
bytes memory txn = Encoding.encodeDepositTransaction(t);
bytes memory _txn = ffi.encodeDepositTransaction(t);
assertEq(
txn,
_txn
);
}
} }
...@@ -127,10 +127,10 @@ contract Hashing_Test is CommonTest { ...@@ -127,10 +127,10 @@ contract Hashing_Test is CommonTest {
Types.UserDepositTransaction( Types.UserDepositTransaction(
_from, _from,
_to, _to,
false, // isCreate
_value, _value,
_mint, _mint,
_gas, _gas,
false, // isCreate
_data, _data,
bytes32(uint256(0)), bytes32(uint256(0)),
_logIndex _logIndex
......
...@@ -93,6 +93,7 @@ const command = args[0] ...@@ -93,6 +93,7 @@ const command = args[0]
value, value,
gas, gas,
data, data,
isSystemTransaction: false,
domain: SourceHashDomain.UserDeposit, domain: SourceHashDomain.UserDeposit,
}) })
...@@ -101,6 +102,34 @@ const command = args[0] ...@@ -101,6 +102,34 @@ const command = args[0]
process.stdout.write(output) process.stdout.write(output)
break break
} }
case 'encodeDepositTransaction': {
const from = args[1]
const to = args[2]
const value = BigNumber.from(args[3])
const mint = BigNumber.from(args[4])
const gasLimit = BigNumber.from(args[5])
const isCreate = args[6] === 'true' ? true : false
const data = args[7]
const l1BlockHash = args[8]
const logIndex = BigNumber.from(args[9])
const tx = new DepositTx({
from,
to: isCreate ? null : to,
value,
mint,
gas: gasLimit,
data,
l1BlockHash,
logIndex,
domain: SourceHashDomain.UserDeposit,
})
const raw = tx.encode()
const output = utils.defaultAbiCoder.encode(['bytes'], [raw])
process.stdout.write(output)
break
}
case 'hashWithdrawal': { case 'hashWithdrawal': {
const nonce = BigNumber.from(args[1]) const nonce = BigNumber.from(args[1])
const sender = args[2] const sender = args[2]
......
...@@ -10,6 +10,10 @@ import { ...@@ -10,6 +10,10 @@ import {
const { hexDataSlice, stripZeros, hexConcat, keccak256, zeroPad } = utils const { hexDataSlice, stripZeros, hexConcat, keccak256, zeroPad } = utils
const formatBoolean = (value: boolean): Uint8Array => {
return value ? new Uint8Array([1]) : new Uint8Array([])
}
const formatNumber = (value: BigNumberish, name: string): Uint8Array => { const formatNumber = (value: BigNumberish, name: string): Uint8Array => {
const result = stripZeros(BigNumber.from(value).toHexString()) const result = stripZeros(BigNumber.from(value).toHexString())
if (result.length > 32) { if (result.length > 32) {
...@@ -18,6 +22,16 @@ const formatNumber = (value: BigNumberish, name: string): Uint8Array => { ...@@ -18,6 +22,16 @@ const formatNumber = (value: BigNumberish, name: string): Uint8Array => {
return result return result
} }
const handleBoolean = (value: string): boolean => {
if (value === '0x') {
return false
}
if (value === '0x01') {
return true
}
throw new Error(`invalid boolean RLP hex value ${value}`)
}
const handleNumber = (value: string): BigNumber => { const handleNumber = (value: string): BigNumber => {
if (value === '0x') { if (value === '0x') {
return ethers.constants.Zero return ethers.constants.Zero
...@@ -45,6 +59,7 @@ interface DepositTxOpts { ...@@ -45,6 +59,7 @@ interface DepositTxOpts {
mint: BigNumberish mint: BigNumberish
value: BigNumberish value: BigNumberish
gas: BigNumberish gas: BigNumberish
isSystemTransaction: boolean
data: string data: string
domain?: SourceHashDomain domain?: SourceHashDomain
l1BlockHash?: string l1BlockHash?: string
...@@ -68,6 +83,7 @@ export class DepositTx { ...@@ -68,6 +83,7 @@ export class DepositTx {
public mint: BigNumberish public mint: BigNumberish
public value: BigNumberish public value: BigNumberish
public gas: BigNumberish public gas: BigNumberish
public isSystemTransaction: boolean
public data: BigNumberish public data: BigNumberish
public domain?: SourceHashDomain public domain?: SourceHashDomain
...@@ -82,6 +98,7 @@ export class DepositTx { ...@@ -82,6 +98,7 @@ export class DepositTx {
this.mint = opts.mint! this.mint = opts.mint!
this.value = opts.value! this.value = opts.value!
this.gas = opts.gas! this.gas = opts.gas!
this.isSystemTransaction = opts.isSystemTransaction || false
this.data = opts.data! this.data = opts.data!
this.domain = opts.domain this.domain = opts.domain
this.l1BlockHash = opts.l1BlockHash this.l1BlockHash = opts.l1BlockHash
...@@ -130,6 +147,7 @@ export class DepositTx { ...@@ -130,6 +147,7 @@ export class DepositTx {
formatNumber(this.mint || 0, 'mint'), formatNumber(this.mint || 0, 'mint'),
formatNumber(this.value || 0, 'value'), formatNumber(this.value || 0, 'value'),
formatNumber(this.gas || 0, 'gas'), formatNumber(this.gas || 0, 'gas'),
formatBoolean(this.isSystemTransaction),
this.data || '0x', this.data || '0x',
] ]
...@@ -145,15 +163,15 @@ export class DepositTx { ...@@ -145,15 +163,15 @@ export class DepositTx {
throw new Error(`Invalid type ${payload[0]}`) throw new Error(`Invalid type ${payload[0]}`)
} }
this.version = payload[1] this.version = payload[1]
const transaction = utils.RLP.decode(payload.slice(1))
const transaction = utils.RLP.decode(payload.slice(2))
this._sourceHash = transaction[0] this._sourceHash = transaction[0]
this.from = handleAddress(transaction[1]) this.from = handleAddress(transaction[1])
this.to = handleAddress(transaction[2]) this.to = handleAddress(transaction[2])
this.mint = handleNumber(transaction[3]) this.mint = handleNumber(transaction[3])
this.value = handleNumber(transaction[4]) this.value = handleNumber(transaction[4])
this.gas = handleNumber(transaction[5]) this.gas = handleNumber(transaction[5])
this.data = transaction[6] this.isSystemTransaction = handleBoolean(transaction[6])
this.data = transaction[7]
if ('l1BlockHash' in extra) { if ('l1BlockHash' in extra) {
this.l1BlockHash = extra.l1BlockHash this.l1BlockHash = extra.l1BlockHash
...@@ -229,6 +247,7 @@ export class DepositTx { ...@@ -229,6 +247,7 @@ export class DepositTx {
offset += 1 offset += 1
this.to = isCreation === true ? null : event.args.to this.to = isCreation === true ? null : event.args.to
const length = opaqueData.length - offset const length = opaqueData.length - offset
this.isSystemTransaction = false
this.data = hexDataSlice(opaqueData, offset, offset + length) this.data = hexDataSlice(opaqueData, offset, offset + length)
this.domain = SourceHashDomain.UserDeposit this.domain = SourceHashDomain.UserDeposit
this.l1BlockHash = event.blockHash this.l1BlockHash = event.blockHash
......
...@@ -148,6 +148,9 @@ the gas pool on L2. Gas usage exactly matches other transaction types (including ...@@ -148,6 +148,9 @@ the gas pool on L2. Gas usage exactly matches other transaction types (including
If a deposit runs out of gas or has some other failure, the mint will succeed and the nonce of the If a deposit runs out of gas or has some other failure, the mint will succeed and the nonce of the
account will be increased, but no other state transition will occur. account will be increased, but no other state transition will occur.
If `isSystemTransaction` in the deposit is set to `true`, the gas used by the deposit is unmetered.
It must not be subtracted from the gas pool and the `usedGas` field of the receipt must be set to 0.
#### Nonce Handling #### Nonce Handling
Despite the lack of signature validation, we still increment the nonce of the `from` account when a Despite the lack of signature validation, we still increment the nonce of the `from` account when a
...@@ -173,8 +176,9 @@ This transaction MUST have the following values: ...@@ -173,8 +176,9 @@ This transaction MUST have the following values:
contract][predeploy]). contract][predeploy]).
3. `mint` is `0` 3. `mint` is `0`
4. `value` is `0` 4. `value` is `0`
5. `gasLimit` is set to 75,000. 5. `gasLimit` is set to 150,000,000.
6. `data` is an [ABI] encoded call to the [L1 attributes predeployed contract][predeploy]'s 6. `isSystemTransaction` is set to `true`.
7. `data` is an [ABI] encoded call to the [L1 attributes predeployed contract][predeploy]'s
`setL1BlockValues()` function with correct values associated with the corresponding L1 block (cf. `setL1BlockValues()` function with correct values associated with the corresponding L1 block (cf.
[reference implementation][l1-attr-ref-implem]). [reference implementation][l1-attr-ref-implem]).
...@@ -246,6 +250,8 @@ transaction are determined by the corresponding `TransactionDeposited` event emi ...@@ -246,6 +250,8 @@ transaction are determined by the corresponding `TransactionDeposited` event emi
6. `isCreation` is set to `true` if the transaction is a contract creation, `false` otherwise. 6. `isCreation` is set to `true` if the transaction is a contract creation, `false` otherwise.
7. `data` is unchanged from the emitted value. Depending on the value of `isCreation` it is handled 7. `data` is unchanged from the emitted value. Depending on the value of `isCreation` it is handled
as either calldata or contract initialization code. as either calldata or contract initialization code.
8. `isSystemTransaction` is set by the rollup node for certain transactions that have unmetered execution.
It is `false` for user deposited transactions
### Deposit Contract ### Deposit Contract
......
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