Skip to content

Commit 0de663e

Browse files
authored
feat: add rollup address and rollup manager address in monitor (#433)
* feat: add rollup address and rollup manager address in monitor Signed-off-by: Ji Hwan <[email protected]> * chore: lint for consistency Signed-off-by: Ji Hwan <[email protected]> --------- Signed-off-by: Ji Hwan <[email protected]>
1 parent 3641488 commit 0de663e

File tree

3 files changed

+63
-24
lines changed

3 files changed

+63
-24
lines changed

cmd/monitor/monitor.go

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,29 +58,33 @@ var (
5858

5959
type (
6060
monitorStatus struct {
61-
TopDisplayedBlock *big.Int
62-
UpperBlock *big.Int
63-
LowerBlock *big.Int
64-
ChainID *big.Int
65-
ForkID uint64
66-
HeadBlock *big.Int
67-
PeerCount uint64
68-
GasPrice *big.Int
69-
TxPoolStatus txPoolStatus
70-
ZkEVMBatches zkEVMBatches
71-
SelectedBlock rpctypes.PolyBlock
72-
SelectedTransaction rpctypes.PolyTransaction
73-
BlockCache *lru.Cache `json:"-"`
74-
BlocksLock sync.RWMutex `json:"-"`
61+
TopDisplayedBlock *big.Int
62+
UpperBlock *big.Int
63+
LowerBlock *big.Int
64+
ChainID *big.Int
65+
ForkID uint64
66+
HeadBlock *big.Int
67+
PeerCount uint64
68+
GasPrice *big.Int
69+
TxPoolStatus txPoolStatus
70+
ZkEVMBatches zkEVMBatches
71+
SelectedBlock rpctypes.PolyBlock
72+
SelectedTransaction rpctypes.PolyTransaction
73+
BlockCache *lru.Cache `json:"-"`
74+
BlocksLock sync.RWMutex `json:"-"`
75+
RollupAddress string
76+
RollupManagerAddress string
7577
}
7678
chainState struct {
77-
HeadBlock uint64
78-
ChainID *big.Int
79-
PeerCount uint64
80-
GasPrice *big.Int
81-
TxPoolStatus txPoolStatus
82-
ZkEVMBatches zkEVMBatches
83-
ForkID uint64
79+
HeadBlock uint64
80+
ChainID *big.Int
81+
PeerCount uint64
82+
GasPrice *big.Int
83+
TxPoolStatus txPoolStatus
84+
ZkEVMBatches zkEVMBatches
85+
ForkID uint64
86+
RollupAddress string
87+
RollupManagerAddress string
8488
}
8589
txPoolStatus struct {
8690
pending uint64
@@ -241,6 +245,16 @@ func getChainState(ctx context.Context, ec *ethclient.Client) (*chainState, erro
241245
log.Debug().Err(err).Msg("Unable to get fork id")
242246
}
243247

248+
cs.RollupAddress, err = util.GetRollupAddress(ec.Client())
249+
if err != nil {
250+
log.Debug().Err(err).Msg("Unable to get rollup address")
251+
}
252+
253+
cs.RollupManagerAddress, err = util.GetRollupManagerAddress(ec.Client())
254+
if err != nil {
255+
log.Debug().Err(err).Msg("Unable to get rollup manager address")
256+
}
257+
244258
return cs, nil
245259

246260
}
@@ -284,6 +298,8 @@ func fetchCurrentBlockData(ctx context.Context, ec *ethclient.Client, ms *monito
284298
ms.TxPoolStatus = cs.TxPoolStatus
285299
ms.ZkEVMBatches = cs.ZkEVMBatches
286300
ms.ForkID = cs.ForkID
301+
ms.RollupAddress = cs.RollupAddress
302+
ms.RollupManagerAddress = cs.RollupManagerAddress
287303

288304
return
289305
}
@@ -606,7 +622,7 @@ func renderMonitorUI(ctx context.Context, ec *ethclient.Client, ms *monitorStatu
606622
if zkEVMBatchesSupported {
607623
skeleton.ZkEVM.Text = ui.GetZkEVMText(skeleton.ZkEVM, ms.ZkEVMBatches.trusted, ms.ZkEVMBatches.virtual, ms.ZkEVMBatches.verified)
608624

609-
skeleton.Rollup.Text = ui.GetRollupText(skeleton.Rollup, ms.ForkID)
625+
skeleton.Rollup.Text = ui.GetRollupText(skeleton.Rollup, ms.ForkID, ms.RollupAddress, ms.RollupManagerAddress)
610626
}
611627

612628
skeleton.TxPerBlockChart.Data = metrics.GetTxsPerBlock(renderedBlocks)

cmd/monitor/ui/ui.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,12 @@ func GetZkEVMText(widget *widgets.Paragraph, trustedBatchesCount, virtualBatches
6666
return formatParagraph(widget, []string{trustedBatches, virtualBatches, verifiedBatches})
6767
}
6868

69-
func GetRollupText(widget *widgets.Paragraph, forkID uint64) string {
69+
func GetRollupText(widget *widgets.Paragraph, forkID uint64, rollupAddress string, rollupManagerAddress string) string {
7070
forkIDString := fmt.Sprintf("ForkID: %d", forkID)
71-
return formatParagraph(widget, []string{forkIDString})
71+
rollupAddressString := fmt.Sprintf("RollupAddress: %s", rollupAddress)
72+
rollupManagerAddressString := fmt.Sprintf("RollupManagerAddress: %s", rollupManagerAddress)
73+
74+
return formatParagraph(widget, []string{forkIDString, rollupAddressString, rollupManagerAddressString})
7275
}
7376

7477
func formatParagraph(widget *widgets.Paragraph, content []string) string {

util/util.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,26 @@ func GetForkID(rpc *ethrpc.Client) (uint64, error) {
244244
return forkID, nil
245245
}
246246

247+
func GetRollupAddress(rpc *ethrpc.Client) (string, error) {
248+
var raw interface{}
249+
if err := rpc.Call(&raw, "zkevm_getRollupAddress"); err != nil {
250+
return "", err
251+
}
252+
rollupAddress := fmt.Sprintf("%v", raw)
253+
254+
return rollupAddress, nil
255+
}
256+
257+
func GetRollupManagerAddress(rpc *ethrpc.Client) (string, error) {
258+
var raw interface{}
259+
if err := rpc.Call(&raw, "zkevm_getRollupManagerAddress"); err != nil {
260+
return "", err
261+
}
262+
rollupManagerAddress := fmt.Sprintf("%v", raw)
263+
264+
return rollupManagerAddress, nil
265+
}
266+
247267
type batch string
248268

249269
const (

0 commit comments

Comments
 (0)