Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

* [#747](https://github.com/allora-network/allora-chain/pull/747) New stdnorm calc + weights onchain

### Deprecated

### Removed
Expand All @@ -85,6 +87,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Security


# v0.8.3

### Added
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ FROM golang:1.22-bookworm AS builder

ENV GO111MODULE=on
ENV GOMODCACHE=/gocache
ENV BASELINE_VERSION_TAG=v0.7.0
ENV UPGRADE_VERSION_TAG=v0.8.0
ENV BASELINE_VERSION_TAG=v0.8.0
ENV UPGRADE_VERSION_TAG=v0.9.0
ENV GIT_STASH_MESSAGE="Docker build"


Expand Down
2 changes: 2 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/allora-network/allora-chain/app/upgrades/v0_6_0"
"github.com/allora-network/allora-chain/app/upgrades/v0_7_0"
"github.com/allora-network/allora-chain/app/upgrades/v0_8_0"
"github.com/allora-network/allora-chain/app/upgrades/v0_9_0"
)

var upgradeHandlers = []upgrades.Upgrade{
Expand All @@ -21,6 +22,7 @@ var upgradeHandlers = []upgrades.Upgrade{
v0_6_0.Upgrade,
v0_7_0.Upgrade,
v0_8_0.Upgrade,
v0_9_0.Upgrade,
// Add more upgrade handlers here
// ...
}
Expand Down
40 changes: 40 additions & 0 deletions app/upgrades/v0_9_0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package v0_9_0 //nolint:revive // var-naming: don't use an underscore in package name

import (
"context"

storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/allora-network/allora-chain/app/keepers"
"github.com/allora-network/allora-chain/app/upgrades"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
)

const (
UpgradeName = "v0.9.0"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: storetypes.StoreUpgrades{Added: nil, Renamed: nil, Deleted: nil},
}

func CreateUpgradeHandler(
moduleManager *module.Manager,
configurator module.Configurator,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
sdkCtx.Logger().Info("RUN MIGRATIONS")
vm, err := moduleManager.RunMigrations(ctx, configurator, vm)
if err != nil {
return vm, err
}

sdkCtx.Logger().Info("MIGRATIONS COMPLETED")
return vm, nil
}
}
4 changes: 2 additions & 2 deletions math/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func NCalcEma(
// Used for deterministic ranging of maps
func GetSortedKeys[K cmp.Ordered, V any](m map[K]V) []K {
keys := make([]K, 0, len(m))
for k := range m {
for k := range m { // nolint: maprange // reason: iteration to array before sorting
keys = append(keys, k)
}
sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] })
Expand All @@ -125,7 +125,7 @@ func GetSortedKeys[K cmp.Ordered, V any](m map[K]V) []K {
func GetSortedElementsByDecWeightDesc[K cmp.Ordered](m map[K]*Dec) []K {
// Create a new array that only contains unique elements that are in the map
newL := make([]K, 0)
for id := range m {
for id := range m { // nolint: maprange // reason: iteration to array before sorting
newL = append(newL, id)
}

Expand Down
8 changes: 5 additions & 3 deletions test/integration/update_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package integration_test

import (
"context"
"fmt"

alloraMath "github.com/allora-network/allora-chain/math"
testCommon "github.com/allora-network/allora-chain/test/common"
Expand All @@ -28,8 +27,8 @@ func checkIfAdmin(m testCommon.TestConfig, address string) bool {
func UpdateParamsChecks(m testCommon.TestConfig) {
ctx := context.Background()
// Ensure Alice is in the whitelist and Bob is not
require.True(m.T, checkIfAdmin(m, m.AliceAddr), fmt.Sprintf("Alice %s should be a whitelist admin", m.AliceAddr))
require.False(m.T, checkIfAdmin(m, m.BobAddr), fmt.Sprintf("Bob %s should not be a whitelist admin", m.BobAddr))
require.True(m.T, checkIfAdmin(m, m.AliceAddr), "Alice %s should be a whitelist admin", m.AliceAddr)
require.False(m.T, checkIfAdmin(m, m.BobAddr), "Bob %s should not be a whitelist admin", m.BobAddr)

// Keep old params to revert back to
oldParams := GetEmissionsParams(m)
Expand Down Expand Up @@ -96,6 +95,7 @@ func UpdateParamsChecks(m testCommon.TestConfig) {
GlobalReputerWhitelistEnabled: nil,
GlobalAdminWhitelistAppended: nil,
MaxWhitelistInputArrayLength: nil,
MinWeightThresholdForStdnorm: nil,
},
}
txResp, err := m.Client.BroadcastTx(ctx, m.AliceAcc, updateParamRequest)
Expand Down Expand Up @@ -162,6 +162,7 @@ func UpdateParamsChecks(m testCommon.TestConfig) {
GlobalReputerWhitelistEnabled: nil,
GlobalAdminWhitelistAppended: nil,
MaxWhitelistInputArrayLength: nil,
MinWeightThresholdForStdnorm: nil,
},
}
_, err = m.Client.BroadcastTx(ctx, m.BobAcc, updateParamRequest)
Expand Down Expand Up @@ -232,6 +233,7 @@ func UpdateParamsChecks(m testCommon.TestConfig) {
GlobalReputerWhitelistEnabled: nil,
GlobalAdminWhitelistAppended: nil,
MaxWhitelistInputArrayLength: nil,
MinWeightThresholdForStdnorm: nil,
},
}
txResp, err = m.Client.BroadcastTx(ctx, m.AliceAcc, updateParamRequest)
Expand Down
6 changes: 3 additions & 3 deletions test/integration/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

upgradetypes "cosmossdk.io/x/upgrade/types"
v0_8_0 "github.com/allora-network/allora-chain/app/upgrades/v0_8_0"
v0_9_0 "github.com/allora-network/allora-chain/app/upgrades/v0_9_0"
testCommon "github.com/allora-network/allora-chain/test/common"
sdktypes "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -57,7 +57,7 @@ func voteOnProposal(m testCommon.TestConfig, proposalId uint64) {
// propose an upgrade to the v0.5.0 software version
func proposeUpgrade(m testCommon.TestConfig) (proposalId uint64, proposalHeight int64) {
ctx := context.Background()
name := v0_8_0.UpgradeName
name := v0_9_0.UpgradeName
summary := "Upgrade to " + name + " software version"

currHeight, err := m.Client.BlockHeight(ctx)
Expand Down Expand Up @@ -162,7 +162,7 @@ func getAppliedVersionHeight(m testCommon.TestConfig, version string) int64 {
}

func UpgradeChecks(m testCommon.TestConfig) {
versionName := v0_8_0.UpgradeName
versionName := v0_9_0.UpgradeName
m.T.Log("--- Getting Emissions Module Version Before Upgrade ---")
emissionsVersionBefore := getEmissionsVersion(m)
m.T.Logf("--- Propose Upgrade to %s software version from v0 (%d) ---", versionName, emissionsVersionBefore)
Expand Down
2 changes: 1 addition & 1 deletion test/local_testnet_l1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ VALIDATORS_API_PORT_START=1317
HEADS_IP_START=20
CHAIN_ID="${CHAIN_ID:-localnet}"
LOCALNET_DATADIR="$(pwd)/$CHAIN_ID"
UPGRADE_VERSION="${UPGRADE_VERSION:-"v0.7.0"}"
UPGRADE_VERSION="${UPGRADE_VERSION:-"v0.9.0"}"
DO_UPGRADE="${DO_UPGRADE:-"false"}"
if [ "$DO_UPGRADE" == "true" ]; then
DOCKERFILE="${DOCKERFILE:-"./Dockerfile.upgrade"}"
Expand Down
3 changes: 1 addition & 2 deletions utils/migutils/migutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package migutils_test
import (
"fmt"
rand "math/rand/v2"
"strings"
"testing"

"cosmossdk.io/collections"
Expand Down Expand Up @@ -133,6 +132,6 @@ func runSafelyClearWholeMapCase[K, V any](
for _, key := range keys {
_, err := m.Get(testDB.TestCtx.Ctx, key)
require.Error(t, err)
require.True(t, strings.Contains(err.Error(), "collections: not found"))
require.Contains(t, err.Error(), "collections: not found")
}
}
47 changes: 47 additions & 0 deletions x/emissions/api/emissions/v7/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package emissionsv7

import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// nolint: exhaustruct
func RegisterInterfaces(registry types.InterfaceRegistry) {
registry.RegisterImplementations((*sdk.Msg)(nil),
&UpdateParamsRequest{},
&CreateNewTopicRequest{},
&RegisterRequest{},
&RemoveRegistrationRequest{},
&AddStakeRequest{},
&RemoveStakeRequest{},
&CancelRemoveStakeRequest{},
&DelegateStakeRequest{},
&RewardDelegateStakeRequest{},
&RemoveDelegateStakeRequest{},
&CancelRemoveDelegateStakeRequest{},
&FundTopicRequest{},
&AddToWhitelistAdminRequest{},
&RemoveFromWhitelistAdminRequest{},
&InsertWorkerPayloadRequest{},
&InsertReputerPayloadRequest{},
&AddToGlobalWhitelistRequest{},
&RemoveFromGlobalWhitelistRequest{},
&EnableTopicWorkerWhitelistRequest{},
&DisableTopicWorkerWhitelistRequest{},
&EnableTopicReputerWhitelistRequest{},
&DisableTopicReputerWhitelistRequest{},
&AddToTopicCreatorWhitelistRequest{},
&RemoveFromTopicCreatorWhitelistRequest{},
&AddToTopicWorkerWhitelistRequest{},
&RemoveFromTopicWorkerWhitelistRequest{},
&AddToTopicReputerWhitelistRequest{},
&RemoveFromTopicReputerWhitelistRequest{},
)
}

// So we need to register types like:
func RegisterTypes(registry *codec.LegacyAmino) {
// Internal types used by requests
registry.RegisterConcrete(&OptionalParams{}, "emissions/v7/OptionalParams", nil) //nolint:exhaustruct
}
Loading
Loading