Skip to content

Commit

Permalink
Merge pull request #1976 from OffchainLabs/empty-escrow-test
Browse files Browse the repository at this point in the history
Add a regression test for the empty retryable escrow account
  • Loading branch information
joshuacolvin0 authored Nov 21, 2023
2 parents 9f9fef4 + 3238fcc commit 7d5ee32
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 14 deletions.
2 changes: 1 addition & 1 deletion go-ethereum
Submodule go-ethereum updated 48 files
+2 −2 accounts/keystore/account_cache.go
+14 −5 build/ci.go
+1 −1 build/deb/ethereum/deb.rules
+9 −3 cmd/devp2p/dns_route53.go
+10 −4 cmd/devp2p/nodeset.go
+6 −6 common/types.go
+1 −1 consensus/clique/snapshot.go
+1 −1 consensus/clique/snapshot_test.go
+2 −2 core/blockchain.go
+2 −2 core/rawdb/accessors_chain.go
+3 −5 core/rawdb/chain_iterator_test.go
+7 −2 core/state/journal.go
+2 −2 core/state/snapshot/difflayer.go
+11 −7 core/state/snapshot/iterator_fast.go
+0 −1 core/state/statedb.go
+2 −0 core/state/statedb_fuzz_test.go
+8 −8 core/txpool/blobpool/metrics.go
+1 −1 eth/api_debug_test.go
+2 −2 eth/gasprice/feehistory.go
+3 −3 eth/gasprice/gasprice.go
+8 −8 eth/protocols/snap/sync_test.go
+1 −1 eth/tracers/api_test.go
+1 −1 ethdb/dbtest/testsuite.go
+7 −9 ethdb/leveldb/leveldb.go
+4 −4 go.mod
+8 −8 go.sum
+11 −6 internal/build/env.go
+2 −2 internal/build/gotool.go
+1 −1 internal/ethapi/api_test.go
+8 −2 les/servingqueue.go
+8 −2 les/utils/limiter.go
+4 −4 metrics/writer.go
+1 −1 metrics/writer_test.go
+4 −4 p2p/discover/table_util_test.go
+2 −2 p2p/discover/v4_lookup_test.go
+2 −2 p2p/discover/v5_udp_test.go
+2 −2 p2p/dnsdisc/tree.go
+1 −1 p2p/peer.go
+11 −4 p2p/protocol.go
+1 −1 p2p/server.go
+1 −1 params/version.go
+2 −2 tests/fuzzers/rangeproof/rangeproof-fuzzer.go
+2 −2 tests/fuzzers/stacktrie/trie_fuzzer.go
+2 −2 trie/iterator_test.go
+16 −16 trie/proof_test.go
+3 −3 trie/triedb/pathdb/history.go
+1 −1 trie/triedb/pathdb/testutils.go
+2 −4 trie/trienode/node.go
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ require (
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/elastic/gosigar v0.14.2 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/ethereum/c-kzg-4844 v0.3.0 // indirect
github.com/ethereum/c-kzg-4844 v0.3.1 // indirect
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 // indirect
github.com/flynn/noise v1.0.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
Expand Down Expand Up @@ -248,7 +248,7 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/samber/lo v1.36.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/supranational/blst v0.3.11-0.20230406105308-e9dfc5ee724b // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/urfave/cli/v2 v2.24.1 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
Expand Down Expand Up @@ -277,8 +277,8 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
go4.org v0.0.0-20200411211856-f5505b9728dd // indirect
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad // indirect
golang.org/x/mod v0.11.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/text v0.13.0 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw=
github.com/ethereum/c-kzg-4844 v0.3.0 h1:3Y3hD6l5i0dEYsBL50C+Om644kve3pNqoAcvE26o9zI=
github.com/ethereum/c-kzg-4844 v0.3.0/go.mod h1:WI2Nd82DMZAAZI1wV2neKGost9EKjvbpQR9OqE5Qqa8=
github.com/ethereum/c-kzg-4844 v0.3.1 h1:sR65+68+WdnMKxseNWxSJuAv2tsUrihTpVBTfM/U5Zg=
github.com/ethereum/c-kzg-4844 v0.3.1/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 h1:BBso6MBKW8ncyZLv37o+KNyy0HrrHgfnOaGQC2qvN+A=
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5/go.mod h1:JpoxHjuQauoxiFMl1ie8Xc/7TfLuMZ5eOCONd1sUBHg=
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8=
Expand Down Expand Up @@ -1589,8 +1589,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/supranational/blst v0.3.11-0.20230406105308-e9dfc5ee724b h1:u49mjRnygnB34h8OKbnNJFVUtWSKIKb1KukdV8bILUM=
github.com/supranational/blst v0.3.11-0.20230406105308-e9dfc5ee724b/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
Expand Down Expand Up @@ -1798,8 +1798,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6Rrf6TF9htwo2pJVSjIU=
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad h1:g0bG7Z4uG+OgH2QDODnjp6ggkk1bJDsINcuWmJN1iJU=
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand All @@ -1824,8 +1824,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180406214816-61147c48b25b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down
83 changes: 82 additions & 1 deletion system_tests/retryable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,92 @@ func TestSubmitRetryableImmediateSuccess(t *testing.T) {
l2balance, err := builder.L2.Client.BalanceAt(ctx, builder.L2Info.GetAddress("User2"), nil)
Require(t, err)

if !arbmath.BigEquals(l2balance, big.NewInt(1e6)) {
if !arbmath.BigEquals(l2balance, callValue) {
Fatal(t, "Unexpected balance:", l2balance)
}
}

func TestSubmitRetryableEmptyEscrow(t *testing.T) {
t.Parallel()
builder, delayedInbox, lookupL2Tx, ctx, teardown := retryableSetup(t)
defer teardown()

user2Address := builder.L2Info.GetAddress("User2")
beneficiaryAddress := builder.L2Info.GetAddress("Beneficiary")

deposit := arbmath.BigMul(big.NewInt(1e12), big.NewInt(1e12))
callValue := common.Big0

nodeInterface, err := node_interfacegen.NewNodeInterface(types.NodeInterfaceAddress, builder.L2.Client)
Require(t, err, "failed to deploy NodeInterface")

// estimate the gas needed to auto redeem the retryable
usertxoptsL2 := builder.L2Info.GetDefaultTransactOpts("Faucet", ctx)
usertxoptsL2.NoSend = true
usertxoptsL2.GasMargin = 0
tx, err := nodeInterface.EstimateRetryableTicket(
&usertxoptsL2,
usertxoptsL2.From,
deposit,
user2Address,
callValue,
beneficiaryAddress,
beneficiaryAddress,
[]byte{0x32, 0x42, 0x32, 0x88}, // increase the cost to beyond that of params.TxGas
)
Require(t, err, "failed to estimate retryable submission")
estimate := tx.Gas()
colors.PrintBlue("estimate: ", estimate)

// submit & auto redeem the retryable using the gas estimate
usertxoptsL1 := builder.L1Info.GetDefaultTransactOpts("Faucet", ctx)
usertxoptsL1.Value = deposit
l1tx, err := delayedInbox.CreateRetryableTicket(
&usertxoptsL1,
user2Address,
callValue,
big.NewInt(1e16),
beneficiaryAddress,
beneficiaryAddress,
arbmath.UintToBig(estimate),
big.NewInt(l2pricing.InitialBaseFeeWei*2),
[]byte{0x32, 0x42, 0x32, 0x88},
)
Require(t, err)

l1Receipt, err := builder.L1.EnsureTxSucceeded(l1tx)
Require(t, err)
if l1Receipt.Status != types.ReceiptStatusSuccessful {
Fatal(t, "l1Receipt indicated failure")
}

waitForL1DelayBlocks(t, ctx, builder)

l2Tx := lookupL2Tx(l1Receipt)
receipt, err := builder.L2.EnsureTxSucceeded(l2Tx)
Require(t, err)
if receipt.Status != types.ReceiptStatusSuccessful {
Fatal(t)
}

l2balance, err := builder.L2.Client.BalanceAt(ctx, builder.L2Info.GetAddress("User2"), nil)
Require(t, err)

if !arbmath.BigEquals(l2balance, callValue) {
Fatal(t, "Unexpected balance:", l2balance)
}

escrowAccount := retryables.RetryableEscrowAddress(l2Tx.Hash())
state, err := builder.L2.ExecNode.ArbInterface.BlockChain().State()
Require(t, err)
escrowCodeHash := state.GetCodeHash(escrowAccount)
if escrowCodeHash == (common.Hash{}) {
Fatal(t, "Escrow account deleted (or not created)")
} else if escrowCodeHash != types.EmptyCodeHash {
Fatal(t, "Escrow account has unexpected code hash", escrowCodeHash)
}
}

func TestSubmitRetryableFailThenRetry(t *testing.T) {
t.Parallel()
builder, delayedInbox, lookupL2Tx, ctx, teardown := retryableSetup(t)
Expand Down

0 comments on commit 7d5ee32

Please sign in to comment.