From 86ad4a1b4e7d2a2f56a97cc4fbf40e9a9f0d5248 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Wed, 23 Oct 2024 17:08:12 +0200 Subject: [PATCH] chore: Address review change reqeusts --- pkg/relayer/session/sessiontree.go | 9 +++++++++ x/proof/keeper/msg_server_submit_proof.go | 12 +++++++----- x/supplier/keeper/unbond_suppliers.go | 1 + 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/pkg/relayer/session/sessiontree.go b/pkg/relayer/session/sessiontree.go index 31d2a0a4c..78641c9d5 100644 --- a/pkg/relayer/session/sessiontree.go +++ b/pkg/relayer/session/sessiontree.go @@ -3,6 +3,7 @@ package session import ( "bytes" "crypto/sha256" + "fmt" "os" "path/filepath" "sync" @@ -12,6 +13,7 @@ import ( "github.com/pokt-network/smt/kvstore/pebble" "github.com/pokt-network/poktroll/pkg/crypto/protocol" + "github.com/pokt-network/poktroll/pkg/polylog" "github.com/pokt-network/poktroll/pkg/relayer" sessiontypes "github.com/pokt-network/poktroll/x/session/types" ) @@ -27,6 +29,8 @@ var _ relayer.SessionTree = (*sessionTree)(nil) // default value for this should be -1, implying "unlimited". // Ref discussion: https://github.com/pokt-network/poktroll/pull/755#discussion_r1737287860 type sessionTree struct { + logger polylog.Logger + // sessionMu is a mutex used to protect sessionTree operations from concurrent access. sessionMu *sync.Mutex @@ -277,6 +281,11 @@ func (st *sessionTree) Delete() error { if err := st.treeStore.Stop(); err != nil { return err } + } else { + st.logger.With( + "claim_root", fmt.Sprintf("%x", st.GetClaimRoot()), + "session_id", st.GetSessionHeader().SessionId, + ).Info().Msg("KVStore is already stopped") } // Delete the KVStore from disk diff --git a/x/proof/keeper/msg_server_submit_proof.go b/x/proof/keeper/msg_server_submit_proof.go index 0e0b3446f..625c29e68 100644 --- a/x/proof/keeper/msg_server_submit_proof.go +++ b/x/proof/keeper/msg_server_submit_proof.go @@ -257,13 +257,13 @@ func (k Keeper) ProofRequirementForClaim(ctx context.Context, claim *types.Claim } // Hash of block when proof submission is allowed. - earliestProofCommitBlockHash, err := k.getEarliestSupplierProofCommitBlockHash(ctx, claim) + proofRequirementSeedBlockHash, err := k.getProofRequirementSeedBlockHash(ctx, claim) if err != nil { return requirementReason, err } // The probability that a proof is required. - proofRequirementSampleValue, err := claim.GetProofRequirementSampleValue(earliestProofCommitBlockHash) + proofRequirementSampleValue, err := claim.GetProofRequirementSampleValue(proofRequirementSeedBlockHash) if err != nil { return requirementReason, err } @@ -292,9 +292,9 @@ func (k Keeper) ProofRequirementForClaim(ctx context.Context, claim *types.Claim return requirementReason, nil } -// getEarliestSupplierProofCommitBlockHash returns the block hash of the earliest -// block at which a claim may have its proof committed. -func (k Keeper) getEarliestSupplierProofCommitBlockHash( +// getProofRequirementSeedBlockHash returns the block hash of the seed block for +// the proof requirement probabilistic check. +func (k Keeper) getProofRequirementSeedBlockHash( ctx context.Context, claim *types.Claim, ) (blockHash []byte, err error) { @@ -318,5 +318,7 @@ func (k Keeper) getEarliestSupplierProofCommitBlockHash( supplierOperatorAddress, ) + // The proof requirement seed block is the last block of the session, and it is + // the block that is before the earliest block at which a proof can be committed. return k.sessionKeeper.GetBlockHash(ctx, earliestSupplierProofCommitHeight-1), nil } diff --git a/x/supplier/keeper/unbond_suppliers.go b/x/supplier/keeper/unbond_suppliers.go index ca684fa84..c01971fa9 100644 --- a/x/supplier/keeper/unbond_suppliers.go +++ b/x/supplier/keeper/unbond_suppliers.go @@ -56,6 +56,7 @@ func (k Keeper) EndBlockerUnbondSuppliers(ctx context.Context) error { // If the supplier stake is 0 due to slashing, then do not move 0 coins // to its account. + // Coin#IsPositive returns false if the coin is 0. if supplier.Stake.IsPositive() { // Send the coins from the supplier pool back to the supplier. if err = k.bankKeeper.SendCoinsFromModuleToAccount(