Skip to content

Commit

Permalink
Merge pull request #75 from OffchainLabs/gzeoneth-patch-1
Browse files Browse the repository at this point in the history
fix: prysm config
  • Loading branch information
tsahee authored Aug 22, 2024
2 parents 9cf4d8f + ed40ac0 commit 91b59a8
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 56 deletions.
52 changes: 27 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,38 @@ name: CI
run-name: CI triggered from @${{ github.actor }} of ${{ github.head_ref }}

on:
workflow_dispatch:
merge_group:
pull_request:
push:
branches:
- master
- develop

workflow_dispatch:
merge_group:
pull_request:
push:
branches:
- master
- develop

jobs:
build_and_run:
runs-on: ubuntu-8
strategy:
matrix:
pos: [true, false]

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }}
restore-keys: ${{ runner.os }}-buildx-
- name: Startup Nitro testnode
run: ${{ github.workspace }}/.github/workflows/testnode.bash
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }}
restore-keys: ${{ runner.os }}-buildx-

- name: Startup Nitro testnode
run: ${{ github.workspace }}/.github/workflows/testnode.bash ${{ matrix.pos == true && '--pos' || '' }}
30 changes: 27 additions & 3 deletions .github/workflows/testnode.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,32 @@
# Start the test node and get PID, to terminate it once send-l2 is done.
cd ${GITHUB_WORKSPACE}

while [[ $# -gt 0 ]]; do
case $1 in
--pos)
pos=true
shift
;;
*)
echo "Unknown option $1"
exit 1
;;
esac
done

# TODO once develop is merged into nitro-contract's master, remove the NITRO_CONTRACTS_BRANCH env var
./test-node.bash --init-force --l3node --no-simple --detach
if [ "$pos" = true ]; then
echo "Running with --pos"
./test-node.bash --init-force --l3node --no-simple --detach --pos
else
./test-node.bash --init-force --l3node --no-simple --detach
fi

if [ $? -ne 0 ]; then
echo "test-node.bash failed"
docker compose logs --tail=1000
exit 1
fi

START=$(date +%s)
L2_TRANSACTION_SUCCEEDED=false
Expand Down Expand Up @@ -44,10 +68,10 @@ while true; do
sleep 10
done

docker-compose stop
docker compose stop

if [ "$SUCCEEDED" = false ]; then
docker-compose logs
docker compose logs
exit 1
fi

Expand Down
12 changes: 9 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ services:
- "127.0.0.1:6379:6379"

geth:
image: ethereum/client-go:v1.10.23
image: ethereum/client-go:latest
ports:
- "127.0.0.1:8545:8545"
- "127.0.0.1:8551:8551"
Expand Down Expand Up @@ -77,6 +77,7 @@ services:
- --authrpc.jwtsecret=/config/jwt.hex
- --nodiscover
- --syncmode=full
- --state.scheme=hash
- --dev
- --dev.period=1
- --mine
Expand All @@ -91,9 +92,13 @@ services:
command:
- testnet
- generate-genesis
- --fork=deneb
- --num-validators=64
- --genesis-time-delay=15
- --output-ssz=/consensus/genesis.ssz
- --chain-config-file=/config/prysm.yaml
- --geth-genesis-json-in=/config/geth_genesis.json
- --geth-genesis-json-out=/config/geth_genesis.json
volumes:
- "consensus:/consensus"
- "config:/config"
Expand All @@ -108,16 +113,17 @@ services:
- --datadir=/consensus/beacondata
- --rpc-port=5000
- --min-sync-peers=0
- --interop-genesis-state=/consensus/genesis.ssz
- --genesis-state=/consensus/genesis.ssz
- --interop-eth1data-votes
- --bootstrap-node=
- --chain-config-file=/config/prysm.yaml
- --rpc-host=0.0.0.0
- --grpc-gateway-host=0.0.0.0
- --chain-id=32382
- --chain-id=1337
- --execution-endpoint=http://geth:8551
- --accept-terms-of-use
- --jwt-secret=/config/jwt.hex
- --suggested-fee-recipient=0x000000000000000000000000000000000000dEaD
depends_on:
geth:
condition: service_started
Expand Down
32 changes: 21 additions & 11 deletions scripts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,28 @@ PRESET_BASE: interop
GENESIS_FORK_VERSION: 0x20000089
# Altair
ALTAIR_FORK_EPOCH: 1
ALTAIR_FORK_EPOCH: 0
ALTAIR_FORK_VERSION: 0x20000090
# Merge
BELLATRIX_FORK_EPOCH: 2
BELLATRIX_FORK_EPOCH: 0
BELLATRIX_FORK_VERSION: 0x20000091
TERMINAL_TOTAL_DIFFICULTY: 50
# Capella
CAPELLA_FORK_EPOCH: 0
CAPELLA_FORK_VERSION: 0x20000092
MAX_WITHDRAWALS_PER_PAYLOAD: 16
# DENEB
DENEB_FORK_EPOCH: 0
DENEB_FORK_VERSION: 0x20000093
# ELECTRA
ELECTRA_FORK_VERSION: 0x20000094
# Time parameters
SECONDS_PER_SLOT: 12
SECONDS_PER_SLOT: 2
SLOTS_PER_EPOCH: 6
# Deposit contract
Expand All @@ -36,8 +48,7 @@ function writeGethGenesisConfig(argv: any) {
{
"config": {
"ChainName": "l1_chain",
"chainId": 32382,
"consensus": "clique",
"chainId": 1337,
"homesteadBlock": 0,
"daoForkSupport": true,
"eip150Block": 0,
Expand All @@ -54,13 +65,12 @@ function writeGethGenesisConfig(argv: any) {
"terminalBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"arrowGlacierBlock": 0,
"grayGlacierBlock": 0,
"clique": {
"period": 5,
"epoch": 30000
},
"terminalTotalDifficulty": 50
"shanghaiTime": 0,
"cancunTime": 1706778826,
"terminalTotalDifficulty": 0,
"terminalTotalDifficultyPassed": true
},
"difficulty": "1",
"difficulty": "0",
"extradata": "0x00000000000000000000000000000000000000000000000000000000000000003f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E0B0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x42",
"timestamp": "0x0",
Expand Down
19 changes: 19 additions & 0 deletions scripts/ethcommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,3 +525,22 @@ export const sendRPCCommand = {
await rpcProvider.send(argv.method, argv.params)
}
}

export const waitForSyncCommand = {
command: "wait-for-sync",
describe: "wait for rpc to sync",
builder: {
url: { string: true, describe: "url to send rpc call", default: "http://sequencer:8547"},
},
handler: async (argv: any) => {
const rpcProvider = new ethers.providers.JsonRpcProvider(argv.url)
let syncStatus;
do {
syncStatus = await rpcProvider.send("eth_syncing", [])
if (syncStatus !== false) {
// Wait for a short interval before checking again
await new Promise(resolve => setTimeout(resolve, 5000))
}
} while (syncStatus !== false)
},
};
2 changes: 2 additions & 0 deletions scripts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
sendL2Command,
sendL3Command,
sendRPCCommand,
waitForSyncCommand,
transferL3ChainOwnershipCommand,
} from "./ethcommands";

Expand Down Expand Up @@ -53,6 +54,7 @@ async function main() {
.command(printPrivateKeyCommand)
.command(redisReadCommand)
.command(redisInitCommand)
.command(waitForSyncCommand)
.strict()
.demandCommand(1, "a command must be specified")
.epilogue(namedAccountHelpString)
Expand Down
31 changes: 17 additions & 14 deletions test-node.bash
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ while [[ $# -gt 0 ]]; do
;;
--pos)
consensusclient=true
l1chainid=32382
l1chainid=1337
shift
;;
--l3node)
Expand Down Expand Up @@ -336,29 +336,32 @@ if $force_init; then
docker compose run --entrypoint sh geth -c "chown -R 1000:1000 /keystore"
docker compose run --entrypoint sh geth -c "chown -R 1000:1000 /config"

if $consensusclient; then
echo == Writing configs
docker compose run scripts write-geth-genesis-config
echo == Writing geth configs
docker compose run scripts write-geth-genesis-config

echo == Writing configs
if $consensusclient; then
echo == Writing prysm configs
docker compose run scripts write-prysm-config

echo == Initializing go-ethereum genesis configuration
docker compose run geth init --datadir /datadir/ /config/geth_genesis.json

echo == Starting geth
docker compose up --wait geth

echo == Creating prysm genesis
docker compose up create_beacon_chain_genesis
docker compose run create_beacon_chain_genesis
fi

echo == Initializing go-ethereum genesis configuration
docker compose run geth init --state.scheme hash --datadir /datadir/ /config/geth_genesis.json

if $consensusclient; then
echo == Running prysm
docker compose up --wait prysm_beacon_chain
docker compose up --wait prysm_validator
else
docker compose up --wait geth
fi

echo == Starting geth
docker compose up --wait geth

echo == Waiting for geth to sync
docker compose run scripts wait-for-sync --url http://geth:8545

echo == Funding validator, sequencer and l2owner
docker compose run scripts send-l1 --ethamount 1000 --to validator --wait
docker compose run scripts send-l1 --ethamount 1000 --to sequencer --wait
Expand Down

0 comments on commit 91b59a8

Please sign in to comment.