Skip to content

Commit 7fe5d2c

Browse files
maurelianmslipper
andauthored
Update standard.go for rc.8 (#16505)
* Update standard.go for rc.8 * Update superchain registry with op-contracts/v4.0.0-rc.8 * Update Validator address * Update registry commit * op-deployer: Add support for upgrading and validating v4.0.0 (#16048) * op-deployer: Add support for upgrading to v4.0.0 * simplify versions * rebase, add validator v4 support * update address test * lint --------- Co-authored-by: Matthew Slipper <[email protected]>
1 parent f34669c commit 7fe5d2c

File tree

14 files changed

+148
-101
lines changed

14 files changed

+148
-101
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
1919
github.com/docker/docker v27.5.1+incompatible
2020
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3
21-
github.com/ethereum-optimism/superchain-registry/validation v0.0.0-20250603144016-9c45ca7d4508
21+
github.com/ethereum-optimism/superchain-registry/validation v0.0.0-20250620202749-6b65f330434d
2222
github.com/ethereum/go-ethereum v1.15.11
2323
github.com/fatih/color v1.18.0
2424
github.com/fsnotify/fsnotify v1.9.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 h1:RWHKLhCrQThMfch+QJ1Z
228228
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3/go.mod h1:QziizLAiF0KqyLdNJYD7O5cpDlaFMNZzlxYNcWsJUxs=
229229
github.com/ethereum-optimism/op-geth v1.101511.1-0.20250602182422-2ba5f6b747a4 h1:dNSl6HTSLsjQH8644PzLijoeMK0vyeQVEMfYVUTxGf4=
230230
github.com/ethereum-optimism/op-geth v1.101511.1-0.20250602182422-2ba5f6b747a4/go.mod h1:SkytozVEPtnUeBlquwl0Qv5JKvrN/Y5aqh+VkQo/EOI=
231-
github.com/ethereum-optimism/superchain-registry/validation v0.0.0-20250603144016-9c45ca7d4508 h1:A/3QVFt+Aa9ozpPVXxUTLui8honBjSusAaiCVRbafgs=
232-
github.com/ethereum-optimism/superchain-registry/validation v0.0.0-20250603144016-9c45ca7d4508/go.mod h1:NZ816PzLU1TLv1RdAvYAb6KWOj4Zm5aInT0YpDVml2Y=
231+
github.com/ethereum-optimism/superchain-registry/validation v0.0.0-20250620202749-6b65f330434d h1:hAgJ89B40bIk7BNHt61Noe3kVQCs9niFli0CeSiJnEY=
232+
github.com/ethereum-optimism/superchain-registry/validation v0.0.0-20250620202749-6b65f330434d/go.mod h1:NZ816PzLU1TLv1RdAvYAb6KWOj4Zm5aInT0YpDVml2Y=
233233
github.com/ethereum/c-kzg-4844/v2 v2.1.0 h1:gQropX9YFBhl3g4HYhwE70zq3IHFRgbbNPw0Shwzf5w=
234234
github.com/ethereum/c-kzg-4844/v2 v2.1.0/go.mod h1:TC48kOKjJKPbN7C++qIgt0TJzZ70QznYR7Ob+WXl57E=
235235
github.com/ethereum/go-verkle v0.2.2 h1:I2W0WjnrFUIzzVPwm8ykY+7pL2d4VhlsePn4j7cnFk8=

op-deployer/pkg/deployer/standard/standard.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const (
4242
ContractsV170Beta1L2Tag = "op-contracts/v1.7.0-beta.1+l2-contracts"
4343
ContractsV200Tag = "op-contracts/v2.0.0"
4444
ContractsV300Tag = "op-contracts/v3.0.0"
45-
ContractsV400Tag = "op-contracts/v4.0.0-rc.7"
45+
ContractsV400Tag = "op-contracts/v4.0.0-rc.8"
4646
)
4747

4848
var DisputeAbsolutePrestate = common.HexToHash("0x038512e02c4c3f7bdaec27d00edf55b7155e0905301e1a88083e4e0a6764d54c")
@@ -86,8 +86,8 @@ var taggedReleases = map[string]TaggedRelease{
8686
ContentHash: common.HexToHash("147b9fae70608da2975a01be3d98948306f89ba1930af7c917eea41a54d87cdb"),
8787
},
8888
ContractsV400Tag: {
89-
ArtifactsHash: common.HexToHash("da1d9ca1a4ebf80c4842ee3414ef1d13db7d1bb9e1fbbded5a21f28479d7cdf4"),
90-
ContentHash: common.HexToHash("67966a2cb9945e1d9ab40e9c61f499e73cdb31d21b8d29a5a5c909b2b13ecd70"),
89+
ArtifactsHash: common.HexToHash("e9c20b45d7f6ad4c83ef9c0d5ba50f18d62493706aec2b556606151879e5b9f1"),
90+
ContentHash: common.HexToHash("8b4f4b0ff67d05dce382e7b7bc0d967cdb9a4d2c88d53d5640b618ac671fb7a0"),
9191
},
9292
}
9393

op-deployer/pkg/deployer/upgrade/flags.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer"
55
v200 "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/upgrade/v2_0_0"
66
v300 "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/upgrade/v3_0_0"
7+
v400 "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/upgrade/v4_0_0"
78
oplog "github.com/ethereum-optimism/optimism/op-service/log"
89
"github.com/urfave/cli/v2"
910
)
@@ -40,4 +41,14 @@ var Commands = cli.Commands{
4041
}, oplog.CLIFlags(deployer.EnvVarPrefix)...),
4142
Action: UpgradeCLI(v300.DefaultUpgrader),
4243
},
44+
&cli.Command{
45+
Name: "v4.0.0",
46+
Usage: "upgrades a chain to version v.0.0",
47+
Flags: append([]cli.Flag{
48+
deployer.L1RPCURLFlag,
49+
ConfigFlag,
50+
OverrideArtifactsURLFlag,
51+
}, oplog.CLIFlags(deployer.EnvVarPrefix)...),
52+
Action: UpgradeCLI(v400.DefaultUpgrader),
53+
},
4354
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Package v4_0_0 implements the upgrade to v4.0.0 (U16). The interface for the upgrade is identical
2+
// to the upgrade for v2.0.0 (U13), so all this package does is implement the Upgrader interface and
3+
// call into the v2.0.0 upgrade.
4+
package v4_0_0
5+
6+
import (
7+
"encoding/json"
8+
9+
"github.com/ethereum-optimism/optimism/op-chain-ops/script"
10+
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard"
11+
v200 "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/upgrade/v2_0_0"
12+
)
13+
14+
type Upgrader struct {
15+
}
16+
17+
func (u *Upgrader) Upgrade(host *script.Host, input json.RawMessage) error {
18+
return v200.DefaultUpgrader.Upgrade(host, input)
19+
}
20+
21+
func (u *Upgrader) ArtifactsURL() string {
22+
return "tag://" + standard.ContractsV400Tag
23+
}
24+
25+
var DefaultUpgrader = new(Upgrader)

op-service/testutils/mockrpc/mockrpc.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ func WithExpectationsFile(t *testing.T, path string) Option {
100100
}
101101
}
102102

103+
func WithOkCall(method string, pm ParamsMatcher, result any) Option {
104+
return func(rpc *MockRPC) {
105+
rpc.calls = append(rpc.calls, rpcCall{
106+
Method: method,
107+
ParamsMatcher: pm,
108+
Result: result,
109+
})
110+
}
111+
}
112+
103113
func NewMockRPC(t *testing.T, lgr log.Logger, opts ...Option) *MockRPC {
104114
m := &MockRPC{
105115
lgr: lgr,

op-validator/cmd/main.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package main
33
import (
44
"fmt"
55
"os"
6+
"strings"
67

7-
"github.com/ethereum-optimism/optimism/op-validator/pkg/validations"
8+
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard"
89

910
oplog "github.com/ethereum-optimism/optimism/op-service/log"
1011
"github.com/ethereum-optimism/optimism/op-validator/pkg/service"
@@ -31,9 +32,10 @@ func main() {
3132
Name: "validate",
3233
Usage: "Run validation for a specific version",
3334
Subcommands: []*cli.Command{
34-
versionCmd(validations.VersionV180),
35-
versionCmd(validations.VersionV200),
36-
versionCmd(validations.VersionV300),
35+
versionCmd(standard.ContractsV180Tag),
36+
versionCmd(standard.ContractsV200Tag),
37+
versionCmd(standard.ContractsV300Tag),
38+
versionCmd(standard.ContractsV400Tag),
3739
},
3840
},
3941
}
@@ -49,7 +51,7 @@ func main() {
4951

5052
func versionCmd(version string) *cli.Command {
5153
return &cli.Command{
52-
Name: version,
54+
Name: strings.Replace(version, "op-contracts/", "", 1),
5355
Usage: fmt.Sprintf("Run validation for %s", version),
5456
Flags: append(service.ValidateFlags, oplog.CLIFlags(EnvVarPrefix)...),
5557
Action: func(cliCtx *cli.Context) error {

op-validator/pkg/service/validate.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"context"
55
"fmt"
66

7+
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard"
8+
79
oplog "github.com/ethereum-optimism/optimism/op-service/log"
810
"github.com/ethereum-optimism/optimism/op-validator/pkg/validations"
911
"github.com/ethereum/go-ethereum/log"
@@ -45,10 +47,14 @@ func Validate(ctx context.Context, lgr log.Logger, release string, cfg *Config)
4547

4648
var validator validations.Validator
4749
switch release {
48-
case validations.VersionV180:
50+
case standard.ContractsV180Tag:
4951
validator = validations.NewV180Validator(l1Client)
50-
case validations.VersionV200:
52+
case standard.ContractsV200Tag:
5153
validator = validations.NewV200Validator(l1Client)
54+
case standard.ContractsV300Tag:
55+
validator = validations.NewV300Validator(l1Client)
56+
case standard.ContractsV400Tag:
57+
validator = validations.NewV400Validator(l1Client)
5258
default:
5359
return nil, fmt.Errorf("invalid release: %s", release)
5460
}

op-validator/pkg/validations/addresses.go

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,31 @@ package validations
33
import (
44
"fmt"
55

6-
"github.com/ethereum/go-ethereum/common"
7-
)
6+
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard"
87

9-
const (
10-
VersionV180 = "v1.8.0"
11-
VersionV200 = "v2.0.0"
12-
VersionV300 = "v3.0.0"
13-
VersionV400 = "v4.0.0"
8+
"github.com/ethereum/go-ethereum/common"
149
)
1510

1611
var addresses = map[uint64]map[string]common.Address{
1712
1: {
1813
// Bootstrapped on 03/07/2025 using OP Deployer.
19-
VersionV180: common.HexToAddress("0x37fb5b21750d0e08a992350574bd1c24f4bcedf9"),
14+
standard.ContractsV180Tag: common.HexToAddress("0x37fb5b21750d0e08a992350574bd1c24f4bcedf9"),
2015
// Bootstrapped on 03/07/2025 using OP Deployer.
21-
VersionV200: common.HexToAddress("0x12a9e38628e5a5b24d18b1956ed68a24fe4e3dc0"),
16+
standard.ContractsV200Tag: common.HexToAddress("0x12a9e38628e5a5b24d18b1956ed68a24fe4e3dc0"),
2217
// Bootstrapped on 04/16/2025 using OP Deployer.
23-
VersionV300: common.HexToAddress("0xf989Df70FB46c581ba6157Ab335c0833bA60e1f0"),
24-
// Bootstrapped on 06/03/2025 using OP Deployer.
25-
VersionV400: common.HexToAddress("0x3246b056A3C9B14AA25b75ee133DC3747476DBc5"),
18+
standard.ContractsV300Tag: common.HexToAddress("0xf989Df70FB46c581ba6157Ab335c0833bA60e1f0"),
19+
// Bootstrapped on 06/19/2025 using OP Deployer.
20+
standard.ContractsV400Tag: common.HexToAddress("0xbb43313d206a9b02032c749ca0828a07c962b4b5"),
2621
},
2722
11155111: {
2823
// Bootstrapped on 03/02/2025 using OP Deployer.
29-
VersionV180: common.HexToAddress("0x0a5bf8ebb4b177b2dcc6eba933db726a2e2e2b4d"),
24+
standard.ContractsV180Tag: common.HexToAddress("0x0a5bf8ebb4b177b2dcc6eba933db726a2e2e2b4d"),
3025
// Bootstrapped on 03/02/2025 using OP Deployer.
31-
VersionV200: common.HexToAddress("0x37739a6b0a3f1e7429499a4ec4a0685439daff5c"),
26+
standard.ContractsV200Tag: common.HexToAddress("0x37739a6b0a3f1e7429499a4ec4a0685439daff5c"),
3227
// Bootstrapped on 04/03/2025 using OP Deployer.
33-
VersionV300: common.HexToAddress("0x2d56022cb84ce6b961c3b4288ca36386bcd9024c"),
34-
// Bootstrapped on 06/03/2025 using OP Deployer.
35-
VersionV400: common.HexToAddress("0x3246b056A3C9B14AA25b75ee133DC3747476DBc5"),
28+
standard.ContractsV300Tag: common.HexToAddress("0x2d56022cb84ce6b961c3b4288ca36386bcd9024c"),
29+
// Bootstrapped on 06/19/2025 using OP Deployer.
30+
standard.ContractsV400Tag: common.HexToAddress("0xaaabe70a4198ab9e99e1a22b1afa0a43cc7f2c79"),
3631
},
3732
}
3833

op-validator/pkg/validations/addresses_test.go

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"context"
55
"fmt"
66
"os"
7-
"regexp"
8-
"slices"
97
"testing"
108
"time"
119

10+
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard"
11+
1212
op_e2e "github.com/ethereum-optimism/optimism/op-e2e"
1313

1414
"github.com/ethereum-optimism/superchain-registry/validation"
@@ -19,7 +19,6 @@ import (
1919

2020
"github.com/ethereum/go-ethereum/common"
2121
"github.com/stretchr/testify/require"
22-
"golang.org/x/exp/maps"
2322
)
2423

2524
func TestValidatorAddress(t *testing.T) {
@@ -33,21 +32,21 @@ func TestValidatorAddress(t *testing.T) {
3332
{
3433
name: "Valid Sepolia v1.8.0",
3534
chainID: 11155111,
36-
version: VersionV180,
35+
version: standard.ContractsV180Tag,
3736
want: common.HexToAddress("0x0a5bf8ebb4b177b2dcc6eba933db726a2e2e2b4d"),
3837
expectError: false,
3938
},
4039
{
4140
name: "Valid Sepolia v2.0.0",
4241
chainID: 11155111,
43-
version: VersionV200,
42+
version: standard.ContractsV200Tag,
4443
want: common.HexToAddress("0x37739a6b0a3F1E7429499a4eC4A0685439Daff5C"),
4544
expectError: false,
4645
},
4746
{
4847
name: "Invalid Chain ID",
4948
chainID: 999,
50-
version: VersionV180,
49+
version: standard.ContractsV180Tag,
5150
want: common.Address{},
5251
expectError: true,
5352
},
@@ -85,52 +84,41 @@ func TestAddressValidDeployment(t *testing.T) {
8584
}
8685
}
8786

88-
// Regex to match version strings, removing op-contracts/ prefix and -rc.* suffix
89-
var cleanVersionRegex = regexp.MustCompile(`^(?:op-contracts/)?(v\d+\.\d+\.\d+)(?:-rc\.\d+)?$`)
90-
9187
func testStandardVersionNetwork(t *testing.T, network string) {
9288
var rpcURL string
93-
var versions validation.Versions
89+
var stdVersDefs validation.Versions
9490
var chainID uint64
9591
if network == "mainnet" {
9692
rpcURL = os.Getenv("MAINNET_RPC_URL")
97-
versions = validation.StandardVersionsMainnet
93+
stdVersDefs = validation.StandardVersionsMainnet
9894
chainID = 1
9995
} else if network == "sepolia" {
10096
rpcURL = os.Getenv("SEPOLIA_RPC_URL")
101-
versions = validation.StandardVersionsSepolia
97+
stdVersDefs = validation.StandardVersionsSepolia
10298
chainID = 11155111
10399
} else {
104100
t.Fatalf("Invalid network: %s", network)
105101
}
106102

107103
require.NotEmpty(t, rpcURL, "RPC URL is empty")
108104

109-
// Use maps.keys to ensure the versions are sorted in descending order.
110-
sortedKeys := maps.Keys(versions)
111-
slices.Sort(sortedKeys)
112-
slices.Reverse(sortedKeys)
113-
114-
for _, semver := range sortedKeys {
115-
// Versions are in descending order, to stop at all versions prior to v1.8.0 since
116-
// they don't have validators.
117-
if string(semver) == "op-contracts/v1.6.0" {
118-
break
119-
}
120-
121-
version := versions[semver]
105+
contractVersions := []string{
106+
standard.ContractsV180Tag,
107+
standard.ContractsV200Tag,
108+
standard.ContractsV300Tag,
109+
standard.ContractsV400Tag,
110+
}
122111

123-
matches := cleanVersionRegex.FindStringSubmatch(string(semver))
124-
require.Len(t, matches, 2, "Invalid version format: %s", semver)
125-
cleanVersion := matches[1]
112+
for _, semver := range contractVersions {
113+
version := stdVersDefs[validation.Semver(semver)]
126114

127-
address, err := ValidatorAddress(chainID, cleanVersion)
115+
address, err := ValidatorAddress(chainID, semver)
128116
require.NoError(t, err)
129117

130118
rpcClient, err := rpc.Dial(rpcURL)
131119
require.NoError(t, err)
132120

133-
t.Run(string(semver), func(t *testing.T) {
121+
t.Run(semver, func(t *testing.T) {
134122
testStandardVersion(t, address, rpcClient, version)
135123
})
136124
}

op-validator/pkg/validations/testdata/validations-v180.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

op-validator/pkg/validations/testdata/validations-v200.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

op-validator/pkg/validations/validations.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"math/big"
77
"strings"
88

9+
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard"
10+
911
"github.com/ethereum/go-ethereum/common"
1012
"github.com/ethereum/go-ethereum/ethclient"
1113
"github.com/ethereum/go-ethereum/rpc"
@@ -82,9 +84,17 @@ func (v *BaseValidator) Validate(ctx context.Context, input BaseValidatorInput)
8284
}
8385

8486
func NewV180Validator(client *rpc.Client) *BaseValidator {
85-
return newBaseValidator(client, VersionV180)
87+
return newBaseValidator(client, standard.ContractsV180Tag)
8688
}
8789

8890
func NewV200Validator(client *rpc.Client) *BaseValidator {
89-
return newBaseValidator(client, VersionV200)
91+
return newBaseValidator(client, standard.ContractsV200Tag)
92+
}
93+
94+
func NewV300Validator(client *rpc.Client) *BaseValidator {
95+
return newBaseValidator(client, standard.ContractsV300Tag)
96+
}
97+
98+
func NewV400Validator(client *rpc.Client) *BaseValidator {
99+
return newBaseValidator(client, standard.ContractsV400Tag)
90100
}

0 commit comments

Comments
 (0)