From 607a35231ab5c8555398ed13f54bbef262effafc Mon Sep 17 00:00:00 2001 From: Kirill Date: Sat, 7 Dec 2024 14:59:08 +0400 Subject: [PATCH 1/3] 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 From 018aee2fce571f77d483cd9920c8478f3b0430c3 Mon Sep 17 00:00:00 2001 From: Kirill Date: Mon, 9 Dec 2024 16:25:13 +0400 Subject: [PATCH 2/3] Format imports in cmd/juno/dbcmd.go --- cmd/juno/dbcmd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/juno/dbcmd.go b/cmd/juno/dbcmd.go index 657321a849..428b24f70f 100644 --- a/cmd/juno/dbcmd.go +++ b/cmd/juno/dbcmd.go @@ -10,10 +10,10 @@ 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" - "github.com/NethermindEth/juno/migration" ) const ( From 7acefe6f175d6a04502eef2953926dd531329f9c Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 11 Dec 2024 14:56:23 +0400 Subject: [PATCH 3/3] Reorder assignment --- cmd/juno/dbcmd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/juno/dbcmd.go b/cmd/juno/dbcmd.go index 428b24f70f..8d80ae1ccc 100644 --- a/cmd/juno/dbcmd.go +++ b/cmd/juno/dbcmd.go @@ -103,8 +103,8 @@ func dbInfo(cmd *cobra.Command, args []string) error { if err != nil { return fmt.Errorf("failed to get schema metadata: %v", err) } - info.SchemaVersion = schemaMeta.Version + info.SchemaVersion = schemaMeta.Version info.Network = getNetwork(headBlock, stateUpdate.StateDiff) info.ChainHeight = headBlock.Number info.LatestBlockHash = headBlock.Hash