Skip to content

Commit

Permalink
fix + minor refactor (#577)
Browse files Browse the repository at this point in the history
  • Loading branch information
ARR552 authored Jan 24, 2024
1 parent 429207c commit 22d0ce3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
12 changes: 8 additions & 4 deletions etherman/etherman.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,25 @@ func NewClient(cfg Config, polygonBridgeAddr, polygonZkEVMGlobalExitRootAddress,
}

// NewL2Client creates a new etherman for L2.
func NewL2Client(url string, bridgeAddr common.Address) (*Client, error) {
func NewL2Client(url string, polygonBridgeAddr common.Address) (*Client, error) {
// Connect to ethereum node
ethClient, err := ethclient.Dial(url)
if err != nil {
log.Errorf("error connecting to %s: %+v", url, err)
return nil, err
}
// Create smc clients
bridge, err := polygonzkevmbridge.NewPolygonzkevmbridge(bridgeAddr, ethClient)
bridge, err := polygonzkevmbridge.NewPolygonzkevmbridge(polygonBridgeAddr, ethClient)
if err != nil {
return nil, err
}
scAddresses := []common.Address{bridgeAddr}
oldpolygonBridge, err := oldpolygonzkevmbridge.NewOldpolygonzkevmbridge(polygonBridgeAddr, ethClient)
if err != nil {
return nil, err
}
scAddresses := []common.Address{polygonBridgeAddr}

return &Client{EtherClient: ethClient, PolygonBridge: bridge, SCAddresses: scAddresses}, nil
return &Client{EtherClient: ethClient, PolygonBridge: bridge, OldPolygonBridge: oldpolygonBridge, SCAddresses: scAddresses}, nil
}

// GetRollupInfoByBlockRange function retrieves the Rollup information that are included in all this ethereum blocks
Expand Down
15 changes: 2 additions & 13 deletions synchronizer/synchronizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type ClientSynchronizer struct {
chSynced chan uint
zkEVMClient zkEVMClientInterface
synced bool
isLxLyEtrog bool
l1RollupExitRoot common.Hash
}

Expand Down Expand Up @@ -73,7 +72,6 @@ func NewSynchronizer(
}
if networkID == 0 {
return &ClientSynchronizer{
isLxLyEtrog: isActivated,
bridgeCtrl: bridge,
storage: storage.(storageInterface),
etherMan: ethMan,
Expand All @@ -89,7 +87,6 @@ func NewSynchronizer(
}, nil
}
return &ClientSynchronizer{
isLxLyEtrog: isActivated,
bridgeCtrl: bridge,
storage: storage.(storageInterface),
etherMan: ethMan,
Expand Down Expand Up @@ -367,10 +364,8 @@ func (s *ClientSynchronizer) processBlockRange(blocks []etherman.Block, order ma
return err
}
case etherman.ActivateEtrogOrder:
s.activateLxLyEtrog()
if err != nil {
return err
}
// this is activated when the bridge detects the CreateNewRollup or the AddExistingRollup event from the rollupManager
log.Info("Event received. Activating LxLyEtrog...")
}
}
err = s.storage.Commit(s.ctx, dbTx)
Expand Down Expand Up @@ -670,9 +665,3 @@ func (s *ClientSynchronizer) processTokenWrapped(tokenWrapped etherman.TokenWrap
}
return nil
}

func (s *ClientSynchronizer) activateLxLyEtrog() {
// this is activated when the bridge detects the CreateNewRollup or the AddExistingRollup event from the rollupManager
log.Info("Event received. Activating LxLyEtrog...")
s.isLxLyEtrog = true
}

0 comments on commit 22d0ce3

Please sign in to comment.