Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into classictax
Browse files Browse the repository at this point in the history
  • Loading branch information
StrathCole committed Nov 29, 2023
2 parents c26a79c + d01e662 commit 70d2833
Show file tree
Hide file tree
Showing 16 changed files with 234 additions and 143 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ run:
linters:
disable-all: true
enable:
- depguard
- dogsled
- exportloopref
- goconst
Expand Down
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
v4 "github.com/classic-terra/core/v2/app/upgrades/v4"
v5 "github.com/classic-terra/core/v2/app/upgrades/v5"
v6 "github.com/classic-terra/core/v2/app/upgrades/v6"
v6_1 "github.com/classic-terra/core/v2/app/upgrades/v6_1"

customante "github.com/classic-terra/core/v2/custom/auth/ante"
custompost "github.com/classic-terra/core/v2/custom/auth/post"
Expand All @@ -66,7 +67,7 @@ var (
DefaultNodeHome string

// Upgrades defines upgrades to be applied to the network
Upgrades = []upgrades.Upgrade{v2.Upgrade, v3.Upgrade, v4.Upgrade, v5.Upgrade, v6.Upgrade}
Upgrades = []upgrades.Upgrade{v2.Upgrade, v3.Upgrade, v4.Upgrade, v5.Upgrade, v6.Upgrade, v6_1.Upgrade}

// Forks defines forks to be applied to the network
Forks = []upgrades.Fork{}
Expand Down
19 changes: 12 additions & 7 deletions app/testing/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/testutil"
Expand All @@ -21,8 +24,6 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
Expand All @@ -43,14 +44,16 @@ type KeeperTestHelper struct {
suite.Suite

App *app.TerraApp
Ctx sdk.Context
Ctx sdk.Context // ctx is deliver ctx
CheckCtx sdk.Context
QueryHelper *baseapp.QueryServiceTestHelper
TestAccs []sdk.AccAddress
}

func (s *KeeperTestHelper) Setup(t *testing.T) {
func (s *KeeperTestHelper) Setup(_ *testing.T, chainID string) {
s.App = SetupApp(s.T())
s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{Height: 1, ChainID: "columbus-5", Time: time.Now().UTC()})
s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{Height: 1, ChainID: chainID, Time: time.Now().UTC()})
s.CheckCtx = s.App.BaseApp.NewContext(true, tmproto.Header{Height: 1, ChainID: chainID, Time: time.Now().UTC()})
s.QueryHelper = &baseapp.QueryServiceTestHelper{
GRPCQueryRouter: s.App.GRPCQueryRouter(),
Ctx: s.Ctx,
Expand Down Expand Up @@ -126,6 +129,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs
// init chain will set the validator set and initialize the genesis accounts
terraApp.InitChain(
abci.RequestInitChain{
ChainId: SimAppChainID,
Validators: []abci.ValidatorUpdate{},
ConsensusParams: DefaultConsensusParams,
AppStateBytes: stateBytes,
Expand All @@ -135,6 +139,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs
// commit genesis changes
terraApp.Commit()
terraApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{
ChainID: SimAppChainID,
Height: terraApp.LastBlockHeight() + 1,
AppHash: terraApp.LastCommitID().Hash,
ValidatorsHash: valSet.Hash(),
Expand Down Expand Up @@ -248,7 +253,7 @@ func genesisStateWithValSet(t *testing.T,
return genesisState
}

func (s *KeeperTestHelper) KeyPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) {
func (s *KeeperTestHelper) Ed25519PubAddr() (cryptotypes.PrivKey, cryptotypes.PubKey, sdk.AccAddress) {
key := ed25519.GenPrivKey()
pub := key.PubKey()
addr := sdk.AccAddress(pub.Address())
Expand All @@ -258,7 +263,7 @@ func (s *KeeperTestHelper) KeyPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccA
func (s *KeeperTestHelper) RandomAccountAddresses(n int) []sdk.AccAddress {
addrsList := make([]sdk.AccAddress, n)
for i := 0; i < n; i++ {
_, _, addrs := s.KeyPubAddr()
_, _, addrs := testdata.KeyTestPubAddr()
addrsList[i] = addrs
}
return addrsList
Expand Down
14 changes: 14 additions & 0 deletions app/upgrades/v6_1/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package v61

import (
"github.com/classic-terra/core/v2/app/upgrades"
store "github.com/cosmos/cosmos-sdk/store/types"
)

const UpgradeName = "v6_1"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateV6_1UpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}
20 changes: 20 additions & 0 deletions app/upgrades/v6_1/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package v61

import (
"github.com/classic-terra/core/v2/app/keepers"
"github.com/classic-terra/core/v2/app/upgrades"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateV6_1UpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
_ upgrades.BaseAppParamManager,
_ *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, cfg, fromVM)
}
}
2 changes: 1 addition & 1 deletion contrib/updates/prepare_cosmovisor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# These fields should be fetched automatically in the future
# Need to do more upgrade to see upgrade patterns
OLD_VERSION=v2.2.1
OLD_VERSION=v2.3.0
# this command will retrieve the folder with the largest number in format v<number>
SOFTWARE_UPGRADE_NAME=$(ls -d -- ./app/upgrades/v* | sort -Vr | head -n 1 | xargs basename)
BUILDDIR=$1
Expand Down
4 changes: 3 additions & 1 deletion custom/auth/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
NewMinInitialDepositDecorator(options.GovKeeper, options.TreasuryKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
classictax.NewClassicTaxFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TreasuryKeeper, options.DefaultOracleKeeper, options.ClassicTaxKeeper),
dyncommante.NewDyncommDecorator(options.DyncommKeeper, options.StakingKeeper),

// Do not add any other decorators below this point unless explicitly explain.
ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewRedundantRelayDecorator(&options.IBCKeeper),
dyncommante.NewDyncommDecorator(options.DyncommKeeper, options.StakingKeeper),
), nil
}
3 changes: 2 additions & 1 deletion custom/staking/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

apptesting "github.com/classic-terra/core/v2/app/testing"
"github.com/classic-terra/core/v2/types"
simapp "github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
disttypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
Expand All @@ -23,7 +24,7 @@ func TestStakingTestSuite(t *testing.T) {

// go test -v -run=TestStakingTestSuite/TestValidatorVPLimit github.com/classic-terra/core/v2/custom/staking
func (s *StakingTestSuite) TestValidatorVPLimit() {
s.KeeperTestHelper.Setup(s.T())
s.KeeperTestHelper.Setup(s.T(), types.ColumbusChainID)

// construct new validators, to a total of 10 validators, each with 10% of the total voting power
num := 9
Expand Down
3 changes: 0 additions & 3 deletions types/fork/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,4 @@ const (
// v1.0.5
// VersionMapEnableHeight - set the version map to enable software upgrades, approximately February 14, 2023
VersionMapEnableHeight = int64(11_543_150)
// Revert Min Commission slip during v2.2.0 upgrade
FixMinCommissionHeight = int64(14_890_000)
FixMinCommissionHeightRebel = int64(16_300_000)
)
2 changes: 1 addition & 1 deletion wasmbinding/test/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestWasmTestSuite(t *testing.T) {
}

func (s *WasmTestSuite) SetupTest() {
s.Setup(s.T())
s.Setup(s.T(), apptesting.SimAppChainID)
}

func (s *WasmTestSuite) InstantiateContract(addr sdk.AccAddress, contractPath string) sdk.AccAddress {
Expand Down
4 changes: 0 additions & 4 deletions x/dyncomm/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ func (dd DyncommDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool,
return next(ctx, tx, simulate)
}

if ctx.IsCheckTx() {
return next(ctx, tx, simulate)
}

msgs := tx.GetMsgs()
err := dd.FilterMsgsAndProcessMsgs(ctx, msgs...)
if err != nil {
Expand Down
Loading

0 comments on commit 70d2833

Please sign in to comment.