Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #30 from 0xPolygon/remove-validium-dep
Browse files Browse the repository at this point in the history
Remove validium dep
  • Loading branch information
vcastellm authored Jan 2, 2024
2 parents cbbad29 + 7bd6ce4 commit 0572fbf
Show file tree
Hide file tree
Showing 22 changed files with 746 additions and 212 deletions.
6 changes: 3 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"fmt"
"time"

"github.com/0xPolygon/cdk-validium-node/ethtxmanager"
"github.com/0xPolygon/cdk-validium-node/jsonrpc/client"
"github.com/0xPolygon/cdk-validium-node/jsonrpc/types"
"github.com/0xPolygon/beethoven/rpc/types"
"github.com/0xPolygonHermez/zkevm-node/ethtxmanager"
"github.com/0xPolygonHermez/zkevm-node/jsonrpc/client"
"github.com/ethereum/go-ethereum/common"

"github.com/0xPolygon/beethoven/tx"
Expand Down
17 changes: 6 additions & 11 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import (
"os/signal"
"time"

"github.com/0xPolygon/cdk-data-availability/dummyinterfaces"
dbConf "github.com/0xPolygon/cdk-validium-node/db"
"github.com/0xPolygon/cdk-validium-node/ethtxmanager"
"github.com/0xPolygon/cdk-validium-node/jsonrpc"
"github.com/0xPolygon/cdk-validium-node/log"
jRPC "github.com/0xPolygon/cdk-data-availability/rpc"
dbConf "github.com/0xPolygonHermez/zkevm-node/db"
"github.com/0xPolygonHermez/zkevm-node/ethtxmanager"
"github.com/0xPolygonHermez/zkevm-node/log"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
Expand Down Expand Up @@ -125,13 +124,9 @@ func start(cliCtx *cli.Context) error {
}

// Register services
server := jsonrpc.NewServer(
server := jRPC.NewServer(
c.RPC,
0,
&dummyinterfaces.DummyPool{},
&dummyinterfaces.DummyState{},
&dummyinterfaces.DummyStorage{},
[]jsonrpc.Service{
[]jRPC.Service{
{
Name: rpc.INTEROP,
Service: rpc.NewInteropEndpoints(addr, storage, &ethMan,
Expand Down
12 changes: 6 additions & 6 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"path/filepath"
"strings"

"github.com/0xPolygon/cdk-validium-node/config/types"
"github.com/0xPolygon/cdk-validium-node/db"
"github.com/0xPolygon/cdk-validium-node/ethtxmanager"
"github.com/0xPolygon/cdk-validium-node/jsonrpc"
"github.com/0xPolygon/cdk-validium-node/log"
jRPC "github.com/0xPolygon/cdk-data-availability/rpc"
"github.com/0xPolygonHermez/zkevm-node/config/types"
"github.com/0xPolygonHermez/zkevm-node/db"
"github.com/0xPolygonHermez/zkevm-node/ethtxmanager"
"github.com/0xPolygonHermez/zkevm-node/log"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/mitchellh/mapstructure"
"github.com/spf13/viper"
Expand All @@ -27,7 +27,7 @@ const (
// Config represents the full configuration of the data node
type Config struct {
FullNodeRPCs rpc.FullNodeRPCs `mapstructure:"FullNodeRPCs"`
RPC jsonrpc.Config `mapstructure:"RPC"`
RPC jRPC.Config `mapstructure:"RPC"`
Log log.Config `mapstructure:"Log"`
DB db.Config `mapstructure:"DB"`
EthTxManager ethtxmanager.Config `mapstructure:"EthTxManager"`
Expand Down
2 changes: 1 addition & 1 deletion db/migrations.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package db

import (
"github.com/0xPolygon/cdk-validium-node/log"
"github.com/0xPolygonHermez/zkevm-node/log"
"github.com/gobuffalo/packr/v2"
"github.com/jackc/pgx/v4/pgxpool"
"github.com/jackc/pgx/v4/stdlib"
Expand Down
1 change: 1 addition & 0 deletions db/migrations/0001.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ CREATE TABLE state.monitored_txs
data VARCHAR,
gas DECIMAL(78, 0) NOT NULL,
gas_price DECIMAL(78, 0) NOT NULL,
gas_offset DECIMAL(78, 0) NOT NULL DEFAULT 0,
status VARCHAR NOT NULL,
history VARCHAR[],
block_num BIGINT,
Expand Down
6 changes: 3 additions & 3 deletions docker/data/zkevm/genesis.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"l1Config" : {
"chainId": 1337,
"cdkValidiumAddress": "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
"polygonZkEVMAddress": "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
"maticTokenAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"polygonZkEVMGlobalExitRootAddress": "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
"cdkDataCommitteeContract": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6"
},
"root": "0xd88680f1b151dd67518f9aca85161424c0cac61df2f5424a3ddc04ea25adecc7",
"genesisBlockNumber": 75,
"genesisBlockNumber": 76,
"genesis": [
{
"contractName": "PolygonZkEVMDeployer",
Expand Down Expand Up @@ -100,4 +100,4 @@
"address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
}
]
}
}
132 changes: 76 additions & 56 deletions docker/data/zkevm/node.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,63 @@ Environment = "development" # "production" or "development"
Level = "debug"
Outputs = ["stderr"]

[StateDB]
[State]
[State.DB]
User = "state_user"
Password = "state_password"
Name = "state_db"
Host = "zkevm-state-db"
Port = "5432"
EnableLog = false
MaxConns = 200
[State.Batch]
[State.Batch.Constraints]
MaxTxsPerBatch = 300
MaxBatchBytesSize = 120000
MaxCumulativeGasUsed = 30000000
MaxKeccakHashes = 2145
MaxPoseidonHashes = 252357
MaxPoseidonPaddings = 135191
MaxMemAligns = 236585
MaxArithmetics = 236585
MaxBinaries = 473170
MaxSteps = 7570538

[Pool]
FreeClaimGasLimit = 1500000
IntervalToRefreshBlockedAddresses = "5m"
IntervalToRefreshGasPrices = "5s"
MaxTxBytesSize=100132
MaxTxDataBytesSize=100000
MaxTxBytesSize = 100132
MaxTxDataBytesSize = 100000
DefaultMinGasPriceAllowed = 1000000000
MinAllowedGasPriceInterval = "5m"
PollMinAllowedGasPriceInterval = "15s"
[Pool.DB]
User = "pool_user"
Password = "pool_password"
Name = "pool_db"
Host = "zkevm-pool-db"
Port = "5432"
EnableLog = false
MaxConns = 200
AccountQueue = 64
GlobalQueue = 1024
[Pool.EffectiveGasPrice]
Enabled = false
L1GasPriceFactor = 0.25
ByteGasCost = 16
ZeroByteGasCost = 4
NetProfit = 1
BreakEvenFactor = 1.1
FinalDeviationPct = 10
L2GasPriceSuggesterFactor = 0.5
[Pool.DB]
User = "pool_user"
Password = "pool_password"
Name = "pool_db"
Host = "zkevm-pool-db"
Port = "5432"
EnableLog = false
MaxConns = 200

[Etherman]
URL = "http://l1:8545"
ForkIDChunkSize = 20000
MultiGasProvider = false
[Etherscan]
ApiKey = ""
[Etherscan]
ApiKey = ""

[RPC]
Host = "0.0.0.0"
Expand All @@ -47,60 +71,58 @@ WriteTimeout = "60s"
MaxRequestsPerIPAndSecond = 5000
SequencerNodeURI = ""
EnableL2SuggestedGasPricePolling = true
[RPC.WebSockets]
Enabled = true
Port = 8133
[RPC.WebSockets]
Enabled = true
Port = 8133

[Synchronizer]
SyncInterval = "1s"
SyncChunkSize = 100
TrustedSequencerURL = "" # If it is empty or not specified, then the value is read from the smc.
TrustedSequencerURL = "" # If it is empty or not specified, then the value is read from the smc.
L1SynchronizationMode = "sequential" # "sequential" or "parallel"
[Synchronizer.L1ParallelSynchronization]
MaxClients = 10
MaxPendingNoProcessedBlocks = 25
RequestLastBlockPeriod = "5s"
RequestLastBlockTimeout = "5s"
RequestLastBlockMaxRetries = 3
StatisticsPeriod = "5m"
TimeoutMainLoop = "5m"
RollupInfoRetriesSpacing = "5s"
FallbackToSequentialModeOnSynchronized = false
[Synchronizer.L1ParallelSynchronization.PerformanceWarning]
AceptableInacctivityTime = "5s"
ApplyAfterNumRollupReceived = 10

[Sequencer]
WaitPeriodPoolIsEmpty = "1s"
LastBatchVirtualizationTimeMaxWaitPeriod = "10s"
BlocksAmountForTxsToBeDeleted = 100
FrequencyToCheckTxsForDelete = "12h"
MaxTxsPerBatch = 300
MaxBatchBytesSize = 120000
MaxCumulativeGasUsed = 30000000
MaxKeccakHashes = 2145
MaxPoseidonHashes = 252357
MaxPoseidonPaddings = 135191
MaxMemAligns = 236585
MaxArithmetics = 236585
MaxBinaries = 473170
MaxSteps = 7570538
TxLifetimeCheckTimeout = "10m"
MaxTxLifetime = "3h"
[Sequencer.Finalizer]
GERDeadlineTimeout = "2s"
ForcedBatchDeadlineTimeout = "5s"
SleepDuration = "100ms"
ResourcePercentageToCloseBatch = 10
GERFinalityNumberOfBlocks = 0
ClosingSignalsManagerWaitForCheckingL1Timeout = "10s"
ClosingSignalsManagerWaitForCheckingGER = "10s"
ClosingSignalsManagerWaitForCheckingForcedBatches = "10s"
ForcedBatchesFinalityNumberOfBlocks = 0
TimestampResolution = "10s"
StopSequencerOnBatchNum = 0
[Sequencer.DBManager]
PoolRetrievalInterval = "500ms"
L2ReorgRetrievalInterval = "5s"
[Sequencer.EffectiveGasPrice]
MaxBreakEvenGasPriceDeviationPercentage = 10
L1GasPriceFactor = 0.25
ByteGasCost = 16
MarginFactor = 1
Enabled = false
[Sequencer.Finalizer]
GERDeadlineTimeout = "2s"
ForcedBatchDeadlineTimeout = "5s"
SleepDuration = "100ms"
ResourcePercentageToCloseBatch = 10
GERFinalityNumberOfBlocks = 0
ClosingSignalsManagerWaitForCheckingL1Timeout = "10s"
ClosingSignalsManagerWaitForCheckingGER = "10s"
ClosingSignalsManagerWaitForCheckingForcedBatches = "10s"
ForcedBatchesFinalityNumberOfBlocks = 0
TimestampResolution = "10s"
StopSequencerOnBatchNum = 0
[Sequencer.DBManager]
PoolRetrievalInterval = "500ms"
L2ReorgRetrievalInterval = "5s"

[SequenceSender]
WaitPeriodSendSequence = "15s"
LastBatchVirtualizationTimeMaxWaitPeriod = "10s"
MaxTxSizeForL1 = 131072
L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
PrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"}
PrivateKey = { Path = "/pk/sequencer.keystore", Password = "testonly" }

[Aggregator]
Host = "0.0.0.0"
Expand All @@ -113,16 +135,14 @@ ProofStatePollingInterval = "5s"
SenderAddress = "0x70997970c51812dc3a010c7d01b50e0d17dc79c8"
CleanupLockedProofsInterval = "2m"
GeneratingProofCleanupThreshold = "10m"
SetlementBackend = "beethoven"
SettlementBackend = "beethoven"
BeethovenURL = "http://beethoven:4444"
BeethovenTxTimeout = "30s"
SequencerPrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"}
SequencerPrivateKey = { Path = "/pk/sequencer.keystore", Password = "testonly" }

[EthTxManager]
ForcedGas = 0
PrivateKeys = [
{Path = "/pk/sequencer.keystore", Password = "testonly"},
]
PrivateKeys = [{ Path = "/pk/sequencer.keystore", Password = "testonly" }]

[L2GasPriceSuggester]
Type = "default"
Expand All @@ -132,7 +152,7 @@ DefaultGasPriceWei = 1000000000
MaxGasPriceWei = 0

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

[Executor]
URI = "zkevm-prover:50071"
Expand All @@ -153,4 +173,4 @@ Name = "prover_db"
Host = "zkevm-state-db"
Port = "5432"
EnableLog = false
MaxConns = 200
MaxConns = 200
10 changes: 5 additions & 5 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.9'
services:
l1:
container_name: l1
image: hermeznetwork/geth-cdk-validium-contracts:v0.0.1
image: hermeznetwork/geth-cdk-validium-contracts:v0.0.2
command: [
"--http",
"--http.api", "admin,eth,debug,miner,net,txpool,personal,web3",
Expand Down Expand Up @@ -64,7 +64,7 @@ services:
- beethoven-localnet

zkevm-prover:
image: hermeznetwork/zkevm-prover:v2.2.0
image: hermeznetwork/zkevm-prover:v3.0.2
command: [
"zkProver",
"-c",
Expand All @@ -82,12 +82,12 @@ services:
- beethoven-localnet

zkevm-node:
image: hermeznetwork/cdk-validium-node:beethoven
image: hermeznetwork/cdk-validium-node:beethoven-v0.0.1
command:
- "/bin/sh"
- "-c"
- "/app/cdk-validium-node approve --network custom --custom-network-file /app/genesis.json --am 115792089237316195423570985008687907853269984665640564039457584007913129639935 -y --cfg /app/config.toml --key-store-path /pk/sequencer.keystore --password testonly &&
/app/cdk-validium-node run --network custom --custom-network-file /app/genesis.json --cfg /app/config.toml --components \"synchronizer,rpc,sequencer,sequence-sender,aggregator,eth-tx-manager,l2gaspricer\""
- "/app/zkevm-node approve --network custom --custom-network-file /app/genesis.json --am 115792089237316195423570985008687907853269984665640564039457584007913129639935 -y --cfg /app/config.toml --key-store-path /pk/sequencer.keystore --password testonly &&
/app/zkevm-node run --network custom --custom-network-file /app/genesis.json --cfg /app/config.toml --components \"synchronizer,rpc,sequencer,sequence-sender,aggregator,eth-tx-manager,l2gaspricer\""
ports:
- '8123:8123'
- '61090:61090'
Expand Down
14 changes: 7 additions & 7 deletions etherman/etherman.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"math/big"
"time"

"github.com/0xPolygon/cdk-validium-node/etherman/smartcontracts/cdkvalidium"
"github.com/0xPolygon/cdk-validium-node/log"
"github.com/0xPolygon/cdk-validium-node/state"
"github.com/0xPolygon/cdk-validium-node/test/operations"
"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygonzkevm"
"github.com/0xPolygonHermez/zkevm-node/log"
"github.com/0xPolygonHermez/zkevm-node/state"
"github.com/0xPolygonHermez/zkevm-node/test/operations"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -57,7 +57,7 @@ func (e *Etherman) BuildTrustedVerifyBatchesTxData(lastVerifiedBatch, newVerifie
}

const pendStateNum uint64 = 0 // TODO hardcoded for now until we implement the pending state feature
abi, err := cdkvalidium.CdkvalidiumMetaData.GetAbi()
abi, err := polygonzkevm.PolygonzkevmMetaData.GetAbi()
if err != nil {
log.Errorf("error geting ABI: %v, Proof: %s", err)
return nil, err
Expand All @@ -78,15 +78,15 @@ func (e *Etherman) CallContract(ctx context.Context, call ethereum.CallMsg, bloc
return e.ethClient.CallContract(ctx, call, blockNumber)
}

func (e *Etherman) contractCaller(from, to common.Address) (*bind.TransactOpts, *cdkvalidium.Cdkvalidium, error) {
func (e *Etherman) contractCaller(from, to common.Address) (*bind.TransactOpts, *polygonzkevm.Polygonzkevm, error) {
opts := bind.TransactOpts{}
opts.From = from
opts.NoSend = true
// force nonce, gas limit and gas price to avoid querying it from the chain
opts.Nonce = big.NewInt(1)
opts.GasLimit = uint64(1)
opts.GasPrice = big.NewInt(1)
contract, err := cdkvalidium.NewCdkvalidium(to, e.ethClient)
contract, err := polygonzkevm.NewPolygonzkevm(to, e.ethClient)
if err != nil {
log.Errorf("error instantiating contract: %s", err)
return nil, nil, err
Expand Down
Loading

0 comments on commit 0572fbf

Please sign in to comment.