From 2c1ffe6265472247c354fe7771db1d5a4195154e Mon Sep 17 00:00:00 2001 From: Kirill Date: Sat, 7 Dec 2024 14:59:08 +0400 Subject: [PATCH] Add schema_version to output of db info command --- cmd/juno/dbcmd.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/juno/dbcmd.go b/cmd/juno/dbcmd.go index 4fe5cd3a81..657321a849 100644 --- a/cmd/juno/dbcmd.go +++ b/cmd/juno/dbcmd.go @@ -13,6 +13,7 @@ import ( "github.com/NethermindEth/juno/utils" "github.com/olekukonko/tablewriter" "github.com/spf13/cobra" + "github.com/NethermindEth/juno/migration" ) const ( @@ -21,6 +22,7 @@ const ( type DBInfo struct { Network string `json:"network"` + SchemaVersion uint64 `json:"schema_version"` ChainHeight uint64 `json:"chain_height"` LatestBlockHash *felt.Felt `json:"latest_block_hash"` LatestStateRoot *felt.Felt `json:"latest_state_root"` @@ -84,7 +86,7 @@ func dbInfo(cmd *cobra.Command, args []string) error { defer database.Close() chain := blockchain.New(database, nil) - info := DBInfo{} + var info DBInfo // Get the latest block information headBlock, err := chain.Head() @@ -97,6 +99,12 @@ func dbInfo(cmd *cobra.Command, args []string) error { return fmt.Errorf("failed to get the state update: %v", err) } + schemaMeta, err := migration.SchemaMetadata(database) + if err != nil { + return fmt.Errorf("failed to get schema metadata: %v", err) + } + info.SchemaVersion = schemaMeta.Version + info.Network = getNetwork(headBlock, stateUpdate.StateDiff) info.ChainHeight = headBlock.Number info.LatestBlockHash = headBlock.Hash