Skip to content

Commit

Permalink
Get genesis validation checks to run on CI (#529)
Browse files Browse the repository at this point in the history
* switch to cimg/go:1.22.6-node docker image for genesis validation

* remove set -e

(nvm.sh exits with code 3, we can apparently just ignore that)

* use bash instead of sh

* use . instead of source

* install pnpm

* move optimism-temporary out from under superchain-registry

this seems to make go module resolution work as expected

* do not allow validate-genesis to timeout

* improve pipefail behaviour

we allow the scripts which load nvm and gvm to fail

* just lint-all

* remove all set -e behaviour

gives highest chance that validation can succeed

* stream output from test

helps with debugging, prevents timeouts on circleci

* try running as a matrix

* add base and base sepolia to genesis validation list (#530)

* add base sepolia to genesis validation list

* add base mainnet to genesis validation list

* Add validation metadata for Lisk mainnet + testnet (#531)

* temp:  gk/genadd lisk mainnet (revertme)

* add lisk metadata for genesis validation

* temp: add lisk sepolia (revertme)

* add genesis validation metadata for lisk sepolia

* Update .circleci/config.yml

* add comment
  • Loading branch information
geoknee committed Sep 2, 2024
1 parent 26e3e96 commit 8a521d9
Show file tree
Hide file tree
Showing 28 changed files with 387 additions and 43 deletions.
30 changes: 22 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ commands:
steps:
- run:
command: |
apt-get update
apt-get -yq install curl git mercurial make binutils bison gcc build-essential bsdmainutils
sudo apt-get update
sudo apt-get -yq install curl git mercurial make binutils bison gcc build-essential bsdmainutils
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
validate-genesis:
description: "Runs genesis validation checks"
install-pnpm:
description: "Installs pnpm"
steps:
- run: just validate-genesis "*"
- run:
command: |
sudo npm install -g pnpm
jobs:
golang-lint:
Expand Down Expand Up @@ -104,18 +106,27 @@ jobs:
channel: C03N11M0BBN # to slack channel `notify-ci-failures`
golang-validate-genesis:
docker:
- image: us-docker.pkg.dev/oplabs-tools-artifacts/images/ci-builder:v0.49.0
- image: cimg/go:1.22.6-node
resource_class: medium
parameters:
chainid:
type: string
steps:
- checkout
- install-pnpm
- install-just
- install-foundry
- install-gvm
- run:
name: Install NVM
command: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
source ~/.bashrc
nvm --version
- validate-genesis # TODO this should also be filtered on modified chains
- run: just validate-genesis <<parameters.chainid>>
# TODO this should also be filtered on modified chains
golang-validate-modified:
shell: /bin/bash -eo pipefail
executor:
Expand Down Expand Up @@ -252,6 +263,9 @@ workflows:
- golang-lint
- golang-modules-tidy
- golang-test
- golang-validate-genesis
- golang-validate-genesis:
matrix:
parameters:
chainid: ["7777777", "4801", "1750", "480","34443", "6806", "84532", "8453", "1135", "4202"]
- golang-validate-modified
- check-codegen
3 changes: 1 addition & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,13 @@ test-validation: clean-add-chain
validate-modified-chains REF:
# Running validation checks only for chains whose config has changed:
git diff --merge-base {{REF}} --name-only 'superchain/configs/*.toml' ':(exclude)superchain/**/superchain.toml' | xargs -r awk '/chain_id/ {print $3}' | xargs -I {} just validate {}

# Run validation checks for chains with a name or chain ID matching the supplied regex, example: just validate 10
validate CHAIN_ID:
TEST_DIRECTORY=./validation go run gotest.tools/gotestsum@latest --format testname -- -run='TestValidation/.+\({{CHAIN_ID}}\)$' -count=1

# Run genesis validation (this is separated from other validation checks, because it is not a part of drift detection)
validate-genesis CHAIN_ID:
TEST_DIRECTORY=./validation/genesis go run gotest.tools/gotestsum@latest --format testname -- -run='TestGenesisPredeploys/.+\({{CHAIN_ID}}\)$' -v
TEST_DIRECTORY=./validation/genesis go run gotest.tools/gotestsum@latest --format standard-verbose -- -run='TestGenesisPredeploys/.+\({{CHAIN_ID}}\)$' -timeout 0

promotion-test:
TEST_DIRECTORY=./validation go run gotest.tools/gotestsum@latest --format dots -- -run Promotion
Expand Down
50 changes: 50 additions & 0 deletions superchain/configs/mainnet/lisk.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name = "Lisk"
chain_id = 1135
public_rpc = "https://rpc.api.lisk.com"
sequencer_rpc = "https://rpc.api.lisk.com"
explorer = "https://blockscout.lisk.com"
superchain_level = 0
standard_chain_candidate = true # This is a temporary field which causes most of the standard validation checks to run on this chain
batch_inbox_addr = "0xFf00000000000000000000000000000000001135"
canyon_time = 0 # Thu 1 Jan 1970 00:00:00 UTC
delta_time = 0 # Thu 1 Jan 1970 00:00:00 UTC
ecotone_time = 0 # Thu 1 Jan 1970 00:00:00 UTC
fjord_time = 1720627201 # Wed 10 Jul 2024 16:00:01 UTC
block_time = 2
seq_window_size = 3600
max_sequencer_drift = 600
data_availability_type = "eth-da"

[genesis]
l2_time = 1714728791
[genesis.l1]
hash = "0xd580bdbd001908860f225c16ddaa08ada64471a68435694760c111253d97ffce"
number = 19788720
[genesis.l2]
hash = "0x5a693d1d8ee27b8e62868d0349af430a2d2e173c8c8988e7b0c9ef91893cbf00"
number = 0
[genesis.system_config]
batcherAddress = "0xa6Ea2f3299b63c53143c993d2d5E60A69Cd6Fe24"
overhead = "0x00000000000000000000000000000000000000000000000000000000000000bc"
scalar = "0x00000000000000000000000000000000000000000000000000000000000f4240"
gasLimit = 30000000

[addresses]
SystemConfigOwner = "0xBeA2Bc852a160B8547273660E22F4F08C2fa9Bbb"
ProxyAdminOwner = "0xECd4150ABbb1EBff13f74e42Fb43C3d78B4E0b45"
Guardian = "0xBeA2Bc852a160B8547273660E22F4F08C2fa9Bbb"
Challenger = "0xBeA2Bc852a160B8547273660E22F4F08C2fa9Bbb"
Proposer = "0x0AbD6da1cE10D1cD6c7C9C14b905786D20f3EB23"
UnsafeBlockSigner = "0xb9DE90a90c5E441C483e754FE7341100D5fbaEcA"
BatchSubmitter = "0xa6Ea2f3299b63c53143c993d2d5E60A69Cd6Fe24"
AddressManager = "0x2dF7057d3F25212E51aFEA8dA628668229Ea423f"
L1CrossDomainMessengerProxy = "0x31B72D76FB666844C41EdF08dF0254875Dbb7edB"
L1ERC721BridgeProxy = "0x3A44A3b263FB631cdbf25f339e2D29497511A81f"
L1StandardBridgeProxy = "0x2658723Bf70c7667De6B25F99fcce13A16D25d08"
L2OutputOracleProxy = "0x113cB99283AF242Da0A0C54347667edF531Aa7d6"
OptimismMintableERC20FactoryProxy = "0xc1dA06CC5DD5cE23bABa924463de7F762039252d"
OptimismPortalProxy = "0x26dB93F8b8b4f7016240af62F7730979d353f9A7"
SystemConfigProxy = "0x05f23282FFDCA8286E4738C1aF79079f3d843750"
ProxyAdmin = "0xeC432c4F1d0E12737f3a42a459B84848Af979b2d"
SuperchainConfig = "0x26C7bFB430d68Bf74d2d52497836d4336b555dE7"
DisputeGameFactoryProxy = "0x0479e6757eb4743843b309DDDF78E6bA242F38BE"
52 changes: 52 additions & 0 deletions superchain/configs/sepolia/lisk.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

name = "Lisk Sepolia Testnet"
chain_id = 4202
public_rpc = "https://rpc.sepolia-api.lisk.com"
sequencer_rpc = "https://rpc.sepolia-api.lisk.com"
explorer = "https://sepolia-blockscout.lisk.com"
superchain_level = 0
standard_chain_candidate = true # This is a temporary field which causes most of the standard validation checks to run on this chain
batch_inbox_addr = "0xff00000000000000000000000000000000004202"
canyon_time = 1705312994 # Mon 15 Jan 2024 10:03:14 UTC
delta_time = 1705312994 # Mon 15 Jan 2024 10:03:14 UTC
ecotone_time = 1708534800 # Wed 21 Feb 2024 17:00:00 UTC
fjord_time = 1716998400 # Wed 29 May 2024 16:00:00 UTC
granite_time = 1723478400 # Mon 12 Aug 2024 16:00:00 UTC
block_time = 2
seq_window_size = 3600
max_sequencer_drift = 600
data_availability_type = "eth-da"

[genesis]
l2_time = 1705312992
[genesis.l1]
hash = "0x7d9d6dcec39efe182119f41b1bd2aa7b35b82e43927522afea86d210a4eace4b"
number = 5089851
[genesis.l2]
hash = "0xead3e6ddd08ae7e27fd952b74ceb468ba889047ac96b351dd13bd55e5faf3372"
number = 0
[genesis.system_config]
batcherAddress = "0x246E119a5BcC2875161b23E4e602e25cEcE96E37"
overhead = "0x0000000000000000000000000000000000000000000000000000000000000834"
scalar = "0x00000000000000000000000000000000000000000000000000000000000f4240"
gasLimit = 30000000

[addresses]
SystemConfigOwner = "0x19De6D30Bf43654B7244B8adA135E1AA639bF091"
ProxyAdminOwner = "0x465874903125F26316c730aE84862606a3326cA5"
Guardian = "0x7a50f00e8D05b95F98fE38d8BeE366a7324dCf7E"
Challenger = "0x19De6D30Bf43654B7244B8adA135E1AA639bF091"
Proposer = "0xBbD3a1D90B0Ef416581ACdC6a72046b38D3af9AD"
UnsafeBlockSigner = "0x99804980804e9EbE78db89C049fFe36ceaaEF654"
BatchSubmitter = "0x246E119a5BcC2875161b23E4e602e25cEcE96E37"
AddressManager = "0x27Bb4A7cd8FB20cb816BF4Aac668BF841bb3D5d3"
L1CrossDomainMessengerProxy = "0x857824E6234f7733ecA4e9A76804fd1afa1A3A2C"
L1ERC721BridgeProxy = "0xb4E988CF1aD8C361D56118437502A8f11C7FaA01"
L1StandardBridgeProxy = "0x1Fb30e446eA791cd1f011675E5F3f5311b70faF5"
L2OutputOracleProxy = "0xA0E35F56C318DE1bD5D9ca6A94Fe7e37C5663348"
OptimismMintableERC20FactoryProxy = "0x269d632C1E518a922C30C749cFD3f82Eb5C779B0"
OptimismPortalProxy = "0xe3d90F21490686Ec7eF37BE788E02dfC12787264"
SystemConfigProxy = "0xF54791059df4a12BA461b881B4080Ae81a1d0AC0"
ProxyAdmin = "0x5Db9F05921d8d5a6a157F6f49c411cc0e46c6330"
SuperchainConfig = "0xC2Be75506d5724086DEB7245bd260Cc9753911Be"
DisputeGameFactoryProxy = "0x9AA3890a87E6BD2CB85Dad1A5D8B0A9D669e658a"
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added superchain/extra/genesis/mainnet/lisk.json.gz
Binary file not shown.
Binary file added superchain/extra/genesis/sepolia/lisk.json.gz
Binary file not shown.
3 changes: 0 additions & 3 deletions validation/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@ generate-genesis/output-*

# test output artifacts
genesis/validation-inputs/*-test

# optimism monorepo used for genesis validation
genesis/optimism-temporary
49 changes: 47 additions & 2 deletions validation/genesis/genesis-predeploy_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package genesis

import (
"bufio"
"encoding/json"
"fmt"
"io"
"log"
"os"
"os/exec"
Expand All @@ -26,7 +28,23 @@ func perChainTestName(chain *superchain.ChainConfig) string {
return chain.Name + fmt.Sprintf(" (%d)", chain.ChainID)
}

var temporaryOptimismDir string

func TestGenesisPredeploys(t *testing.T) {
// Clone optimism into gitignored temporary directory (if that directory does not yet exist)
// We avoid cloning under the superchain-registry tree, since this causes dependency resolution problems
_, filename, _, ok := runtime.Caller(0)
if !ok {
panic("No caller information")
}
thisDir := filepath.Dir(filename)
temporaryOptimismDir = path.Join(thisDir, "../../../optimism-temporary")

if _, err := os.Stat(temporaryOptimismDir); os.IsNotExist(err) {
mustExecuteCommandInDir(thisDir,
exec.Command("git", "clone", "https://github.com/ethereum-optimism/optimism.git", temporaryOptimismDir))
}

for _, chain := range OPChains {
if chain.SuperchainLevel == Standard || chain.StandardChainCandidate {
t.Run(perChainTestName(chain), func(t *testing.T) {
Expand All @@ -35,6 +53,8 @@ func TestGenesisPredeploys(t *testing.T) {
})
}
}

// TODO cleanup temporaryOptimismDir
}

// Invoke this with go test -timeout 0 ./validation/genesis -run=TestGenesisPredeploys -v
Expand All @@ -55,7 +75,7 @@ func testGenesisPredeploys(t *testing.T, chain *ChainConfig) {
thisDir := getDirOfThisFile()
chainIdString := strconv.Itoa(int(chainId))
validationInputsDir := path.Join(thisDir, "validation-inputs", chainIdString)
monorepoDir := path.Join(thisDir, "optimism-temporary")
monorepoDir := temporaryOptimismDir
contractsDir := path.Join(monorepoDir, "packages/contracts-bedrock")

// reset to appropriate commit, this is preferred to git checkout because it will
Expand Down Expand Up @@ -92,7 +112,22 @@ func testGenesisPredeploys(t *testing.T, chain *ChainConfig) {
panic("must set node_version in meta.toml")
}
creationCommand := GenesisCreationCommand[vis.GenesisCreationCommand](chainId, Superchains[chain.Superchain].Config.L1.PublicRPC)
mustExecuteCommandInDir(monorepoDir, exec.Command("sh", "./monorepo-outputs.sh", vis.NodeVersion, buildCommand, creationCommand))
cmd := exec.Command("bash", "./monorepo-outputs.sh", vis.NodeVersion, buildCommand, creationCommand)
// Create a pipe to read the command's output
stdoutPipe, err := cmd.StdoutPipe()
if err != nil {
t.Fatalf("Failed to get stdout pipe: %v", err)
}

stderrPipe, err := cmd.StderrPipe()
if err != nil {
t.Fatalf("Failed to get stderr pipe: %v", err)
}
// Stream the command's stdout and stderr to the test logger
go streamOutputToLogger(stdoutPipe, t)
go streamOutputToLogger(stderrPipe, t)

mustExecuteCommandInDir(monorepoDir, cmd)

expectedData, err := os.ReadFile(path.Join(monorepoDir, "expected-genesis.json"))
require.NoError(t, err)
Expand Down Expand Up @@ -142,6 +177,16 @@ func writeDeployments(chainId uint64, directory string) error {
return nil
}

func streamOutputToLogger(reader io.Reader, t *testing.T) {
scanner := bufio.NewScanner(reader)
for scanner.Scan() {
t.Log(scanner.Text())
}
if err := scanner.Err(); err != nil {
t.Errorf("Error reading command output: %v", err)
}
}

func writeDeploymentsLegacy(chainId uint64, directory string) error {
// Prepare a HardHat Deployment type, we need this whole structure to make things
// work, although it is only the Address field which ends up getting used.
Expand Down
15 changes: 0 additions & 15 deletions validation/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ package genesis
import (
"embed"
"fmt"
"os"
"os/exec"
"path"
"path/filepath"
"runtime"
"strconv"
"strings"

Expand Down Expand Up @@ -56,17 +52,6 @@ func init() {

ValidationInputs[uint64(chainID)] = *m

// Clone optimism into gitignored temporary directory (if that directory does not yet exist)
_, filename, _, ok := runtime.Caller(0)
if !ok {
panic("No caller information")
}
thisDir := filepath.Dir(filename)

if _, err := os.Stat(path.Join(thisDir, "optimism-temporary")); os.IsNotExist(err) {
mustExecuteCommandInDir(filepath.Dir(filename),
exec.Command("git", "clone", "https://github.com/ethereum-optimism/optimism.git", path.Join(thisDir, "optimism-temporary")))
}
}
}

Expand Down
21 changes: 8 additions & 13 deletions validation/genesis/monorepo-outputs.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
set -e
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

echo "Inferring and selecting correct Node version"
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
echo "Installing and selecting correct Node version"
nvm install $1
nvm use $1

echo "Running install command"
eval $2

echo "Inferring and selecting correct go version"

echo "Installing and selecting correct go version"
go_version=$(grep -m 1 '^go ' go.mod | awk '{print $2}')

# Source the gvm script to load gvm functions into the shell
set +e
source ~/.gvm/scripts/gvm || exit 1
gvm install go${go_version} || exit 1
gvm use go${go_version} || exit 1
set -e

. ~/.gvm/scripts/gvm
gvm install go${go_version}
gvm use go${go_version}

echo "Running op-node genesis l2 command"

eval "$3"
Loading

0 comments on commit 8a521d9

Please sign in to comment.