mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
[R4R] add bep3 module param to committee (#547)
* update committee test * update committee params * update default deputy address to expected mainnet address * spelling in comment * fix bep3 sim values to 1 * bep3 sims:generate 32 length random number
This commit is contained in:
parent
09a75bd7c6
commit
ba3b353ee9
@ -47,7 +47,7 @@
|
||||
"assets_supplies": [],
|
||||
"atomic_swaps": [],
|
||||
"params": {
|
||||
"bnb_deputy_address": "kava1tfvn5t8qwngqd2q427za2mel48pcus3z9u73fl",
|
||||
"bnb_deputy_address": "kava1r4v2zdhdalfj2ydazallqvrus9fkphmglhn6u6",
|
||||
"bnb_deputy_fixed_fee": "1000",
|
||||
"min_amount": "0",
|
||||
"max_amount": "1000000000000",
|
||||
@ -172,6 +172,22 @@
|
||||
"subspace": "auction",
|
||||
"key": "IncrementCollateral"
|
||||
},
|
||||
{
|
||||
"subspace": "bep3",
|
||||
"key": "BnbDeputyAddress"
|
||||
},
|
||||
{
|
||||
"subspace": "bep3",
|
||||
"key": "BnbDeputyFixedFee"
|
||||
},
|
||||
{
|
||||
"subspace": "bep3",
|
||||
"key": "MinAmount"
|
||||
},
|
||||
{
|
||||
"subspace": "bep3",
|
||||
"key": "MaxAmount"
|
||||
},
|
||||
{
|
||||
"subspace": "bep3",
|
||||
"key": "SupportedAssets"
|
||||
@ -231,21 +247,6 @@
|
||||
],
|
||||
"vote_threshold": "0.750000000000000000",
|
||||
"proposal_duration": "604800000000000"
|
||||
},
|
||||
{
|
||||
"id": "1",
|
||||
"description": "This committee is for testnet",
|
||||
"members": [
|
||||
"kava109fpwjvq6un86tw8f8emav2l0e0dha924scrj9"
|
||||
],
|
||||
"permissions": [
|
||||
{
|
||||
"type": "kava/GodPermission",
|
||||
"value": {}
|
||||
}
|
||||
],
|
||||
"vote_threshold": "0.750000000000000000",
|
||||
"proposal_duration": "604800000000000"
|
||||
}
|
||||
],
|
||||
"proposals": [],
|
||||
|
2
migrate/v0_8/testdata/all-new.json
vendored
2
migrate/v0_8/testdata/all-new.json
vendored
@ -304,7 +304,7 @@
|
||||
},
|
||||
"bep3": {
|
||||
"params": {
|
||||
"bnb_deputy_address": "kava1xy7hrjy9r0algz9w3gzm8u6mrpq97kwta747gj",
|
||||
"bnb_deputy_address": "kava1r4v2zdhdalfj2ydazallqvrus9fkphmglhn6u6",
|
||||
"bnb_deputy_fixed_fee": "1000",
|
||||
"min_amount": "0",
|
||||
"max_amount": "1000000000000",
|
||||
|
@ -41,7 +41,7 @@ func GenRandBnbDeputy(r *rand.Rand) simulation.Account {
|
||||
|
||||
// GenRandBnbDeputyFixedFee randomized BnbDeputyFixedFee in range [2, 10000]
|
||||
func GenRandBnbDeputyFixedFee(r *rand.Rand) sdk.Int {
|
||||
min := int(2)
|
||||
min := int(1)
|
||||
max := types.DefaultBnbDeputyFixedFee.Int64()
|
||||
return sdk.NewInt(int64(r.Intn(int(max)-min) + min))
|
||||
}
|
||||
@ -62,7 +62,7 @@ func GenMaxAmount(r *rand.Rand, minAmount sdk.Int) sdk.Int {
|
||||
|
||||
// GenMinBlockLock randomized MinBlockLock
|
||||
func GenMinBlockLock(r *rand.Rand) uint64 {
|
||||
min := 20
|
||||
min := int(1)
|
||||
max := int(types.DefaultMaxBlockLock)
|
||||
return uint64(r.Intn(max-min) + min)
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package simulation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"math/rand"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
@ -100,13 +99,12 @@ func SimulateMsgCreateAtomicSwap(ak types.AccountKeeper, k keeper.Keeper) simula
|
||||
senderOtherChain := simulation.RandStringOfLength(r, 43)
|
||||
|
||||
// Generate cryptographically strong pseudo-random number
|
||||
randomNumber, err := simulation.RandPositiveInt(r, sdk.NewInt(math.MaxInt64))
|
||||
randomNumber, err := types.GenerateSecureRandomNumber()
|
||||
if err != nil {
|
||||
return noOpMsg, nil, err
|
||||
}
|
||||
// Must use current blocktime instead of 'now' since initial blocktime was randomly generated
|
||||
timestamp := ctx.BlockTime().Unix()
|
||||
randomNumberHash := types.CalculateRandomHash(randomNumber.BigInt().Bytes(), timestamp)
|
||||
randomNumberHash := types.CalculateRandomHash(randomNumber, timestamp)
|
||||
|
||||
// Check that the sender has coins for fee
|
||||
senderAcc := ak.GetAccount(ctx, sender.Address)
|
||||
@ -171,7 +169,7 @@ func SimulateMsgCreateAtomicSwap(ak types.AccountKeeper, k keeper.Keeper) simula
|
||||
executionBlock := uint64(ctx.BlockHeight()) + msg.HeightSpan/2
|
||||
futureOp = simulation.FutureOperation{
|
||||
BlockHeight: int(executionBlock),
|
||||
Op: operationClaimAtomicSwap(ak, k, swapID, randomNumber.BigInt().Bytes()),
|
||||
Op: operationClaimAtomicSwap(ak, k, swapID, randomNumber),
|
||||
}
|
||||
} else {
|
||||
// Refund future operation
|
||||
|
@ -8,7 +8,7 @@ The bep3 module contains the following parameters:
|
||||
|
||||
| Key | Type | Example | Description |
|
||||
|-------------------|-------------------------|-----------------------------------------------|-------------------------------|
|
||||
| BnbDeputyAddress | string (sdk.AccAddress) | "kava1xy7hrjy9r0algz9w3gzm8u6mrpq97kwta747gj" | deputy's Kava address |
|
||||
| BnbDeputyAddress | string (sdk.AccAddress) | "kava1r4v2zdhdalfj2ydazallqvrus9fkphmglhn6u6" | deputy's Kava address |
|
||||
| BnbDeputyFixedFee | sdk.Int | sdk.NewInt(1000) | deputy's fixed bnb fee |
|
||||
| MinAmount | sdk.Int | sdk.NewInt(0) | minimum swap amount |
|
||||
| MaxAmount | sdk.Int | sdk.NewInt(1000000000000) | maximum swap amount |
|
||||
|
@ -80,7 +80,7 @@ func NewParams(bnbDeputyAddress sdk.AccAddress, bnbDeputyFixedFee, minAmount,
|
||||
|
||||
// DefaultParams returns default params for bep3 module
|
||||
func DefaultParams() Params {
|
||||
defaultBnbDeputyAddress, err := sdk.AccAddressFromBech32("kava1xy7hrjy9r0algz9w3gzm8u6mrpq97kwta747gj")
|
||||
defaultBnbDeputyAddress, err := sdk.AccAddressFromBech32("kava1r4v2zdhdalfj2ydazallqvrus9fkphmglhn6u6")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ func SimulateCommitteeChangeProposalContent(k keeper.Keeper, paramChanges []simu
|
||||
// update members
|
||||
if r.Intn(100) < 50 {
|
||||
if len(accs) == 0 {
|
||||
panic("must have at least one account availabel to use as committee member")
|
||||
panic("must have at least one account available to use as committee member")
|
||||
}
|
||||
var members []sdk.AccAddress
|
||||
for len(members) < 1 {
|
||||
|
@ -36,6 +36,10 @@ func (suite *PermissionsTestSuite) SetupTest() {
|
||||
Subspace: "auction",
|
||||
Key: "BidDuration",
|
||||
},
|
||||
{
|
||||
Subspace: "bep3",
|
||||
Key: "MinAmount",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,6 +86,12 @@ func (suite *PermissionsTestSuite) TestSimpleParamChangePermission_Allows() {
|
||||
|
||||
Value: `[]`,
|
||||
},
|
||||
{
|
||||
Subspace: "bep3",
|
||||
Key: "MinAmount",
|
||||
|
||||
Value: `2000`,
|
||||
},
|
||||
},
|
||||
),
|
||||
expectAllowed: true,
|
||||
|
Loading…
Reference in New Issue
Block a user