diff --git a/proto/cosmos/auth/v1beta1/auth.proto b/proto/cosmos/auth/v1beta1/auth.proto index 72e1d9ec28..799568c186 100644 --- a/proto/cosmos/auth/v1beta1/auth.proto +++ b/proto/cosmos/auth/v1beta1/auth.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package cosmos.auth.v1beta1; import "cosmos_proto/cosmos.proto"; +//import "cosmos.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; @@ -47,4 +48,6 @@ message Params { [(gogoproto.customname) = "SigVerifyCostED25519", (gogoproto.moretags) = "yaml:\"sig_verify_cost_ed25519\""]; uint64 sig_verify_cost_secp256k1 = 5 [(gogoproto.customname) = "SigVerifyCostSecp256k1", (gogoproto.moretags) = "yaml:\"sig_verify_cost_secp256k1\""]; + uint64 sig_verify_cost_bls12381 = 6 + [(gogoproto.customname) = "SigVerifyCostBls12381", (gogoproto.moretags) = "yaml:\"sig_verify_cost_bls12381\""]; } diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 84ea7a0ae7..223d81b296 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -5,7 +5,6 @@ import ( "encoding/hex" "fmt" "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -389,9 +388,8 @@ func DefaultSigVerificationGasConsumer( } return nil - // todo: add gas option to params and genesis.json case *bls12381.PubKey: - meter.ConsumeGas(6213, "ante verify: bls12381") + meter.ConsumeGas(params.SigVerifyCostBls12381, "ante verify: bls12381") return nil default: diff --git a/x/auth/simulation/genesis.go b/x/auth/simulation/genesis.go index 2da36b54fa..5bb2297f29 100644 --- a/x/auth/simulation/genesis.go +++ b/x/auth/simulation/genesis.go @@ -19,6 +19,7 @@ const ( TxSizeCostPerByte = "tx_size_cost_per_byte" SigVerifyCostED25519 = "sig_verify_cost_ed25519" SigVerifyCostSECP256K1 = "sig_verify_cost_secp256k1" + SigVerifyCostBLS12381 = "sig_verify_cost_bls12381" ) // RandomGenesisAccounts defines the default RandomGenesisAccountsFn used on the SDK. @@ -87,6 +88,11 @@ func GenSigVerifyCostSECP256K1(r *rand.Rand) uint64 { return uint64(simulation.RandIntBetween(r, 500, 1000)) } +// GenSigVerifyCostBLS12381 randomized SigVerifyCostBLS12381 +func GenSigVerifyCostBLS12381(r *rand.Rand) uint64 { + return uint64(simulation.RandIntBetween(r, 6000, 12000)) +} + // RandomizedGenState generates a random GenesisState for auth func RandomizedGenState(simState *module.SimulationState, randGenAccountsFn types.RandomGenesisAccountsFn) { var maxMemoChars uint64 @@ -119,8 +125,14 @@ func RandomizedGenState(simState *module.SimulationState, randGenAccountsFn type func(r *rand.Rand) { sigVerifyCostSECP256K1 = GenSigVerifyCostSECP256K1(r) }, ) + var sigVerifyCostBLS12381 uint64 + simState.AppParams.GetOrGenerate( + simState.Cdc, SigVerifyCostBLS12381, &sigVerifyCostBLS12381, simState.Rand, + func(r *rand.Rand) { sigVerifyCostBLS12381 = GenSigVerifyCostBLS12381(r) }, + ) + params := types.NewParams(maxMemoChars, txSigLimit, txSizeCostPerByte, - sigVerifyCostED25519, sigVerifyCostSECP256K1) + sigVerifyCostED25519, sigVerifyCostSECP256K1, sigVerifyCostBLS12381) genesisAccs := randGenAccountsFn(simState) authGenesis := types.NewGenesisState(params, genesisAccs) diff --git a/x/auth/types/auth.pb.go b/x/auth/types/auth.pb.go index fa52ac5a8b..ad2283b816 100644 --- a/x/auth/types/auth.pb.go +++ b/x/auth/types/auth.pb.go @@ -113,6 +113,7 @@ type Params struct { TxSizeCostPerByte uint64 `protobuf:"varint,3,opt,name=tx_size_cost_per_byte,json=txSizeCostPerByte,proto3" json:"tx_size_cost_per_byte,omitempty" yaml:"tx_size_cost_per_byte"` SigVerifyCostED25519 uint64 `protobuf:"varint,4,opt,name=sig_verify_cost_ed25519,json=sigVerifyCostEd25519,proto3" json:"sig_verify_cost_ed25519,omitempty" yaml:"sig_verify_cost_ed25519"` SigVerifyCostSecp256k1 uint64 `protobuf:"varint,5,opt,name=sig_verify_cost_secp256k1,json=sigVerifyCostSecp256k1,proto3" json:"sig_verify_cost_secp256k1,omitempty" yaml:"sig_verify_cost_secp256k1"` + SigVerifyCostBls12381 uint64 `protobuf:"varint,6,opt,name=sig_verify_cost_bls12381,json=sigVerifyCostBls12381,proto3" json:"sig_verify_cost_bls12381,omitempty" yaml:"sig_verify_cost_bls12381"` } func (m *Params) Reset() { *m = Params{} } @@ -182,6 +183,13 @@ func (m *Params) GetSigVerifyCostSecp256k1() uint64 { return 0 } +func (m *Params) GetSigVerifyCostBls12381() uint64 { + if m != nil { + return m.SigVerifyCostBls12381 + } + return 0 +} + func init() { proto.RegisterType((*BaseAccount)(nil), "cosmos.auth.v1beta1.BaseAccount") proto.RegisterType((*ModuleAccount)(nil), "cosmos.auth.v1beta1.ModuleAccount") @@ -191,50 +199,52 @@ func init() { func init() { proto.RegisterFile("cosmos/auth/v1beta1/auth.proto", fileDescriptor_7e1f7e915d020d2d) } var fileDescriptor_7e1f7e915d020d2d = []byte{ - // 674 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0x4d, 0x4f, 0xdb, 0x4a, - 0x14, 0x8d, 0x5f, 0xf2, 0xf8, 0x98, 0x00, 0x12, 0x26, 0x80, 0x93, 0xf7, 0x64, 0x5b, 0x5e, 0xe5, - 0x49, 0x2f, 0x8e, 0x92, 0x8a, 0x4a, 0x64, 0x51, 0x15, 0xd3, 0x2e, 0x50, 0x0b, 0x42, 0x46, 0xea, - 0xa2, 0xaa, 0xe4, 0x8e, 0x9d, 0xc1, 0x58, 0x64, 0x32, 0xc6, 0x33, 0x46, 0x31, 0xbf, 0xa0, 0xcb, - 0x2e, 0xbb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, 0x95, 0x6e, 0x87, 0xaa, 0xf4, 0x7d, 0xa8, 0x4a, 0x1f, 0xef, 0xd5, 0xc2, 0xed, - 0xbd, 0x5a, 0xf8, 0x7a, 0xaf, 0x16, 0xde, 0xfe, 0xe7, 0x07, 0xec, 0x2c, 0x76, 0x4d, 0x8f, 0xe0, - 0xfc, 0x2d, 0xc8, 0x7f, 0x1a, 0xb4, 0x7b, 0xde, 0x1c, 0x88, 0xa7, 0x85, 0x25, 0x21, 0xa2, 0xee, - 0x02, 0xff, 0x52, 0x9f, 0xfc, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x49, 0x90, 0x16, 0xd9, 0x76, 0x04, - 0x00, 0x00, + // 707 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0x4f, 0x4f, 0xdb, 0x48, + 0x14, 0x8f, 0x97, 0x6c, 0x80, 0x09, 0x20, 0x61, 0x12, 0x30, 0xd9, 0x95, 0xc7, 0xf2, 0x29, 0x2b, + 0x6d, 0x1c, 0x25, 0x88, 0xd5, 0x12, 0xad, 0x56, 0x8b, 0xd9, 0x1e, 0x50, 0x0b, 0x42, 0x46, 0xea, + 0xa1, 0xaa, 0xe4, 0x8e, 0x9d, 0xc1, 0x58, 0x64, 0x32, 0xc6, 0x33, 0x46, 0x31, 0x9f, 0xa0, 0xc7, + 0x1e, 0x7b, 0xe4, 0x43, 0xf0, 0x0d, 0x7a, 0xe9, 0x11, 0x71, 0xa8, 0x7a, 0xb2, 0xaa, 0x70, 0xa9, + 0x7a, 0xf4, 0xbd, 0x52, 0x95, 0xb1, 0x13, 0x12, 0x94, 0x9e, 0xe2, 0xf7, 0x7e, 0xff, 0xde, 0xbc, + 0x51, 0x06, 0xa8, 0x2e, 0x65, 0x84, 0xb2, 0x26, 0x8a, 0xf8, 0x79, 0xf3, 0xaa, 0xe5, 0x60, 0x8e, + 0x5a, 0xa2, 0x30, 0x82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 0xea, 0x0f, 0xcf, 0xe7, 0xe7, 0x91, 0x63, 0xb8, 0x94, + 0x34, 0xf3, 0x77, 0x2b, 0xfb, 0x69, 0xb0, 0xee, 0x45, 0x73, 0x90, 0x3d, 0x62, 0x3c, 0x0e, 0x30, + 0x73, 0x4a, 0xe2, 0x81, 0xd8, 0xf9, 0x11, 0x00, 0x00, 0xff, 0xff, 0xd3, 0xe6, 0x37, 0xa1, 0xe0, + 0x04, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -271,6 +281,9 @@ func (this *Params) Equal(that interface{}) bool { if this.SigVerifyCostSecp256k1 != that1.SigVerifyCostSecp256k1 { return false } + if this.SigVerifyCostBls12381 != that1.SigVerifyCostBls12381 { + return false + } return true } func (m *BaseAccount) Marshal() (dAtA []byte, err error) { @@ -396,6 +409,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.SigVerifyCostBls12381 != 0 { + i = encodeVarintAuth(dAtA, i, uint64(m.SigVerifyCostBls12381)) + i-- + dAtA[i] = 0x30 + } if m.SigVerifyCostSecp256k1 != 0 { i = encodeVarintAuth(dAtA, i, uint64(m.SigVerifyCostSecp256k1)) i-- @@ -502,6 +520,9 @@ func (m *Params) Size() (n int) { if m.SigVerifyCostSecp256k1 != 0 { n += 1 + sovAuth(uint64(m.SigVerifyCostSecp256k1)) } + if m.SigVerifyCostBls12381 != 0 { + n += 1 + sovAuth(uint64(m.SigVerifyCostBls12381)) + } return n } @@ -941,6 +962,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SigVerifyCostBls12381", wireType) + } + m.SigVerifyCostBls12381 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuth + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SigVerifyCostBls12381 |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipAuth(dAtA[iNdEx:]) diff --git a/x/auth/types/params.go b/x/auth/types/params.go index 13db369d23..fb2a47ec50 100644 --- a/x/auth/types/params.go +++ b/x/auth/types/params.go @@ -15,6 +15,7 @@ const ( DefaultTxSizeCostPerByte uint64 = 10 DefaultSigVerifyCostED25519 uint64 = 590 DefaultSigVerifyCostSecp256k1 uint64 = 1000 + DefaultSigVerifyCostBls12381 uint64 = 6300 ) // Parameter keys @@ -24,13 +25,14 @@ var ( KeyTxSizeCostPerByte = []byte("TxSizeCostPerByte") KeySigVerifyCostED25519 = []byte("SigVerifyCostED25519") KeySigVerifyCostSecp256k1 = []byte("SigVerifyCostSecp256k1") + KeySigVerifyCostBls12381 = []byte("SigVerifyCostBls12381") ) var _ paramtypes.ParamSet = &Params{} // NewParams creates a new Params object func NewParams( - maxMemoCharacters, txSigLimit, txSizeCostPerByte, sigVerifyCostED25519, sigVerifyCostSecp256k1 uint64, + maxMemoCharacters, txSigLimit, txSizeCostPerByte, sigVerifyCostED25519, sigVerifyCostSecp256k1 uint64, sigVerifyCostBls12381 uint64, ) Params { return Params{ MaxMemoCharacters: maxMemoCharacters, @@ -38,6 +40,7 @@ func NewParams( TxSizeCostPerByte: txSizeCostPerByte, SigVerifyCostED25519: sigVerifyCostED25519, SigVerifyCostSecp256k1: sigVerifyCostSecp256k1, + SigVerifyCostBls12381: sigVerifyCostBls12381, } } @@ -55,6 +58,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyTxSizeCostPerByte, &p.TxSizeCostPerByte, validateTxSizeCostPerByte), paramtypes.NewParamSetPair(KeySigVerifyCostED25519, &p.SigVerifyCostED25519, validateSigVerifyCostED25519), paramtypes.NewParamSetPair(KeySigVerifyCostSecp256k1, &p.SigVerifyCostSecp256k1, validateSigVerifyCostSecp256k1), + paramtypes.NewParamSetPair(KeySigVerifyCostBls12381, &p.SigVerifyCostBls12381, validateSigVerifyCostBls12381), } } @@ -66,6 +70,7 @@ func DefaultParams() Params { TxSizeCostPerByte: DefaultTxSizeCostPerByte, SigVerifyCostED25519: DefaultSigVerifyCostED25519, SigVerifyCostSecp256k1: DefaultSigVerifyCostSecp256k1, + SigVerifyCostBls12381: DefaultSigVerifyCostBls12381, } } @@ -114,6 +119,20 @@ func validateSigVerifyCostSecp256k1(i interface{}) error { return nil } + +func validateSigVerifyCostBls12381(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == 0 { + return fmt.Errorf("invalid BLS12381 signature verification cost: %d", v) + } + + return nil +} + func validateMaxMemoCharacters(i interface{}) error { v, ok := i.(uint64) if !ok { @@ -151,6 +170,9 @@ func (p Params) Validate() error { if err := validateSigVerifyCostSecp256k1(p.SigVerifyCostSecp256k1); err != nil { return err } + if err := validateSigVerifyCostBls12381(p.SigVerifyCostBls12381); err != nil { + return err + } if err := validateMaxMemoCharacters(p.MaxMemoCharacters); err != nil { return err }