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

feat: update default parameters for challenge module #97

Merged
merged 2 commits into from
Mar 10, 2023
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
2 changes: 2 additions & 0 deletions deployment/localup/localup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ function generate_genesis() {
sed -i -e "s/172800s/${DEPOSIT_VOTE_PERIOD}/g" ${workspace}/.local/validator${i}/config/genesis.json
sed -i -e "s/\"10000000\"/\"${GOV_MIN_DEPOSIT_AMOUNT}\"/g" ${workspace}/.local/validator${i}/config/genesis.json
sed -i -e "s/\"max_bytes\": \"22020096\"/\"max_bytes\": \"1048576\"/g" ${workspace}/.local/validator${i}/config/genesis.json
sed -i -e "s/\"challenge_count_per_block\": \"1\"/\"challenge_count_per_block\": \"5\"/g" ${workspace}/.local/validator${i}/config/genesis.json
sed -i -e "s/\"heartbeat_interval\": \"1000\"/\"heartbeat_interval\": \"100\"/g" ${workspace}/.local/validator${i}/config/genesis.json
done

# enable swagger API for validator0
Expand Down
8 changes: 2 additions & 6 deletions x/challenge/keeper/msg_server_attest.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,8 @@ func (k msgServer) Attest(goCtx context.Context, msg *types.MsgAttest) (*types.M

func (k msgServer) calculateSlashAmount(ctx sdk.Context, objectSize uint64) sdkmath.Int {
sizeRate := k.SlashAmountSizeRate(ctx)
decSize := sdk.NewDecFromBigInt(new(big.Int).SetUint64(objectSize))
decRoot, err := decSize.ApproxSqrt()
if err != nil {
panic(err)
}
slashAmount := decRoot.MulMut(sizeRate).TruncateInt()
objectSizeInGB := sdk.NewDecFromBigInt(new(big.Int).SetUint64(objectSize)).QuoRoundUp(sdk.NewDec(1073741824))
slashAmount := objectSizeInGB.MulMut(sizeRate).MulMut(sdk.NewDec(1e18)).TruncateInt()

min := k.SlashAmountMin(ctx)
if slashAmount.LT(min) {
Expand Down
12 changes: 6 additions & 6 deletions x/challenge/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ var _ paramtypes.ParamSet = (*Params)(nil)

var (
KeyChallengeCountPerBlock = []byte("ChallengeCountPerBlock")
DefaultChallengeCountPerBlock uint64 = 3
DefaultChallengeCountPerBlock uint64 = 1
)

var (
KeySlashCoolingOffPeriod = []byte("SlashCoolingOffPeriod")
DefaultSlashCoolingOffPeriod uint64 = 100
DefaultSlashCoolingOffPeriod uint64 = 300
)

var (
KeySlashAmountSizeRate = []byte("SlashAmountSizeRate")
DefaultSlashAmountSizeRate = sdk.NewDecWithPrec(5, 1)
DefaultSlashAmountSizeRate = sdk.NewDecWithPrec(85, 4)
)

var (
KeySlashAmountMin = []byte("SlashAmountMin")
DefaultSlashAmountMin = math.NewIntFromBigInt(new(big.Int).Mul(big.NewInt(10), big.NewInt(1e18)))
DefaultSlashAmountMin = math.NewIntFromBigInt(big.NewInt(1e16))
)

var (
KeySlashAmountMax = []byte("SlashAmountMax")
DefaultSlashAmountMax = math.NewIntFromBigInt(new(big.Int).Mul(big.NewInt(100), big.NewInt(1e18)))
DefaultSlashAmountMax = math.NewIntFromBigInt(big.NewInt(1e18))
)

var (
Expand All @@ -55,7 +55,7 @@ var (

var (
KeyHeartbeatInterval = []byte("HeartbeatInterval")
DefaultHeartbeatInterval uint64 = 100
DefaultHeartbeatInterval uint64 = 1000
)

// ParamKeyTable the param key table for launch module
Expand Down