From 91d0f8e87c454d989273022ffc43d6a4040b71e2 Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 11 Dec 2024 16:01:10 +0400 Subject: [PATCH] Add schema_version to output of db info command (#2309) --- 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 4fe5cd3a8..8d80ae1cc 100644 --- a/cmd/juno/dbcmd.go +++ b/cmd/juno/dbcmd.go @@ -10,6 +10,7 @@ import ( "github.com/NethermindEth/juno/core/felt" "github.com/NethermindEth/juno/db" "github.com/NethermindEth/juno/db/pebble" + "github.com/NethermindEth/juno/migration" "github.com/NethermindEth/juno/utils" "github.com/olekukonko/tablewriter" "github.com/spf13/cobra" @@ -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