Skip to content
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

validation: add global chainId check #153

Closed
wants to merge 20 commits into from
Closed

Conversation

geoknee
Copy link
Collaborator

@geoknee geoknee commented Apr 2, 2024

Closes #299

Test currently failing due to name mismatches.
It is likely and acceptable for a chain to already exist at chainId.network, so we need a way of checking whether it is the "same chain" or not. Using the name seems reasonable, since that it is required to be unique also .

=== RUN   TestGloballyUniqueChainId
    /Users/georgeknee/code/ethereum-optimism/superchain-registry/validation/chainId_test.go:22: Chain OP-Mainnet with ID 10 exists in global chain list with name OP Mainnet
    /Users/georgeknee/code/ethereum-optimism/superchain-registry/validation/chainId_test.go:22: Chain Zora Sepolia with ID 999999999 exists in global chain list with name Zora Sepolia Testnet
    /Users/georgeknee/code/ethereum-optimism/superchain-registry/validation/chainId_test.go:22: Chain Lyra with ID 957 exists in global chain list with name Lyra Chain
    /Users/georgeknee/code/ethereum-optimism/superchain-registry/validation/chainId_test.go:22: Chain Orderly Network with ID 291 exists in global chain list with name Orderly Mainnet
    /Users/georgeknee/code/ethereum-optimism/superchain-registry/validation/chainId_test.go:22: Chain PGN with ID 424 exists in global chain list with name PGN (Public Goods Network)
    /Users/georgeknee/code/ethereum-optimism/superchain-registry/validation/chainId_test.go:22: Chain Base Sepolia with ID 84532 exists in global chain list with name Base Sepolia Testnet
    /Users/georgeknee/code/ethereum-optimism/superchain-registry/validation/chainId_test.go:22: Chain OP-Sepolia with ID 11155420 exists in global chain list with name OP Sepolia Testnet
    /Users/georgeknee/code/ethereum-optimism/superchain-registry/validation/chainId_test.go:22: Chain PGN Sepolia with ID 58008 exists in global chain list with name Sepolia PGN (Public Goods Network)

Open to suggestions on how to resolve this. i think it seems reasonable to require the same name in both repos?

@mds1
Copy link
Contributor

mds1 commented Apr 2, 2024

My preferred solution would be:

  • If the chain is not in the upstream repo: we do the chain ID + name + short name uniqueness checks ourselves
  • If the chain is in the upstream repo: make sure everything added here matches

What do you think of that?

@geoknee geoknee self-assigned this Apr 3, 2024
@geoknee
Copy link
Collaborator Author

geoknee commented Apr 3, 2024

@mds1 I updated the logic to match your suggestion.

I also went through the existing chains to add a short name and correct the existing names where discrepancies exist.

Further, the contributing guide has been updated.

Note that this will fail all in flight PRs, but they won't be hard to fix.

@geoknee geoknee requested a review from mds1 April 3, 2024 21:10
@geoknee geoknee marked this pull request as ready for review April 3, 2024 21:10
@geoknee geoknee requested review from a team as code owners April 3, 2024 21:10
@geoknee geoknee requested a review from ajsutton April 3, 2024 21:10
If the chain is not in the upstream repo: we do the chain ID + name uniqueness checks ourselves
If the chain is in the upstream repo: make sure everything added here matches

TODO for short names (we don't have any of these committed at present)
if in the global list, it matches the short name from there
@@ -1,4 +1,5 @@
name: OP-Mainnet
name: OP Mainnet
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We should verify if these changes will break something in the downstream dependencies (or even somewhere in this repo that I have missed).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@zchn zchn assigned mds1 Apr 4, 2024
geoknee added a commit to ethereum-optimism/optimism that referenced this pull request Apr 4, 2024
circular dependencies, sigh
@geoknee geoknee marked this pull request as draft April 4, 2024 16:14
renaming on a mac, git doesn't detect the change otherwise
@geoknee
Copy link
Collaborator Author

geoknee commented Apr 4, 2024

@mds1 I'm not sure why chek-security-configs is failing. Do you have any insight?

@mds1
Copy link
Contributor

mds1 commented Apr 4, 2024

Checking OptimismPortalProxy 0x16Fc5058F25648194471939df75CF27A2fdC48BC
    -- Success: 0x189aBAAaa82DfC015A588A7dbaD6F13b1D3485Bc == 0x16Fc5058F25648194471939df75CF27A2fdC48BC.admin().
    -- Success: 0xDEe57160aAfCF04c34C887B5962D0a69676d3C8B == 0x16Fc5058F25648194471939df75CF27A2fdC48BC.GUARDIAN().
    !! Error calling 0x16Fc5058F25648194471939df75CF27A2fdC48BC.L2_ORACLE()
    !! Error: 0x90E9c4f8a994a250F6aEfd61CAFb4F2e895D458F != 0x16Fc5058F25648194471939df75CF27A2fdC48BC.L2_ORACLE(), 
             which is 0x0000000000000000000000000000000000000000
├─ [648] 0x16Fc5058F25648194471939df75CF27A2fdC48BC::L2_ORACLE() [staticcall]
    │   ├─ [192] 0x215b3A2d1766616d1C4701f3D117348711BaAe93::L2_ORACLE() [delegatecall]
    │   │   └─ ← EvmError: Revert

So it's reverting because L2_ORACLE method does not exist on the target contract. And the 0x215b3A2d1766616d1C4701f3D117348711BaAe93 contract is the FPAC OptimismPortal2 where the L2OO has been removed. So I think we need to use chainUpgradedToFPAC for basesep now. (I did not realize Base Sepolia upgraded to FPAC but seems they have)

@geoknee
Copy link
Collaborator Author

geoknee commented Apr 4, 2024

Thanks, need to get better at parsing those traces :-) Is there anything we can do to make that easier?

(I did not realize Base Sepolia upgraded to FPAC but seems they have)

I did run this check on main and it passes, so there must be something linked to my renaming changes on this branch which are causing the test to fail.

I think we actually just need to update chainUpgradedToFPAC for opsep (not basesep).

@mds1
Copy link
Contributor

mds1 commented Apr 4, 2024

I think we actually just need to update chainUpgradedToFPAC for opsep (not basesep).

Ah yes, foundry runs tests in parallel so the console.logs get a little confusing. But given the address you are correct

Comment on lines 93 to 95
sliceString(addressesJsonPath, bytes(addressesJsonPath).length - 18, bytes(addressesJsonPath).length)
)
) == keccak256(abi.encodePacked("sepolia/op.json"));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Really keen to replace this code (see #144).

Copy link
Contributor

Choose a reason for hiding this comment

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

Just pushed 3e61dba to clean this up, feel free to revert the commit if you prefer

@geoknee
Copy link
Collaborator Author

geoknee commented Jun 25, 2024

In favour of #320

@geoknee geoknee closed this Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SuperchainRegistry: Update chain ID check to check for global uniqueness
2 participants