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

[TODO] chore: cleanup done TODOs #627

Merged
merged 94 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 93 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
88e4cd4
refactor: relayminer to use proof_window_open_offset_blocks shared mo…
bryanchriswhite Jun 6, 2024
6b6df27
feat: add on-chain proof window validation
bryanchriswhite Jun 6, 2024
f105c8c
chore: add proof_request_probability proof module param
bryanchriswhite Jun 6, 2024
54bec5c
Merge branch 'main' into issues/516/feat/on-chain-proof-window
bryanchriswhite Jun 7, 2024
01fd0d6
chore: review improvements
bryanchriswhite Jun 7, 2024
6b74295
chore: review
bryanchriswhite Jun 7, 2024
1f19a18
Merge branch 'issues/516/feat/on-chain-proof-window' into issues/579/…
bryanchriswhite Jun 7, 2024
34d7ffb
fix: test error format strings
bryanchriswhite Jun 7, 2024
d169254
Merge branch 'issues/516/feat/on-chain-proof-window' into issues/579/…
bryanchriswhite Jun 7, 2024
0b53c3f
fix: param update json
bryanchriswhite Jun 7, 2024
f8a6f91
fix: test types
bryanchriswhite Jun 7, 2024
c2f442c
chore: regen protobufs
bryanchriswhite Jun 7, 2024
a4f6ac0
feat: add proof_requirement_threshold proof module param
bryanchriswhite Jun 7, 2024
de0a5ce
Merge remote-tracking branch 'pokt/main' into issues/579/param/proof_…
bryanchriswhite Jun 7, 2024
0880826
Merge branch 'issues/579/param/proof_request_probability' into issues…
bryanchriswhite Jun 7, 2024
c8b7472
Merge remote-tracking branch 'pokt/main' into issues/579/param/proof_…
bryanchriswhite Jun 7, 2024
07e0d96
chore: self-review
bryanchriswhite Jun 7, 2024
1b8fe2d
feat: add proof_missing_penalty proof module param
bryanchriswhite Jun 7, 2024
63963c7
refactor: pre-generated-accounts
bryanchriswhite Jun 11, 2024
f0c4d1e
fix: pre-generated-accounts prefix
bryanchriswhite Jun 11, 2024
65d20f0
chore: regenerate pre-generated-accounts
bryanchriswhite Jun 11, 2024
151c4e3
chore: review
bryanchriswhite Jun 11, 2024
1917db6
chore: self-review
bryanchriswhite Jun 11, 2024
66b678c
refactor: tokenomics keeper tests
bryanchriswhite Jun 11, 2024
87d7c65
chore: self-review improvements
bryanchriswhite Jun 11, 2024
9fa62e3
fixup! chore: self-review improvements
bryanchriswhite Jun 11, 2024
f93d42f
test: add coverage for proof required via probability only
bryanchriswhite Jun 11, 2024
638a31e
feat: add probabilistic proof requirement case when settling
bryanchriswhite Jun 11, 2024
3c9bf6f
refactor: tokenomics keeper tests to use claim/proof window height he…
bryanchriswhite Jun 11, 2024
499588e
test: secureRandomProbability
bryanchriswhite Jun 11, 2024
9060087
docs: add adding on-chain params page
bryanchriswhite Jun 11, 2024
2c3ca90
chore: update yarn.lock
bryanchriswhite Jun 11, 2024
3d9b83b
fix: keyring.Keyring#NewAccount() arg ordering
bryanchriswhite Jun 12, 2024
071d99f
chore: udpate comments
bryanchriswhite Jun 12, 2024
39366d6
chore: review improvements
bryanchriswhite Jun 12, 2024
a6c2e42
chore: add logging
bryanchriswhite Jun 12, 2024
24dd28a
chore: udpate comments
bryanchriswhite Jun 12, 2024
3318e9e
chore: review improvements
bryanchriswhite Jun 12, 2024
6e7366b
chore: review improvements
bryanchriswhite Jun 12, 2024
d9d642e
Empty commit
bryanchriswhite Jun 12, 2024
db277ce
Merge branch 'main' into issues/579/param/proof_requirement_threshold
bryanchriswhite Jun 12, 2024
e564bf6
refactor: proof_missing_penalty to cosmos.base.v1beta1.Coin type
bryanchriswhite Jun 12, 2024
0994d02
chore: review improvements
bryanchriswhite Jun 12, 2024
4c79c3a
Merge branch 'issues/579/test/tokenomics-keeper' into issues/579/feat…
bryanchriswhite Jun 12, 2024
3811b39
telemetry: add proof requirement count
bryanchriswhite Jun 12, 2024
ac71fdf
telemetry: add compute unit lifecycle count
bryanchriswhite Jun 12, 2024
3167b63
telemetry: update stress test dashboard
bryanchriswhite Jun 12, 2024
62137e3
Merge branch 'issues/579/param/proof_requirement_threshold' into issu…
bryanchriswhite Jun 12, 2024
7df1f18
Merge remote-tracking branch 'pokt/main' into issues/579/param/proof_…
bryanchriswhite Jun 12, 2024
a2c4dab
fix: use seeded deterministic PRNG
bryanchriswhite Jun 13, 2024
1f7d39e
test: add coverage for tokenomicstypes.Keeper#isProofRequired()
bryanchriswhite Jun 13, 2024
133a2d3
fix: failing CI unit test
bryanchriswhite Jun 13, 2024
60c646d
chore: review feedback improvements
bryanchriswhite Jun 13, 2024
39a0fa6
Merge branch 'issues/579/param/proof_missing_penalty' into issues/579…
bryanchriswhite Jun 13, 2024
5eb0989
chore: review improvements
bryanchriswhite Jun 13, 2024
6112066
Merge remote-tracking branch 'pokt/issues/579/refactor/pre-generated-…
bryanchriswhite Jun 13, 2024
3b1faf1
Merge branch 'issues/579/test/tokenomics-keeper' into issues/579/feat…
bryanchriswhite Jun 13, 2024
74126d7
chore: post-merge cleanup
bryanchriswhite Jun 13, 2024
9fe2226
Merge branch 'issues/579/feat/probabilistic-proofs' into issues/579/c…
bryanchriswhite Jun 13, 2024
869474f
chore/fix: review improvements + proper claim expiration & test coverage
bryanchriswhite Jun 13, 2024
57de938
fix: claim window close height calculation
bryanchriswhite Jun 13, 2024
85656c8
telemetry: add expirations to Claims & Proofs plot
bryanchriswhite Jun 13, 2024
217e275
Empty commit
bryanchriswhite Jun 13, 2024
5d0939e
fix: dashboard
bryanchriswhite Jun 13, 2024
57645f9
fix: failing test
bryanchriswhite Jun 13, 2024
aa53faf
Merge branch 'main' into issues/579/param/proof_missing_penalty
bryanchriswhite Jun 14, 2024
27906cd
Merge branch 'issues/579/param/proof_missing_penalty' into issues/579…
bryanchriswhite Jun 14, 2024
dab1541
Merge branch 'issues/579/refactor/pre-generated-accounts' into issues…
bryanchriswhite Jun 14, 2024
cb08520
Merge branch 'issues/579/test/tokenomics-keeper' into issues/579/feat…
bryanchriswhite Jun 14, 2024
bf49725
Merge branch 'issues/579/feat/probabilistic-proofs' into issues/579/c…
bryanchriswhite Jun 14, 2024
e79d147
chore: review improvements
bryanchriswhite Jun 14, 2024
f53ed05
chore: review improvements
bryanchriswhite Jun 14, 2024
dcd7435
chore: review improvements
bryanchriswhite Jun 14, 2024
cd08709
Merge branch 'issues/579/feat/probabilistic-proofs' into issues/579/c…
bryanchriswhite Jun 14, 2024
eb3f061
Merge branch 'issues/579/param/proof_missing_penalty' into issues/579…
bryanchriswhite Jun 14, 2024
cea9c67
Merge branch 'main' into issues/579/refactor/pre-generated-accounts
bryanchriswhite Jun 14, 2024
f2f7548
Merge branch 'issues/579/refactor/pre-generated-accounts' into issues…
bryanchriswhite Jun 14, 2024
77bc81c
Merge branch 'main' into issues/579/test/tokenomics-keeper
bryanchriswhite Jun 14, 2024
df36a79
Merge branch 'issues/579/test/tokenomics-keeper' into issues/579/feat…
bryanchriswhite Jun 14, 2024
9b85f24
Merge remote-tracking branch 'pokt/main' into issues/579/feat/probabi…
bryanchriswhite Jun 14, 2024
68712fc
Merge branch 'issues/579/feat/probabilistic-proofs' into issues/579/c…
bryanchriswhite Jun 14, 2024
94a677b
chore: cleanup session ID validation todos
bryanchriswhite Jun 14, 2024
3cfb819
Merge branch 'main' into issues/579/feat/probabilistic-proofs
bryanchriswhite Jun 17, 2024
9850dcb
Merge remote-tracking branch 'pokt/issues/579/feat/probabilistic-proo…
bryanchriswhite Jun 17, 2024
1800dea
Merge branch 'issues/579/chore/telemetry' into issues/586/todos/sessi…
bryanchriswhite Jun 17, 2024
497e834
Merge remote-tracking branch 'pokt/main' into issues/586/todos/sessio…
bryanchriswhite Jun 20, 2024
be36e39
chore: review feedback improvements
bryanchriswhite Jun 20, 2024
2bb0f1c
chore: cleanup done TODOs
bryanchriswhite Jun 20, 2024
0a236a1
fix: unit test
bryanchriswhite Jun 20, 2024
e4cca3a
Merge branch 'issues/586/todos/session-id-validation' into issues/586…
bryanchriswhite Jun 20, 2024
16d139c
Merge branch 'main' into issues/586/todos/session-id-validation
bryanchriswhite Jun 21, 2024
4d34e58
Merge branch 'main' into issues/586/todos/session-id-validation
bryanchriswhite Jun 24, 2024
5d16db3
Merge branch 'issues/586/todos/session-id-validation' into issues/586…
bryanchriswhite Jun 24, 2024
9e30299
Merge branch 'main' into issues/586/todos/done
bryanchriswhite Jun 24, 2024
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: 0 additions & 2 deletions load-testing/tests/relays_stress_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,6 @@ func (plan *actorLoadTestIncrementPlan) shouldIncrementActorCount(
}

initialSessionNumber := testsession.GetSessionNumberWithDefaultParams(startBlockHeight)
// TODO_BLOCKER(@bryanchriswhite): replace with gov param query when available.
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
actorSessionIncRate := plan.blocksPerIncrement / int64(sharedParams.GetNumBlocksPerSession())
nextSessionNumber := sessionInfo.sessionNumber + 1 - initialSessionNumber
isSessionStartHeight := sessionInfo.blockHeight == sessionInfo.sessionStartBlockHeight
Expand All @@ -757,7 +756,6 @@ func (plan *actorLoadTestIncrementPlan) shouldIncrementSupplierCount(
}

initialSessionNumber := testsession.GetSessionNumberWithDefaultParams(startBlockHeight)
// TODO_BLOCKER(@bryanchriswhite): replace with gov param query when available.
supplierSessionIncRate := plan.blocksPerIncrement / int64(sharedParams.GetNumBlocksPerSession())
nextSessionNumber := sessionInfo.sessionNumber + 1 - initialSessionNumber
isSessionEndHeight := sessionInfo.blockHeight == sessionInfo.sessionEndBlockHeight
Expand Down
2 changes: 0 additions & 2 deletions pkg/relayer/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@ func (rs *relayerSessionsManager) forEachBlockClaimSessionsFn(
// no longer eligible to be claimed, but that's not always the case.
// Once claim window closing is implemented, they will be filtered out
// downstream at the waitForEarliestCreateClaimsHeight step.
// TODO_BLOCKER(@bryanchriswhite): Introduce governance claim and
// proof window durations, implement off-chain window closing and on-chain window checks.
if sessionGracePeriodEndHeight <= block.Height() {
// Iterate over the sessionsTrees that have grace period ending at this
// block height and add them to the list of sessionTrees to be published.
Expand Down
3 changes: 0 additions & 3 deletions x/proof/keeper/msg_server_create_claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ func (k msgServer) CreateClaim(
ctx context.Context,
msg *types.MsgCreateClaim,
) (_ *types.MsgCreateClaimResponse, err error) {
// TODO_BLOCKER(@bryanchriswhite): Prevent Claim upserts after the ClaimWindow is closed.
// TODO_BLOCKER(@bryanchriswhite): Validate the signature on the Claim message corresponds to the supplier before Upserting.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is guaranteed by the presence of the the cosmos.msg.v1.signer option on the MsgCreateClaim protobuf type.


// Declare claim to reference in telemetry.
var claim types.Claim

Expand Down
3 changes: 0 additions & 3 deletions x/proof/keeper/msg_server_submit_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ func init() {
// A proof that's stored on-chain is what leads to rewards (i.e. inflation)
// downstream, making the series of checks a critical part of the protocol.
//
// TODO_BLOCKER(@bryanchriswhite): Prevent proof upserts after the tokenomics
// module has processed the respective session.
//
// Note: The entity sending the SubmitProof messages does not necessarily need
// to correspond to the supplier signing the proof. For example, a single entity
// could (theoretically) batch multiple proofs (signed by the corresponding supplier)
Expand Down
5 changes: 2 additions & 3 deletions x/proof/keeper/query_claim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ func TestClaimQuerySingle(t *testing.T) {

expectedErr: status.Error(
codes.InvalidArgument,
types.ErrProofInvalidSessionId.Wrapf(
"invalid session ID for claim being retrieved %s",
"",
types.ErrProofInvalidSessionId.Wrap(
"invalid empty session ID for claim being retrieved",
).Error(),
),
},
Expand Down
5 changes: 2 additions & 3 deletions x/proof/keeper/query_proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ func TestProofQuerySingle(t *testing.T) {
},
expectedErr: status.Error(
codes.InvalidArgument,
types.ErrProofInvalidSessionId.Wrapf(
"invalid session ID for proof being retrieved %s",
"",
types.ErrProofInvalidSessionId.Wrap(
"invalid empty session ID for proof being retrieved",
).Error(),
),
},
Expand Down
20 changes: 8 additions & 12 deletions x/proof/types/query_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,25 @@ func (query *QueryGetClaimRequest) ValidateBasic() error {
return ErrProofInvalidAddress.Wrapf("invalid supplier address for claim being retrieved %s; (%v)", query.SupplierAddress, err)
}

// TODO_BLOCKER(@bryanchriswhite): Validate the session ID once we have a deterministic way to generate it
if query.SessionId == "" {
return ErrProofInvalidSessionId.Wrapf("invalid session ID for claim being retrieved %s", query.SessionId)
return ErrProofInvalidSessionId.Wrap("invalid empty session ID for claim being retrieved")
}

return nil
}

// ValidateBasic performs basic (non-state-dependant) validation on a QueryAllClaimsRequest.
func (query *QueryAllClaimsRequest) ValidateBasic() error {
logger := polylog.Ctx(context.Background())

switch filter := query.Filter.(type) {
case *QueryAllClaimsRequest_SupplierAddress:
if _, err := sdk.AccAddressFromBech32(filter.SupplierAddress); err != nil {
return ErrProofInvalidAddress.Wrapf("invalid supplier address for claims being retrieved %s; (%v)", filter.SupplierAddress, err)
}

case *QueryAllClaimsRequest_SessionId:
logger.Warn().
Str("session_id", filter.SessionId).
Msg("TODO_BLOCKER(@bryanchriswhite): Validate the session ID once we have a deterministic way to generate it")
if filter.SessionId == "" {
return ErrProofInvalidSessionId.Wrap("invalid empty session ID for claims being retrieved")
}

case *QueryAllClaimsRequest_SessionEndHeight:
if filter.SessionEndHeight < 0 {
Expand All @@ -57,9 +54,8 @@ func (query *QueryGetProofRequest) ValidateBasic() error {
return ErrProofInvalidAddress.Wrapf("invalid supplier address for proof being retrieved %s; (%v)", query.SupplierAddress, err)
}

// TODO_BLOCKER(@bryanchriswhite): Validate the session ID once we have a deterministic way to generate it
if query.SessionId == "" {
return ErrProofInvalidSessionId.Wrapf("invalid session ID for proof being retrieved %s", query.SessionId)
return ErrProofInvalidSessionId.Wrap("invalid empty session ID for proof being retrieved")
}

return nil
Expand All @@ -76,9 +72,9 @@ func (query *QueryAllProofsRequest) ValidateBasic() error {
}

case *QueryAllProofsRequest_SessionId:
logger.Warn().
Str("session_id", filter.SessionId).
Msg("TODO_BLOCKER(@bryanchriswhite): Validate the session ID once we have a deterministic way to generate it")
if filter.SessionId == "" {
return ErrProofInvalidSessionId.Wrap("invalid empty session ID for proofs being retrieved")
}

case *QueryAllProofsRequest_SessionEndHeight:
if filter.SessionEndHeight < 0 {
Expand Down
2 changes: 1 addition & 1 deletion x/session/keeper/query_get_session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestSession_GetSession_Success(t *testing.T) {
blockHeight: 1,

// Intentionally only checking a subset of the session metadata returned
expectedSessionId: "335ca69ea6365eed04d5be2f5553b239bd2e3226b08c394169059ae40dfa1599",
expectedSessionId: "afd00273055a4fddc0beb30074e14d474c07f9e895d2795db006a5139048d54b",
expectedSessionNumber: 1,
expectedNumSuppliers: 1,
},
Expand Down
17 changes: 7 additions & 10 deletions x/session/keeper/session_hydrator.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper

import (
"bytes"
"context"
"crypto"
"encoding/binary"
Expand Down Expand Up @@ -254,12 +255,8 @@ func uniqueRandomIndices(seed, maxIndex, numIndices int64) map[int64]struct{} {
return indicesMap
}

func concatWithDelimiter(delimiter string, bz ...[]byte) (result []byte) {
for _, b := range bz {
result = append(result, b...)
result = append(result, []byte(delimiter)...)
}
return result
func concatWithDelimiter(delimiter string, bz ...[]byte) []byte {
return bytes.Join(bz, []byte(delimiter))
}

func sha3Hash(bz []byte) []byte {
Expand Down Expand Up @@ -292,16 +289,16 @@ func GetSessionId(
blockHashBz []byte,
blockHeight int64,
) (sessionId string, sessionIdBz []byte) {
appPubKeyBz := []byte(appAddr)
appAddrBz := []byte(appAddr)
serviceIdBz := []byte(serviceId)

blockHeightBz := getSessionStartBlockHeightBz(sharedParams, blockHeight)
sessionStartHeightBz := getSessionStartBlockHeightBz(sharedParams, blockHeight)
sessionIdBz = concatWithDelimiter(
SessionIDComponentDelimiter,
blockHashBz,
serviceIdBz,
appPubKeyBz,
blockHeightBz,
appAddrBz,
sessionStartHeightBz,
)
sessionId = hex.EncodeToString(sha3Hash(sessionIdBz))

Expand Down
16 changes: 8 additions & 8 deletions x/session/keeper/session_hydrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ func TestSession_HydrateSession_Success_BaseCase(t *testing.T) {
require.Equal(t, "", sessionHeader.Service.Name)
require.Equal(t, int64(9), sessionHeader.SessionStartBlockHeight)
require.Equal(t, int64(12), sessionHeader.SessionEndBlockHeight)
require.Equal(t, "20650c94d0bcc4b855654b5533bf880345ae96933c5fa7424ce59c698d208e22", sessionHeader.SessionId)
require.Equal(t, "fea5d6f7544ff6d8af5c22529b2ccf01ed7930b3d454d42dda5ccc0b65b6ebfd", sessionHeader.SessionId)

// Check the session
require.Equal(t, int64(4), session.NumBlocksPerSession)
require.Equal(t, "20650c94d0bcc4b855654b5533bf880345ae96933c5fa7424ce59c698d208e22", session.SessionId)
require.Equal(t, "fea5d6f7544ff6d8af5c22529b2ccf01ed7930b3d454d42dda5ccc0b65b6ebfd", session.SessionId)
require.Equal(t, int64(3), session.SessionNumber)

// Check the application
Expand Down Expand Up @@ -165,8 +165,8 @@ func TestSession_HydrateSession_SessionId(t *testing.T) {
serviceId1: keepertest.TestServiceId1, // svc1
serviceId2: keepertest.TestServiceId1, // svc1

expectedSessionId1: "c8a3d0135e2d0ed3a2d579adcd3b91708e59adf558b7c8bd474473de669cb18a",
expectedSessionId2: "20650c94d0bcc4b855654b5533bf880345ae96933c5fa7424ce59c698d208e22",
expectedSessionId1: "e161348f2153bb41092040c3c287596f8daf98e90986475be21412a1ded945ed",
expectedSessionId2: "fea5d6f7544ff6d8af5c22529b2ccf01ed7930b3d454d42dda5ccc0b65b6ebfd",
},
{
desc: "app1: sessionId for svc1 != sessionId for svc12",
Expand All @@ -180,8 +180,8 @@ func TestSession_HydrateSession_SessionId(t *testing.T) {
serviceId1: keepertest.TestServiceId1, // svc1
serviceId2: keepertest.TestServiceId12, // svc12

expectedSessionId1: "c8a3d0135e2d0ed3a2d579adcd3b91708e59adf558b7c8bd474473de669cb18a",
expectedSessionId2: "bf37fcbc62fe728f356384e9a765584f1c9d761566b2d46c0f77297675d966c6",
expectedSessionId1: "e161348f2153bb41092040c3c287596f8daf98e90986475be21412a1ded945ed",
expectedSessionId2: "c01eb8924dbb9dae7cab8ed56016ce8fdd2d23542f9e0b7ca8d6972d3fb45ce5",
},
{
desc: "svc12: sessionId for app1 != sessionId for app2",
Expand All @@ -195,8 +195,8 @@ func TestSession_HydrateSession_SessionId(t *testing.T) {
serviceId1: keepertest.TestServiceId12, // svc12
serviceId2: keepertest.TestServiceId12, // svc12

expectedSessionId1: "bf37fcbc62fe728f356384e9a765584f1c9d761566b2d46c0f77297675d966c6",
expectedSessionId2: "8806550a46a16fcb6bc0a4bd0803081a2478d25868057bcf86204c8aaefb28ac",
expectedSessionId1: "c01eb8924dbb9dae7cab8ed56016ce8fdd2d23542f9e0b7ca8d6972d3fb45ce5",
expectedSessionId2: "f6dbe4961afd8ff0e444a1159d02bc645f9ded3daaa605c187e6bd7ee2232a68",
},
}

Expand Down
Loading