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 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
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
6 changes: 3 additions & 3 deletions x/wasm/keeper/recursive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func initRecurseContract(t *testing.T) (contract sdk.AccAddress, creator sdk.Acc
}

func TestGasCostOnQuery(t *testing.T) {
GasNoWork := types.InstanceCost + 4_375
GasNoWork := types.InstanceCost + 4_372
// Note: about 100 SDK gas (10k wasmVM gas) for each round of sha256
GasWork50 := GasNoWork + 5_692 // this is a little shy of 50k gas - to keep an eye on the limit

Expand Down Expand Up @@ -182,7 +182,7 @@ func TestGasCostOnQuery(t *testing.T) {
}

func TestGasOnExternalQuery(t *testing.T) {
GasNoWork := types.InstanceCost + 4_375
GasNoWork := types.InstanceCost + 4_372
// Note: about 100 SDK gas (10k wasmVM gas) for each round of sha256
GasWork50 := GasNoWork + 5_692 // this is a little shy of 50k gas - to keep an eye on the limit

Expand Down Expand Up @@ -260,7 +260,7 @@ func TestLimitRecursiveQueryGas(t *testing.T) {
// This attack would allow us to use far more than the provided gas before
// eventually hitting an OutOfGas panic.

GasNoWork := types.InstanceCost + 4_375
GasNoWork := types.InstanceCost + 4_372
GasWork2k := GasNoWork + 229_495

// This is overhead for calling into a sub-contract
Expand Down
14 changes: 5 additions & 9 deletions x/wasm/legacy/v05/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,11 @@ func Migrate(

return &v05wasm.GenesisState{
Params: v05wasm.Params{
MaxContractSize: wasmGenState.Params.MaxContractSize,
MaxContractMsgSize: wasmGenState.Params.MaxContractMsgSize,
MaxContractGas: wasmGenState.Params.MaxContractGas,
MaxContractDataSize: 256,
EventParams: v05wasm.EventParams{
MaxAttributeNum: 16,
MaxAttributeKeyLength: 64,
MaxAttributeValueLength: 256,
},
MaxContractSize: v05wasm.DefaultMaxContractSize,
MaxContractMsgSize: v05wasm.DefaultMaxContractMsgSize,
MaxContractGas: v05wasm.DefaultMaxContractGas,
MaxContractDataSize: v05wasm.DefaultMaxContractDataSize,
EventParams: v05wasm.DefaultEventParams,
},
Codes: codes,
Contracts: contracts,
Expand Down
8 changes: 4 additions & 4 deletions x/wasm/legacy/v05/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ func TestMigrate(t *testing.T) {
"max_attribute_num": "16",
"max_attribute_value_length": "256"
},
"max_contract_data_size": "256",
"max_contract_gas": "10000",
"max_contract_msg_size": "1024",
"max_contract_size": "100"
"max_contract_data_size": "1024",
"max_contract_gas": "20000000",
"max_contract_msg_size": "4096",
"max_contract_size": "614400"
}
}`
require.Equal(t, expected, string(indentedBz))
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