diff --git a/cmd/rekor-cli/app/log_info.go b/cmd/rekor-cli/app/log_info.go index 9a7f27107..78ce185f8 100644 --- a/cmd/rekor-cli/app/log_info.go +++ b/cmd/rekor-cli/app/log_info.go @@ -43,7 +43,8 @@ import ( ) type logInfoCmdOutput struct { - TreeSize int64 + ActiveTreeSize int64 + TotalTreeSize int64 RootHash string TimestampNanos uint64 TreeID string @@ -54,11 +55,12 @@ func (l *logInfoCmdOutput) String() string { ts := time.Unix(0, int64(l.TimestampNanos)).UTC().Format(time.RFC3339) return fmt.Sprintf(`Verification Successful! -Tree Size: %v -Root Hash: %s -Timestamp: %s -TreeID: %s -`, l.TreeSize, l.RootHash, ts, l.TreeID) +Active Tree Size: %v +Total Tree Size: %v +Root Hash: %s +Timestamp: %s +TreeID: %s +`, l.ActiveTreeSize, l.TotalTreeSize, l.RootHash, ts, l.TreeID) } // logInfoCmd represents the current information about the transparency log @@ -100,7 +102,8 @@ var logInfoCmd = &cobra.Command{ } cmdOutput := &logInfoCmdOutput{ - TreeSize: swag.Int64Value(logInfo.TreeSize), + ActiveTreeSize: swag.Int64Value(logInfo.TreeSize), + TotalTreeSize: totalTreeSize(logInfo, logInfo.InactiveShards), RootHash: swag.StringValue(logInfo.RootHash), TimestampNanos: sth.GetTimestamp(), TreeID: swag.StringValue(logInfo.TreeID), @@ -222,6 +225,14 @@ func loadVerifier(rekorClient *rclient.Rekor) (signature.Verifier, error) { return signature.LoadVerifier(pub, crypto.SHA256) } +func totalTreeSize(activeShard *models.LogInfo, inactiveShards []*models.InactiveShardLogInfo) int64 { + total := swag.Int64Value(activeShard.TreeSize) + for _, i := range inactiveShards { + total += swag.Int64Value(i.TreeSize) + } + return total +} + func init() { initializePFlagMap() rootCmd.AddCommand(logInfoCmd) diff --git a/tests/sharding-e2e-test.sh b/tests/sharding-e2e-test.sh index 36707e05a..1a970f322 100755 --- a/tests/sharding-e2e-test.sh +++ b/tests/sharding-e2e-test.sh @@ -194,6 +194,15 @@ popd # Pass in the universal log_index & make sure it resolves check_log_index 3 +# Make sure the shard tree size is 1 and the total tree size is 4 +rm $HOME/.rekor/state.json # We have to remove this since we can't prove consistency between entry 0 and entry 1 +TREE_SIZE=$($REKOR_CLI loginfo --rekor_server http://localhost:3000 --format json | jq -r .ActiveTreeSize) +stringsMatch $TREE_SIZE "1" + +TOTAL_TREE_SIZE=$($REKOR_CLI loginfo --rekor_server http://localhost:3000 --format json | jq -r .TotalTreeSize) +stringsMatch $TOTAL_TREE_SIZE "4" + + # Make sure we can still get logproof for the now-inactive shard $REKOR_CLI logproof --last-size 2 --tree-id $INITIAL_TREE_ID --rekor_server http://localhost:3000 # And the logproof for the now active shard @@ -215,7 +224,6 @@ if [[ "$ENCODED_PUBLIC_KEY" == "$NEW_PUB_KEY" ]]; then exit 1 fi - # TODO: Try to get the entry via Entry ID (Tree ID in hex + UUID) UUID=$($REKOR_CLI get --log-index 2 --rekor_server http://localhost:3000 --format json | jq -r .UUID)