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

Incoming value limiting with exponent (with migration) #757

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

* [#757](https://github.com/allora-network/allora-chain/pull/757) Incoming value limiting

### Security

# v0.9.0
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.8.0
ENV UPGRADE_VERSION_TAG=v0.9.0
ENV BASELINE_VERSION_TAG=v0.9.0
ENV UPGRADE_VERSION_TAG=v0.10.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 @@ -6,6 +6,7 @@ import (
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/allora-network/allora-chain/app/keepers"
"github.com/allora-network/allora-chain/app/upgrades"
"github.com/allora-network/allora-chain/app/upgrades/v0_10_0"
"github.com/allora-network/allora-chain/app/upgrades/v0_3_0"
"github.com/allora-network/allora-chain/app/upgrades/v0_4_0"
"github.com/allora-network/allora-chain/app/upgrades/v0_5_0"
Expand All @@ -23,6 +24,7 @@ var upgradeHandlers = []upgrades.Upgrade{
v0_7_0.Upgrade,
v0_8_0.Upgrade,
v0_9_0.Upgrade,
v0_10_0.Upgrade,
// Add more upgrade handlers here
// ...
}
Expand Down
40 changes: 40 additions & 0 deletions app/upgrades/v0_10_0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package v0_10_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.10.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
}
}
3 changes: 3 additions & 0 deletions test/integration/update_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func UpdateParamsChecks(m testCommon.TestConfig) {
GlobalAdminWhitelistAppended: nil,
MaxWhitelistInputArrayLength: nil,
MinWeightThresholdForStdnorm: nil,
DataLimitExponent: nil,
},
}
txResp, err := m.Client.BroadcastTx(ctx, m.AliceAcc, updateParamRequest)
Expand Down Expand Up @@ -163,6 +164,7 @@ func UpdateParamsChecks(m testCommon.TestConfig) {
GlobalAdminWhitelistAppended: nil,
MaxWhitelistInputArrayLength: nil,
MinWeightThresholdForStdnorm: nil,
DataLimitExponent: nil,
},
}
_, err = m.Client.BroadcastTx(ctx, m.BobAcc, updateParamRequest)
Expand Down Expand Up @@ -234,6 +236,7 @@ func UpdateParamsChecks(m testCommon.TestConfig) {
GlobalAdminWhitelistAppended: nil,
MaxWhitelistInputArrayLength: nil,
MinWeightThresholdForStdnorm: nil,
DataLimitExponent: 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_9_0 "github.com/allora-network/allora-chain/app/upgrades/v0_9_0"
v0_10_0 "github.com/allora-network/allora-chain/app/upgrades/v0_10_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_9_0.UpgradeName
name := v0_10_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_9_0.UpgradeName
versionName := v0_10_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
4 changes: 2 additions & 2 deletions x/emissions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ docker
go mod tidy

# rebuild the autogenerated protobuf files
make proto-gen
make proto-all

# build the module, making sure the source compiles
make
Expand All @@ -25,5 +25,5 @@ cd ../minimal-chain
go mod tidy
make install
make init
minid start
allorad start
```
47 changes: 47 additions & 0 deletions x/emissions/api/emissions/v8/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package emissionsv8

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/v8/OptionalParams", nil) //nolint:exhaustruct
}
Loading
Loading