Skip to content

Commit

Permalink
set bls cost multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
kitty committed Aug 24, 2021
1 parent f8d996d commit 63072c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions x/auth/legacy/v040/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
v040vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
)

// blsCostMultiplier is used to calculate bls signature verification cost = blsCostMultiplier * SigVerifyCostED25519
const blsCostMultiplier = 10

// convertBaseAccount converts a 0.39 BaseAccount to a 0.40 BaseAccount.
func convertBaseAccount(old *v039auth.BaseAccount) *v040auth.BaseAccount {
var any *codectypes.Any
Expand Down Expand Up @@ -46,7 +49,7 @@ func convertBaseVestingAccount(old *v039auth.BaseVestingAccount) *v040vesting.Ba
//
// - Removing coins from account encoding.
// - Re-encode in v0.40 GenesisState.
func Migrate(authGenState v039auth.GenesisState, blsCost uint64) *v040auth.GenesisState {
func Migrate(authGenState v039auth.GenesisState) *v040auth.GenesisState {
// Convert v0.39 accounts to v0.40 ones.
var v040Accounts = make([]v040auth.GenesisAccount, len(authGenState.Accounts))
for i, v039Account := range authGenState.Accounts {
Expand Down Expand Up @@ -117,7 +120,7 @@ func Migrate(authGenState v039auth.GenesisState, blsCost uint64) *v040auth.Genes
MaxMemoCharacters: authGenState.Params.MaxMemoCharacters,
TxSigLimit: authGenState.Params.TxSigLimit,
TxSizeCostPerByte: authGenState.Params.TxSizeCostPerByte,
SigVerifyCostBls12381: blsCost,
SigVerifyCostBls12381: blsCostMultiplier * authGenState.Params.SigVerifyCostED25519,
SigVerifyCostED25519: authGenState.Params.SigVerifyCostED25519,
SigVerifyCostSecp256k1: authGenState.Params.SigVerifyCostSecp256k1,
},
Expand Down
2 changes: 1 addition & 1 deletion x/auth/legacy/v040/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestMigrate(t *testing.T) {
Accounts: v038auth.GenesisAccounts{acc1, acc2, acc3, acc4, acc5, acc6, acc7},
}

migrated := v040auth.Migrate(gs, 400)
migrated := v040auth.Migrate(gs)
expected := `{
"accounts": [
{
Expand Down

0 comments on commit 63072c1

Please sign in to comment.