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

[DO NOT MERGE] Erigon Tests #3689

Draft
wants to merge 4 commits into
base: release/v0.7.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/test/datastreamer/*.db/*
/test/*.bin
/test/*.db/*
/test/erigon

**/.DS_Store
.vscode
Expand Down
22 changes: 18 additions & 4 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ DOCKERCOMPOSEAPPL2GASPV1TOV2 := zkevm-l2gaspricer-v1tov2
DOCKERCOMPOSEAPPAGG := zkevm-aggregator
DOCKERCOMPOSEAPPAGGV1TOV2 := zkevm-aggregator-v1tov2
DOCKERCOMPOSEAPPRPC := zkevm-json-rpc
DOCKERCOMPOSEAPPERIGONRPC := zkevm-erigon-rpc
DOCKERCOMPOSEAPPRPCV1TOV2 := zkevm-json-rpc-v1tov2
DOCKERCOMPOSEAPPSYNC := zkevm-sync
DOCKERCOMPOSEAPPSYNCV1TOV2 := zkevm-sync-v1tov2
Expand Down Expand Up @@ -44,6 +45,7 @@ RUNV1TOV2L2GASPRICER := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEAPPL2GASPV1TOV2)
RUNAGGREGATOR := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEAPPAGG)
RUNV1TOV2AGGREGATOR := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEAPPAGGV1TOV2)
RUNJSONRPC := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEAPPRPC)
RUNERIGONRPC := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEAPPERIGONRPC)
RUNV1TOV2JSONRPC := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEAPPRPCV1TOV2)
RUNSYNC := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEAPPSYNC)
RUNV1TOV2SYNC := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEAPPSYNCV1TOV2)
Expand Down Expand Up @@ -83,6 +85,7 @@ STOPV1TOV2L2GASPRICER := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEAPPL2GASPV1TOV2) &
STOPAGGREGATOR := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEAPPAGG) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEAPPAGG)
STOPV1TOV2AGGREGATOR := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEAPPAGGV1TOV2) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEAPPAGGV1TOV2)
STOPJSONRPC := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEAPPRPC) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEAPPRPC)
STOPERIGONRPC := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEAPPERIGONRPC) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEAPPERIGONRPC)
STOPV1TOV2JSONRPC := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEAPPRPCV1TOV2) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEAPPRPCV1TOV2)
STOPSYNC := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEAPPSYNC) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEAPPSYNC)
STOPV1TOV2SYNC := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEAPPSYNCV1TOV2) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEAPPSYNCV1TOV2)
Expand Down Expand Up @@ -328,16 +331,18 @@ run-node: ## Runs the node
$(RUNL2GASPRICER)
$(RUNAGGREGATOR)
$(RUNJSONRPC)
$(RUNERIGONRPC)

.PHONY: stop-node
stop-node: ## Stops the node
$(STOPSEQUENCER)
$(STOPSEQUENCESENDER)
$(STOPERIGONRPC)
$(STOPJSONRPC)
$(STOPL2GASPRICER)
$(STOPAGGREGATOR)
$(STOPSYNC)
$(STOPL2GASPRICER)
$(STOPSEQUENCESENDER)
$(STOPSEQUENCER)
$(STOPETHTXMANAGER)
$(STOPSYNC)

.PHONY: run-network
run-network: ## Runs the l1 network
Expand Down Expand Up @@ -455,6 +460,10 @@ stop-sync-v1tov2: ## stops the synchronizer
run-json-rpc: ## runs the JSON-RPC
$(RUNJSONRPC)

.PHONY: run-erigon-rpc
run-erigon-rpc: ## runs the Erigon RPC
$(RUNERIGONRPC)

.PHONY: run-json-rpc-v1tov2
run-json-rpc-v1tov2: ## runs the JSON-RPC
$(RUNV1TOV2JSONRPC)
Expand All @@ -463,6 +472,10 @@ run-json-rpc-v1tov2: ## runs the JSON-RPC
stop-json-rpc: ## stops the JSON-RPC
$(STOPJSONRPC)

.PHONY: stop-erigon-rpc
stop-erigon-rpc: ## stops the Erigon RPC
$(STOPERIGONRPC)

.PHONY: stop-json-rpc-v1tov2
stop-json-rpc-v1tov2: ## stops the JSON-RPC
$(STOPV1TOV2JSONRPC)
Expand Down Expand Up @@ -582,6 +595,7 @@ run: ## Runs a full node
$(RUNL2GASPRICER)
$(RUNAGGREGATOR)
$(RUNJSONRPC)
$(RUNERIGONRPC)

.PHONY: run-v1tov2
run-v1tov2: ## Runs a full node using v1tov2 network
Expand Down
39 changes: 39 additions & 0 deletions test/config/erigon/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
datadir: '~/datadir'
chain: "dynamic-test"
http: true
private.api.addr: "localhost:9096"
zkevm.l2-chain-id: 1001
zkevm.l2-sequencer-rpc-url: "http://zkevm-json-rpc:8123"
zkevm.l2-datastreamer-url: "zkevm-sequencer:6900"
zkevm.l1-chain-id: 1337
zkevm.l1-rpc-url: "http://zkevm-mock-l1-network:8545"

zkevm.address-admin: "0x40aDF03fEff7079d37Bbf2BF06E51D02c659FBB0"

zkevm.address-sequencer: "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
zkevm.address-zkevm: "0x8dAF17A20c9DBA35f005b6324F493785D239719d"
zkevm.address-rollup: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e"
zkevm.address-ger-manager: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"

zkevm.l1-matic-contract-address: "0x5FbDB2315678afecb367f032d93F642f64180aa3"
zkevm.l1-block-range: 20000
zkevm.l1-query-delay: 6000
zkevm.l1-first-block: 136
zkevm.rpc-ratelimit: 250
zkevm.data-stream-port: 6900
zkevm.datastream-version: 2
zkevm.data-stream-host: "127.0.0.1"
zkevm.sequencer-initial-fork-id: 9
zkevm.executor-strict: false
zkevm.executor-urls: "zkevm-prover:50071"
zkevm.witness-full: false
# zkevm.sequencer-block-seal-time: "6s"
# zkevm.sequencer-batch-seal-time: "1h"
zkevm.allow-pre-eip155-transactions: true

externalcl: true
http.api: ["eth","debug","net","trace","web3","erigon","txpool","zkevm"]
http.addr: "0.0.0.0"
http.port: 8223
http.vhosts: '*'
ws: true
86 changes: 86 additions & 0 deletions test/config/erigon/dynamic-test-allocs.json

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions test/config/erigon/dynamic-test-chainspec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"ChainName": "dynamic-test",
"chainId": 1001,
"consensus": "ethash",
"homesteadBlock": 0,
"daoForkBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 9999999999999999999999999999999999999999999999999,
"arrowGlacierBlock": 9999999999999999999999999999999999999999999999999,
"grayGlacierBlock": 9999999999999999999999999999999999999999999999999,
"terminalTotalDifficulty": 58750000000000000000000,
"terminalTotalDifficultyPassed": false,
"shanghaiTime": 9999999999999999999999999999999999999999999999999,
"cancunTime": 9999999999999999999999999999999999999999999999999,
"pragueTime": 9999999999999999999999999999999999999999999999999,
"ethash": {}
}


6 changes: 6 additions & 0 deletions test/config/erigon/dynamic-test-conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"root": "0x489e44072604e671274ea693d5309e797fb37a3e0d91e5b0f04639c251c05332",
"timestamp": 0,
"gasLimit": 0,
"difficulty": 0
}
2 changes: 1 addition & 1 deletion test/config/test.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ StateConsistencyCheckInterval = "5s"
EnableLog = true
[Sequencer.StreamServer]
Port = 6900
Filename = "/datastreamer/datastream.bin"
Filename = "/home/datastream.bin"
Version = 1
ChainID = 1337
Enabled = true
Expand Down
22 changes: 20 additions & 2 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ services:
volumes:
- ./config/test.node.config.toml:/app/config.toml
- ./config/test.genesis.config.json:/app/genesis.json
- ./:/datastreamer
# - ./:/datastreamer
command:
- "/bin/sh"
- "-c"
Expand All @@ -82,7 +82,7 @@ services:
volumes:
- ./config/test.node.config.toml:/app/config.toml
- ./config/test.genesis-v1tov2.config.json:/app/genesis.json
- ./:/datastreamer
# - ./:/datastreamer
command:
- "/bin/sh"
- "-c"
Expand Down Expand Up @@ -145,6 +145,24 @@ services:
- "-c"
- "/app/zkevm-node run --network custom --custom-network-file /app/genesis.json --cfg /app/config.toml --components rpc"

zkevm-erigon-rpc:
container_name: zkevm-erigon-rpc
image: hermeznetwork/cdk-erigon:v1.1.2
ports:
- 0.0.0.0:8223:8223
environment:
- CDK_ERIGON_SEQUENCER=0
volumes:
# - ./erigon:/Volumes/External/hermez/dev
- ./config/erigon/config.yaml:/etc/erigon/config.yaml:ro
- ./config/erigon/dynamic-test-allocs.json:/home/erigon/dynamic-configs/dynamic-test-allocs.json
- ./config/erigon/dynamic-test-chainspec.json:/home/erigon/dynamic-configs/dynamic-test-chainspec.json
- ./config/erigon/dynamic-test-conf.json:/home/erigon/dynamic-configs/dynamic-test-conf.json
- ./config/erigon/dynamic-test-allocs.json:/home/erigon/dynamic-configs/-allocs.json
- ./config/erigon/dynamic-test-chainspec.json:/home/erigon/dynamic-configs/-chainspec.json
- ./config/erigon/dynamic-test-conf.json:/home/erigon/dynamic-configs/-conf.json
command: ["--config", "/etc/erigon/config.yaml"]

zkevm-json-rpc-v1tov2:
container_name: zkevm-json-rpc-v1tov2
image: zkevm-node
Expand Down
7 changes: 6 additions & 1 deletion test/e2e/jsonrpc1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func TestJSONRPC(t *testing.T) {
}
setup()
defer teardown()

for _, network := range networks {
log.Infof("Network %s", network.Name)
sc, err := deployContracts(network.URL, operations.DefaultSequencerPrivateKey, network.ChainID)
Expand All @@ -54,6 +55,8 @@ func deployContracts(url, privateKey string, chainId uint64) (*Double.Double, er
client := operations.MustGetClient(url)
auth := operations.MustGetAuth(privateKey, chainId)

auth.GasPrice = big.NewInt(1000000000)

_, scTx, sc, err := Double.DeployDouble(auth, client)
if err != nil {
return nil, err
Expand All @@ -73,6 +76,7 @@ func Test_Filters(t *testing.T) {
ctx := context.Background()
setup()
defer teardown()

for _, network := range networks {
// test newBlockFilter creation
log.Infof("Network %s", network.Name)
Expand Down Expand Up @@ -467,6 +471,7 @@ func Test_Transactions(t *testing.T) {
ctx := context.Background()
setup()
defer teardown()

for _, network := range networks {
log.Infof("Network %s", network.Name)
ethClient, err := ethclient.Dial(network.URL)
Expand Down Expand Up @@ -539,7 +544,7 @@ func Test_Transactions(t *testing.T) {
balance, err := ethClient.BalanceAt(context.Background(), auth.From, nil)
require.NoError(t, err)

nonce, err = ethClient.NonceAt(context.Background(), auth.From, nil)
nonce, err = ethClient.PendingNonceAt(context.Background(), auth.From)
require.NoError(t, err)

log.Infof("Balance: %d", balance)
Expand Down
16 changes: 12 additions & 4 deletions test/e2e/jsonrpc2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func Test_Misc(t *testing.T) {
ctx := context.Background()
setup()
defer teardown()

for _, network := range networks {
log.Infof("Network %s", network.Name)

Expand Down Expand Up @@ -68,6 +69,7 @@ func Test_Misc(t *testing.T) {
sc_retrieve := common.HexToHash("0x2a")
auth, err := operations.GetAuth(operations.DefaultSequencerPrivateKey, network.ChainID)
require.NoError(t, err)
auth.GasPrice = big.NewInt(1000000000)
contractAddress, tx, storageSC, err := Storage.DeployStorage(auth, ethereumClient)
require.NoError(t, err)
err = operations.WaitTxToBeMined(ctx, ethereumClient, tx, operations.DefaultTimeoutTxToBeMined)
Expand Down Expand Up @@ -274,6 +276,7 @@ func Test_RevertOnConstructorTransaction(t *testing.T) {
auth := operations.MustGetAuth(network.PrivateKey, network.ChainID)

auth.GasLimit = 1000000
auth.GasPrice = big.NewInt(1000000000)

_, scTx, _, err := Revert.DeployRevert(auth, client)
require.NoError(t, err)
Expand Down Expand Up @@ -330,10 +333,13 @@ func Test_RevertOnSCCallTransaction(t *testing.T) {
auth := operations.MustGetAuth(network.PrivateKey, network.ChainID)

auth.GasLimit = 1000000
auth.GasPrice = big.NewInt(1000000000)

_, scTx, sc, err := Revert2.DeployRevert2(auth, client)
require.NoError(t, err)

log.Debugf("waiting tx to be mined: %v", scTx.Hash().String())

err = operations.WaitTxToBeMined(ctx, client, scTx, operations.DefaultTimeoutTxToBeMined)
require.NoError(t, err)

Expand Down Expand Up @@ -391,6 +397,7 @@ func Test_RevertOnSCCallGasEstimation(t *testing.T) {
auth := operations.MustGetAuth(network.PrivateKey, network.ChainID)

auth.GasLimit = 1000000
auth.GasPrice = big.NewInt(1000000000)

_, scTx, sc, err := Revert2.DeployRevert2(auth, client)
require.NoError(t, err)
Expand Down Expand Up @@ -608,17 +615,18 @@ func TestEstimateGas(t *testing.T) {
ethereumClient, err := ethclient.Dial(network.URL)
require.NoError(t, err)

auth := operations.MustGetAuth(network.PrivateKey, network.ChainID)
gasPrice, err := ethereumClient.SuggestGasPrice(ctx)
require.NoError(t, err)
gasPrice = big.NewInt(1000000000)

auth := operations.MustGetAuth(network.PrivateKey, network.ChainID)
auth.GasPrice = gasPrice
// deploy a smart contract
_, tx, sc, err := Counter.DeployCounter(auth, ethereumClient)
require.NoError(t, err)
err = operations.WaitTxToBeMined(ctx, ethereumClient, tx, operations.DefaultTimeoutTxToBeMined)
require.NoError(t, err)

gasPrice, err := ethereumClient.SuggestGasPrice(ctx)
require.NoError(t, err)

// prepare a tx information to be estimated
auth.NoSend = true // force the tx to not be sent while using the sc method
auth.GasLimit = 1 // force gas limit to avoid estimation while building the tx
Expand Down
47 changes: 27 additions & 20 deletions test/e2e/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,33 @@ var (
opsMan *operations.Manager
)

var networks = []struct {
type network struct {
Name string
URL string
WebSocketURL string
ChainID uint64
PrivateKey string
}{
{
Name: "Local L1",
URL: operations.DefaultL1NetworkURL,
WebSocketURL: operations.DefaultL1NetworkWebSocketURL,
ChainID: operations.DefaultL1ChainID,
PrivateKey: operations.DefaultSequencerPrivateKey,
},
{
Name: "Local L2",
URL: operations.DefaultL2NetworkURL,
WebSocketURL: operations.DefaultL2NetworkWebSocketURL,
ChainID: operations.DefaultL2ChainID,
PrivateKey: operations.DefaultSequencerPrivateKey,
},
}

var localGethNetwork = network{
Name: "Local L1",
URL: operations.DefaultL1NetworkURL,
WebSocketURL: operations.DefaultL1NetworkWebSocketURL,
ChainID: operations.DefaultL1ChainID,
PrivateKey: operations.DefaultSequencerPrivateKey,
}

var localErigonNetwork = network{
Name: "Local Erigon L2",
URL: operations.DefaultL2NetworkURL,
WebSocketURL: operations.DefaultL2NetworkWebSocketURL,
ChainID: operations.DefaultL2ChainID,
PrivateKey: operations.DefaultSequencerPrivateKey,
}

var networks = []network{
localGethNetwork,
localErigonNetwork,
}

func setup() {
Expand Down Expand Up @@ -93,10 +99,11 @@ func createTX(client *ethclient.Client, auth *bind.TransactOpts, to common.Addre
return nil, err
}

gasPrice, err := client.SuggestGasPrice(context.Background())
if err != nil {
return nil, err
}
// gasPrice, err := client.SuggestGasPrice(context.Background())
// if err != nil {
// return nil, err
// }
gasPrice := big.NewInt(1000000000)

log.Infof("\nTX details:\n\tNonce: %d\n\tGasLimit: %d\n\tGasPrice: %d", nonce, gasLimit, gasPrice)
if gasLimit != uint64(21000) { //nolint:gomnd
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/uniswap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestUniswap(t *testing.T) {
require.NoError(t, opsman.StartNode())
require.NoError(t, opsman.InitNetwork())

client, err := ethclient.Dial("http://localhost:8123")
client, err := ethclient.Dial(operations.DefaultL2NetworkURL)
require.NoError(t, err)
accountAddr := common.HexToAddress("0xC949254d682D8c9ad5682521675b8F43b102aec4")

Expand Down
Loading
Loading