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

Sync old network compatibility #3166

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions config/mainnetgenesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ const MainnetNetworkConfigJSON = `
{
"l1Config" : {
"chainId": 1,
"polygonZkEVMAddress": "0x5132A183E9F3CB7C848b0AAC5Ae0c4f0491B7aB2",
"polTokenAddress": "0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0",
"polygonZkEVMAddress": "0x519E42c24163192Dca44CD3fBDCEBF6be9130987",
"polygonRollupManagerAddress": "0x5132A183E9F3CB7C848b0AAC5Ae0c4f0491B7aB2",
"polTokenAddress": "0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6",
"polygonZkEVMGlobalExitRootAddress": "0x580bda1e7A0CFAe92Fa7F6c20A3794F169CE3CFb"
},
"root": "0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5c9",
Expand Down
34 changes: 28 additions & 6 deletions etherman/etherman.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ func NewClient(cfg Config, l1Config L1Config) (*Client, error) {
// Get RollupID
rollupID, err := rollupManager.RollupAddressToID(&bind.CallOpts{Pending: false}, l1Config.ZkEVMAddr)
if err != nil {
log.Errorf("error rollupManager.cRollupAddressToID(%s). Error: %w", l1Config.RollupManagerAddr, err)
return nil, err
log.Warnf("error rollupManager.RollupAddressToID(%s). Error: %w", l1Config.RollupManagerAddr, err)
// TODO return error after the upgrade
}
log.Debug("rollupID: ", rollupID)

Expand Down Expand Up @@ -667,6 +667,14 @@ func (etherMan *Client) addExistingRollup(ctx context.Context, vLog types.Log, b
if etherMan.RollupID != addExistingRollup.RollupID {
return nil
}
// TODO Delete after upgrade Get RollupID
rollupID, err := etherMan.RollupManager.RollupAddressToID(&bind.CallOpts{Pending: false}, etherMan.SCAddresses[0])
if err != nil {
log.Error("error getting rollupID. Error: ", err)
return err
}
log.Debug("rollupID: ", rollupID)

return etherMan.updateForkId(ctx, vLog, blocks, blocksOrder, addExistingRollup.LastVerifiedBatchBeforeUpgrade, addExistingRollup.ForkID, "")
}

Expand Down Expand Up @@ -1553,11 +1561,18 @@ func (etherMan *Client) EthBlockByNumber(ctx context.Context, blockNumber uint64

// GetLatestBatchNumber function allows to retrieve the latest proposed batch in the smc
func (etherMan *Client) GetLatestBatchNumber() (uint64, error) {
var latestBatchNum uint64
rollupData, err := etherMan.RollupManager.RollupIDToRollupData(&bind.CallOpts{Pending: false}, etherMan.RollupID)
if err != nil {
return 0, err
log.Warn("error getting latestBatchNum from rollupManager. Trying old zkevm smc... Error: ", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Using old contracts are going to fill logs with Warning, maybe we can decide which one to use (configuration or in runtime) and just call to the right one

latestBatchNum, err = etherMan.OldZkEVM.LastBatchSequenced(&bind.CallOpts{Pending: false})
if err != nil {
return latestBatchNum, err
}
} else {
latestBatchNum = rollupData.LastBatchSequenced
}
return rollupData.LastBatchSequenced, nil
return latestBatchNum, nil
}

// GetLatestBlockNumber gets the latest block number from the ethereum
Expand Down Expand Up @@ -1595,11 +1610,18 @@ func (etherMan *Client) GetLatestBlockTimestamp(ctx context.Context) (uint64, er

// GetLatestVerifiedBatchNum gets latest verified batch from ethereum
func (etherMan *Client) GetLatestVerifiedBatchNum() (uint64, error) {
var lastVerifiedBatchNum uint64
rollupData, err := etherMan.RollupManager.RollupIDToRollupData(&bind.CallOpts{Pending: false}, etherMan.RollupID)
if err != nil {
return 0, err
log.Warn("error getting lastVerifiedBatchNum from rollupManager. Trying old zkevm smc... Error: ", err)
lastVerifiedBatchNum, err = etherMan.OldZkEVM.LastVerifiedBatch(&bind.CallOpts{Pending: false})
if err != nil {
return lastVerifiedBatchNum, err
}
} else {
lastVerifiedBatchNum = rollupData.LastVerifiedBatch
}
return rollupData.LastVerifiedBatch, nil
return lastVerifiedBatchNum, nil
}

// GetTx function get ethereum tx
Expand Down
Loading