Skip to content

Commit

Permalink
disable create validator operation (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
keefel authored Dec 29, 2022
1 parent 61f69e8 commit dfbee4c
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 24 deletions.
3 changes: 3 additions & 0 deletions contrib/images/simd-env/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ FROM alpine AS run
RUN apk add bash curl jq libstdc++
COPY contrib/images/simd-env/wrapper.sh /usr/bin/wrapper.sh

ENV CGO_CFLAGS="-O -D__BLST_PORTABLE__"
ENV CGO_CFLAGS_ALLOW="-O -D__BLST_PORTABLE__"

VOLUME /simd
COPY --from=build /work/build/simd /simd/
WORKDIR /simd
Expand Down
5 changes: 3 additions & 2 deletions simapp/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,9 @@ func TestAppSimulationAfterImport(t *testing.T) {
// TODO: Make another test for the fuzzer itself, which just has noOp txs
// and doesn't depend on the application.
func TestAppStateDeterminism(t *testing.T) {
// TODO skip first, Keefe fix it later
t.Skip("skipping application simulation")
if !FlagEnabledValue {
t.Skip("skipping application simulation")
}

config := NewConfigFromFlags()
config.InitialBlockHeight = 1
Expand Down
1 change: 1 addition & 0 deletions types/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const (

// BLSPubKeyLength defines a valid BLS Public key length
BLSPubKeyLength = 48
BLSEmptyPubKey = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dead"
)

// cache variables
Expand Down
17 changes: 1 addition & 16 deletions x/staking/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

// Simulation operation weights constants
const (
OpWeightMsgCreateValidator = "op_weight_msg_create_validator" //nolint:gosec
OpWeightMsgEditValidator = "op_weight_msg_edit_validator" //nolint:gosec
OpWeightMsgDelegate = "op_weight_msg_delegate" //nolint:gosec
OpWeightMsgUndelegate = "op_weight_msg_undelegate" //nolint:gosec
Expand All @@ -33,20 +32,13 @@ func WeightedOperations(
bk types.BankKeeper, k keeper.Keeper,
) simulation.WeightedOperations {
var (
weightMsgCreateValidator int
weightMsgEditValidator int
weightMsgDelegate int
weightMsgUndelegate int
weightMsgBeginRedelegate int
weightMsgCancelUnbondingDelegation int
)

appParams.GetOrGenerate(cdc, OpWeightMsgCreateValidator, &weightMsgCreateValidator, nil,
func(_ *rand.Rand) {
weightMsgCreateValidator = simappparams.DefaultWeightMsgCreateValidator
},
)

appParams.GetOrGenerate(cdc, OpWeightMsgEditValidator, &weightMsgEditValidator, nil,
func(_ *rand.Rand) {
weightMsgEditValidator = simappparams.DefaultWeightMsgEditValidator
Expand Down Expand Up @@ -78,10 +70,6 @@ func WeightedOperations(
)

return simulation.WeightedOperations{
simulation.NewWeightedOperation(
weightMsgCreateValidator,
SimulateMsgCreateValidator(ak, bk, k),
),
simulation.NewWeightedOperation(
weightMsgEditValidator,
SimulateMsgEditValidator(ak, bk, k),
Expand Down Expand Up @@ -229,10 +217,7 @@ func SimulateMsgEditValidator(ak types.AccountKeeper, bk types.BankKeeper, k kee
simtypes.RandStringOfLength(r, 10),
)

blsSecretKey, _ := bls.RandKey()
blsPk := hex.EncodeToString(blsSecretKey.PublicKey().Marshal())

msg := types.NewMsgEditValidator(address, description, &newCommissionRate, nil, sdk.AccAddress(address), blsPk)
msg := types.NewMsgEditValidator(address, description, &newCommissionRate, nil, sdk.AccAddress(address), "")

txCtx := simulation.OperationInput{
R: r,
Expand Down
1 change: 0 additions & 1 deletion x/staking/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func TestWeightedOperations(t *testing.T) {
opMsgRoute string
opMsgName string
}{
{simappparams.DefaultWeightMsgCreateValidator, types.ModuleName, types.TypeMsgCreateValidator},
{simappparams.DefaultWeightMsgEditValidator, types.ModuleName, types.TypeMsgEditValidator},
{simappparams.DefaultWeightMsgDelegate, types.ModuleName, types.TypeMsgDelegate},
{simappparams.DefaultWeightMsgUndelegate, types.ModuleName, types.TypeMsgUndelegate},
Expand Down
6 changes: 3 additions & 3 deletions x/staking/types/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package types

import (
"bytes"
"encoding/hex"
"fmt"
"sort"
"strings"
"time"

"cosmossdk.io/math"
"github.com/prysmaticlabs/prysm/crypto/bls"
abci "github.com/tendermint/tendermint/abci/types"
tmprotocrypto "github.com/tendermint/tendermint/proto/tendermint/crypto"
"sigs.k8s.io/yaml"
Expand Down Expand Up @@ -48,7 +48,7 @@ func NewSimpleValidator(operator sdk.ValAddress, pubKey cryptotypes.PubKey, desc
return Validator{}, err
}

blsSk, err := bls.RandKey()
blsPk, err := hex.DecodeString(sdk.BLSEmptyPubKey)
if err != nil {
return Validator{}, err
}
Expand All @@ -67,7 +67,7 @@ func NewSimpleValidator(operator sdk.ValAddress, pubKey cryptotypes.PubKey, desc
MinSelfDelegation: sdk.OneInt(),
SelfDelAddress: operator.String(),
RelayerAddress: operator.String(),
RelayerBlsKey: blsSk.PublicKey().Marshal(),
RelayerBlsKey: blsPk,
}, nil
}

Expand Down
3 changes: 1 addition & 2 deletions x/staking/types/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import (
func TestValidatorTestEquivalent(t *testing.T) {
val1 := newValidator(t, valAddr1, pk1)
val2 := newValidator(t, valAddr1, pk1)
// When call newValidator, its bls pubkey is generated randomly
require.NotEqual(t, val1.String(), val2.String())
require.Equal(t, val1.String(), val2.String())

val2 = newValidator(t, valAddr2, pk2)
require.NotEqual(t, val1.String(), val2.String())
Expand Down

0 comments on commit dfbee4c

Please sign in to comment.