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

pre-shanghai: Shandong/EOF testnet setup #2316

Merged
merged 9 commits into from
Dec 5, 2022
Merged

pre-shanghai: Shandong/EOF testnet setup #2316

merged 9 commits into from
Dec 5, 2022

Conversation

g11tech
Copy link
Contributor

@g11tech g11tech commented Sep 27, 2022

Eof sim setup

This sim test is to setup a single ethereumjs<>lodestar instance to allow executing testvectors for the EIPs targetting Shanghai hardfork.

EIP(s) testing

Target EIPs are: 3540,3651,3670,3855,3860

Prerequisite(s)

  • Docker since lodestar docker image is used to run CL to drive the post-merge sim run
  • Docker should run without sudo, else prefix sudo in from of docker commands in test/sim/single-run.sh
  • Mac users should skip docker and install directly install and use lodestar binary as instructed below

How to run

  1. npm install the ethereumjs-monorepo
  2. cd packages/client
  3. docker pull chainsafe/lodestar:latest, for MAC users: npm install -g @chainsafe/lodestar:latest
  4. Install linux package jq is not installed
  5. Create a data directory data/eof (or any other place convinient for you).

There are three ways to run tests with varying degree of automation:

Fully automated sim run

Just run:

DATADIR=/data/eof npm run tape -- test/sim/eof.spec.ts

for MAC add extra env variable LODE_BINARY="lodestar" (or LODE_BINARY="npx lodestar" if you didn't install lodestar globally) , i.e.

DATADIR=/data/eof LODE_BINARY="lodestar" npm run tape -- test/sim/eof.spec.ts

It will auto run the script to run custom network, run tests and in end tear it down. You can modify test/sim/eof.spec.ts transaction scenarios to test your custom functionality.

Semi-Auto run using script to start custom network

Currently you can just start the local instance by
DATADIR=data/eof test/sim/./single-run.sh

MAC users:
DATADIR=data/eof LODE_BINARY="lodestar" test/sim/./single-run.sh

This command run should start both ethereumjs and lodestar in terminal. Soon you should see lodestar driving ethereumjs in PoS configuration.

Once the network looks synced to you, you can run tests:

EXTERNAL_RUN=true npm run tape -- test/sim/eof.spec.ts

Manual run to setup network

  1. Clean DATADIR (rm -rf data/eof/*) in start of each run and do mkdir data/eof/ethereumjs && mkdir data/eof/lodestar
  2. Start ethereumjs: npm run client:start -- --datadir data/eof/ethereumjs --gethGenesis test/sim/configs/geth-genesis.json --rpc --rpcEngine --rpcEngineAuth false
  3. Get genesis hash from ethereumjs client:
curl --location --request POST 'http://localhost:8545' --header 'Content-Type: application/json' --data-raw '{
      "jsonrpc": "2.0",
      "method": "eth_getBlockByNumber",
      "params": [
          "0x0",
          true
      ],
      "id": 1
    }' 2>/dev/null | jq ".result.hash"

Currently it should give you 0x3feda37f61eaa3d50deaa39cf04e352af0b54c521b0f16d26f826b54edeef756

  1. Get current time stamp: date +%s and add 30 to it which gives you current time + 30 seconds for e.g. 1664538222
  2. Start lodestar replacing the timestamp that you got from step 3 in --genesisTime: docker run --rm --name beacon --network host chainsafe/lodestar:latest dev --dataDir data/eof/lodestar --genesisValidators 8 --startValidators 0..7 --enr.ip 127.0.0.1 --genesisEth1Hash 0x3feda37f61eaa3d50deaa39cf04e352af0b54c521b0f16d26f826b54edeef756 --params.ALTAIR_FORK_EPOCH 0 --params.BELLATRIX_FORK_EPOCH 0 --params.TERMINAL_TOTAL_DIFFICULTY 0x01 --genesisTime 1664538222
    For MAC users: lodestar dev --dataDir data/eof/lodestar --genesisValidators 8 --startValidators 0..7 --enr.ip 127.0.0.1 --genesisEth1Hash $GENESIS_HASH --params.ALTAIR_FORK_EPOCH 0 --params.BELLATRIX_FORK_EPOCH 0 --params.TERMINAL_TOTAL_DIFFICULTY 0x01 --genesisTime 1664538222

Test the sim tests using the set network as:

EXTERNAL_RUN=true npm run tape -- test/sim/eof.spec.ts

Custom Transaction testing/development

You may want to do your own custom transaction development/testing to target the EIP functionality in the hardfork. Using Semi Auto network script or via Manual network setup steps, you may start ethereumjs<>lodestar custom network.
Ethereumjs rpc endpoint should now be available at http://127.0.0.1:8545 for you to play with!

happy Testing the Shanghai!

Process cleanup

The script should auto clean the processes. In case it fails to do so:

  1. Remove lodestar by docker rm -f beacon
  2. Find the ethereumjs process by doing ps -a | grep client and do kill <process id>

Multi peer setup

Start peer 1

DATADIR=/data/eof LODE_BINARY=lodestar MULTIPEER=peer1 test/sim/./single-run.sh

As soon as you see lodestar started and see a count down to genesis, you can start peer 2:

DATADIR=/data/eof LODE_BINARY=lodestar MULTIPEER=peer2 test/sim/./single-run.sh

(Pls use lodestar stable version i.e. latest tag, if you omit LODE_BINARY then chainsafe/lodestar:latest docker image will be used)

TODOs: (cc: @holgerd77 )

  • Remove GENESIS_HASH specification requirement [@g11tech]
    Extract total difficulty from the genesis to pass to lodestar instead of hardcoding [@g11tech] NOT relevant for CI spec run
  • Enable executing the run from the sim [@g11tech]
  • Enable running the sim test in CI [@g11tech]
  • Modify gensis to activate the EIPs [@jochem-brouwer /@acolytec3]
  • Add transaction test cases to test the EIP scenarios as follows: [@jochem-brouwer /@acolytec3 ??]
    • 3540
    • 3651
    • 3670
    • 3855
    • 3860

@codecov
Copy link

codecov bot commented Sep 27, 2022

Codecov Report

Merging #2316 (47629a3) into master (4549045) will increase coverage by 1.75%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 89.51% <ø> (ø)
blockchain 90.03% <ø> (ø)
client 87.47% <100.00%> (+<0.01%) ⬆️
common 98.17% <100.00%> (+0.01%) ⬆️
devp2p 91.59% <ø> (-0.03%) ⬇️
ethash ?
evm ?
rlp ∅ <ø> (∅)
statemanager 89.61% <ø> (ø)
trie 90.36% <ø> (+0.34%) ⬆️
tx 97.80% <ø> (ø)
util 84.59% <ø> (ø)
vm 85.67% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


// ------------EIP 3670 tests-------------------------------
t.test(' EIP 3670 tests', async (st) => {
const data = '0x67EF0001010001006060005260086018F3'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we get a description to whatever is being tested here?

Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, great work, some questions!

@g11tech g11tech force-pushed the shandong-testnet branch 2 times, most recently from dc8a56f to e2e7e82 Compare October 6, 2022 09:44
@g11tech g11tech marked this pull request as ready for review October 7, 2022 15:37
@g11tech g11tech added PR state: merge ready target: master Work to be done towards master branch labels Oct 7, 2022
@g11tech g11tech force-pushed the shandong-testnet branch 3 times, most recently from 828e0a3 to e23ebf4 Compare October 14, 2022 16:53
@g11tech g11tech force-pushed the shandong-testnet branch 3 times, most recently from 290b6db to 4fda8f6 Compare October 24, 2022 19:20
@g11tech g11tech changed the title shanghai: Shandong testnet setup shanghai: Eof testnet setup Dec 5, 2022
@g11tech g11tech changed the title shanghai: Eof testnet setup pre-shanghai: Eof testnet setup Dec 5, 2022
Copy link
Contributor

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@g11tech g11tech merged commit 48c3d85 into master Dec 5, 2022
@holgerd77 holgerd77 changed the title pre-shanghai: Eof testnet setup pre-shanghai: Shandong/EOF testnet setup Dec 7, 2022
@holgerd77 holgerd77 deleted the shandong-testnet branch March 28, 2023 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants