From bbbe359d3d1885d1640447d80413d2e56e72a401 Mon Sep 17 00:00:00 2001 From: ap0calypse644 Date: Mon, 19 Jun 2023 19:53:16 +0530 Subject: [PATCH] fix:issue #35; replace with constants --- x/keyshare/keeper/msg_server_send_keyshare.go | 10 ++++++++-- x/keyshare/types/keys.go | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/x/keyshare/keeper/msg_server_send_keyshare.go b/x/keyshare/keeper/msg_server_send_keyshare.go index da2d27ec..150536bc 100644 --- a/x/keyshare/keeper/msg_server_send_keyshare.go +++ b/x/keyshare/keeper/msg_server_send_keyshare.go @@ -5,9 +5,10 @@ import ( "encoding/hex" "fairyring/x/keyshare/types" "fmt" - distIBE "github.com/FairBlock/DistributedIBE" "strconv" + distIBE "github.com/FairBlock/DistributedIBE" + "github.com/drand/kyber" bls "github.com/drand/kyber-bls12381" "github.com/drand/kyber/pairing" @@ -48,7 +49,12 @@ func (k msgServer) SendKeyshare(goCtx context.Context, msg *types.MsgSendKeyshar return nil, err } - k.stakingKeeper.Slash(ctx, consAddr, ctx.BlockHeight()-1, 100, sdk.NewDecWithPrec(5, 1)) + k.stakingKeeper.Slash( + ctx, consAddr, + ctx.BlockHeight()-1, + types.SlashPower, + sdk.NewDecWithPrec(types.SlashFactorValue, types.SlashFactorPrecision), + ) return &types.MsgSendKeyshareResponse{ Creator: msg.Creator, diff --git a/x/keyshare/types/keys.go b/x/keyshare/types/keys.go index c96f7c14..eb468d0f 100644 --- a/x/keyshare/types/keys.go +++ b/x/keyshare/types/keys.go @@ -20,6 +20,12 @@ const ( KeyAggregationThresholdDenominator = 3 ) +const ( + SlashPower int64 = 100 + SlashFactorValue int64 = 5 + SlashFactorPrecision int64 = 10 +) + const ( RegisteredValidatorEventType = "new validator-registered" RegisteredValidatorEventCreator = "creator"