Skip to content

Commit

Permalink
revert multi-fork for etherman and remove wrappers for contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
joanestebanr committed Jul 19, 2024
1 parent 187efc6 commit 9925aa8
Show file tree
Hide file tree
Showing 26 changed files with 271 additions and 597 deletions.
11 changes: 6 additions & 5 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/0xPolygon/cdk/dataavailability"
"github.com/0xPolygon/cdk/dataavailability/datacommittee"
"github.com/0xPolygon/cdk/etherman"
ethermanconfig "github.com/0xPolygon/cdk/etherman/config"
"github.com/0xPolygon/cdk/etherman/contracts"
"github.com/0xPolygon/cdk/log"
"github.com/0xPolygon/cdk/sequencesender"
Expand Down Expand Up @@ -113,7 +114,7 @@ func createAggregator(ctx context.Context, c config.Config, runMigrations bool)
}

func createSequenceSender(cfg config.Config) *sequencesender.SequenceSender {
ethman, err := etherman.NewClient(etherman.Config{
ethman, err := etherman.NewClient(ethermanconfig.Config{
EthermanConfig: ethtxman.Config{
URL: cfg.SequenceSender.EthTxManager.Etherman.URL,
MultiGasProvider: cfg.SequenceSender.EthTxManager.Etherman.MultiGasProvider,
Expand Down Expand Up @@ -161,16 +162,16 @@ func newTxBuilder(cfg config.Config, ethman *etherman.Client) (txbuilder.TxBuild
switch contracts.VersionType(cfg.Common.ContractVersions) {
case contracts.VersionBanana:
if cfg.Common.IsValidiumMode {
txBuilder = txbuilder.NewTxBuilderBananaValidium(*ethman.Contracts.Banana.ZkEVM, da, *auth, auth.From, cfg.SequenceSender.MaxBatchesForL1)
txBuilder = txbuilder.NewTxBuilderBananaValidium(ethman.Contracts.Banana.Rollup, ethman.Contracts.Banana.GlobalExitRoot, da, *auth, auth.From, cfg.SequenceSender.MaxBatchesForL1)
} else {
txBuilder = txbuilder.NewTxBuilderBananaZKEVM(*ethman.Contracts.Banana.ZkEVM, *auth, auth.From, cfg.SequenceSender.MaxTxSizeForL1)
txBuilder = txbuilder.NewTxBuilderBananaZKEVM(ethman.Contracts.Banana.Rollup, ethman.Contracts.Banana.GlobalExitRoot, *auth, auth.From, cfg.SequenceSender.MaxTxSizeForL1)
}
case contracts.VersionElderberry:
if cfg.Common.IsValidiumMode {
err = fmt.Errorf("Elderberry+Validium not implemented yet")
//txBuilder = txbuilder.NewTxBuilderElderberryValidium(*ethman.Contracts.Elderberry.ZkEVM, da, *auth, auth.From)
} else {
txBuilder = txbuilder.NewTxBuilderElderberryZKEVM(*ethman.Contracts.Elderberry.ZkEVM, *auth, auth.From, cfg.SequenceSender.MaxTxSizeForL1)
txBuilder = txbuilder.NewTxBuilderElderberryZKEVM(ethman.Contracts.Elderberry.Rollup, *auth, auth.From, cfg.SequenceSender.MaxTxSizeForL1)
}
default:
err = fmt.Errorf("unknown contract version: %s", cfg.Common.ContractVersions)
Expand Down Expand Up @@ -241,7 +242,7 @@ func runMigrations(c db.Config, name string) {
}

func newEtherman(c config.Config) (*etherman.Client, error) {
config := etherman.Config{
config := ethermanconfig.Config{
URL: c.Aggregator.EthTxManager.Etherman.URL,
}
return etherman.NewClient(config, c.NetworkConfig.L1Config, c.Common)
Expand Down
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/0xPolygon/cdk/aggregator"
"github.com/0xPolygon/cdk/common"
"github.com/0xPolygon/cdk/etherman"
ethermanconfig "github.com/0xPolygon/cdk/etherman/config"
"github.com/0xPolygon/cdk/log"
"github.com/0xPolygon/cdk/sequencesender"
"github.com/0xPolygonHermez/zkevm-ethtx-manager/ethtxmanager"
Expand Down Expand Up @@ -56,7 +56,7 @@ You could find some examples:
*/
type Config struct {
// Configuration of the etherman (client for access L1)
Etherman etherman.Config
Etherman ethermanconfig.Config
// Configuration for ethereum transaction manager
EthTxManager ethtxmanager.Config
// Configuration of the aggregator
Expand Down
6 changes: 3 additions & 3 deletions config/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"io"
"os"

"github.com/0xPolygon/cdk/etherman"
ethermanconfig "github.com/0xPolygon/cdk/etherman/config"
"github.com/0xPolygon/cdk/log"
"github.com/0xPolygon/cdk/state"
"github.com/ethereum/go-ethereum/common"
Expand All @@ -17,7 +17,7 @@ import (
// NetworkConfig is the configuration struct for the different environments
type NetworkConfig struct {
// L1: Configuration related to L1
L1Config etherman.L1Config `json:"l1Config"`
L1Config ethermanconfig.L1Config `json:"l1Config"`
// L1: Genesis of the rollup, first block number and root
Genesis state.Genesis
}
Expand Down Expand Up @@ -48,7 +48,7 @@ type GenesisFromJSON struct {
// L2: List of states contracts used to populate merkle tree at initial state
Genesis []genesisAccountFromJSON `json:"genesis"`
// L1: configuration of the network
L1Config etherman.L1Config
L1Config ethermanconfig.L1Config
}

type genesisAccountFromJSON struct {
Expand Down
4 changes: 2 additions & 2 deletions etherman/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (etherMan *Client) BuildTrustedVerifyBatchesTxData(lastVerifiedBatch, newVe

const pendStateNum = 0 // TODO hardcoded for now until we implement the pending state feature

tx, err := etherMan.Contracts.RollupManager(nil).VerifyBatchesTrustedAggregator(
tx, err := etherMan.Contracts.Banana.RollupManager.Contract().VerifyBatchesTrustedAggregator(
&opts,
etherMan.RollupID,
pendStateNum,
Expand All @@ -64,7 +64,7 @@ func (etherMan *Client) BuildTrustedVerifyBatchesTxData(lastVerifiedBatch, newVe

// GetBatchAccInputHash gets the batch accumulated input hash from the ethereum
func (etherman *Client) GetBatchAccInputHash(ctx context.Context, batchNumber uint64) (common.Hash, error) {
rollupData, err := etherman.Contracts.RollupManager(nil).GetRollupSequencedBatches(etherman.RollupID, batchNumber)
rollupData, err := etherman.Contracts.Banana.RollupManager.Contract().GetRollupSequencedBatches(&bind.CallOpts{Pending: false}, etherman.RollupID, batchNumber)
if err != nil {
return common.Hash{}, err
}
Expand Down
14 changes: 0 additions & 14 deletions etherman/config.go

This file was deleted.

31 changes: 31 additions & 0 deletions etherman/config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package config

import (
"github.com/0xPolygonHermez/zkevm-ethtx-manager/etherman"
"github.com/ethereum/go-ethereum/common"
)

// Config represents the configuration of the etherman
type Config struct {
// URL is the URL of the Ethereum node for L1
URL string `mapstructure:"URL"`

EthermanConfig etherman.Config

// ForkIDChunkSize is the max interval for each call to L1 provider to get the forkIDs
ForkIDChunkSize uint64 `mapstructure:"ForkIDChunkSize"`
}

// L1Config represents the configuration of the network used in L1
type L1Config struct {
// Chain ID of the L1 network
L1ChainID uint64 `json:"chainId"`
// ZkEVMAddr Address of the L1 contract polygonZkEVMAddress
ZkEVMAddr common.Address `json:"polygonZkEVMAddress"`
// RollupManagerAddr Address of the L1 contract
RollupManagerAddr common.Address `json:"polygonRollupManagerAddress"`
// PolAddr Address of the L1 Pol token Contract
PolAddr common.Address `json:"polTokenAddress"`
// GlobalExitRootManagerAddr Address of the L1 GlobalExitRootManager contract
GlobalExitRootManagerAddr common.Address `json:"polygonZkEVMGlobalExitRootAddress"`
}
152 changes: 0 additions & 152 deletions etherman/contracts.go

This file was deleted.

21 changes: 0 additions & 21 deletions etherman/contracts/banana_daprotocol.go

This file was deleted.

59 changes: 0 additions & 59 deletions etherman/contracts/banana_globalexitroot.go

This file was deleted.

Loading

0 comments on commit 9925aa8

Please sign in to comment.