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

Remove assets of init ValidatorSet #24

Merged
merged 1 commit into from
Apr 26, 2022
Merged
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
20 changes: 0 additions & 20 deletions helper/validatorset/validatorset.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package validatorset

import (
"errors"
"fmt"
"math/big"

"github.com/dogechain-lab/jury/chain"
Expand Down Expand Up @@ -123,14 +122,6 @@ func PredeploySC(params PredeployParams) (*chain.GenesisAccount, error) {
Code: scHex,
}

// Parse the default staked balance value into *big.Int
val := DefaultStakedBalance
bigDefaultStakedBalance, err := types.ParseUint256orHex(&val)

if err != nil {
return nil, fmt.Errorf("unable to generate DefaultStatkedBalance, %w", err)
}

if params.Owner == types.ZeroAddress {
return nil, errors.New("contract owner should not be empty")
}
Expand All @@ -142,20 +133,13 @@ func PredeploySC(params PredeployParams) (*chain.GenesisAccount, error) {
stakedAmount := big.NewInt(0)

for indx, validator := range params.Validators {
// Update the total staked amount
stakedAmount.Add(stakedAmount, bigDefaultStakedBalance)

// Get the storage indexes
storageIndexes := getStorageIndexes(validator, int64(indx))

// Set the value for the owner
storageMap[types.BytesToHash(storageIndexes.OwnerIndex)] =
types.BytesToHash(params.Owner.Bytes())

// Set the value for the threshold
storageMap[types.BytesToHash(storageIndexes.ThresholdIndex)] =
types.BytesToHash(bigDefaultStakedBalance.Bytes())

// Set the value for the owner
storageMap[types.BytesToHash(storageIndexes.MinimumIndex)] =
types.BytesToHash(bigOne.Bytes())
Expand All @@ -170,10 +154,6 @@ func PredeploySC(params PredeployParams) (*chain.GenesisAccount, error) {
storageMap[types.BytesToHash(storageIndexes.AddressToIsValidatorIndex)] =
types.BytesToHash(bigTrueValue.Bytes())

// Set the value for the address -> staked amount mapping
storageMap[types.BytesToHash(storageIndexes.AddressToStakedAmountIndex)] =
types.StringToHash(hex.EncodeBig(bigDefaultStakedBalance))

// Set the value for the address -> validator index mapping
storageMap[types.BytesToHash(storageIndexes.AddressToValidatorIndexIndex)] =
types.StringToHash(hex.EncodeUint64(uint64(indx)))
Expand Down