-
Notifications
You must be signed in to change notification settings - Fork 74
feat: add sequencer init logic for qa-deploy #1064
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -66,6 +66,59 @@ export const SequencerInit = async ( | |||||||||||||||
|
|
||||||||||||||||
| console.log('L1SequencerProxy upgrade success') | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| return '' | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| // SetFirstSequencer must run *after* the proxy admin has been handed over to | ||||||||||||||||
| // ProxyAdmin. While the deployer is still the proxy admin, any call that falls | ||||||||||||||||
| // through to the implementation reverts with | ||||||||||||||||
| // "TransparentUpgradeableProxy: admin cannot fallback to proxy target". | ||||||||||||||||
| export const SetFirstSequencer = async ( | ||||||||||||||||
| hre: HardhatRuntimeEnvironment, | ||||||||||||||||
| path: string, | ||||||||||||||||
| deployer: any, | ||||||||||||||||
| configTmp: any | ||||||||||||||||
| ): Promise<string> => { | ||||||||||||||||
| const L1SequencerProxyAddress = getContractAddressByName(path, ProxyStorageName.L1SequencerProxyStorageName) | ||||||||||||||||
| const L1SequencerFactory = await hre.ethers.getContractFactory(ContractFactoryName.L1Sequencer) | ||||||||||||||||
|
|
||||||||||||||||
| const L1Sequencer = new ethers.Contract( | ||||||||||||||||
| L1SequencerProxyAddress, | ||||||||||||||||
| L1SequencerFactory.interface, | ||||||||||||||||
| deployer, | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
| // deployConfig is a Proxy that throws on unknown keys, so probe with `in` | ||||||||||||||||
| // before reading. | ||||||||||||||||
| const firstSequencer: string = process.env.firstSequencerAddress || | ||||||||||||||||
| ('firstSequencerAddress' in configTmp ? configTmp.firstSequencerAddress : '') | ||||||||||||||||
| if (!firstSequencer) { | ||||||||||||||||
| // Networks that register the first sequencer out-of-band (devnet does it | ||||||||||||||||
| // from ops/devnet-morph) leave this unset. | ||||||||||||||||
| console.log('firstSequencerAddress not configured, skipping setFirstSequencer') | ||||||||||||||||
| return '' | ||||||||||||||||
| } | ||||||||||||||||
| if (!ethers.utils.isAddress(firstSequencer)) { | ||||||||||||||||
| return `invalid firstSequencerAddress: ${firstSequencer}` | ||||||||||||||||
|
Comment on lines
+102
to
+103
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. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
set -euo pipefail
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
curl -fsSL "$(npm view ethers@5.7.2 dist.tarball)" -o "$tmpdir/ethers.tgz"
tar -xzf "$tmpdir/ethers.tgz" -C "$tmpdir"
# Confirm that `isAddress` delegates to address parsing without a zero-address rejection.
rg -n -C 8 'isAddress|AddressZero|getAddress' "$tmpdir/package"Repository: morph-l2/morph Length of output: 50371 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- deployment script ---'
sed -n '1,130p' contracts/deploy/022-SequencerInit.ts
printf '%s\n' '--- bound setFirstSequencer definitions and calls ---'
rg -n -C 12 'setFirstSequencer|contract L1Sequencer|function setFirstSequencer' contracts
printf '%s\n' '--- ethers dependency ---'
rg -n -C 3 '"ethers"|"version"' package.json contracts package.json 2>/dev/null || trueRepository: morph-l2/morph Length of output: 42575 Reject the zero address before sending the transaction. When the history is empty, Proposed fix- if (!ethers.utils.isAddress(firstSequencer)) {
+ if (
+ !ethers.utils.isAddress(firstSequencer) ||
+ firstSequencer.toLowerCase() === ethers.constants.AddressZero
+ ) {
return `invalid firstSequencerAddress: ${firstSequencer}`
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| if ((await L1Sequencer.getSequencerHistoryLength()).gt(0)) { | ||||||||||||||||
| console.log('First sequencer already set:', await L1Sequencer.getSequencer()) | ||||||||||||||||
| return '' | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| console.log('Setting first sequencer:', firstSequencer) | ||||||||||||||||
| const tx = await L1Sequencer.setFirstSequencer(firstSequencer) | ||||||||||||||||
| await tx.wait() | ||||||||||||||||
|
|
||||||||||||||||
| await assertContractVariable( | ||||||||||||||||
| L1Sequencer, | ||||||||||||||||
| 'getSequencer', | ||||||||||||||||
| firstSequencer, | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
| console.log('setFirstSequencer success') | ||||||||||||||||
| return '' | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| +4 −5 | core/blockchain_test.go | |
| +81 −0 | core/genesis_test.go | |
| +20 −1 | core/state/snapshot/difflayer.go | |
| +3 −7 | core/tx_pool.go | |
| +1 −1 | miner/worker.go | |
| +13 −24 | params/config.go | |
| +25 −1 | params/network_params.go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Reject the zero address before calling
setFirstSequencer.ethers.utils.isAddressacceptsethers.constants.AddressZero, so a zerofirstSequencerAddressreachesL1Sequencer.setFirstSequencer. The contract rejects it with"invalid address", which causes the deployment task to stop before registering the first sequencer.🤖 Prompt for AI Agents