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

Update migration params for col5 #491

Merged
merged 3 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions app/legacy/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ $ terrad migrate /path/to/genesis.json --chain-id=cosmoshub-4 --genesis-time=201
return errors.Wrapf(err, "failed to read genesis document from file %s", importGenesis)
}

// increase block consensus params
genDoc.ConsensusParams.Block.MaxBytes = int64(3000000)
genDoc.ConsensusParams.Block.MaxGas = int64(100000000)

// decrease evidence max bytes
genDoc.ConsensusParams.Evidence.MaxBytes = int64(50000)

var initialState types.AppMap
if err := json.Unmarshal(genDoc.AppState, &initialState); err != nil {
return errors.Wrap(err, "failed to JSON unmarshal initial genesis state")
Expand Down
18 changes: 16 additions & 2 deletions app/legacy/v05/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v05
import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
v039auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v039"
v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040"
v036supply "github.com/cosmos/cosmos-sdk/x/bank/legacy/v036"
Expand All @@ -18,7 +19,7 @@ import (
v040genutil "github.com/cosmos/cosmos-sdk/x/genutil/legacy/v040"
"github.com/cosmos/cosmos-sdk/x/genutil/types"
v036gov "github.com/cosmos/cosmos-sdk/x/gov/legacy/v036"
v040gov "github.com/cosmos/cosmos-sdk/x/gov/legacy/v040"
v043gov "github.com/cosmos/cosmos-sdk/x/gov/legacy/v043"
v039mint "github.com/cosmos/cosmos-sdk/x/mint/legacy/v039"
v040mint "github.com/cosmos/cosmos-sdk/x/mint/legacy/v040"
v039slashing "github.com/cosmos/cosmos-sdk/x/slashing/legacy/v039"
Expand Down Expand Up @@ -158,7 +159,7 @@ func Migrate(appState types.AppMap, clientCtx client.Context) types.AppMap {

// Migrate relative source genesis application state and marshal it into
// the respective key.
appState[v040gov.ModuleName] = v05Codec.MustMarshalJSON(v043govcustom.Migrate(govGenState))
appState[v043gov.ModuleName] = v05Codec.MustMarshalJSON(v043govcustom.Migrate(govGenState))
}

// Migrate x/mint.
Expand All @@ -184,6 +185,19 @@ func Migrate(appState types.AppMap, clientCtx client.Context) types.AppMap {
// delete deprecated x/slashing genesis state
delete(appState, v039slashing.ModuleName)

// fill empty cons address
for address, info := range slashingGenState.SigningInfos {
if info.Address.Empty() {
if addr, err := sdk.ConsAddressFromBech32(address); err != nil {
panic(err)
} else {
info.Address = addr
}

slashingGenState.SigningInfos[address] = info
}
}

// Migrate relative source genesis application state and marshal it into
// the respective key.
appState[v040slashing.ModuleName] = v05Codec.MustMarshalJSON(v040slashing.Migrate(slashingGenState))
Expand Down
15 changes: 14 additions & 1 deletion custom/auth/legacy/v040/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
v039auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v039"
v040auth "github.com/cosmos/cosmos-sdk/x/auth/types"
v040authvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
v40mint "github.com/cosmos/cosmos-sdk/x/mint/types"

v039authcustom "github.com/terra-money/core/custom/auth/legacy/v039"
v040vesting "github.com/terra-money/core/x/vesting/types"
Expand Down Expand Up @@ -52,13 +53,25 @@ func convertBaseVestingAccount(old *v039auth.BaseVestingAccount) *v040authvestin
// - Removing coins from account encoding.
// - Re-encode in v0.40 GenesisState.
func Migrate(authGenState v039auth.GenesisState) *v040auth.GenesisState {
mintModuleAddress := v040auth.NewModuleAddress(v40mint.ModuleName)

// Convert v0.39 accounts to v0.40 ones.
var v040Accounts = make([]v040auth.GenesisAccount, len(authGenState.Accounts))
for i, v039Account := range authGenState.Accounts {
switch v039Account := v039Account.(type) {
case *v039auth.BaseAccount:
{
v040Accounts[i] = convertBaseAccount(v039Account)
// columbus chain has mint address as normal account
// so need to changes this to module account
if !v039Account.GetAddress().Equals(mintModuleAddress) {
v040Accounts[i] = convertBaseAccount(v039Account)
} else {
v040Accounts[i] = &v040auth.ModuleAccount{
BaseAccount: convertBaseAccount(v039Account),
Name: v40mint.ModuleName,
Permissions: []string{v040auth.Minter},
}
}
}
case *v039auth.ModuleAccount:
{
Expand Down
4 changes: 2 additions & 2 deletions x/wasm/legacy/v05/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func Migrate(
Params: v05wasm.Params{
MaxContractSize: wasmGenState.Params.MaxContractSize,
MaxContractMsgSize: wasmGenState.Params.MaxContractMsgSize,
MaxContractGas: wasmGenState.Params.MaxContractGas,
MaxContractDataSize: 256,
MaxContractGas: 20_000_000,
MaxContractDataSize: 1024,
EventParams: v05wasm.EventParams{
MaxAttributeNum: 16,
MaxAttributeKeyLength: 64,
Expand Down
14 changes: 7 additions & 7 deletions x/wasm/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (

// Max params for static check
const (
EnforcedMaxContractSize = uint64(500 * 1024) // 500KB
EnforcedMaxContractSize = uint64(3000 * 1024) // 3MB
EnforcedMaxContractGas = uint64(100_000_000) // 100,000,000
EnforcedMaxContractMsgSize = uint64(10 * 1024) // 10KB
EnforcedMaxContractDataSize = uint64(1024) // 1KB
EnforcedMaxContractMsgSize = uint64(20 * 1024) // 10KB
EnforcedMaxContractDataSize = uint64(5 * 1024) // 5KB
)

// Parameter keys
Expand All @@ -27,10 +27,10 @@ var (

// Default parameter values
const (
DefaultMaxContractSize = EnforcedMaxContractSize // 500 KB
DefaultMaxContractGas = EnforcedMaxContractGas // 100,000,000
DefaultMaxContractMsgSize = uint64(1 * 1024) // 1KB
DefaultMaxContractDataSize = uint64(256) // 256 bytes
DefaultMaxContractSize = uint64(600 * 1024) // 600 KB
DefaultMaxContractGas = uint64(20_000_000) // 20,000,000
DefaultMaxContractMsgSize = uint64(4 * 1024) // 4KB
DefaultMaxContractDataSize = uint64(1024) // 1KB
)

// Default event parameter values
Expand Down