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

fix: Nil session tree logger #1007

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
2 changes: 1 addition & 1 deletion api/poktroll/application/tx.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pkg/relayer/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (rs *relayerSessionsManager) ensureSessionTree(
// If the sessionTree does not exist, create and assign it to the
// sessionTreeWithSessionId map for the given supplier operator address.
if !ok {
sessionTree, err = NewSessionTree(sessionHeader, &supplierOperatorAccAddress, rs.storesDirectory)
sessionTree, err = NewSessionTree(sessionHeader, &supplierOperatorAccAddress, rs.storesDirectory, rs.logger)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -468,6 +468,7 @@ func (rs *relayerSessionsManager) deleteExpiredSessionTreesFn(
return
}

// TODO_TEST: Add tests that cover existing expired failed session trees.
for _, sessionTree := range failedSessionTrees {
sessionEndHeight := sessionTree.GetSessionHeader().GetSessionEndBlockHeight()
proofWindowCloseHeight := expirationHeightFn(sharedParams, sessionEndHeight)
Expand Down
2 changes: 2 additions & 0 deletions pkg/relayer/session/sessiontree.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func NewSessionTree(
sessionHeader *sessiontypes.SessionHeader,
supplierOperatorAddress *cosmostypes.AccAddress,
storesDirectory string,
logger polylog.Logger,
) (relayer.SessionTree, error) {
// Join the storePrefix and the session.sessionId and supplier's operator address to
// create a unique storePath.
Expand Down Expand Up @@ -102,6 +103,7 @@ func NewSessionTree(
sessionSMT: trie,
sessionMu: &sync.Mutex{},
supplierOperatorAddress: supplierOperatorAddress,
logger: logger,
}

return sessionTree, nil
Expand Down
5 changes: 4 additions & 1 deletion testutil/testtree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/pkg/crypto"
"github.com/pokt-network/poktroll/pkg/polylog"
"github.com/pokt-network/poktroll/pkg/relayer"
"github.com/pokt-network/poktroll/pkg/relayer/session"
"github.com/pokt-network/poktroll/testutil/testrelayer"
Expand All @@ -31,7 +32,7 @@ func NewFilledSessionTree(
t.Helper()

// Initialize an empty session tree with the given session header.
sessionTree := NewEmptySessionTree(t, sessionTreeHeader, supplierOperatorAddr)
sessionTree := NewEmptySessionTree(t, sessionTreeHeader, supplierOperatorAddr, ctx)
red-0ne marked this conversation as resolved.
Show resolved Hide resolved

// Add numRelays of relays to the session tree.
FillSessionTree(
Expand All @@ -52,6 +53,7 @@ func NewEmptySessionTree(
t *testing.T,
sessionTreeHeader *sessiontypes.SessionHeader,
supplierOperatorAddr string,
ctx context.Context,
) relayer.SessionTree {
t.Helper()

Expand All @@ -71,6 +73,7 @@ func NewEmptySessionTree(
sessionTreeHeader,
&accAddress,
testSessionTreeStoreDir,
polylog.Ctx(ctx),
red-0ne marked this conversation as resolved.
Show resolved Hide resolved
)
require.NoError(t, err)

Expand Down
6 changes: 3 additions & 3 deletions x/proof/keeper/proof_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func TestEnsureValidProof_Error(t *testing.T) {
desc: "relay must be deserializable",
newProof: func(t *testing.T) *prooftypes.Proof {
// Construct a session tree to which we'll add 1 unserializable relay.
mangledRelaySessionTree := testtree.NewEmptySessionTree(t, validSessionHeader, supplierOperatorAddr)
mangledRelaySessionTree := testtree.NewEmptySessionTree(t, validSessionHeader, supplierOperatorAddr, ctx)

// Add the mangled relay to the session tree.
err = mangledRelaySessionTree.Update([]byte{1}, mangledRelayBz, 1)
Expand Down Expand Up @@ -444,7 +444,7 @@ func TestEnsureValidProof_Error(t *testing.T) {

// Construct a session tree with 1 relay with a session header containing
// a session ID that doesn't match the expected session ID.
invalidRequestSignatureSessionTree := testtree.NewEmptySessionTree(t, validSessionHeader, supplierOperatorAddr)
invalidRequestSignatureSessionTree := testtree.NewEmptySessionTree(t, validSessionHeader, supplierOperatorAddr, ctx)

// Add the relay to the session tree.
err = invalidRequestSignatureSessionTree.Update([]byte{1}, invalidRequestSignatureRelayBz, 1)
Expand Down Expand Up @@ -505,7 +505,7 @@ func TestEnsureValidProof_Error(t *testing.T) {

// Construct a session tree with 1 relay with a session header containing
// a session ID that doesn't match the expected session ID.
invalidResponseSignatureSessionTree := testtree.NewEmptySessionTree(t, validSessionHeader, supplierOperatorAddr)
invalidResponseSignatureSessionTree := testtree.NewEmptySessionTree(t, validSessionHeader, supplierOperatorAddr, ctx)

// Add the relay to the session tree.
err = invalidResponseSignatureSessionTree.Update([]byte{1}, relayBz, 1)
Expand Down
Loading