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

Commit

Permalink
Merge remote-tracking branch 'origin/remove-validium-dep' into vcaste…
Browse files Browse the repository at this point in the history
…llm/refactor_rpc
  • Loading branch information
Victor Castell committed Dec 20, 2023
2 parents 0717692 + 7135f88 commit 6eac949
Show file tree
Hide file tree
Showing 20 changed files with 361 additions and 215 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 @@ -137,13 +136,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(ctx, executor, storage),
Expand Down
14 changes: 7 additions & 7 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/ethereum/go-ethereum/common"
"github.com/mitchellh/mapstructure"
Expand All @@ -27,8 +27,8 @@ type FullNodeRPCs map[common.Address]string

// Config represents the full configuration of the data node
type Config struct {
FullNodeRPCs FullNodeRPCs `mapstructure:"FullNodeRPCs"`
RPC jsonrpc.Config `mapstructure:"RPC"`
FullNodeRPCs rpc.FullNodeRPCs `mapstructure:"FullNodeRPCs"`
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
2 changes: 1 addition & 1 deletion docker/data/zkevm/genesis.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"l1Config" : {
"chainId": 1337,
"cdkValidiumAddress": "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
"polygonZkEVMAddress": "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
"maticTokenAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"polygonZkEVMGlobalExitRootAddress": "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
"cdkDataCommitteeContract": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6"
Expand Down
72 changes: 47 additions & 25 deletions docker/data/zkevm/node.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,27 @@ Environment = "development" # "production" or "development"
Level = "debug"
Outputs = ["stderr"]

[StateDB]
User = "state_user"
Password = "state_password"
Name = "state_db"
Host = "zkevm-state-db"
Port = "5432"
EnableLog = false
MaxConns = 200
[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
Expand All @@ -23,6 +36,17 @@ MaxTxDataBytesSize=100000
DefaultMinGasPriceAllowed = 1000000000
MinAllowedGasPriceInterval = "5m"
PollMinAllowedGasPriceInterval = "15s"
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"
Expand Down Expand Up @@ -55,22 +79,26 @@ EnableL2SuggestedGasPricePolling = true
SyncInterval = "1s"
SyncChunkSize = 100
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]
Expand All @@ -88,12 +116,6 @@ MaxTxLifetime = "3h"
[Sequencer.DBManager]
PoolRetrievalInterval = "500ms"
L2ReorgRetrievalInterval = "5s"
[Sequencer.EffectiveGasPrice]
MaxBreakEvenGasPriceDeviationPercentage = 10
L1GasPriceFactor = 0.25
ByteGasCost = 16
MarginFactor = 1
Enabled = false

[SequenceSender]
WaitPeriodSendSequence = "15s"
Expand All @@ -113,7 +135,7 @@ 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"}
Expand Down
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
7 changes: 4 additions & 3 deletions etherman/etherman_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ package etherman
import (
"context"
"errors"
"math/big"
"testing"

"github.com/0xPolygon/beethoven/mocks"
cdkTypes "github.com/0xPolygon/beethoven/rpc/types"
"github.com/0xPolygon/beethoven/tx"
cdkTypes "github.com/0xPolygon/cdk-validium-node/jsonrpc/types"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"math/big"
"testing"
)

func signer(from common.Address, tx *types.Transaction) (*types.Transaction, error) {
Expand Down
2 changes: 1 addition & 1 deletion etherman/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"strings"

"github.com/0xPolygon/cdk-validium-node/encoding"
"github.com/0xPolygonHermez/zkevm-node/encoding"
)

type Proof [ProofLength][HashLength]byte
Expand Down
Loading

0 comments on commit 6eac949

Please sign in to comment.