Skip to content

Commit

Permalink
op-deployer: Package for production (#12491)
Browse files Browse the repository at this point in the history
* op-deployer: Package for production

This PR:

1. Moves op-deployer into a standalone package at the root of the monorepo.
2. Updates CI given the move above.
3. Adds infrastructure for `goreleaser` so that we can provide pre-build binaries to our users.

* fix error in config

* add dep

* move filter

* filters

* goimports

* remove deployer docker builds

* goimports

* remove superfluous package renames

* use correct monorepo dir

* fix bad package renames

* cancel child context

* use different context in cleanup

* log enclave ID
  • Loading branch information
mslipper authored Oct 16, 2024
1 parent c92c822 commit 1f106f7
Show file tree
Hide file tree
Showing 48 changed files with 199 additions and 87 deletions.
39 changes: 33 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@ jobs:
op-program
op-service
op-supervisor
op-deployer
packages/contracts-bedrock/scripts/checks/semver-natspec
)
formatted_packages=""
Expand Down Expand Up @@ -1274,6 +1275,24 @@ jobs:
command: bash scripts/ops/publish-artifacts.sh
working_directory: packages/contracts-bedrock

go-release:
parameters:
module:
description: Go Module Name
type: string
filename:
description: Goreleaser config file
default: .goreleaser.yaml
type: string
machine: true
resource_class: ethereum-optimism/latitude-1
steps:
- checkout
- run:
name: Run goreleaser
command: |
./bin/goreleaser release --clean -f ./<<parameters.module>>/<<parameters.filename>>
workflows:
main:
when:
Expand Down Expand Up @@ -1351,9 +1370,9 @@ workflows:
requires:
- contracts-bedrock-build
- go-test-kurtosis:
name: op-chain-ops-integration
module: op-chain-ops
test_directory: ./deployer/integration_test
name: op-deployer-integration
module: op-deployer
test_directory: ./pkg/deployer/integration_test
uses_artifacts: true
requires: ["contracts-bedrock-build"]
- go-e2e-test:
Expand Down Expand Up @@ -1385,7 +1404,7 @@ workflows:
- check-generated-mocks-op-node
- check-generated-mocks-op-service
- go-mod-download
- op-chain-ops-integration
- op-deployer-integration
- op-program-compat
- op-e2e-HTTP-tests
- op-e2e-fault-proof-tests
Expand Down Expand Up @@ -1414,7 +1433,6 @@ workflows:
- op-conductor
- da-server
- op-supervisor
- op-deployer
- cannon
- cannon-prestate
- check-generated-mocks-op-node
Expand All @@ -1435,6 +1453,16 @@ workflows:
ignore-dirs:
./packages/contracts-bedrock/lib

go-release-deployer:
jobs:
- go-release:
filters:
tags:
only: /^op-deployer.*/
branches:
ignore: /.*/
module: op-deployer

release:
when:
not:
Expand Down Expand Up @@ -1505,7 +1533,6 @@ workflows:
- da-server-docker-release
- op-ufm-docker-release
- op-supervisor-docker-release
- op-deployer-docker-release
- cannon-docker-release
# Standard (xlarge) AMD-only docker images go here
- docker-build:
Expand Down
3 changes: 2 additions & 1 deletion op-chain-ops/interopgen/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"fmt"
"math/big"

"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/opcm"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/opcm"
"github.com/ethereum-optimism/optimism/op-chain-ops/foundry"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis/beacondeposit"
Expand Down
3 changes: 2 additions & 1 deletion op-chain-ops/interopgen/recipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"fmt"
"math/big"

"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/opcm"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/params"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/opcm"
"github.com/ethereum-optimism/optimism/op-chain-ops/devkeys"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
)
Expand Down
68 changes: 68 additions & 0 deletions op-deployer/.goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

project_name: op-deployer

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy

builds:
- id: main
main: ./cmd/op-deployer
binary: op-deployer
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
ignore:
- goos: windows
goarch: arm64
- goos: linux
goarch: arm64
mod_timestamp: "{{ .CommitTimestamp }}"
ldflags:
- -X main.GitCommit={{ .FullCommit }}
- -X main.GitDate={{ .CommitDate }}
- -X github.com/ethereum-optimism/optimism/op-chain-ops/deployer/version.Version={{ .Version }}
- -X github.com/ethereum-optimism/optimism/op-chain-ops/deployer/version.Meta="unstable"

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: "{{ .ProjectName }}-{{.Version}}-{{ tolower .Os }}-{{ .Arch }}"
# use zip for windows archives
wrap_in_directory: true
format_overrides:
- goos: windows
format: zip

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

release:
github:
owner: ethereum-optimism
name: optimism
make_latest: false

monorepo:
tag_prefix: op-deployer/
dir: op-deployer
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import (
"fmt"
"os"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/bootstrap"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/bootstrap"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/inspect"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/version"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/version"
opservice "github.com/ethereum-optimism/optimism/op-service"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/inspect"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer"
"github.com/ethereum-optimism/optimism/op-service/cliapp"
"github.com/urfave/cli/v2"
)
Expand Down
2 changes: 2 additions & 0 deletions op-deployer/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build:
go build -o bin/op-deployer cmd/op-deployer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"fmt"
"strings"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/state"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/pipeline"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/state"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/pipeline"
opcrypto "github.com/ethereum-optimism/optimism/op-service/crypto"
"github.com/ethereum-optimism/optimism/op-service/ctxinterrupt"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"math/big"
"strings"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer"
"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/opcm"
"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/pipeline"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/opcm"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/pipeline"

"github.com/ethereum-optimism/optimism/op-chain-ops/script"
opcrypto "github.com/ethereum-optimism/optimism/op-service/crypto"
"github.com/ethereum-optimism/optimism/op-service/ctxinterrupt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package bootstrap

import (
"github.com/ethereum-optimism/optimism/op-chain-ops/deployer"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer"
"github.com/ethereum-optimism/optimism/op-service/cliapp"
"github.com/urfave/cli/v2"
)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"path"
"strings"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/opcm"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/opcm"
state2 "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/state"

op_service "github.com/ethereum-optimism/optimism/op-service"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/state"
"github.com/ethereum-optimism/optimism/op-chain-ops/devkeys"
"github.com/ethereum/go-ethereum/common"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -74,7 +74,7 @@ func Init(cfg InitConfig) error {
return fmt.Errorf("invalid config for init: %w", err)
}

intent := &state.Intent{
intent := &state2.Intent{
L1ChainID: cfg.L1ChainID,
FundDevAccounts: true,
L1ContractsLocator: opcm.DefaultL1ContractsLocator,
Expand All @@ -96,22 +96,22 @@ func Init(cfg InitConfig) error {
}
return addr
}
intent.SuperchainRoles = state.SuperchainRoles{
intent.SuperchainRoles = state2.SuperchainRoles{
ProxyAdminOwner: addrFor(devkeys.L1ProxyAdminOwnerRole.Key(l1ChainIDBig)),
ProtocolVersionsOwner: addrFor(devkeys.SuperchainProtocolVersionsOwner.Key(l1ChainIDBig)),
Guardian: addrFor(devkeys.SuperchainConfigGuardianKey.Key(l1ChainIDBig)),
}

for _, l2ChainID := range cfg.L2ChainIDs {
l2ChainIDBig := l2ChainID.Big()
intent.Chains = append(intent.Chains, &state.ChainIntent{
intent.Chains = append(intent.Chains, &state2.ChainIntent{
ID: l2ChainID,
BaseFeeVaultRecipient: common.Address{},
L1FeeVaultRecipient: common.Address{},
SequencerFeeVaultRecipient: common.Address{},
Eip1559Denominator: 50,
Eip1559Elasticity: 6,
Roles: state.ChainRoles{
Roles: state2.ChainRoles{
ProxyAdminOwner: addrFor(devkeys.L2ProxyAdminOwnerRole.Key(l2ChainIDBig)),
SystemConfigOwner: addrFor(devkeys.SystemConfigOwner.Key(l2ChainIDBig)),
GovernanceTokenOwner: addrFor(devkeys.L2ProxyAdminOwnerRole.Key(l2ChainIDBig)),
Expand All @@ -123,7 +123,7 @@ func Init(cfg InitConfig) error {
})
}

st := &state.State{
st := &state2.State{
Version: 1,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package inspect
import (
"fmt"

"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer"

op_service "github.com/ethereum-optimism/optimism/op-service"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer"
"github.com/ethereum/go-ethereum/common"
"github.com/urfave/cli/v2"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package inspect
import (
"fmt"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/pipeline"
"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/state"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/pipeline"
state2 "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/state"

"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum/go-ethereum/core"
Expand Down Expand Up @@ -38,7 +39,7 @@ func GenesisCLI(cliCtx *cli.Context) error {
return nil
}

func GenesisAndRollup(globalState *state.State, chainID common.Hash) (*core.Genesis, *rollup.Config, error) {
func GenesisAndRollup(globalState *state2.State, chainID common.Hash) (*core.Genesis, *rollup.Config, error) {
if globalState.AppliedIntent == nil {
return nil, nil, fmt.Errorf("chain state is not applied - run op-deployer apply")
}
Expand All @@ -58,7 +59,7 @@ func GenesisAndRollup(globalState *state.State, chainID common.Hash) (*core.Gene
return nil, nil, fmt.Errorf("failed to unmarshal genesis: %w", err)
}

config, err := state.CombineDeployConfig(
config, err := state2.CombineDeployConfig(
globalState.AppliedIntent,
chainIntent,
globalState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package inspect
import (
"fmt"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/pipeline"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/pipeline"

"github.com/ethereum-optimism/optimism/op-service/ioutil"
"github.com/ethereum-optimism/optimism/op-service/jsonutil"
"github.com/ethereum/go-ethereum/common"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package inspect
import (
"fmt"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/pipeline"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/pipeline"

"github.com/ethereum-optimism/optimism/op-service/ioutil"
"github.com/ethereum-optimism/optimism/op-service/jsonutil"
"github.com/urfave/cli/v2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import (
"testing"
"time"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/opcm"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/opcm"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/pipeline"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/state"

op_e2e "github.com/ethereum-optimism/optimism/op-e2e"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer"
"github.com/holiman/uint256"

"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/pipeline"
"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/state"
"github.com/ethereum-optimism/optimism/op-chain-ops/devkeys"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
opcrypto "github.com/ethereum-optimism/optimism/op-service/crypto"
Expand Down Expand Up @@ -192,7 +192,7 @@ func makeIntent(
) (*state.Intent, *state.State) {
_, testFilename, _, ok := runtime.Caller(0)
require.Truef(t, ok, "failed to get test filename")
monorepoDir := path.Join(path.Dir(testFilename), "..", "..", "..")
monorepoDir := path.Join(path.Dir(testFilename), "..", "..", "..", "..")
artifactsDir := path.Join(monorepoDir, "packages", "contracts-bedrock", "forge-artifacts")
artifactsURL, err := url.Parse(fmt.Sprintf("file://%s", artifactsDir))
require.NoError(t, err)
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 1f106f7

Please sign in to comment.