https://github.com/protolambda/rollup-node-experiments
rollup node experiments
https://github.com/protolambda/rollup-node-experiments
Last synced: 16 days ago
JSON representation
rollup node experiments
- Host: GitHub
- URL: https://github.com/protolambda/rollup-node-experiments
- Owner: protolambda
- License: mit
- Created: 2021-12-22T12:18:18.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-25T18:38:18.000Z (over 3 years ago)
- Last Synced: 2025-03-31T04:02:55.655Z (about 2 months ago)
- Language: Shell
- Size: 48.8 KB
- Stars: 15
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rollup node experiments
Test scripts etc. for *experimental* optimistic rollup testing of the new [Optimism 1.0 specs](https://github.com/ethereum-optimism/optimistic-specs).
Running `./install.sh` will run a complete configuration + installation of the system, so that it is
ready to run. Alteratively, follow the instructions below for more figne grained steps.## Config preparation
Change `rollup.yaml` for custom premine / testnet ID / L1 clique signers.
Then run `./setup.sh`, or follow the steps below.
`setup.sh` is idempotent: it produces no changes if ran twice in a row. It does,
as needed rebuild the contracts, regenerate the genesis file configuraiton and
update the `optimistic-specs` and `reference-optimistic-geth` submodule.`setup.sh` does not build the nodes. To do that, runs `./install.sh`, which also
calls `setup.sh`.### Initialize submodules
Run
```
git submodule init
git submodule update
```Alternatively, you can run with these directories being located elsewhere. In
that case, follow the code snippets in this README and do not run the provided
shell scripts.### Optional: recompile system contracts bytecode.
To compile and fetch deployed bytecode, to embed in local testnet genesis states,
run `./build-contracts.sh`, or:```shell
cd ../optimistic-specs/packages/contracts
yarn
yarn build
cat artifacts/contracts/L2/L1Block.sol/L1Block.json | jq -r .deployedBytecode > ../../../rollup-node-experiments/bytecode_l2_l1block.txt
cat artifacts/contracts/L1/DepositFeed.sol/DepositFeed.json | jq -r .deployedBytecode > ../../../rollup-node-experiments/bytecode_l1_depositfeed.txt
```### generate configs
Build the L1 and L2 chain genesis configurations:
```shell
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt# generate a `l1_genesis.json` and `l2_genesis.json` for local L1 and L2 geth instances
python gen_confs.py
```## Node setup
### L1 setup
Run `./build-l1-geth.sh`, or:
```shell
# install upstream geth:
go install github.com/ethereum/go-ethereum/cmd/[email protected]# Create L1 data dir
geth init --datadir data_l1 l1_genesis.json# Import the clique signer secret key into geth
echo -n "foobar" > signer_password.txt
geth --datadir data_l1 account import --password=signer_password.txt signer_0x30eC912c5b1D14aa6d1cb9AA7A6682415C4F7Eb0
```Run `./start-l1-geth.sh`, or:
```
# Start L1 Geth with block production enabled:
geth --datadir data_l1 \
--networkid 900 \
--http --http.api "net,eth,consensus" \
--http.port 8545 \
--http.addr 127.0.0.1 \
--http.corsdomain "*" \
--ws --ws.api "net,eth,consensus" \
--ws.port=8546 \
--ws.addr 0.0.0.0 \
--maxpeers=0 \
--vmodule=rpc=5 \
--allow-insecure-unlock --unlock 0x30eC912c5b1D14aa6d1cb9AA7A6682415C4F7Eb0 \
--password=signer_password.txt --mine
--dev --dev.period=0
```### L2 exec-engine setup
Run `./build-l2-geth.sh` or...
Clone and build the `optimism-prototype` branch into the parent directory containing this repo:
```shell
# Prepare L2 binary (or `go run` directly from source instead)
git clone --branch optimism-prototype https://github.com/ethereum-optimism/reference-optimistic-geth
cd reference-optimistic-geth
go mod download
go build -o refl2geth ./cmd/geth
mv refl2geth ../rollup-node-experiments/
cd ../rollup-node-experiments/# Create L2 data dir
./refl2geth init --datadir data_l2 l2_genesis.json
```Then run `./start-l2-geth.sh` or...
```
# Run L2 geth
# Important: expose engine RPC namespace and activate the merge functionality../refl2geth --datadir data_l2 \
--networkid 901 --catalyst \
--http --http.api "net,eth,consensus,engine" \
--http.port 9000 \
--http.addr 127.0.0.1 \
--http.corsdomain "*" \
--ws --ws.api "net,eth,consensus,engine" \
--ws.port=9001 \
--ws.addr 0.0.0.0 \
--port=30304 \
--nat=none \
--maxpeers=0 \
--vmodule=rpc=5
# TODO: remove maxpeers=0 and --nat=none if testing with more local nodes```
### Rollup-node setup
Run `./get-genesis-hashes.sh` or,
```
# Get the L1 genesis block hash
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x0", false],"id":1}' http://localhost:8545 | jq -r ".result.hash" | tee l1_genesis_hash.txt# Get the L2 genesis block hash
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x0", false],"id":1}' http://localhost:9000 | jq -r ".result.hash" | tee l2_genesis_hash.txt
```Run `./build-rollup-node.sh` or,
```shell
# Prepare rollup-node binary (or `go run` directly from source instead)
git clone https://github.com/ethereum-optimism/optimistic-specs
cd optimistic-specs
go mod download
go build -o rollupnode ./opnode/cmd
mv rollupnode ../rollup-node-experiments/
cd ../rollup-node-experiments/
```Then run `./start-rollup-node.sh` or,
```
./rollupnode run \
--l1=ws://localhost:8546 \
--l2=ws://localhost:9001 \
--log.level=debug \
--genesis.l1-hash=$(cat l1_genesis_hash.txt) \
--genesis.l1-num=0 \
--genesis.l2-hash=$(cat l2_genesis_hash.txt)
```### Running nodes in the background
```
./start-l1-geth-killable.sh &
L1PID=$!
./start-l2-geth-killable.sh &
L2PID=$!
./start-rollup-node-killable.sh &
RNPID=$!# killing
kill $L1PID
kill $L2PID
kill $L3PID
```### Verifying that the system works
Run `./test.sh`, this will run all nodes in the background (just like the previous section) and
additionally submit a deposit on L1.To further play around with the system, you might find it useful to source the `cast-env` file which
sets useful environment variables.### Resetting
In order to restart the test with a new build, you will likely want to wipe the chainstate, which
will also require rebuilding the l1 and l2 nodes. This can be accomplished by running the following
scripts:```
# kill all running L1, L2 and rollup nodes (may include other mainnet nodes!)
./killall.sh# deletes both data_l1 and data_l2 dirs
./clean.sh# rebuild and start l1-geth
./build-l1-geth.sh && ./start-l1-geth.sh# rebuild and start l2-geth
./build-l2-geth.sh && ./start-l2-geth.sh# rebuild and start rollup-node
./get-genesis-hashes.sh && ./build-rollup-node.sh && ./start-rollup-node.sh
```## License
MIT, see [`LICENSE`](./LICENSE) file.