Commit 531e3d9f authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

op-deployer: Block deploying tags to chains without OPCM (#13231)

* op-deployer: Block deploying tags to chains without OPCM

* fix test
parent da85e698
...@@ -152,12 +152,10 @@ func TestEndToEndApply(t *testing.T) { ...@@ -152,12 +152,10 @@ func TestEndToEndApply(t *testing.T) {
t.Run("chain with tagged artifacts", func(t *testing.T) { t.Run("chain with tagged artifacts", func(t *testing.T) {
intent, st := newIntent(t, l1ChainID, dk, l2ChainID1, loc, loc) intent, st := newIntent(t, l1ChainID, dk, l2ChainID1, loc, loc)
cg := ethClientCodeGetter(ctx, l1Client)
intent.L1ContractsLocator = artifacts.DefaultL1ContractsLocator intent.L1ContractsLocator = artifacts.DefaultL1ContractsLocator
intent.L2ContractsLocator = artifacts.DefaultL2ContractsLocator intent.L2ContractsLocator = artifacts.DefaultL2ContractsLocator
require.NoError(t, deployer.ApplyPipeline( require.ErrorIs(t, deployer.ApplyPipeline(
ctx, ctx,
deployer.ApplyPipelineOpts{ deployer.ApplyPipelineOpts{
L1RPCUrl: rpcURL, L1RPCUrl: rpcURL,
...@@ -167,10 +165,7 @@ func TestEndToEndApply(t *testing.T) { ...@@ -167,10 +165,7 @@ func TestEndToEndApply(t *testing.T) {
Logger: lgr, Logger: lgr,
StateWriter: pipeline.NoopStateWriter(), StateWriter: pipeline.NoopStateWriter(),
}, },
)) ), pipeline.ErrRefusingToDeployTaggedReleaseWithoutOPCM)
validateSuperchainDeployment(t, st, cg)
validateOPChainDeployment(t, cg, st, intent)
}) })
} }
......
package pipeline package pipeline
import ( import (
"bufio"
"context" "context"
"crypto/rand" "crypto/rand"
"errors"
"fmt" "fmt"
"os" "os"
"strings" "strings"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard" "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard"
"github.com/mattn/go-isatty"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/state" "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/state"
"github.com/ethereum-optimism/optimism/op-chain-ops/script" "github.com/ethereum-optimism/optimism/op-chain-ops/script"
...@@ -18,6 +16,8 @@ import ( ...@@ -18,6 +16,8 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
) )
var ErrRefusingToDeployTaggedReleaseWithoutOPCM = errors.New("refusing to deploy tagged release without OPCM")
func IsSupportedStateVersion(version int) bool { func IsSupportedStateVersion(version int) bool {
return version == 1 return version == 1
} }
...@@ -141,32 +141,17 @@ func displayWarning() error { ...@@ -141,32 +141,17 @@ func displayWarning() error {
####################### WARNING! WARNING WARNING! ####################### ####################### WARNING! WARNING WARNING! #######################
You are deploying a tagged release to a chain with no pre-deployed OPCM. You are deploying a tagged release to a chain with no pre-deployed OPCM.
The contracts you are deploying may not be audited, or match a governance Due to a quirk of our contract version system, this can lead to deploying
approved release. contracts containing unaudited or untested code. As a result, this
functionality is currently disabled.
We will fix this in an upcoming release.
USE OF THIS DEPLOYMENT IS NOT RECOMMENDED FOR PRODUCTION. USE AT YOUR OWN This process will now exit.
RISK. BUGS OR LOSS OF FUNDS MAY OCCUR. WE HOPE YOU KNOW WHAT YOU ARE
DOING.
####################### WARNING! WARNING WARNING! ####################### ####################### WARNING! WARNING WARNING! #######################
`, "\n") `, "\n")
_, _ = fmt.Fprint(os.Stderr, warning) _, _ = fmt.Fprint(os.Stderr, warning)
return ErrRefusingToDeployTaggedReleaseWithoutOPCM
if isatty.IsTerminal(os.Stdout.Fd()) {
_, _ = fmt.Fprintf(os.Stderr, "Please confirm that you have read and understood the warning above [y/n]: ")
reader := bufio.NewReader(os.Stdin)
input, err := reader.ReadString('\n')
if err != nil {
return fmt.Errorf("failed to read input: %w", err)
}
input = strings.ToLower(strings.TrimSpace(input))
if input != "y" && input != "yes" {
return fmt.Errorf("aborted")
}
}
return nil
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment