Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RelayMiner] Fix non deleted smt when funds are insufficient to submit C&P #1026

Merged
merged 6 commits into from
Jan 16, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: Address review change requests
red-0ne committed Jan 14, 2025
commit 77e033e9429d5aabe49ff038613f067ceb43629d
2 changes: 2 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
@@ -363,6 +363,8 @@ for x in range(localnet_config["path_gateways"]["count"]):
# ],
# TODO_IMPROVE(@okdas): Add port forwards to grafana, pprof, like the other resources
port_forwards=[
# See PATH for the default port used by the gateway. As of PR #1026, it is :3069.
# https://github.com/buildwithgrove/path/blob/main/config/router.go
str(2999 + actor_number) + ":3069"
],
)
21 changes: 12 additions & 9 deletions pkg/relayer/session/claim.go
Original file line number Diff line number Diff line change
@@ -20,12 +20,12 @@ import (
sharedtypes "github.com/pokt-network/poktroll/x/shared/types"
)

// The cumulative cost of submitting a proof and creating a claim.
// This value corresponds to the sum of a single claim and proof message fee
// which was obtained empirically from the network by submitting a claim and
// proof message and observing the fee with a gas price of 0.01uPOKT.
// The cumulative fees of creating a single claim, followed by submitting a single proof.
// The value was obtained empirically by observing logs during load testing and observing
// the claim & proof lifecycle.
// The gas price at the time of observance was 0.01uPOKT.
// The value is subject to change as the network parameters change.
var clamAndProofGasCost = sdktypes.NewInt64Coin(volatile.DenomuPOKT, 50000)
var ClamAndProofGasCost = sdktypes.NewInt64Coin(volatile.DenomuPOKT, 50000)

// createClaims maps over the sessionsToClaimObs observable. For each claim batch, it:
// 1. Calculates the earliest block height at which it is safe to CreateClaims
@@ -272,7 +272,7 @@ func (rs *relayerSessionsManager) payableProofsSessionTrees(

// Account for the gas cost of creating a claim and submitting a proof in addition
// to the ProofSubmissionFee.
claimAndProofSubmissionCost := proofParams.GetProofSubmissionFee().Add(clamAndProofGasCost)
claimAndProofSubmissionCost := proofParams.GetProofSubmissionFee().Add(ClamAndProofGasCost)

supplierOperatorBalanceCoin, err := rs.bankQueryClient.GetBalance(
ctx,
@@ -313,15 +313,18 @@ func (rs *relayerSessionsManager) payableProofsSessionTrees(
for _, sessionTree := range sessionTrees {
// If the supplier operator can afford to claim the session, add it to the
// claimableSessionTrees slice.
if supplierOperatorBalanceCoin.IsGTE(claimAndProofSubmissionCost) {
supplierCanAffordClaimAndProofFees := supplierOperatorBalanceCoin.IsGTE(claimAndProofSubmissionCost)
if supplierCanAffordClaimAndProofFees {
claimableSessionTrees = append(claimableSessionTrees, sessionTree)
newSupplierOperatorBalanceCoin := supplierOperatorBalanceCoin.Sub(claimAndProofSubmissionCost)
supplierOperatorBalanceCoin = &newSupplierOperatorBalanceCoin
continue
}

// Delete the session tree from the KVStore since it won't be claimed due to
// insufficient funds.
// At this point supplierCanAffordClaimAndProofFees is false.
// Delete the session tree from the relayer sessions and the KVStore since
// it won't be claimed due to insufficient funds.
rs.removeFromRelayerSessions(sessionTree)
if err := sessionTree.Delete(); err != nil {
logger.With(
"session_id", sessionTree.GetSessionHeader().GetSessionId(),
5 changes: 4 additions & 1 deletion pkg/relayer/session/session_test.go
Original file line number Diff line number Diff line change
@@ -207,8 +207,11 @@ func TestRelayerSessionsManager_InsufficientBalanceForProofSubmission(t *testing

supplierOperatorAddress := sample.AccAddress()
supplierOperatorAccAddress := sdktypes.MustAccAddressFromBech32(supplierOperatorAddress)

proofSubmissionFee := prooftypes.DefaultParams().ProofSubmissionFee.Amount.Int64()
claimAndProofGasCost := session.ClamAndProofGasCost.Amount.Int64()
// Set the supplier operator balance to be able to submit only a single proof.
supplierOperatorBalance := prooftypes.DefaultParams().ProofSubmissionFee.Amount.Int64() + 1
supplierOperatorBalance := proofSubmissionFee + claimAndProofGasCost + 1
supplierClientMock.EXPECT().
OperatorAddress().
Return(&supplierOperatorAccAddress).