Skip to content

Commit

Permalink
Separate config file for testing and adapt makefile and compose files… (
Browse files Browse the repository at this point in the history
0xPolygonHermez#1068)

* Separate config file for testing and adapt makefile and compose files to env var

* Test with 100 transactions

* works now with values changed

* fix lint

* set nTx to 50
  • Loading branch information
KonradIT authored Aug 24, 2022
1 parent 9e0e4e8 commit d386586
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 11 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ build-docker-nc: ## Builds a docker image with the node binary - but without bui

.PHONY: test
test: compile-scs ## Runs only short tests without checking race conditions
export CONFIG_MODE="test"
$(STOPDB)
$(STOPZKPROVER)
$(RUNDB); sleep 5
Expand All @@ -94,6 +95,7 @@ test: compile-scs ## Runs only short tests without checking race conditions

.PHONY: test-full
test-full: build-docker compile-scs ## Runs all tests checking race conditions
export CONFIG_MODE="test"
$(STOPDB)
$(STOPZKPROVER)
$(RUNDB); sleep 7
Expand All @@ -103,6 +105,7 @@ test-full: build-docker compile-scs ## Runs all tests checking race conditions

.PHONY: test-full-non-e2e
test-full-non-e2e: build-docker compile-scs ## Runs non-e2e tests checking race conditions
export CONFIG_MODE="test"
$(STOPDB)
$(STOPZKPROVER)
$(RUNDB); sleep 7
Expand All @@ -114,22 +117,25 @@ test-full-non-e2e: build-docker compile-scs ## Runs non-e2e tests checking race

.PHONY: test-e2e-group-1
test-e2e-group-1: build-docker compile-scs ## Runs group 1 e2e tests checking race conditions
export CONFIG_MODE="test"
$(STOPDB)
$(RUNDB); sleep 7
trap '$(STOPDB)' EXIT; MallocNanoZone=0 go test -race -p 1 -timeout 600s ./ci/e2e-group1/...

.PHONY: test-e2e-group-2
test-e2e-group-2: build-docker compile-scs ## Runs group 2 e2e tests checking race conditions
export CONFIG_MODE="test"
$(STOPDB)
$(STOPZKPROVER)
$(RUNDB); sleep 7
$(RUNZKPROVER)
CONFIG_MODE="test" $(RUNZKPROVER)
docker ps -a
docker logs $(DOCKERCOMPOSEZKPROVER)
trap '$(STOPDB) && $(STOPZKPROVER)' EXIT; MallocNanoZone=0 go test -race -p 1 -timeout 600s ./ci/e2e-group2/...

.PHONY: test-e2e-group-3
test-e2e-group-3: build-docker compile-scs ## Runs group 3 e2e tests checking race conditions
export CONFIG_MODE="test"
$(STOPDB)
$(RUNDB); sleep 7
trap '$(STOPDB)' EXIT; MallocNanoZone=0 go test -race -p 1 -timeout 600s ./ci/e2e-group3/...
Expand Down
1 change: 1 addition & 0 deletions config/prover.config.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"proverServerPort": 50051,
"proverServerMockPort": 50052,
"proverClientPort": 50051,
"proverServerMockTimeout": 60000000,

"executorServerPort": 50071,
"executorClientPort": 50071,
Expand Down
14 changes: 7 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
- ZKEVM_NODE_ETHERMAN_PRIVATEKEYPATH=/pk/keystore
volumes:
- ./test/test.keystore:/pk/keystore
- ./config/config.local.toml:/app/config.toml
- ./${CONFIG_MODE}/config/config.${CONFIG_MODE:-local}.toml:/app/config.toml
command:
- "/bin/sh"
- "-c"
Expand All @@ -32,7 +32,7 @@ services:
- ZKEVM_NODE_DATABASE_HOST=zkevm-db
- ZKEVM_NODE_RPC_BROADCASTURI=zkevm-broadcast:61090
volumes:
- ./config/config.local.toml:/app/config.toml
- ./${CONFIG_MODE}/config/config.${CONFIG_MODE:-local}.toml:/app/config.toml
command:
- "/bin/sh"
- "-c"
Expand All @@ -50,7 +50,7 @@ services:
- ZKEVM_NODE_DATABASE_HOST=zkevm-db
- ZKEVM_NODE_RPC_SEQUENCERNODEURI=http://zkevm-json-rpc:8123
volumes:
- ./config/config.local.toml:/app/config.toml
- ./${CONFIG_MODE}/config/config.${CONFIG_MODE:-local}.toml:/app/config.toml
command:
- "/bin/sh"
- "-c"
Expand All @@ -67,7 +67,7 @@ services:
- ZKEVM_NODE_ETHERMAN_PRIVATEKEYPATH=/pk/keystore
volumes:
- ./test/test.keystore:/pk/keystore
- ./config/config.local.toml:/app/config.toml
- ./${CONFIG_MODE}/config/config.${CONFIG_MODE:-local}.toml:/app/config.toml
command:
- "/bin/sh"
- "-c"
Expand All @@ -84,7 +84,7 @@ services:
- ZKEVM_NODE_ETHERMAN_PRIVATEKEYPATH=/pk/keystore
volumes:
- ./test/test.keystore:/pk/keystore
- ./config/config.local.toml:/app/config.toml
- ./${CONFIG_MODE}/config/config.${CONFIG_MODE:-local}.toml:/app/config.toml
command:
- "/bin/sh"
- "-c"
Expand Down Expand Up @@ -184,14 +184,14 @@ services:

zkevm-prover:
container_name: zkevm-prover
image: hermeznetwork/zkprover-local@sha256:8d5798f5b1241fce8858386191dcc8b581f3a818fe719929bd5f0d3c0fd005d9
image: hermeznetwork/zkprover-local@sha256:0be88da4159de817f8a78666742eadf4cac367ace2cdb1fca428152057ae3a02
ports:
# - 50051:50051 # Prover
- 50052:50052 # Mock prover
- 50061:50061 # MT
- 50071:50071 # Executor
volumes:
- ./config/prover.config.local.json:/usr/src/app/config.json
- ./${CONFIG_MODE}/config/prover.config.${CONFIG_MODE:-local}.json:/usr/src/app/config.json
command: >
zkprover input_executor.json
Expand Down
79 changes: 79 additions & 0 deletions test/config/config.test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
IsTrustedSequencer = true

[Log]
Level = "debug"
Outputs = ["stdout"]

[Database]
User = "test_user"
Password = "test_password"
Name = "test_db"
Host = "zkevm-db"
Port = "5432"
EnableLog = false
MaxConns = 200

[Etherman]
URL = "http://zkevm-mock-l1-network:8545"
PrivateKeyPath = "./test/test.keystore"
PrivateKeyPassword = "testonly"

[RPC]
Host = "0.0.0.0"
Port = 8123
MaxRequestsPerIPAndSecond = 5000
SequencerNodeURI = ""
BroadcastURI = "127.0.0.1:61090"
DefaultSenderAddress = "0x1111111111111111111111111111111111111111"

[Synchronizer]
SyncInterval = "1s"
SyncChunkSize = 100
TrustedSequencerURI = ""

[Sequencer]
WaitPeriodPoolIsEmpty = "1s"
WaitPeriodSendSequence = "15s"
LastBatchVirtualizationTimeMaxWaitPeriod = "10s"
WaitBlocksToUpdateGER = 10
LastTimeBatchMaxWaitPeriod = "15s"
BlocksAmountForTxsToBeDeleted = 100
FrequencyToCheckTxsForDelete = "12h"
MaxCumulativeGasUsed = 30000000
MaxKeccakHashes = 468
MaxPoseidonHashes = 279620
MaxPoseidonPaddings = 149796
MaxMemAligns = 262144
MaxArithmetics = 262144
MaxBinaries = 262144
MaxSteps = 8388608
[Sequencer.ProfitabilityChecker]
SendBatchesEvenWhenNotProfitable = "true"

[Aggregator]
IntervalToConsolidateState = "10s"
IntervalFrequencyToGetProofGenerationStateInSeconds = "5s"
TxProfitabilityCheckerType = "acceptall"
TxProfitabilityMinReward = "1.1"

[GasPriceEstimator]
Type = "default"
DefaultGasPriceWei = 1000000000

[Prover]
ProverURI = "zkevm-prover:50052"

[MTServer]
Host = "0.0.0.0"
Port = 50060
StoreBackend = "PostgreSQL"

[MTClient]
URI = "zkevm-prover:50061"

[Executor]
URI = "zkevm-prover:50071"

[BroadcastServer]
Host = "0.0.0.0"
Port = 61090
69 changes: 69 additions & 0 deletions test/config/prover.config.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"runProverServer": false,
"runProverServerMock": true,
"runProverClient": false,

"runExecutorServer": true,
"runExecutorClient": false,

"runStateDBServer": true,
"runStateDBTest": false,

"runFile": false,
"runFileFast": false,

"runKeccakScriptGenerator": false,
"runKeccakTest": false,
"runStorageSMTest": false,
"runBinarySMTest": false,
"runMemAlignSMTest": false,
"runStarkTest": false,

"executeInParallel" : false,
"useMainExecGenerated" : false,

"proverServerPort": 50051,
"proverServerMockPort": 50052,
"proverClientPort": 50051,
"proverServerMockTimeout": 10000000,

"executorServerPort": 50071,
"executorClientPort": 50071,
"executorClientHost": "127.0.0.1",

"stateDBServerPort": 50061,
"stateDBURL": "local",

"inputFile": "input_executor.json",
"outputPath": "output",
"romFile": "rom.json",
"pilFile": "zkevm.pil.json",
"cmPolsFile": "commit.bin",
"constPolsFile": "constants.bin",
"constantsTreeFile": "constantstree.bin",
"scriptFile": "starkgen_bmscript.json",
"starkFile_disabled": "stark.json",
"verifierFile": "verifier.dat",
"witnessFile_disabled": "witness.wtns",
"starkVerifierFile": "starkverifier_0001.zkey",
"publicFile": "public.json",
"proofFile": "proof.json",
"keccakScriptFile": "keccak_script.json",
"keccakPolsFile_DISABLED": "keccak_pols.json",
"keccakConnectionsFile": "keccak_connections.json",
"storageRomFile": "storage_sm_rom.json",
"storagePilFile": "storage.pil.json",
"storagePolsFile": "storage.commit.bin",
"memoryPilFile": "mem.pil.json",
"memoryPolsFile": "mem.commit.bin",
"binaryPilFile": "binary.pil.json",
"binaryPolsFile": "binary.commit.bin",
"binaryConstPolsFile": "binary.constants.bin",
"starkInfoFile": "zkevm.starkinfo.json",

"databaseURL": "postgresql://prover_user:prover_pass@zkevm-db:5432/prover_db",
"dbTableName": "state.merkletree",
"dbAsyncWrite": false,
"cleanerPollingPeriod": 600,
"requestsPersistence": 3600
}
11 changes: 8 additions & 3 deletions test/e2e/ethtransfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"math/big"
"os"
"testing"
"time"

Expand All @@ -15,6 +16,10 @@ import (
"github.com/stretchr/testify/require"
)

func init() {
os.Setenv("CONFIG_MODE", "test")
}

func TestEthTransfer(t *testing.T) {
if testing.Short() {
t.Skip()
Expand All @@ -37,7 +42,7 @@ func TestEthTransfer(t *testing.T) {
client, err := ethclient.Dial("http://localhost:8123")
require.NoError(t, err)
// Send txs
nTxs := 10
nTxs := 50
amount := big.NewInt(10000)
toAddress := common.HexToAddress("0x70997970C51812dc3A010C7d01b50e0d17dc79C8")
gasLimit := uint64(21000)
Expand Down Expand Up @@ -89,11 +94,11 @@ func TestEthTransfer(t *testing.T) {

fmt.Printf("\nL2 Block number: %s", blockL2Number)
fmt.Printf("\nLast TX Hash %s", lastTxHash.String())
err = operations.WaitL2BlockToBeVirtualized(blockL2Number, 8*time.Minute)
err = operations.WaitL2BlockToBeVirtualized(blockL2Number, 5*time.Minute)
require.NoError(t, err)

// wait for l2 block number to be consolidated

err = operations.WaitL2BlockToBeConsolidated(blockL2Number, 8*time.Minute)
err = operations.WaitL2BlockToBeConsolidated(blockL2Number, 5*time.Minute)
require.NoError(t, err)
}

0 comments on commit d386586

Please sign in to comment.