-
Notifications
You must be signed in to change notification settings - Fork 3.9k
draft: ban-deposits-interop first RFC draft #11362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
3d3e767
feat: ban-deposits-interop first RFC draft
skeletor-spaceman 0d78e5a
fix: missing marshalling of tx
skeletor-spaceman 37f17de
feat: code cleanup and renaming
skeletor-spaceman 4f9621a
feat: cleaner implementation, always set isDeposit on
skeletor-spaceman 65b6804
feat: simplified deposits complete tx and added Isthmus L1Info tx
skeletor-spaceman 70b7db0
feat: L1Block make ecotone a public function
skeletor-spaceman 24deb1c
feat: re-organized shared functions
skeletor-spaceman 2e322c9
Merge branch 'develop' of github.com:ethereum-optimism/optimism into …
skeletor-spaceman f463e8a
feat: revamp unmarshalBinaryIsthmusAndEcotone function
skeletor-spaceman e90db39
feat: ban deposits interop (#11396)
0xDiscotech 771b319
Merge branch 'develop' into feat/ban-deposits-interop
skeletor-spaceman 2838d6e
fix: removed duplicated function from bad merge
skeletor-spaceman e40d49f
fix: relevant comments added, optional bool removed
skeletor-spaceman c89ffa4
fix: sstore of isDeposit
skeletor-spaceman ebc225d
fix: sstore of isDeposit
skeletor-spaceman 198d683
fix: is deposit relevant tests
skeletor-spaceman 1434e89
fix: is deposit relevant tests
skeletor-spaceman 8e93fcc
fix: reorder marshal funcs
skeletor-spaceman abe646b
feat: add DepositSource to avoid possible collitions
skeletor-spaceman 13096e8
feat: renames and revert isDeposit on legacy L1 set
skeletor-spaceman 057fc5b
feat: rename Deposit for AfterForceInclude
skeletor-spaceman 5e0d64c
feat: ban deposits interop (#11451)
0xDiscotech 2c370f7
fix: typo
skeletor-spaceman da494fd
feat: ban deposits interop (#11454)
0xDiscotech 09c549c
feat: ban deposits interop (#11481)
0xDiscotech bc562de
chore: some renames
skeletor-spaceman a8fd430
chore: update gas limit of DepositsComplete
skeletor-spaceman 0a803e5
chore: merged main
skeletor-spaceman 78aa2c4
Merge branch 'develop' of github.com:ethereum-optimism/optimism into …
skeletor-spaceman 5eaf39d
fix: deprecate Interop L1 block
skeletor-spaceman d5ba5d1
fix: missed interop filename changes
skeletor-spaceman f2d8fb8
feat: merged from upstream
skeletor-spaceman ccf505d
feat: ban deposits client tests (#11504)
skeletor-spaceman a17e357
feat: merged from develop
skeletor-spaceman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,14 +20,24 @@ import ( | |
| const ( | ||
| L1InfoFuncBedrockSignature = "setL1BlockValues(uint64,uint64,uint256,bytes32,uint64,bytes32,uint256,uint256)" | ||
| L1InfoFuncEcotoneSignature = "setL1BlockValuesEcotone()" | ||
|
skeletor-spaceman marked this conversation as resolved.
|
||
| L1InfoFuncIsthmusSignature = "setL1BlockValuesIsthmus()" | ||
| DepositsCompleteSignature = "depositsComplete()" | ||
| L1InfoArguments = 8 | ||
| L1InfoBedrockLen = 4 + 32*L1InfoArguments | ||
| L1InfoEcotoneLen = 4 + 32*5 // after Ecotone upgrade, args are packed into 5 32-byte slots | ||
| DepositsCompleteLen = 4 // only the selector | ||
| // We set the gas limit to 15k to ensure that the DepositsComplete Transaction does not run out of gas. | ||
| // GasBenchMark_L1BlockIsthmus_DepositsComplete:test_depositsComplete_benchmark() (gas: 7768) | ||
| // GasBenchMark_L1BlockIsthmus_DepositsComplete_Warm:test_depositsComplete_benchmark() (gas: 5768) | ||
| // see `test_depositsComplete_benchmark` at: `/packages/contracts-bedrock/test/BenchmarkTest.t.sol` | ||
| DepositsCompleteGas = uint64(15_000) | ||
| ) | ||
|
|
||
| var ( | ||
| L1InfoFuncBedrockBytes4 = crypto.Keccak256([]byte(L1InfoFuncBedrockSignature))[:4] | ||
| L1InfoFuncEcotoneBytes4 = crypto.Keccak256([]byte(L1InfoFuncEcotoneSignature))[:4] | ||
| L1InfoFuncIsthmusBytes4 = crypto.Keccak256([]byte(L1InfoFuncIsthmusSignature))[:4] | ||
| DepositsCompleteBytes4 = crypto.Keccak256([]byte(DepositsCompleteSignature))[:4] | ||
| L1InfoDepositerAddress = common.HexToAddress("0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001") | ||
| L1BlockAddress = predeploys.L1BlockAddr | ||
| ErrInvalidFormat = errors.New("invalid ecotone l1 block info format") | ||
|
|
@@ -144,7 +154,7 @@ func (info *L1BlockInfo) unmarshalBinaryBedrock(data []byte) error { | |
| return nil | ||
| } | ||
|
|
||
| // Ecotone Binary Format | ||
| // Isthmus & Ecotone Binary Format | ||
| // +---------+--------------------------+ | ||
| // | Bytes | Field | | ||
| // +---------+--------------------------+ | ||
|
|
@@ -159,10 +169,24 @@ func (info *L1BlockInfo) unmarshalBinaryBedrock(data []byte) error { | |
| // | 32 | BlockHash | | ||
| // | 32 | BatcherHash | | ||
| // +---------+--------------------------+ | ||
|
|
||
| // Marshal Ecotone and Isthmus | ||
| func (info *L1BlockInfo) marshalBinaryEcotone() ([]byte, error) { | ||
| w := bytes.NewBuffer(make([]byte, 0, L1InfoEcotoneLen)) | ||
| if err := solabi.WriteSignature(w, L1InfoFuncEcotoneBytes4); err != nil { | ||
| out, err := marshalBinaryWithSignature(info, L1InfoFuncEcotoneBytes4) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to marshal Ecotone l1 block info: %w", err) | ||
| } | ||
| return out, nil | ||
| } | ||
| func (info *L1BlockInfo) marshalBinaryIsthmus() ([]byte, error) { | ||
| out, err := marshalBinaryWithSignature(info, L1InfoFuncIsthmusBytes4) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to marshal Isthmus l1 block info: %w", err) | ||
| } | ||
| return out, nil | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: no newline
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tynes not sure what you mean. do you want a new-line? the other set of 3 |
||
| func marshalBinaryWithSignature(info *L1BlockInfo, signature []byte) ([]byte, error) { | ||
| w := bytes.NewBuffer(make([]byte, 0, L1InfoEcotoneLen)) // Ecotone and Isthmus have the same length | ||
| if err := solabi.WriteSignature(w, signature); err != nil { | ||
| return nil, err | ||
| } | ||
| if err := binary.Write(w, binary.BigEndian, info.BaseFeeScalar); err != nil { | ||
|
|
@@ -200,14 +224,21 @@ func (info *L1BlockInfo) marshalBinaryEcotone() ([]byte, error) { | |
| return w.Bytes(), nil | ||
| } | ||
|
|
||
| // Unmarshal Ecotone and Isthmus | ||
| func (info *L1BlockInfo) unmarshalBinaryEcotone(data []byte) error { | ||
| return unmarshalBinaryWithSignatureAndData(info, L1InfoFuncEcotoneBytes4, data) | ||
| } | ||
| func (info *L1BlockInfo) unmarshalBinaryIsthmus(data []byte) error { | ||
| return unmarshalBinaryWithSignatureAndData(info, L1InfoFuncIsthmusBytes4, data) | ||
| } | ||
| func unmarshalBinaryWithSignatureAndData(info *L1BlockInfo, signature []byte, data []byte) error { | ||
| if len(data) != L1InfoEcotoneLen { | ||
| return fmt.Errorf("data is unexpected length: %d", len(data)) | ||
| } | ||
| r := bytes.NewReader(data) | ||
|
|
||
| var err error | ||
| if _, err := solabi.ReadAndValidateSignature(r, L1InfoFuncEcotoneBytes4); err != nil { | ||
| if _, err := solabi.ReadAndValidateSignature(r, signature); err != nil { | ||
| return err | ||
| } | ||
| if err := binary.Read(r, binary.BigEndian, &info.BaseFeeScalar); err != nil { | ||
|
|
@@ -250,9 +281,24 @@ func isEcotoneButNotFirstBlock(rollupCfg *rollup.Config, l2BlockTime uint64) boo | |
| return rollupCfg.IsEcotone(l2BlockTime) && !rollupCfg.IsEcotoneActivationBlock(l2BlockTime) | ||
| } | ||
|
|
||
| // isInteropButNotFirstBlock returns whether the specified block is subject to the Isthmus upgrade, | ||
| // but is not the actiation block itself. | ||
| func isInteropButNotFirstBlock(rollupCfg *rollup.Config, l2BlockTime uint64) bool { | ||
| // note from Proto: | ||
| // Since we use the pre-interop L1 tx one last time during the upgrade block, | ||
| // we must disallow the deposit-txs from using the CrossL2Inbox during this block. | ||
| // If the CrossL2Inbox does not exist yet, then it is safe, | ||
| // but we have to ensure that the spec and code puts any Interop upgrade-txs after the user deposits. | ||
| return rollupCfg.IsInterop(l2BlockTime) && !rollupCfg.IsInteropActivationBlock(l2BlockTime) | ||
| } | ||
|
|
||
| // L1BlockInfoFromBytes is the inverse of L1InfoDeposit, to see where the L2 chain is derived from | ||
| func L1BlockInfoFromBytes(rollupCfg *rollup.Config, l2BlockTime uint64, data []byte) (*L1BlockInfo, error) { | ||
| var info L1BlockInfo | ||
| // Important, this should be ordered from most recent to oldest | ||
| if isInteropButNotFirstBlock(rollupCfg, l2BlockTime) { | ||
|
skeletor-spaceman marked this conversation as resolved.
|
||
| return &info, info.unmarshalBinaryIsthmus(data) | ||
| } | ||
| if isEcotoneButNotFirstBlock(rollupCfg, l2BlockTime) { | ||
| return &info, info.unmarshalBinaryEcotone(data) | ||
| } | ||
|
|
@@ -271,6 +317,7 @@ func L1InfoDeposit(rollupCfg *rollup.Config, sysCfg eth.SystemConfig, seqNumber | |
| BatcherAddr: sysCfg.BatcherAddr, | ||
| } | ||
| var data []byte | ||
|
|
||
|
skeletor-spaceman marked this conversation as resolved.
|
||
| if isEcotoneButNotFirstBlock(rollupCfg, l2BlockTime) { | ||
| l1BlockInfo.BlobBaseFee = block.BlobBaseFee() | ||
| if l1BlockInfo.BlobBaseFee == nil { | ||
|
|
@@ -283,11 +330,19 @@ func L1InfoDeposit(rollupCfg *rollup.Config, sysCfg eth.SystemConfig, seqNumber | |
| } | ||
| l1BlockInfo.BlobBaseFeeScalar = scalars.BlobBaseFeeScalar | ||
| l1BlockInfo.BaseFeeScalar = scalars.BaseFeeScalar | ||
| out, err := l1BlockInfo.marshalBinaryEcotone() | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to marshal Ecotone l1 block info: %w", err) | ||
| if isInteropButNotFirstBlock(rollupCfg, l2BlockTime) { | ||
|
skeletor-spaceman marked this conversation as resolved.
|
||
| out, err := l1BlockInfo.marshalBinaryIsthmus() | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to marshal Isthmus l1 block info: %w", err) | ||
| } | ||
| data = out | ||
| } else { | ||
| out, err := l1BlockInfo.marshalBinaryEcotone() | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to marshal Ecotone l1 block info: %w", err) | ||
| } | ||
| data = out | ||
| } | ||
| data = out | ||
| } else { | ||
| l1BlockInfo.L1FeeOverhead = sysCfg.Overhead | ||
| l1BlockInfo.L1FeeScalar = sysCfg.Scalar | ||
|
|
@@ -335,3 +390,33 @@ func L1InfoDepositBytes(rollupCfg *rollup.Config, sysCfg eth.SystemConfig, seqNu | |
| } | ||
| return opaqueL1Tx, nil | ||
| } | ||
|
|
||
| func DepositsCompleteDeposit(seqNumber uint64, block eth.BlockInfo) (*types.DepositTx, error) { | ||
| source := AfterForceIncludeSource{ | ||
| L1BlockHash: block.Hash(), | ||
| } | ||
| out := &types.DepositTx{ | ||
| SourceHash: source.SourceHash(), | ||
| From: L1InfoDepositerAddress, | ||
| To: &L1BlockAddress, | ||
| Mint: nil, | ||
| Value: big.NewInt(0), | ||
| Gas: DepositsCompleteGas, | ||
| IsSystemTransaction: false, | ||
| Data: DepositsCompleteBytes4, | ||
| } | ||
| return out, nil | ||
| } | ||
|
|
||
| func DepositsCompleteBytes(seqNumber uint64, l1Info eth.BlockInfo) ([]byte, error) { | ||
| dep, err := DepositsCompleteDeposit(seqNumber, l1Info) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to create DepositsComplete tx: %w", err) | ||
| } | ||
| depositsCompleteTx := types.NewTx(dep) | ||
| opaqueDepositsCompleteTx, err := depositsCompleteTx.MarshalBinary() | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to encode DepositsComplete tx: %w", err) | ||
| } | ||
| return opaqueDepositsCompleteTx, nil | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.