Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

opnode: Withdrawal E2E test in go#423

Merged
trianglesphere merged 3 commits intomainfrom
jg/withdrawal_e2e_test
May 13, 2022
Merged

opnode: Withdrawal E2E test in go#423
trianglesphere merged 3 commits intomainfrom
jg/withdrawal_e2e_test

Conversation

@trianglesphere
Copy link
Contributor

Description

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

Metadata

  • Fixes ENG-2202

--type OptimismPortal \
--out ./deposit/deposit_feed_raw.go


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why exactly is this commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the L2 Output Oracle Contract is built in the l2os package. I can remove these fully.

@tynes
Copy link
Contributor

tynes commented May 9, 2022

Some of this stuff is going to change pending #421 due to it being updated to support backwards compatible withdrawals

@tynes tynes mentioned this pull request May 11, 2022
@trianglesphere trianglesphere force-pushed the jg/fix_l2_output_timestamps_v2 branch from 746e1d3 to 65980a2 Compare May 12, 2022 17:40
@trianglesphere trianglesphere force-pushed the jg/withdrawal_e2e_test branch from 661e2d3 to 0a3c387 Compare May 12, 2022 18:36
@codecov-commenter
Copy link

codecov-commenter commented May 12, 2022

Codecov Report

Merging #423 (20143e9) into main (fb044a6) will decrease coverage by 1.35%.
The diff coverage is 28.65%.

@@            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     
Impacted Files Coverage Δ
opnode/contracts/withdrawer/withdrawer_raw.go 4.18% <4.18%> (ø)
opnode/withdrawals/utils.go 59.23% <59.23%> (ø)
opnode/withdrawals/proof.go 59.70% <59.70%> (ø)
opnode/test/geth.go 65.07% <100.00%> (+0.27%) ⬆️
opnode/test/setup.go 72.81% <100.00%> (ø)
l2os/txmgr/txmgr.go 95.65% <0.00%> (+1.86%) ⬆️
opnode/contracts/deposit/deposit_feed_raw.go 11.40% <0.00%> (+6.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb044a6...20143e9. Read the comment docs.

--type L1Block \
--out ./l1block/l1_block_info_raw.go

bindings-L2ToL1MessagePasser:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some mismatched names in files here, withdrawer -> L2ToL1MessagePasser

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I'm ok with the go names being out of date, I've got an issue to update them (ENG-2195)

"github.com/ethereum/go-ethereum/rpc"
)

var L2WithdrawalAddr = common.HexToAddress("0x4200000000000000000000000000000000000016")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer correct, the predeploy is at address(42...0)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No zeroes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working in the tests because we init the code at predeploy.WithdrawalsAddress and then reference it at that address later.

@tynes
Copy link
Contributor

tynes commented May 12, 2022

This could use a rebase

@trianglesphere
Copy link
Contributor Author

This could use a rebase

Will do once #416 is merged

Base automatically changed from jg/fix_l2_output_timestamps_v2 to main May 13, 2022 16:54
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
@trianglesphere trianglesphere force-pushed the jg/withdrawal_e2e_test branch from ef47acf to 9be0792 Compare May 13, 2022 16:55
Copy link
Contributor

@protolambda protolambda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun fact 😅
We're withdrawing only 500 gwei though, so it makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to test a params.Data that's not empty, but integration tests can pick that up too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, there's a lot of boilerplate that's hard to avoid.

@trianglesphere trianglesphere merged commit 92fccc2 into main May 13, 2022
@trianglesphere trianglesphere deleted the jg/withdrawal_e2e_test branch May 13, 2022 18:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants