-
Notifications
You must be signed in to change notification settings - Fork 212
Add Sepolia v2.0.0-rc.1 versions #920
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
23b7831
Add Sepolia v2.0.0-rc.1 versions
mslipper a183fc5
Update validation/standard/standard-versions-sepolia.toml
mslipper d3f4386
cr updates
mslipper bee89f2
add test
mslipper f17c76e
Add oracle test
mslipper d489b9a
remove unused type
mslipper fb51023
cci ip ranges
mslipper 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ parameters: | |
|
|
||
| jobs: | ||
| go-lint-test: | ||
| circleci_ip_ranges: true | ||
| parameters: | ||
| package: | ||
| type: string | ||
|
|
||
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 |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| package validation | ||
|
|
||
| import ( | ||
| "context" | ||
| "os" | ||
| "reflect" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/ethereum-optimism/superchain-registry/validation" | ||
| "github.com/ethereum/go-ethereum/common" | ||
| "github.com/ethereum/go-ethereum/rpc" | ||
| "github.com/lmittmann/w3" | ||
| "github.com/lmittmann/w3/module/eth" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // This test file tests the integrity of the standard versions files. However, it can't | ||
| // live in the validation package because the validation package can't import Geth. | ||
|
|
||
| var ( | ||
| versionFn = w3.MustNewFunc("version()", "string") | ||
| implsFn = w3.MustNewFunc("implementations()", "(address superchainConfig,address protocolVersions,address l1ERC721Bridge,address optimismPortal,address systemConfig,address optimismMintableERC20Factory,address l1CrossDomainMessenger,address l1StandardBridge,address disputeGameFactory,address anchorStateRegistry,address delayedWeth,address mips)") | ||
| oracleFn = w3.MustNewFunc("oracle()", "address") | ||
| ) | ||
|
|
||
| type opcmImpls struct { | ||
| SuperchainConfig common.Address | ||
| ProtocolVersions common.Address | ||
| L1ERC721Bridge common.Address | ||
| OptimismPortal common.Address | ||
| SystemConfig common.Address | ||
| OptimismMintableERC20Factory common.Address | ||
| L1CrossDomainMessenger common.Address | ||
| L1StandardBridge common.Address | ||
| DisputeGameFactory common.Address | ||
| AnchorStateRegistry common.Address | ||
| DelayedWeth common.Address | ||
| Mips common.Address | ||
| } | ||
|
|
||
| var rpcURLs = map[string]string{ | ||
| "sepolia": os.Getenv("SEPOLIA_RPC_URL"), | ||
| "mainnet": os.Getenv("MAINNET_RPC_URL"), | ||
| } | ||
|
|
||
| var versionMappings = map[string]validation.Versions{ | ||
| "sepolia": validation.StandardVersionsSepolia, | ||
| "mainnet": validation.StandardVersionsMainnet, | ||
| } | ||
|
|
||
| func TestVersionsIntegrity(t *testing.T) { | ||
| for _, network := range []string{"sepolia", "mainnet"} { | ||
| if network == "mainnet" { | ||
| t.Skipf("mainnet temporarily skipped since it isn't deployed yet") | ||
| } | ||
|
|
||
| t.Run(network, func(t *testing.T) { | ||
| testVersionIntegrity(t, network) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func testVersionIntegrity(t *testing.T, network string) { | ||
| rpcURL := rpcURLs[network] | ||
| require.NotEmpty(t, rpcURL) | ||
|
|
||
| versions := versionMappings[network] | ||
| require.NotEmpty(t, versions) | ||
|
|
||
| rpcClient, err := rpc.Dial(rpcURL) | ||
| require.NoError(t, err) | ||
|
|
||
| w3Client := w3.NewClient(rpcClient) | ||
|
|
||
| ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) | ||
| defer cancel() | ||
|
|
||
| for _, semver := range []validation.Semver{"op-contracts/v2.0.0-rc.1"} { | ||
| stdVer, ok := versions[semver] | ||
| require.True(t, ok) | ||
| require.NotNil(t, stdVer.OPContractsManager) | ||
| opcmAddr := stdVer.OPContractsManager.Address | ||
| require.NotNil(t, opcmAddr) | ||
|
|
||
| var impls opcmImpls | ||
| require.NoError(t, w3Client.CallCtx( | ||
| ctx, | ||
| eth.CallFunc(common.Address(*opcmAddr), implsFn).Returns(&impls), | ||
| )) | ||
|
|
||
| vValue := reflect.ValueOf(&stdVer).Elem() | ||
| implsValue := reflect.ValueOf(impls) | ||
|
|
||
| fields := []string{ | ||
| "SuperchainConfig", | ||
| "ProtocolVersions", | ||
| "L1ERC721Bridge", | ||
| "OptimismPortal", | ||
| "SystemConfig", | ||
| "OptimismMintableERC20Factory", | ||
| "L1CrossDomainMessenger", | ||
| "L1StandardBridge", | ||
| "DisputeGameFactory", | ||
| "AnchorStateRegistry", | ||
| "DelayedWeth", | ||
| "Mips", | ||
| } | ||
|
|
||
| for _, field := range fields { | ||
| implsField := implsValue.FieldByName(field) | ||
| require.True(t, implsField.IsValid()) | ||
|
|
||
| address := implsField.Interface().(common.Address) | ||
| contractData := vValue.FieldByName(field).Interface().(*validation.ContractData) | ||
| require.NotNil(t, contractData) | ||
|
|
||
| if contractData.Address != nil { | ||
| require.Equal(t, common.Address(*contractData.Address), address, "invalid address for %s", field) | ||
| } else if contractData.ImplementationAddress != nil { | ||
| require.Equal(t, common.Address(*contractData.ImplementationAddress), address, "invalid implementation address for %s", field) | ||
| } else { | ||
| require.Empty(t, address, "address %s should be empty", field) | ||
| } | ||
|
|
||
| var contractVer string | ||
| require.NoError(t, w3Client.CallCtx(ctx, eth.CallFunc(address, versionFn).Returns(&contractVer))) | ||
| require.Equal(t, contractData.Version, contractVer, "invalid version for %s", field) | ||
| } | ||
|
|
||
| var oracleAddr common.Address | ||
| require.NoError(t, w3Client.CallCtx(ctx, eth.CallFunc(common.Address(*stdVer.Mips.Address), oracleFn).Returns(&oracleAddr))) | ||
| require.Equal(t, common.Address(*stdVer.PreimageOracle.Address), oracleAddr, "invalid oracle address") | ||
| } | ||
| } |
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
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.