Skip to content

Commit

Permalink
Merge pull request #2843 from 0chain/fix/minstake
Browse files Browse the repository at this point in the history
Fix minstake
  • Loading branch information
dabasov committed Oct 10, 2023
2 parents ee39d7d + 4bdc0fe commit d642430
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 10 deletions.
2 changes: 2 additions & 0 deletions code/go/0chain.net/miner/testdata/config/sc.yaml
Expand Up @@ -42,6 +42,7 @@ smart_contracts:
# etc
min_stake: 0.0 # min stake can be set by a node (boundary for all nodes)
max_stake: 20000.0 # max stake can be set by a node (boundary for all nodes)
min_stake_per_delegate: 1
start_rounds: 50
contribute_rounds: 50
share_rounds: 50
Expand Down Expand Up @@ -104,6 +105,7 @@ smart_contracts:
time_unit: "720h"
min_stake: 0.01 # min stake can be set by a node (boundary for all nodes)
max_stake: 20000.0 # max stake can be set by a node (boundary for all nodes)
min_stake_per_delegate: 1
# max_mint
max_mint: 1500000.0 # tokens, max amount of tokens can be minted by SC
# min possible allocations size in bytes allowed by the SC
Expand Down
1 change: 1 addition & 0 deletions code/go/0chain.net/smartcontract/benchmark/benchmark.go
Expand Up @@ -176,6 +176,7 @@ const (
StorageMaxCharge = SmartContract + StorageSc + "max_charge"
StorageMinStake = SmartContract + StorageSc + "min_stake"
StorageMaxStake = SmartContract + StorageSc + "max_stake"
StorageMinStakePerDelegates = SmartContract + StorageSc + "min_stake_per_delegate"
StorageMaxDelegates = SmartContract + StorageSc + "max_delegates"
StorageDiverseBlobbers = SmartContract + StorageSc + "diverse_blobbers"
StorageReadPoolMinLock = SmartContract + StorageSc + "readpool.min_lock"
Expand Down
Expand Up @@ -74,6 +74,7 @@ smart_contracts:
max_delegates: 200
min_stake: 0.0
max_stake: 170.0
min_stake_per_delegate: 1
max_n: 7 # 100
min_n: 3 # 3
max_s: 2 # 30
Expand Down Expand Up @@ -135,6 +136,7 @@ smart_contracts:
max_charge: 0.2
min_stake: 0.0
max_stake: 20000.0
min_stake_per_delegate: 1
max_delegates: 200
diverse_blobbers: false
failed_challenges_to_cancel: 0
Expand Down Expand Up @@ -197,6 +199,7 @@ smart_contracts:
min_mint: 1
min_burn: 1
min_stake: 0
min_stake_per_delegate : 1
max_stake: 2.7
min_lock: 0
min_authorizers: 1
Expand Down
1 change: 1 addition & 0 deletions code/go/0chain.net/smartcontract/minersc/miner.go
Expand Up @@ -51,6 +51,7 @@ func (msc *MinerSmartContract) AddMiner(t *transaction.Transaction,

lockAllMiners.Lock()
defer lockAllMiners.Unlock()

newMiner.Settings.MinStake = gn.MinStakePerDelegate
magicBlockMiners := balances.GetChainCurrentMagicBlock().Miners

Expand Down
2 changes: 2 additions & 0 deletions code/go/0chain.net/smartcontract/minersc/sharder.go
Expand Up @@ -130,6 +130,8 @@ func (msc *MinerSmartContract) AddSharder(

newSharder.NodeType = NodeTypeSharder // set node type
newSharder.ProviderType = spenum.Sharder
newSharder.Settings.MinStake = gn.MinStakePerDelegate

exist, err := msc.getSharderNode(newSharder.ID, balances)
if err != nil && err != util.ErrValueNotPresent {
return "", common.NewErrorf("add_sharder", "unexpected error: %v", err)
Expand Down
Expand Up @@ -770,13 +770,14 @@ func BenchmarkTests(
"blobber_slash": "0.1",
"max_read_price": "100",
"max_write_price": "100",
"max_file_size": "40000000000000",
"max_file_size": "40000000000000",
"challenge_enabled": "true",
"challenge_generation_gap": "1",
"validators_per_challenge": "2",
"num_validators_rewarded": "10",
"max_blobber_select_for_challenge": "5",
"max_delegates": "100",
"min_stake_per_delegate": "1",

"block_reward.block_reward": "1000",
"block_reward.qualifying_stake": "1",
Expand Down
7 changes: 3 additions & 4 deletions code/go/0chain.net/smartcontract/storagesc/stakepool.go
@@ -1,13 +1,12 @@
package storagesc

import (
"encoding/json"
"errors"
"fmt"

"0chain.net/chaincore/state"
"0chain.net/smartcontract/dbs/event"
"0chain.net/smartcontract/stakepool/spenum"
"encoding/json"
"errors"
"fmt"
"github.com/0chain/common/core/currency"

"0chain.net/smartcontract/stakepool"
Expand Down
6 changes: 3 additions & 3 deletions code/go/0chain.net/smartcontract/zcnsc/stakepool.go
@@ -1,16 +1,15 @@
package zcnsc

import (
"errors"
"fmt"

cstate "0chain.net/chaincore/chain/state"
"0chain.net/chaincore/state"
"0chain.net/chaincore/transaction"
"0chain.net/core/common"
"0chain.net/core/datastore"
"0chain.net/smartcontract/stakepool"
"0chain.net/smartcontract/stakepool/spenum"
"errors"
"fmt"
"github.com/0chain/common/core/util"
)

Expand Down Expand Up @@ -137,6 +136,7 @@ func (zcn *ZCNSmartContract) getOrUpdateStakePool(gn *GlobalNode,
sp.Settings.MaxNumDelegates = settings.MaxNumDelegates
changed = true
}

if sp.Settings.MinStake != gn.MinStakePerDelegate {
sp.Settings.MinStake = gn.MinStakePerDelegate
changed = true
Expand Down
3 changes: 3 additions & 0 deletions docker.local/config/benchmark.yaml
Expand Up @@ -67,6 +67,7 @@ smart_contracts:
max_delegates: 200
min_stake: 0.0
max_stake: 170.0
min_stake_per_delegate: 1
max_n: 7 # 100
min_n: 3 # 3
max_s: 2 # 30
Expand Down Expand Up @@ -130,6 +131,7 @@ smart_contracts:
max_charge: 0.2
min_stake: 0.0
max_stake: 20000.0
min_stake_per_delegate: 1
max_delegates: 200
diverse_blobbers: false
failed_challenges_to_cancel: 0
Expand Down Expand Up @@ -192,6 +194,7 @@ smart_contracts:
min_mint: 1
min_burn: 1
min_stake: 0
min_stake_per_delegate : 1
max_stake: 2.7
min_lock: 0
min_authorizers: 1
Expand Down
3 changes: 3 additions & 0 deletions docker.local/config/loadtest_benchmark.yaml
Expand Up @@ -61,6 +61,7 @@ smart_contracts:
max_delegates: 200
min_stake: 0.0
max_stake: 170.0
min_stake_per_delegate: 1
max_n: 7 # 100
min_n: 3 # 3
max_s: 2 # 30
Expand Down Expand Up @@ -103,6 +104,7 @@ smart_contracts:
max_charge: 0.2
min_stake: 0.0
max_stake: 20000.0
min_stake_per_delegate: 1
max_delegates: 200
diverse_blobbers: false
failed_challenges_to_cancel: 0
Expand Down Expand Up @@ -156,6 +158,7 @@ smart_contracts:
min_mint: 1
min_burn: 1
min_stake: 3
min_stake_per_delegate : 1
min_lock: 0
min_authorizers: 1
percent_authorizers: 0
Expand Down
3 changes: 3 additions & 0 deletions docker.local/config/sc.yaml
Expand Up @@ -31,6 +31,7 @@ smart_contracts:
# etc
min_stake: 0.0 # min stake can be set by a node (boundary for all nodes)
max_stake: 20000.0 # max stake can be set by a node (boundary for all nodes)
min_stake_per_delegate: 1
start_rounds: 50
contribute_rounds: 50
share_rounds: 50
Expand Down Expand Up @@ -92,6 +93,7 @@ smart_contracts:
time_unit: "720h"
min_stake: 0.01 # min stake can be set by a node (boundary for all nodes)
max_stake: 20000.0 # max stake can be set by a node (boundary for all nodes)
min_stake_per_delegate: 1
# max_mint
max_mint: 75000000.0 # tokens, max amount of tokens can be minted by SC
# min possible allocations size in bytes allowed by the SC
Expand Down Expand Up @@ -232,6 +234,7 @@ smart_contracts:
min_mint: 1
min_burn: 1
min_stake: 0
min_stake_per_delegate : 1
min_authorizers: 1
percent_authorizers: 0.7
max_delegates: 10
Expand Down
Expand Up @@ -30,6 +30,7 @@ smart_contracts:
# etc
min_stake: 0.0 # 0.01 # min stake can be set by a node (boundary for all nodes)
max_stake: 20000.0 # max stake can be set by a node (boundary for all nodes)
min_stake_per_delegate: 1
start_rounds: 50
contribute_rounds: 50
share_rounds: 50
Expand Down Expand Up @@ -70,6 +71,7 @@ smart_contracts:
time_unit: '720h'
min_stake: 0.01 # min stake can be set by a node (boundary for all nodes)
max_stake: 20000.0 # max stake can be set by a node (boundary for all nodes)
min_stake_per_delegate: 1
# max_mint
max_mint: 4000000.0 # tokens, max amount of tokens can be minted by SC
# min possible allocations size in bytes allowed by the SC
Expand Down
Expand Up @@ -36,7 +36,6 @@ challenge_completion_time: 2m # duration to complete a challenge
# a task and redeem tokens, it should be big enough
read_lock_timeout: 1m
write_lock_timeout: 1m
max_file_size: 10485760 #10MB

# update_allocations_interval used to refresh known allocation objects from SC
update_allocations_interval: 1m
Expand Down
Expand Up @@ -30,6 +30,7 @@ smart_contracts:
# etc
min_stake: 0.0 # 0.01 # min stake can be set by a node (boundary for all nodes)
max_stake: 20000.0 # max stake can be set by a node (boundary for all nodes)
min_stake_per_delegate : 1
start_rounds: 50
contribute_rounds: 50
share_rounds: 50
Expand Down
Expand Up @@ -36,7 +36,6 @@ challenge_completion_time: 2m # duration to complete a challenge
# a task and redeem tokens, it should be big enough
read_lock_timeout: 1m
write_lock_timeout: 1m
max_file_size: 10485760 #10MB

# update_allocations_interval used to refresh known allocation objects from SC
update_allocations_interval: 1m
Expand Down

0 comments on commit d642430

Please sign in to comment.