diff --git a/api/poktroll/application/event.pulsar.go b/api/poktroll/application/event.pulsar.go index 043aa2264..290bbde55 100644 --- a/api/poktroll/application/event.pulsar.go +++ b/api/poktroll/application/event.pulsar.go @@ -3,11 +3,11 @@ package application import ( _ "cosmossdk.io/api/cosmos/base/v1beta1" + _ "github.com/pokt-network/poktroll/api/poktroll/shared" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" - _ "github.com/pokt-network/poktroll/api/poktroll/shared" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" diff --git a/pkg/relayer/session/sessiontree.go b/pkg/relayer/session/sessiontree.go index b55340224..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 @@ -273,8 +277,15 @@ func (st *sessionTree) Delete() error { // This was intentionally removed to lower the IO load. // When the database is closed, it is deleted it from disk right away. - if err := st.treeStore.Stop(); err != nil { - return err + if st.treeStore != nil { + 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 db155546d..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, ) - return k.sessionKeeper.GetBlockHash(ctx, earliestSupplierProofCommitHeight), nil + // 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 1a67f838c..c01971fa9 100644 --- a/x/supplier/keeper/unbond_suppliers.go +++ b/x/supplier/keeper/unbond_suppliers.go @@ -54,15 +54,20 @@ func (k Keeper) EndBlockerUnbondSuppliers(ctx context.Context) error { return err } - // Send the coins from the supplier pool back to the supplier. - if err = k.bankKeeper.SendCoinsFromModuleToAccount( - ctx, suppliertypes.ModuleName, ownerAddress, []cosmostypes.Coin{*supplier.Stake}, - ); err != nil { - logger.Error(fmt.Sprintf( - "could not send %s coins from module %s to account %s due to %s", - supplier.Stake.String(), suppliertypes.ModuleName, ownerAddress, err, - )) - return err + // 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( + ctx, suppliertypes.ModuleName, ownerAddress, []cosmostypes.Coin{*supplier.Stake}, + ); err != nil { + logger.Error(fmt.Sprintf( + "could not send %s coins from module %s to account %s due to %s", + supplier.Stake.String(), suppliertypes.ModuleName, ownerAddress, err, + )) + return err + } } // Remove the supplier from the store. diff --git a/x/tokenomics/types/tx.pb.go b/x/tokenomics/types/tx.pb.go index e4fec264c..9f18a148c 100644 --- a/x/tokenomics/types/tx.pb.go +++ b/x/tokenomics/types/tx.pb.go @@ -125,7 +125,6 @@ type MsgUpdateParam struct { // specified in the `Params` message in `proof/params.proto.` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // Types that are valid to be assigned to AsType: - // // *MsgUpdateParam_AsString // *MsgUpdateParam_AsInt64 // *MsgUpdateParam_AsBytes