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

[Tokenomics] Preparation for proportional relay mining rewards based on difficulty #771

Merged
merged 64 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
6738d21
WIP
Olshansk Aug 16, 2024
3e6a146
Merge branch 'main' into inflation
Olshansk Aug 20, 2024
c3a235a
Checkpoint
Olshansk Aug 21, 2024
846bc1d
Finished first version of the documentation
Olshansk Aug 21, 2024
40c56a5
Merge branch 'main' into inflation
Olshansk Aug 21, 2024
98736f3
Revert tokenomic docs
Olshansk Aug 21, 2024
eeabb30
Performed self review
Olshansk Aug 21, 2024
10ef513
Merge with main
Olshansk Aug 22, 2024
0e725a4
Remove everything related to TLMGlobalMintReimbursementRequest
Olshansk Aug 22, 2024
bbe2366
WIP
Olshansk Aug 23, 2024
ad70e70
Fixed the TestProcessTokenLogicModules_TLMBurnEqualsMintValid test
Olshansk Aug 23, 2024
b02ef24
WIP
Olshansk Aug 24, 2024
8663fac
Finished implementing TestProcessTokenLogicModules_TLMBurnEqualsMint_…
Olshansk Aug 25, 2024
085d134
Implemented TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDist…
Olshansk Aug 25, 2024
1de13ba
Updated comments in e2e/tests/0_settlement.feature
Olshansk Aug 25, 2024
b8dff51
Fixed failing unit test
Olshansk Aug 25, 2024
9231d6f
Merge branch 'main' into issues/732_max_claimable_pokt
Olshansk Aug 25, 2024
f79989a
Merge branch 'main' into issues/732_max_claimable_pokt
Olshansk Aug 26, 2024
4c335e7
update compile proto
Olshansk Aug 26, 2024
e0ea0d5
Merge branch 'main' into issues/732_max_claimable_pokt
Olshansk Aug 28, 2024
ccb4e12
Update proto/poktroll/tokenomics/event.proto
Olshansk Aug 28, 2024
7fce0fc
Update x/tokenomics/keeper/keeper_settle_pending_claims_test.go
Olshansk Aug 28, 2024
f60cc46
WIP comments
Olshansk Aug 28, 2024
6298765
WIP comments
Olshansk Aug 28, 2024
b0266b0
Resolved a few simple comments
Olshansk Aug 28, 2024
754b52c
Apply suggestions from code review
Olshansk Aug 28, 2024
e98ac7a
Apply suggestions from code review
Olshansk Aug 28, 2024
5065264
Apply suggestions from code review
Olshansk Aug 28, 2024
7f098f4
Apply suggestions from code review
Olshansk Aug 28, 2024
f63a8dd
Tending to a partial set of comments
Olshansk Aug 28, 2024
da081e9
Update testutil/testrelayer/relays.go
Olshansk Aug 28, 2024
b32397d
Update tests/integration/tokenomics/relay_mining_difficulty_test.go
Olshansk Aug 28, 2024
02fd89c
Final set of comments
Olshansk Aug 29, 2024
240430c
WIP
Olshansk Aug 29, 2024
2c9d671
Merge branch 'issues/732_max_claimable_pokt' into relay_mining_tests
Olshansk Aug 29, 2024
b0be348
WIP
Olshansk Aug 29, 2024
2964e94
WIP
Olshansk Aug 29, 2024
05f8494
Merge with main
Olshansk Aug 30, 2024
675598b
Checkpoint for WIP
Olshansk Aug 31, 2024
2474df4
Merge with main
Olshansk Aug 31, 2024
18b23d4
Merge with main
Olshansk Aug 31, 2024
7e18714
non compiling merge with main
Olshansk Sep 10, 2024
659fbe6
Revive .pb.go files
Olshansk Sep 10, 2024
a0c6f6e
Compiles but non functional
Olshansk Sep 10, 2024
996d21b
Checkpoint commit
Olshansk Sep 11, 2024
fe6dba6
Merge branch 'main' into relay_mining_tests
Olshansk Sep 12, 2024
7c16371
Compiled some stuff
Olshansk Sep 12, 2024
0c46182
updated one more test
Olshansk Sep 12, 2024
01d7b83
Finishing self review
Olshansk Sep 12, 2024
08bea4e
Minor comment update
Olshansk Sep 12, 2024
8843bdf
unused linter
Olshansk Sep 12, 2024
4b29af6
Merge with main
Olshansk Sep 17, 2024
1fdf19a
Merge remote-tracking branch 'origin/main' into relay_mining_tests
red-0ne Sep 18, 2024
4be2e8a
fix: Linting and unused test function
red-0ne Sep 18, 2024
6cd84d6
Update pkg/crypto/protocol/relay_difficulty_test.go
Olshansk Sep 19, 2024
2f82a56
Fixed TestRelayDifficulty_GetRelayDifficultyMultiplier
Olshansk Sep 19, 2024
0c05da1
About to make major changes for a broken test
Olshansk Sep 19, 2024
da3f151
Cleaned up some code and tests
Olshansk Sep 19, 2024
5041a18
All comments resolved
Olshansk Sep 20, 2024
77b9774
Fixed unit tests and improved comments
Olshansk Sep 20, 2024
08e0c8a
Updated comments
Olshansk Sep 20, 2024
40a59e4
Merge branch 'main' into relay_mining_tests
Olshansk Sep 20, 2024
3bf5f28
Tests passed locally
Olshansk Sep 20, 2024
c715098
Commenting out a test
Olshansk Sep 21, 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
259 changes: 133 additions & 126 deletions api/poktroll/tokenomics/event.pulsar.go

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,16 +398,17 @@ func GetMaccPerms() map[string][]string {
}

// BlockedAddresses returns all the app's blocked account addresses.
// It is returned as a map for easy lookup, but is in essence a set.
func BlockedAddresses() map[string]bool {
result := make(map[string]bool)
blockedAddressSet := make(map[string]bool)
if len(blockAccAddrs) > 0 {
for _, addr := range blockAccAddrs {
result[addr] = true
blockedAddressSet[addr] = true
}
} else {
for addr := range GetMaccPerms() {
result[addr] = true
blockedAddressSet[addr] = true
}
}
return result
return blockedAddressSet
}
46 changes: 23 additions & 23 deletions docusaurus/docs/develop/contributing/observability.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,23 @@ the memory usage and reduce the performance of the Prometheus server. To mitigat
```go
// Declare a named `error` return argument.
func (k msgServer) CreateClaim(...) (_ *types.MsgCreateClaimResponse, err error) {
// Declare claim to reference in telemetry.
var (
claim types.Claim
isExistingClaim bool
numRelays uint64
numComputeUnits uint64
)

// Defer telemetry calls so that they reference the final values the relevant variables.
defer func() {
// Only increment these metrics counters if handling a new claim.
if !isExistingClaim {
telemetry.ClaimCounter(types.ClaimProofStage_CLAIMED, 1, err)
telemetry.ClaimRelaysCounter(types.ClaimProofStage_CLAIMED, numRelays, err)
telemetry.ClaimComputeUnitsCounter(types.ClaimProofStage_CLAIMED, numComputeUnits, err)
}
}()
// Declare claim to reference in telemetry.
var (
claim types.Claim
isExistingClaim bool
numRelays uint64
numComputeUnits uint64
)

// Defer telemetry calls so that they reference the final values the relevant variables.
defer func() {
// Only increment these metrics counters if handling a new claim.
if !isExistingClaim {
telemetry.ClaimCounter(types.ClaimProofStage_CLAIMED, 1, err)
telemetry.ClaimRelaysCounter(types.ClaimProofStage_CLAIMED, numRelays, err)
telemetry.ClaimComputeUnitsCounter(types.ClaimProofStage_CLAIMED, numComputeUnits, err)
}
}()


// Ensure `err` is not shadowed by avoiding `:=` operator.
Expand All @@ -101,12 +101,12 @@ func (k msgServer) CreateClaim(...) (_ *types.MsgCreateClaimResponse, err error)
#### [x/tokenomics/module/abci.go](https://github.com/pokt-network/poktroll/blob/main/x/tokenomics/module/abci.go)

```go
// Emit telemetry for each service's relay mining difficulty.
for serviceId, newDifficulty := range difficultyPerServiceMap {
miningDifficultyNumBits := keeper.RelayMiningTargetHashToDifficulty(newDifficulty.TargetHash)
telemetry.RelayMiningDifficultyGauge(miningDifficultyNumBits, serviceId)
telemetry.RelayEMAGauge(newDifficulty.NumRelaysEma, serviceId)
}
// Emit telemetry for each service's relay mining difficulty.
for serviceId, newDifficulty := range difficultyPerServiceMap {
miningDifficultyNumBits := keeper.RelayMiningTargetHashToDifficulty(newDifficulty.TargetHash)
telemetry.RelayMiningDifficultyGauge(miningDifficultyNumBits, serviceId)
telemetry.RelayEMAGauge(newDifficulty.NumRelaysEma, serviceId)
}
```

### Histogram
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/0_settlement.feature
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Feature: Tokenomics Namespace
Scenario: Settle the session when a valid claim is create but not required
# Baseline
Given the user has the pocketd binary installed
# Network preparation
# Network preparation and validation
And an account exists for "supplier1"
And the "supplier" account for "supplier1" is staked
And an account exists for "app1"
Expand Down
1 change: 0 additions & 1 deletion pkg/client/supplier/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ func TestSupplierClient_SubmitProof(t *testing.T) {

// Generating an ephemeral tree & spec just so we can submit
// a proof of the right size.
// TODO_TECHDEBT(#446): Centralize the configuration for the SMT spec.
tree := smt.NewSparseMerkleSumTrie(kvStore, protocol.NewTrieHasher())
emptyPath := make([]byte, tree.PathHasherSize())
proof, err := tree.ProveClosest(emptyPath)
Expand Down
10 changes: 5 additions & 5 deletions pkg/client/tx/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package tx_test

import (
"context"
"crypto/sha256"
"os"
"sync"
"testing"
Expand All @@ -22,6 +21,7 @@ import (
"github.com/pokt-network/poktroll/pkg/client"
"github.com/pokt-network/poktroll/pkg/client/keyring"
"github.com/pokt-network/poktroll/pkg/client/tx"
"github.com/pokt-network/poktroll/pkg/crypto/protocol"
"github.com/pokt-network/poktroll/pkg/either"
"github.com/pokt-network/poktroll/testutil/mockclient"
"github.com/pokt-network/poktroll/testutil/testclient"
Expand Down Expand Up @@ -364,6 +364,10 @@ func TestTxClient_SignAndBroadcast_Timeout(t *testing.T) {
txResultsBzPublishCh chan<- either.Bytes
blocksPublishCh = make(chan client.Block, tx.DefaultCommitTimeoutHeightOffset)
ctx = context.Background()

// Trie related variables
spec = smt.NewTrieSpec(protocol.NewTrieHasher(), true)
emptyBlockHash = make([]byte, spec.PathHasherSize())
)

keyring, signingKey := testkeyring.NewTestKeyringWithKey(t, testSigningKeyName)
Expand Down Expand Up @@ -415,10 +419,6 @@ func TestTxClient_SignAndBroadcast_Timeout(t *testing.T) {
err, errCh := eitherErr.SyncOrAsyncError()
require.NoError(t, err)

// TODO_TECHDEBT(#446): Centralize the configuration for the SMT spec.
spec := smt.NewTrieSpec(sha256.New(), true)
emptyBlockHash := make([]byte, spec.PathHasherSize())

for i := 0; i < tx.DefaultCommitTimeoutHeightOffset; i++ {
blocksPublishCh <- testblock.NewAnyTimesBlock(t, emptyBlockHash, int64(i+1))
}
Expand Down
46 changes: 0 additions & 46 deletions pkg/crypto/protocol/difficulty.go

This file was deleted.

106 changes: 0 additions & 106 deletions pkg/crypto/protocol/difficulty_test.go

This file was deleted.

Loading
Loading