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

feat: callbacks #153

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 25 additions & 53 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -608,51 +608,21 @@ jobs:
docker pull $image_name || exit 1
docker run $image_name <<parameters.op_component>> --version || exit 1

contracts-bedrock-coverage:
docker:
- image: <<pipeline.parameters.ci_builder_image>>
resource_class: xlarge
steps:
- checkout
- install-contracts-dependencies
- check-changed:
patterns: contracts-bedrock,op-node
- run:
name: print forge version
command: forge --version
working_directory: packages/contracts-bedrock
# We do not use the pre-built contracts becuase forge coverage uses different optimizer settings
- run:
name: test and generate coverage
command: just coverage-lcov
no_output_timeout: 18m
environment:
FOUNDRY_PROFILE: cicoverage
working_directory: packages/contracts-bedrock
- codecov/upload:
disable_search: true
files: ./packages/contracts-bedrock/lcov.info
flags: contracts-bedrock-tests

contracts-bedrock-tests:
machine: true
resource_class: ethereum-optimism/latitude-1
parameters:
test_list:
description: List of test files to run
type: string
test_fuzz_runs:
description: Number of fuzz runs to apply
type: integer
default: 512
test_invariant_runs:
description: Number of invariant runs to apply
type: integer
default: 32
test_invariant_depth:
description: Depth of invariant runs
type: integer
default: 64
test_command:
description: Test command to execute (test or coverage)
type: string
default: test
test_flags:
description: Additional flags to pass to the test command
type: string
default: ""
test_timeout:
description: Timeout for running tests
type: string
Expand Down Expand Up @@ -699,7 +669,7 @@ jobs:
TEST_FILES=$(echo "$TEST_FILES" | circleci tests split --split-by=timings)
TEST_FILES=$(echo "$TEST_FILES" | sed 's|^test/||')
MATCH_PATH="./test/{$(echo "$TEST_FILES" | paste -sd "," -)}"
forge test --match-path "$MATCH_PATH"
forge <<parameters.test_command>> <<parameters.test_flags>> --match-path "$MATCH_PATH"
environment:
FOUNDRY_PROFILE: <<parameters.test_profile>>
working_directory: packages/contracts-bedrock
Expand All @@ -715,6 +685,14 @@ jobs:
name: Lint forge test names
command: just lint-forge-tests-check-no-build
working_directory: packages/contracts-bedrock
- when:
condition:
equal: ["<<parameters.test_command>>", "coverage"]
steps:
- codecov/upload:
disable_search: true
files: ./packages/contracts-bedrock/lcov.info
flags: contracts-bedrock-tests
- save_cache:
name: Save Go build cache
key: golang-build-cache-contracts-bedrock-tests-{{ checksum "go.sum" }}
Expand Down Expand Up @@ -1214,9 +1192,6 @@ workflows:
name: contracts-bedrock-build
# Build with just core + script contracts.
build_args: --deny-warnings --skip test
- contracts-bedrock-build:
name: contracts-bedrock-build-coverage
profile: cicoverage
- check-kontrol-build:
requires:
- contracts-bedrock-build
Expand All @@ -1234,6 +1209,14 @@ workflows:
test_list: git diff origin/develop...HEAD --name-only --diff-filter=AM -- './test/**/*.t.sol' | sed 's|packages/contracts-bedrock/||'
test_timeout: 1h
test_profile: ciheavy
- contracts-bedrock-tests:
# Generate coverage reports.
name: contracts-bedrock-coverage
test_list: find test -name "*.t.sol"
test_command: coverage
test_flags: --report lcov
test_timeout: 1h
test_profile: cicoverage
- contracts-bedrock-checks:
requires:
- contracts-bedrock-build
Expand Down Expand Up @@ -1480,17 +1463,6 @@ workflows:
jobs:
- publish-contract-artifacts

develop-forge-coverage:
when:
and:
- or:
- equal: ["develop", <<pipeline.git.branch>>]
- equal: [true, <<pipeline.parameters.contracts_coverage_dispatch>>]
- not:
equal: [scheduled_pipeline, << pipeline.trigger_source >>]
jobs:
- contracts-bedrock-coverage

develop-fault-proofs:
when:
and:
Expand Down
22 changes: 9 additions & 13 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,20 @@ ignore:

coverage:
status:
patch:
default:
target: auto # target coverage is equal to the PR base
threshold: 0% # coverage is not allowed to reduce vs. the PR base
base: auto
informational: true
enabled: true
project:
default:
informational: true
patch:
contracts:
base: auto
target: auto
threshold: 5%
informational: false
flags:
- contracts-bedrock-tests

flag_management:
# Note: flags should have the same name as the circleci job in which they
# are uploaded.
individual_flags:
- name: contracts-bedrock-coverage
- name: contracts-bedrock-tests
paths:
- packages/contracts-bedrock/src
statuses:
- type: patch
target: 100%
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/crate-crypto/go-kzg-4844 v1.0.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20241126105717-d31591e83048
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20241210175229-327d7af91761
github.com/ethereum/go-ethereum v1.14.11
github.com/fsnotify/fsnotify v1.8.0
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb
Expand Down Expand Up @@ -251,7 +251,7 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/ethereum/go-ethereum => github.com/ethereum-optimism/op-geth v1.101411.3-rc.1.0.20241126165630-b84907bf4d95
replace github.com/ethereum/go-ethereum => github.com/ethereum-optimism/op-geth v1.101411.4-rc.2

//replace github.com/ethereum/go-ethereum => ../go-ethereum

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ github.com/elastic/gosigar v0.14.3 h1:xwkKwPia+hSfg9GqrCUKYdId102m9qTJIIr7egmK/u
github.com/elastic/gosigar v0.14.3/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 h1:RWHKLhCrQThMfch+QJ1Z8veEq5ZO3DfIhZ7xgRP9WTc=
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3/go.mod h1:QziizLAiF0KqyLdNJYD7O5cpDlaFMNZzlxYNcWsJUxs=
github.com/ethereum-optimism/op-geth v1.101411.3-rc.1.0.20241126165630-b84907bf4d95 h1:4bgr/Y/Vl2lntFvFM6l/W6P8EWLMxAdF5CRnJStHGGI=
github.com/ethereum-optimism/op-geth v1.101411.3-rc.1.0.20241126165630-b84907bf4d95/go.mod h1:zBADVb3+aon0Idb3uEg/1TFpep+Jdkz3ge9SLFDBXOo=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20241126105717-d31591e83048 h1:kb220NeqVRRt/XP5JHt3i4zpLsYNCdWMM/0tDnOFk3o=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20241126105717-d31591e83048/go.mod h1:9feO8jcL5OZ1tvRjEfNAHz4Aggvd6373l+ZxmZZAyZs=
github.com/ethereum-optimism/op-geth v1.101411.4-rc.2 h1:4u4RUlN3iwwRxYfHGfihjZ0fwY1bfCjFH5/4hVzrwCE=
github.com/ethereum-optimism/op-geth v1.101411.4-rc.2/go.mod h1:1InG/wgdGY/PgH8BSkjUBd6DfoSHyEN3/v0OTFyywsw=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20241210175229-327d7af91761 h1:sk8fDY7QJOhP/mOnEjMj9K8G+3dmPp5MVZsJu4lhZ2E=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20241210175229-327d7af91761/go.mod h1:9feO8jcL5OZ1tvRjEfNAHz4Aggvd6373l+ZxmZZAyZs=
github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA=
github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A=
Expand Down
18 changes: 14 additions & 4 deletions interop-devnet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,18 @@ services:
volumes:
- "supervisor_data:/db"
- "./depset.json:/depset.json"
- "${PWD}/../ops-bedrock/test-jwt-secret.txt:/config/jwt-secret.txt"
image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-supervisor:devnet
command: >
op-supervisor
--datadir="/db"
--dependency-set="/depset.json"
--l2-rpcs=""
--rpc.addr="0.0.0.0"
--rpc.port=8545
--rpc.enable-admin
--l2-rpcs="ws://l2-a:8546,ws://l2-b:8546"
--l1-rpc="http://l1:8545"
--l2-consensus.nodes="http://op-node-a:9645,http://op-node-b:9645"
--l2-consensus.jwt-secret=/config/jwt-secret.txt
environment:
OP_SUPERVISOR_METRICS_ENABLED: "true"

Expand Down Expand Up @@ -157,7 +159,10 @@ services:
--l1.http-poll-interval=6s
--l2=http://l2-a:8551
--l2.jwt-secret=/config/jwt-secret.txt
--supervisor=http://op-supervisor:8545
--interop.supervisor=http://op-supervisor:8545
--interop.rpc.addr=0.0.0.0
--interop.rpc.port=9645
--interop.jwt-secret=/config/jwt-secret.txt
--sequencer.enabled
--sequencer.l1-confs=0
--verifier.l1-confs=0
Expand All @@ -180,6 +185,7 @@ services:
- "9103:9003"
- "7100:7300"
- "6160:6060"
- "9645:9645"
volumes:
- "safedb_a_data:/db"
- "${PWD}/../ops-bedrock/test-jwt-secret.txt:/config/jwt-secret.txt"
Expand Down Expand Up @@ -208,7 +214,10 @@ services:
--l1.http-poll-interval=6s
--l2=http://l2-b:8551
--l2.jwt-secret=/config/jwt-secret.txt
--supervisor=http://op-supervisor:8545
--interop.supervisor=http://op-supervisor:8545
--interop.rpc.addr=0.0.0.0
--interop.rpc.port=9645
--interop.jwt-secret=/config/jwt-secret.txt
--sequencer.enabled
--sequencer.l1-confs=0
--verifier.l1-confs=0
Expand All @@ -231,6 +240,7 @@ services:
- "9203:9003"
- "7200:7300"
- "6260:6060"
- "9645:9645"
volumes:
- "safedb_b_data:/db"
- "${PWD}/../ops-bedrock/test-jwt-secret.txt:/config/jwt-secret.txt"
Expand Down
6 changes: 3 additions & 3 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ just = "1.37.0"
# Foundry dependencies
# Foundry is a special case because it supplies multiple binaries at the same
# GitHub release, so we need to use the aliasing trick to get mise to not error
forge = "nightly-e5dbb7a320c2b871c4a4a1006ad3c15a08fcf17b"
cast = "nightly-e5dbb7a320c2b871c4a4a1006ad3c15a08fcf17b"
anvil = "nightly-e5dbb7a320c2b871c4a4a1006ad3c15a08fcf17b"
forge = "nightly-59f354c179f4e7f6d7292acb3d068815c79286d1"
cast = "nightly-59f354c179f4e7f6d7292acb3d068815c79286d1"
anvil = "nightly-59f354c179f4e7f6d7292acb3d068815c79286d1"

# Fake dependencies
# Put things here if you need to track versions of tools or projects that can't
Expand Down
4 changes: 4 additions & 0 deletions op-chain-ops/script/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ func (h *Host) ImportAccount(addr common.Address, account types.Account) {
}
}

func (h *Host) SetStorage(addr common.Address, key common.Hash, value common.Hash) {
h.state.SetState(addr, key, value)
}

// getPrecompile overrides any accounts during runtime, to insert special precompiles, if activated.
func (h *Host) getPrecompile(rules params.Rules, original vm.PrecompiledContract, addr common.Address) vm.PrecompiledContract {
if p, ok := h.precompiles[addr]; ok {
Expand Down
13 changes: 10 additions & 3 deletions op-deployer/pkg/deployer/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ func ApplyPipeline(
L2: l2ArtifactsFS,
}

var deployer common.Address
deployer := common.Address{0x01}
if opts.DeployerPrivateKey != nil {
deployer = crypto.PubkeyToAddress(opts.DeployerPrivateKey.PublicKey)
}

var bcaster broadcaster.Broadcaster
var l1Client *ethclient.Client
var l1Host *script.Host
Expand All @@ -193,7 +197,6 @@ func ApplyPipeline(
}

signer := opcrypto.SignerFnFromBind(opcrypto.PrivateKeySignerFn(opts.DeployerPrivateKey, chainID))
deployer = crypto.PubkeyToAddress(opts.DeployerPrivateKey.PublicKey)

bcaster, err = broadcaster.NewKeyedBroadcaster(broadcaster.KeyedBroadcasterOpts{
Logger: opts.Logger,
Expand Down Expand Up @@ -235,7 +238,6 @@ func ApplyPipeline(
return fmt.Errorf("failed to select fork: %w", err)
}
} else {
deployer = common.Address{0x01}
bcaster = broadcaster.NoopBroadcaster()
l1Host, err = env.DefaultScriptHost(
bcaster,
Expand Down Expand Up @@ -286,6 +288,11 @@ func ApplyPipeline(
func() error {
return pipeline.DeployAltDA(pEnv, intent, st, chainID)
},
}, pipelineStage{
fmt.Sprintf("deploy-additional-dispute-games-%s", chainID.Hex()),
func() error {
return pipeline.DeployAdditionalDisputeGames(pEnv, intent, st, chainID)
},
}, pipelineStage{
fmt.Sprintf("generate-l2-genesis-%s", chainID.Hex()),
func() error {
Expand Down
3 changes: 2 additions & 1 deletion op-deployer/pkg/deployer/bootstrap/dispute_game.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/ecdsa"
"fmt"
"math/big"
"strings"

artifacts2 "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/artifacts"
Expand Down Expand Up @@ -224,7 +225,7 @@ func DisputeGame(ctx context.Context, cfg DisputeGameConfig) (opcm.DeployDispute
MaxClockDuration: cfg.MaxClockDuration,
DelayedWethProxy: cfg.DelayedWethProxy,
AnchorStateRegistryProxy: cfg.AnchorStateRegistryProxy,
L2ChainId: cfg.L2ChainId,
L2ChainId: common.BigToHash(new(big.Int).SetUint64(cfg.L2ChainId)),
Proposer: cfg.Proposer,
Challenger: cfg.Challenger,
},
Expand Down
42 changes: 41 additions & 1 deletion op-deployer/pkg/deployer/integration_test/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,47 @@ func TestInvalidL2Genesis(t *testing.T) {
}
}

func TestAdditionalDisputeGames(t *testing.T) {
op_e2e.InitParallel(t)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

opts, intent, st := setupGenesisChain(t, defaultL1ChainID)
(&intent.Chains[0].Roles).L1ProxyAdminOwner = crypto.PubkeyToAddress(opts.DeployerPrivateKey.PublicKey)
intent.GlobalDeployOverrides = map[string]any{
"challengePeriodSeconds": 1,
}
intent.Chains[0].AdditionalDisputeGames = []state.AdditionalDisputeGame{
{
ChainProofParams: state.ChainProofParams{
DisputeGameType: 255,
DisputeAbsolutePrestate: standard.DisputeAbsolutePrestate,
DisputeMaxGameDepth: 50,
DisputeSplitDepth: 14,
DisputeClockExtension: 0,
DisputeMaxClockDuration: 1200,
DangerouslyAllowCustomDisputeParameters: true,
},
UseCustomOracle: true,
OracleMinProposalSize: 10000,
OracleChallengePeriodSeconds: 120,
VMType: state.VMTypeAlphabet,
},
}

require.NoError(t, deployer.ApplyPipeline(ctx, opts))

chainState := st.Chains[0]
require.Equal(t, 1, len(chainState.AdditionalDisputeGames))

gameInfo := chainState.AdditionalDisputeGames[0]
require.NotEmpty(t, gameInfo.VMAddress)
require.NotEmpty(t, gameInfo.GameAddress)
require.NotEmpty(t, gameInfo.OracleAddress)
require.NotEqual(t, st.ImplementationsDeployment.PreimageOracleSingletonAddress, gameInfo.OracleAddress)
}

func setupGenesisChain(t *testing.T, l1ChainID uint64) (deployer.ApplyPipelineOpts, *state.Intent, *state.State) {
lgr := testlog.Logger(t, slog.LevelDebug)

Expand All @@ -711,7 +752,6 @@ func setupGenesisChain(t *testing.T, l1ChainID uint64) (deployer.ApplyPipelineOp
loc, _ := testutil.LocalArtifacts(t)

intent, st := newIntent(t, l1ChainIDBig, dk, l2ChainID1, loc, loc)
intent.Chains = append(intent.Chains, newChainIntent(t, dk, l1ChainIDBig, l2ChainID1))
intent.DeploymentStrategy = state.DeploymentStrategyGenesis

opts := deployer.ApplyPipelineOpts{
Expand Down
Loading