opnode: Withdrawal E2E test in go#423
Conversation
opnode/contracts/Makefile
Outdated
| --type OptimismPortal \ | ||
| --out ./deposit/deposit_feed_raw.go | ||
|
|
||
|
|
There was a problem hiding this comment.
Why exactly is this commented out?
There was a problem hiding this comment.
Because the L2 Output Oracle Contract is built in the l2os package. I can remove these fully.
|
Some of this stuff is going to change pending #421 due to it being updated to support backwards compatible withdrawals |
746e1d3 to
65980a2
Compare
661e2d3 to
0a3c387
Compare
Codecov Report
@@ Coverage Diff @@
## main #423 +/- ##
==========================================
- Coverage 51.88% 50.53% -1.36%
==========================================
Files 63 66 +3
Lines 6703 7215 +512
==========================================
+ Hits 3478 3646 +168
- Misses 2784 3094 +310
- Partials 441 475 +34
Continue to review full report at Codecov.
|
| --type L1Block \ | ||
| --out ./l1block/l1_block_info_raw.go | ||
|
|
||
| bindings-L2ToL1MessagePasser: |
There was a problem hiding this comment.
There are some mismatched names in files here, withdrawer -> L2ToL1MessagePasser
There was a problem hiding this comment.
TBH I'm ok with the go names being out of date, I've got an issue to update them (ENG-2195)
opnode/withdrawals/utils.go
Outdated
| "github.com/ethereum/go-ethereum/rpc" | ||
| ) | ||
|
|
||
| var L2WithdrawalAddr = common.HexToAddress("0x4200000000000000000000000000000000000016") |
There was a problem hiding this comment.
This is no longer correct, the predeploy is at address(42...0)
There was a problem hiding this comment.
Also, this has been removed and I'm using the address in the predeploys package. FYI this address is still found in the typesecript helpers
There was a problem hiding this comment.
This is working in the tests because we init the code at predeploy.WithdrawalsAddress and then reference it at that address later.
|
This could use a rebase |
Will do once #416 is merged |
This does the following: - Adds withdrawal utilities (to opnode/withdrawals) - Adds an end to end test in go of withdrawals - Adds the L2 withdrawer contract - Updates to a newer version of reference-go-ethereum
ef47acf to
9be0792
Compare
protolambda
left a comment
There was a problem hiding this comment.
LGTM! Some things we may want to do in future PRs, nothing blocking though.
| require.Nil(t, err) | ||
|
|
||
| // Ensure that withdrawal - gas fees are added to the L1 balance | ||
| // Fun fact, the fee is greater than the withdrawal amount |
There was a problem hiding this comment.
Fun fact 😅
We're withdrawing only 500 gwei though, so it makes sense
There was a problem hiding this comment.
When it's expressed like that, it makes sense. I always forget how may decimals there actually are.
| "github.com/ethereum/go-ethereum/trie" | ||
| ) | ||
|
|
||
| type proofDB struct { |
There was a problem hiding this comment.
For the output root construction we've some proof code already. But without the storage proof part, just the account proof. There it types the rlp nodes as hexutil.Bytes and maintains a map of common.Hash to nodes, instead of using strings for keys. Here it nicely uses the account type + some of the geth rpc client types though. In both cases it does verify correctly, and does verify all the things in the response (i.e. the account details in the response are checked against the rlp node in the proof). Either way, some opportunity for a later PR to take the best of both and reduce code.
| opts := &bind.CallOpts{Context: ctx} | ||
| timestampBig := new(big.Int).SetUint64(timestamp) | ||
|
|
||
| portal, err := deposit.NewOptimismPortalCaller(portalAddr, client) |
There was a problem hiding this comment.
Same applies to deposit as to withdrawer rename I think? Renames in a later PR are fine
| params.Target, | ||
| params.Value, | ||
| params.GasLimit, | ||
| params.Data, |
There was a problem hiding this comment.
Might want to test a params.Data that's not empty, but integration tests can pick that up too.
There was a problem hiding this comment.
Good call - that'd be part of doing generic contract calls (rather than simple transfer) via the withdrawal mechanism
| // TestWithdrawals checks that a deposit and then withdrawal execution succeeds. It verifies the | ||
| // balance changes on L1 and L2 and has to include gas fees in the balance checks. | ||
| // It does not check that the withdrawal can be executed prior to the end of the finality period. | ||
| func TestWithdrawals(t *testing.T) { |
There was a problem hiding this comment.
Nice test, long function though. With the monorepo change the e2e tests get their own go module (so we can separate any testing dependencies, and pull in all the other modules), maybe after that we can split the system_test.go in themed files (general, deposits, withdrawals, p2p, etc.) or maybe even packages.
There was a problem hiding this comment.
Yea, there's a lot of boilerplate that's hard to avoid.
Description
This does the following:
Metadata