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

New smc version #1581

Merged
merged 8 commits into from
Jan 26, 2023
Merged
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
50 changes: 43 additions & 7 deletions config/environments/local/local.genesis.config.json

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions config/environments/local/local.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ Port = "5432"
EnableLog = false
MaxConns = 200

[PoolDB]
User = "pool_user"
Password = "pool_password"
Name = "pool_db"
Host = "zkevm-pool-db"
Port = "5432"
EnableLog = false
MaxConns = 200
[Pool]
FreeClaimGasLimit = 1500000
[Pool.DB]
User = "pool_user"
Password = "pool_password"
Name = "pool_db"
Host = "zkevm-pool-db"
Port = "5432"
EnableLog = false
MaxConns = 200

[Etherman]
URL = "http://your.L1node.url"
Expand Down Expand Up @@ -88,7 +90,7 @@ VerifyProofInterval = "30s"
TxProfitabilityCheckerType = "acceptall"
TxProfitabilityMinReward = "1.1"
ProofStatePollingInterval = "5s"
SenderAddress = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
SenderAddress = "0x70997970c51812dc3a010c7d01b50e0d17dc79c8"

[EthTxManager]
PrivateKeys = [
Expand Down
2 changes: 1 addition & 1 deletion config/environments/public/public.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ EnableLog = false
MaxConns = 200

[Pool]
FreeClaimGasLimit = 150000
FreeClaimGasLimit = 1500000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason for the increment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, due to some smc updates, right now the claim can be use more gas during an erc20 bridge where the erc20 doesn't exist yet on l2 and the contract needs to be deployed

[Pool.DB]
User = "pool_user"
Password = "pool_password"
Expand Down
48 changes: 24 additions & 24 deletions etherman/etherman.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (

"github.com/0xPolygonHermez/zkevm-node/etherman/etherscan"
"github.com/0xPolygonHermez/zkevm-node/etherman/ethgasstation"
"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/globalexitrootmanager"
"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/matic"
"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/proofofefficiency"
"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygonzkevm"
"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygonzkevmglobalexitroot"
ethmanTypes "github.com/0xPolygonHermez/zkevm-node/etherman/types"
"github.com/0xPolygonHermez/zkevm-node/log"
"github.com/0xPolygonHermez/zkevm-node/state"
Expand Down Expand Up @@ -105,8 +105,8 @@ type externalGasProviders struct {
// Client is a simple implementation of EtherMan.
type Client struct {
EthClient ethereumClient
PoE *proofofefficiency.Proofofefficiency
GlobalExitRootManager *globalexitrootmanager.Globalexitrootmanager
PoE *polygonzkevm.Polygonzkevm
GlobalExitRootManager *polygonzkevmglobalexitroot.Polygonzkevmglobalexitroot
Matic *matic.Matic
SCAddresses []common.Address

Expand All @@ -125,11 +125,11 @@ func NewClient(cfg Config) (*Client, error) {
return nil, err
}
// Create smc clients
poe, err := proofofefficiency.NewProofofefficiency(cfg.PoEAddr, ethClient)
poe, err := polygonzkevm.NewPolygonzkevm(cfg.PoEAddr, ethClient)
if err != nil {
return nil, err
}
globalExitRoot, err := globalexitrootmanager.NewGlobalexitrootmanager(cfg.GlobalExitRootManagerAddr, ethClient)
globalExitRoot, err := polygonzkevmglobalexitroot.NewPolygonzkevmglobalexitroot(cfg.GlobalExitRootManagerAddr, ethClient)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -347,13 +347,13 @@ func (etherMan *Client) BuildSequenceBatchesTxData(sender common.Address, sequen
}

func (etherMan *Client) sequenceBatches(opts bind.TransactOpts, sequences []ethmanTypes.Sequence) (*types.Transaction, error) {
var batches []proofofefficiency.ProofOfEfficiencyBatchData
var batches []polygonzkevm.PolygonZkEVMBatchData
for _, seq := range sequences {
batchL2Data, err := state.EncodeTransactions(seq.Txs)
if err != nil {
return nil, fmt.Errorf("failed to encode transactions, err: %v", err)
}
batch := proofofefficiency.ProofOfEfficiencyBatchData{
batch := polygonzkevm.PolygonZkEVMBatchData{
Transactions: batchL2Data,
GlobalExitRoot: seq.GlobalExitRoot,
Timestamp: uint64(seq.Timestamp),
Expand Down Expand Up @@ -467,7 +467,7 @@ func (etherMan *Client) forcedBatchEvent(ctx context.Context, vLog types.Log, bl
txData := tx.Data()
// Extract coded txs.
// Load contract ABI
abi, err := abi.JSON(strings.NewReader(proofofefficiency.ProofofefficiencyABI))
abi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI))
if err != nil {
return err
}
Expand Down Expand Up @@ -561,7 +561,7 @@ func (etherMan *Client) sequencedBatchesEvent(ctx context.Context, vLog types.Lo
func decodeSequences(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64) ([]SequencedBatch, error) {
// Extract coded txs.
// Load contract ABI
abi, err := abi.JSON(strings.NewReader(proofofefficiency.ProofofefficiencyABI))
abi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI))
if err != nil {
return nil, err
}
Expand All @@ -577,7 +577,7 @@ func decodeSequences(txData []byte, lastBatchNumber uint64, sequencer common.Add
if err != nil {
return nil, err
}
var sequences []proofofefficiency.ProofOfEfficiencyBatchData
var sequences []polygonzkevm.PolygonZkEVMBatchData
bytedata, err := json.Marshal(data[0])
if err != nil {
return nil, err
Expand All @@ -591,11 +591,11 @@ func decodeSequences(txData []byte, lastBatchNumber uint64, sequencer common.Add
for i, seq := range sequences {
bn := lastBatchNumber - uint64(len(sequences)-(i+1))
sequencedBatches[i] = SequencedBatch{
BatchNumber: bn,
Coinbase: sequencer,
TxHash: txHash,
Nonce: nonce,
ProofOfEfficiencyBatchData: seq,
BatchNumber: bn,
Coinbase: sequencer,
TxHash: txHash,
Nonce: nonce,
PolygonZkEVMBatchData: seq,
}
}

Expand Down Expand Up @@ -686,7 +686,7 @@ func (etherMan *Client) forceSequencedBatchesEvent(ctx context.Context, vLog typ
func decodeSequencedForceBatches(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, block *types.Block, nonce uint64) ([]SequencedForceBatch, error) {
// Extract coded txs.
// Load contract ABI
abi, err := abi.JSON(strings.NewReader(proofofefficiency.ProofofefficiencyABI))
abi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI))
if err != nil {
return nil, err
}
Expand All @@ -703,7 +703,7 @@ func decodeSequencedForceBatches(txData []byte, lastBatchNumber uint64, sequence
return nil, err
}

var forceBatches []proofofefficiency.ProofOfEfficiencyForcedBatchData
var forceBatches []polygonzkevm.PolygonZkEVMForcedBatchData
bytedata, err := json.Marshal(data[0])
if err != nil {
return nil, err
Expand All @@ -717,12 +717,12 @@ func decodeSequencedForceBatches(txData []byte, lastBatchNumber uint64, sequence
for i, force := range forceBatches {
bn := lastBatchNumber - uint64(len(forceBatches)-(i+1))
sequencedForcedBatches[i] = SequencedForceBatch{
BatchNumber: bn,
Coinbase: sequencer,
TxHash: txHash,
Timestamp: time.Unix(int64(block.Time()), 0),
Nonce: nonce,
ProofOfEfficiencyForcedBatchData: force,
BatchNumber: bn,
Coinbase: sequencer,
TxHash: txHash,
Timestamp: time.Unix(int64(block.Time()), 0),
Nonce: nonce,
PolygonZkEVMForcedBatchData: force,
}
}
return sequencedForcedBatches, nil
Expand Down
20 changes: 10 additions & 10 deletions etherman/etherman_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"testing"
"time"

"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/bridge"
"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/proofofefficiency"
"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygonzkevm"
"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygonzkevmbridge"
ethmanTypes "github.com/0xPolygonHermez/zkevm-node/etherman/types"
"github.com/0xPolygonHermez/zkevm-node/log"
"github.com/ethereum/go-ethereum"
Expand All @@ -30,7 +30,7 @@ func init() {
}

// This function prepare the blockchain, the wallet with funds and deploy the smc
func newTestingEnv() (ethman *Client, ethBackend *backends.SimulatedBackend, auth *bind.TransactOpts, maticAddr common.Address, br *bridge.Bridge) {
func newTestingEnv() (ethman *Client, ethBackend *backends.SimulatedBackend, auth *bind.TransactOpts, maticAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge) {
privateKey, err := crypto.GenerateKey()
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -150,14 +150,14 @@ func TestSequencedBatchesEvent(t *testing.T) {
currentBlockNumber := currentBlock.NumberU64()
blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &currentBlockNumber)
require.NoError(t, err)
var sequences []proofofefficiency.ProofOfEfficiencyBatchData
sequences = append(sequences, proofofefficiency.ProofOfEfficiencyBatchData{
var sequences []polygonzkevm.PolygonZkEVMBatchData
sequences = append(sequences, polygonzkevm.PolygonZkEVMBatchData{
GlobalExitRoot: ger,
Timestamp: currentBlock.Time(),
MinForcedTimestamp: uint64(blocks[1].ForcedBatches[0].ForcedAt.Unix()),
Transactions: common.Hex2Bytes(rawTxs),
})
sequences = append(sequences, proofofefficiency.ProofOfEfficiencyBatchData{
sequences = append(sequences, polygonzkevm.PolygonZkEVMBatchData{
GlobalExitRoot: ger,
Timestamp: currentBlock.Time() + 1,
MinForcedTimestamp: 0,
Expand Down Expand Up @@ -195,13 +195,13 @@ func TestVerifyBatchEvent(t *testing.T) {
require.NoError(t, err)

rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c"
tx := proofofefficiency.ProofOfEfficiencyBatchData{
tx := polygonzkevm.PolygonZkEVMBatchData{
GlobalExitRoot: common.Hash{},
Timestamp: initBlock.Time(),
MinForcedTimestamp: 0,
Transactions: common.Hex2Bytes(rawTxs),
}
_, err = etherman.PoE.SequenceBatches(auth, []proofofefficiency.ProofOfEfficiencyBatchData{tx})
_, err = etherman.PoE.SequenceBatches(auth, []polygonzkevm.PolygonZkEVMBatchData{tx})
require.NoError(t, err)

// Mine the tx in a block
Expand Down Expand Up @@ -264,12 +264,12 @@ func TestSequenceForceBatchesEvent(t *testing.T) {
blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
require.NoError(t, err)

forceBatchData := proofofefficiency.ProofOfEfficiencyForcedBatchData{
forceBatchData := polygonzkevm.PolygonZkEVMForcedBatchData{
Transactions: blocks[0].ForcedBatches[0].RawTxsData,
GlobalExitRoot: blocks[0].ForcedBatches[0].GlobalExitRoot,
MinForcedTimestamp: uint64(blocks[0].ForcedBatches[0].ForcedAt.Unix()),
}
_, err = etherman.PoE.SequenceForceBatches(auth, []proofofefficiency.ProofOfEfficiencyForcedBatchData{forceBatchData})
_, err = etherman.PoE.SequenceForceBatches(auth, []polygonzkevm.PolygonZkEVMForcedBatchData{forceBatchData})
require.NoError(t, err)
ethBackend.Commit()

Expand Down
16 changes: 8 additions & 8 deletions etherman/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"fmt"
"math/big"

"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/bridge"
"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/globalexitrootmanager"
"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/matic"
"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/mockverifier"
"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/proofofefficiency"
"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygonzkevm"
"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygonzkevmbridge"
"github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygonzkevmglobalexitroot"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/common"
Expand All @@ -19,7 +19,7 @@ import (

// NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth
// must be 1337. The address that holds the auth will have an initial balance of 10 ETH
func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts) (etherman *Client, ethBackend *backends.SimulatedBackend, maticAddr common.Address, br *bridge.Bridge, err error) {
func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts) (etherman *Client, ethBackend *backends.SimulatedBackend, maticAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge, err error) {
if auth == nil {
// read only client
return &Client{}, nil, common.Address{}, nil, nil
Expand Down Expand Up @@ -55,19 +55,19 @@ func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts) (etherman *Client
const posPoE = 3
calculatedPoEAddr := crypto.CreateAddress(auth.From, nonce+posPoE)
genesis := common.HexToHash("0xfd3434cd8f67e59d73488a2b8da242dd1f02849ea5dd99f0ca22c836c3d5b4a9") // Random value. Needs to be different to 0x0
exitManagerAddr, _, globalExitRoot, err := globalexitrootmanager.DeployGlobalexitrootmanager(auth, client)
exitManagerAddr, _, globalExitRoot, err := polygonzkevmglobalexitroot.DeployPolygonzkevmglobalexitroot(auth, client)
if err != nil {
return nil, nil, common.Address{}, nil, err
}
_, err = globalExitRoot.Initialize(auth, calculatedPoEAddr, calculatedBridgeAddr)
if err != nil {
return nil, nil, common.Address{}, nil, err
}
bridgeAddr, _, br, err := bridge.DeployBridge(auth, client)
bridgeAddr, _, br, err := polygonzkevmbridge.DeployPolygonzkevmbridge(auth, client)
if err != nil {
return nil, nil, common.Address{}, nil, err
}
poeAddr, _, poe, err := proofofefficiency.DeployProofofefficiency(auth, client)
poeAddr, _, poe, err := polygonzkevm.DeployPolygonzkevm(auth, client)
if err != nil {
return nil, nil, common.Address{}, nil, err
}
Expand All @@ -76,7 +76,7 @@ func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts) (etherman *Client
return nil, nil, common.Address{}, nil, err
}

poeParams := proofofefficiency.ProofOfEfficiencyInitializePackedParameters{
poeParams := polygonzkevm.PolygonZkEVMInitializePackedParameters{
Admin: auth.From,
ChainID: 1000, //nolint:gomnd
TrustedSequencer: auth.From,
Expand Down
Loading