all: rework statedb utils (#1785)

This commit is contained in:
Daniel Liu 2025-11-18 13:56:28 +08:00 committed by GitHub
parent 0050bef807
commit 6235de71ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 71 additions and 75 deletions

View file

@ -7,7 +7,6 @@ import (
"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/consensus/XDPoS"
"github.com/XinFinOrg/XDPoSChain/core/state"
"github.com/XinFinOrg/XDPoSChain/core/types"
"github.com/XinFinOrg/XDPoSChain/eth/hooks"
"github.com/XinFinOrg/XDPoSChain/eth/util"
@ -52,7 +51,7 @@ func TestHookRewardV2(t *testing.T) {
parentState = statedb.Copy()
reward, err = adaptor.EngineV2.HookReward(blockchain, statedb, parentState, header2700)
assert.Nil(t, err)
owner := state.GetCandidateOwner(parentState, signer)
owner := parentState.GetCandidateOwner(signer)
result := reward["rewards"].(map[common.Address]interface{})
assert.Equal(t, 1, len(result))
for _, x := range result {
@ -147,14 +146,14 @@ func TestHookRewardV2SplitReward(t *testing.T) {
for addr, x := range result {
if addr == acc1Addr {
r := x.(map[common.Address]*big.Int)
owner := state.GetCandidateOwner(parentState, addr)
owner := parentState.GetCandidateOwner(addr)
a, _ := big.NewInt(0).SetString("149999999999999999999", 10)
assert.Zero(t, a.Cmp(r[owner]))
b, _ := big.NewInt(0).SetString("16666666666666666666", 10)
assert.Zero(t, b.Cmp(r[config.XDPoS.FoudationWalletAddr]))
} else if addr == signer {
r := x.(map[common.Address]*big.Int)
owner := state.GetCandidateOwner(parentState, addr)
owner := parentState.GetCandidateOwner(addr)
a, _ := big.NewInt(0).SetString("74999999999999999999", 10)
assert.Zero(t, a.Cmp(r[owner]))
b, _ := big.NewInt(0).SetString("8333333333333333333", 10)
@ -229,14 +228,14 @@ func TestHookRewardAfterUpgrade(t *testing.T) {
for addr, x := range result {
if addr == acc1Addr {
r := x.(map[common.Address]*big.Int)
owner := state.GetCandidateOwner(parentState, addr)
owner := parentState.GetCandidateOwner(addr)
a, _ := big.NewInt(0).SetString("450000000000000000000", 10)
assert.Zero(t, a.Cmp(r[owner]), "real reward is", r[owner])
b, _ := big.NewInt(0).SetString("50000000000000000000", 10)
assert.Zero(t, b.Cmp(r[config.XDPoS.FoudationWalletAddr]), "real reward is", r[config.XDPoS.FoudationWalletAddr])
} else if addr == signer {
r := x.(map[common.Address]*big.Int)
owner := state.GetCandidateOwner(parentState, addr)
owner := parentState.GetCandidateOwner(addr)
a, _ := big.NewInt(0).SetString("450000000000000000000", 10)
assert.Zero(t, a.Cmp(r[owner]), "real reward is", r[owner])
b, _ := big.NewInt(0).SetString("50000000000000000000", 10)
@ -268,14 +267,14 @@ func TestHookRewardAfterUpgrade(t *testing.T) {
for addr, x := range resultProtector {
if addr == protector1Addr {
r := x.(map[common.Address]*big.Int)
owner := state.GetCandidateOwner(parentState, addr)
owner := parentState.GetCandidateOwner(addr)
a, _ := big.NewInt(0).SetString("360000000000000000000", 10)
assert.Zero(t, a.Cmp(r[owner]), "real reward is", r[owner])
b, _ := big.NewInt(0).SetString("40000000000000000000", 10)
assert.Zero(t, b.Cmp(r[config.XDPoS.FoudationWalletAddr]), "real reward is", r[config.XDPoS.FoudationWalletAddr])
} else if addr == protector2Addr {
r := x.(map[common.Address]*big.Int)
owner := state.GetCandidateOwner(parentState, addr)
owner := parentState.GetCandidateOwner(addr)
a, _ := big.NewInt(0).SetString("360000000000000000000", 10)
assert.Zero(t, a.Cmp(r[owner]), "real reward is", r[owner])
b, _ := big.NewInt(0).SetString("40000000000000000000", 10)
@ -291,16 +290,16 @@ func TestHookRewardAfterUpgrade(t *testing.T) {
for addr, x := range resultObserver {
assert.Equal(t, addr, observer1Addr)
r := x.(map[common.Address]*big.Int)
owner := state.GetCandidateOwner(parentState, addr)
owner := parentState.GetCandidateOwner(addr)
a, _ := big.NewInt(0).SetString("270112500000000000000", 10) // this value tests the float64 reward
assert.Zero(t, a.Cmp(r[owner]), "real reward is", r[owner])
b, _ := big.NewInt(0).SetString("30012500000000000000", 10) // this value tests the float64 reward
assert.Zero(t, b.Cmp(r[config.XDPoS.FoudationWalletAddr]), "real reward is", r[config.XDPoS.FoudationWalletAddr])
}
totalMinted := state.GetTotalMinted(statedb).Big()
totalMinted := statedb.GetTotalMinted().Big()
totalExpect, _ := big.NewInt(0).SetString("2100125000000000000000", 10)
assert.Zero(t, totalMinted.Cmp(totalExpect), "statedb records wrong total minted")
lastEpochNum := state.GetLastEpochNum(statedb).Big().Int64()
lastEpochNum := statedb.GetLastEpochNum().Big().Int64()
assert.Equal(t, 3, int(lastEpochNum))
common.TIPUpgradeReward = backup
}
@ -366,7 +365,7 @@ func TestFinalizeAfterUpgrade(t *testing.T) {
assert.Nil(t, err)
// the recorded reward cannot be zero
minted := state.GetTotalMinted(statedbAfterFinalize)
minted := statedbAfterFinalize.GetTotalMinted()
assert.False(t, minted.IsZero())
t.Log("total minted", minted)

View file

@ -210,7 +210,7 @@ func BuildTxOpeningRandomize(nonce uint64, randomizeAddr common.Address, randomi
// Get signers signed for blockNumber from blockSigner contract.
func GetSignersFromContract(statedb *state.StateDB, block *types.Block) ([]common.Address, error) {
return state.GetSigners(statedb, block), nil
return statedb.GetSigners(block), nil
}
// Get signers signed for blockNumber from blockSigner contract.
@ -412,8 +412,7 @@ func CalculateRewardForSigner(chainReward *big.Int, signers map[common.Address]*
// Get candidate owner by address.
func GetCandidatesOwnerBySigner(statedb *state.StateDB, signerAddr common.Address) common.Address {
owner := state.GetCandidateOwner(statedb, signerAddr)
return owner
return statedb.GetCandidateOwner(signerAddr)
}
func CalculateRewardForHolders(foundationWalletAddr common.Address, state *state.StateDB, signer common.Address, calcReward *big.Int, blockNumber uint64) (map[common.Address]*big.Int, error) {
@ -431,7 +430,7 @@ func GetRewardBalancesRate(foundationWalletAddr common.Address, statedb *state.S
rewardMaster = new(big.Int).Div(rewardMaster, new(big.Int).SetInt64(100))
balances[owner] = rewardMaster
// Get voters for masternode.
voters := state.GetVoters(statedb, masterAddr)
voters := statedb.GetVoters(masterAddr)
if len(voters) > 0 {
totalVoterReward := new(big.Int).Mul(totalReward, new(big.Int).SetUint64(common.RewardVoterPercent))
@ -443,7 +442,7 @@ func GetRewardBalancesRate(foundationWalletAddr common.Address, statedb *state.S
if _, ok := voterCaps[voteAddr]; ok && common.TIP2019Block.Uint64() <= blockNumber {
continue
}
voterCap := state.GetVoterCap(statedb, masterAddr, voteAddr)
voterCap := statedb.GetVoterCap(masterAddr, voteAddr)
totalCap.Add(totalCap, voterCap)
voterCaps[voteAddr] = voterCap
}

View file

@ -30,7 +30,6 @@ import (
"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/common/hexutil"
contractValidator "github.com/XinFinOrg/XDPoSChain/contracts/validator/contract"
"github.com/XinFinOrg/XDPoSChain/core/state"
"github.com/XinFinOrg/XDPoSChain/core/types"
"github.com/XinFinOrg/XDPoSChain/crypto"
"github.com/XinFinOrg/XDPoSChain/log"
@ -318,7 +317,7 @@ func TestStatedbUtils(t *testing.T) {
if err != nil {
t.Fatalf("can't get candidates: %v", err)
}
candidates_statedb := state.GetCandidates(statedb)
candidates_statedb := statedb.GetCandidates()
if !reflect.DeepEqual(candidates, candidates_statedb) {
t.Fatalf("candidates not equal, statedb utils is wrong,\nbind calling result\n%v\nstatedb result\n%v", candidates, candidates_statedb)
}
@ -330,7 +329,7 @@ func TestStatedbUtils(t *testing.T) {
if err != nil {
t.Fatalf("can't get candidate cap: %v", err)
}
cap_statedb := state.GetCandidateCap(statedb, it)
cap_statedb := statedb.GetCandidateCap(it)
if cap.Cmp(cap_statedb) != 0 {
t.Fatalf("cap not equal, statedb utils is wrong")
}
@ -341,7 +340,7 @@ func TestStatedbUtils(t *testing.T) {
if err != nil {
t.Fatalf("can't get candidate owner: %v", err)
}
owner_statedb := state.GetCandidateOwner(statedb, it)
owner_statedb := statedb.GetCandidateOwner(it)
if !reflect.DeepEqual(owner, owner_statedb) {
t.Fatalf("owner not equal, statedb utils is wrong")
}
@ -350,7 +349,7 @@ func TestStatedbUtils(t *testing.T) {
if err != nil {
t.Fatalf("can't get voters: %v", err)
}
voters_statedb := state.GetVoters(statedb, acc3Addr)
voters_statedb := statedb.GetVoters(acc3Addr)
if !reflect.DeepEqual(voters, voters_statedb) {
t.Fatalf("voters not equal, statedb utils is wrong,\nbind calling result\n%v\nstatedb result\n%v", voters, voters_statedb)
}
@ -362,7 +361,7 @@ func TestStatedbUtils(t *testing.T) {
if err != nil {
t.Fatalf("can't get voter cap: %v", err)
}
cap_statedb := state.GetVoterCap(statedb, acc3Addr, it)
cap_statedb := statedb.GetVoterCap(acc3Addr, it)
if cap.Cmp(cap_statedb) != 0 {
t.Fatalf("cap not equal, statedb utils is wrong")
}

View file

@ -2788,7 +2788,7 @@ func (bc *BlockChain) UpdateM1() error {
} else if stateDB == nil {
return errors.New("nil stateDB in UpdateM1")
} else {
candidates = state.GetCandidates(stateDB)
candidates = stateDB.GetCandidates()
}
var ms []utils.Masternode

View file

@ -5,7 +5,6 @@ import (
"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/core/types"
"github.com/XinFinOrg/XDPoSChain/crypto"
)
@ -16,19 +15,19 @@ var (
}
)
func GetSigners(statedb *StateDB, block *types.Block) []common.Address {
func (s *StateDB) GetSigners(block *types.Block) []common.Address {
slot := slotBlockSignerMapping["blockSigners"]
keys := []common.Hash{}
keyArrSlot := GetLocMappingAtKey(block.Hash(), slot)
arrSlot := statedb.GetState(common.BlockSignersBinary, common.BigToHash(keyArrSlot))
arrSlot := s.GetState(common.BlockSignersBinary, common.BigToHash(keyArrSlot))
arrLength := arrSlot.Big().Uint64()
for i := uint64(0); i < arrLength; i++ {
for i := range arrLength {
key := GetLocDynamicArrAtElement(common.BigToHash(keyArrSlot), i, 1)
keys = append(keys, key)
}
rets := []common.Address{}
for _, key := range keys {
ret := statedb.GetState(common.BlockSignersBinary, key)
ret := s.GetState(common.BlockSignersBinary, key)
rets = append(rets, common.HexToAddress(ret.Hex()))
}
@ -42,10 +41,10 @@ var (
}
)
func GetSecret(statedb *StateDB, address common.Address) [][32]byte {
func (s *StateDB) GetSecret(address common.Address) [][32]byte {
slot := slotRandomizeMapping["randomSecret"]
locSecret := GetLocMappingAtKey(address.Hash(), slot)
arrLength := statedb.GetState(common.RandomizeSMCBinary, common.BigToHash(locSecret))
arrLength := s.GetState(common.RandomizeSMCBinary, common.BigToHash(locSecret))
keys := []common.Hash{}
for i := uint64(0); i < arrLength.Big().Uint64(); i++ {
key := GetLocDynamicArrAtElement(common.BigToHash(locSecret), i, 1)
@ -53,16 +52,16 @@ func GetSecret(statedb *StateDB, address common.Address) [][32]byte {
}
rets := [][32]byte{}
for _, key := range keys {
ret := statedb.GetState(common.RandomizeSMCBinary, key)
ret := s.GetState(common.RandomizeSMCBinary, key)
rets = append(rets, ret)
}
return rets
}
func GetOpening(statedb *StateDB, address common.Address) [32]byte {
func (s *StateDB) GetOpening(address common.Address) [32]byte {
slot := slotRandomizeMapping["randomOpening"]
locOpening := GetLocMappingAtKey(address.Hash(), slot)
ret := statedb.GetState(common.RandomizeSMCBinary, common.BigToHash(locOpening))
ret := s.GetState(common.RandomizeSMCBinary, common.BigToHash(locOpening))
return ret
}
@ -89,16 +88,16 @@ var (
}
)
func GetCandidates(statedb *StateDB) []common.Address {
func (s *StateDB) GetCandidates() []common.Address {
slot := slotValidatorMapping["candidates"]
slotHash := common.BigToHash(new(big.Int).SetUint64(slot))
arrLength := statedb.GetState(common.MasternodeVotingSMCBinary, slotHash)
arrLength := s.GetState(common.MasternodeVotingSMCBinary, slotHash)
count := arrLength.Big().Uint64()
rets := make([]common.Address, 0, count)
for i := uint64(0); i < count; i++ {
for i := range count {
key := GetLocDynamicArrAtElement(slotHash, i, 1)
ret := statedb.GetState(common.MasternodeVotingSMCBinary, key)
ret := s.GetState(common.MasternodeVotingSMCBinary, key)
if !ret.IsZero() {
rets = append(rets, common.HexToAddress(ret.Hex()))
}
@ -107,29 +106,29 @@ func GetCandidates(statedb *StateDB) []common.Address {
return rets
}
func GetCandidateOwner(statedb *StateDB, candidate common.Address) common.Address {
func (s *StateDB) GetCandidateOwner(candidate common.Address) common.Address {
slot := slotValidatorMapping["validatorsState"]
// validatorsState[_candidate].owner;
locValidatorsState := GetLocMappingAtKey(candidate.Hash(), slot)
locCandidateOwner := locValidatorsState.Add(locValidatorsState, new(big.Int).SetUint64(uint64(0)))
ret := statedb.GetState(common.MasternodeVotingSMCBinary, common.BigToHash(locCandidateOwner))
ret := s.GetState(common.MasternodeVotingSMCBinary, common.BigToHash(locCandidateOwner))
return common.HexToAddress(ret.Hex())
}
func GetCandidateCap(statedb *StateDB, candidate common.Address) *big.Int {
func (s *StateDB) GetCandidateCap(candidate common.Address) *big.Int {
slot := slotValidatorMapping["validatorsState"]
// validatorsState[_candidate].cap;
locValidatorsState := GetLocMappingAtKey(candidate.Hash(), slot)
locCandidateCap := locValidatorsState.Add(locValidatorsState, new(big.Int).SetUint64(uint64(1)))
ret := statedb.GetState(common.MasternodeVotingSMCBinary, common.BigToHash(locCandidateCap))
ret := s.GetState(common.MasternodeVotingSMCBinary, common.BigToHash(locCandidateCap))
return ret.Big()
}
func GetVoters(statedb *StateDB, candidate common.Address) []common.Address {
func (s *StateDB) GetVoters(candidate common.Address) []common.Address {
//mapping(address => address[]) voters;
slot := slotValidatorMapping["voters"]
locVoters := GetLocMappingAtKey(candidate.Hash(), slot)
arrLength := statedb.GetState(common.MasternodeVotingSMCBinary, common.BigToHash(locVoters))
arrLength := s.GetState(common.MasternodeVotingSMCBinary, common.BigToHash(locVoters))
keys := []common.Hash{}
for i := uint64(0); i < arrLength.Big().Uint64(); i++ {
key := GetLocDynamicArrAtElement(common.BigToHash(locVoters), i, 1)
@ -137,19 +136,19 @@ func GetVoters(statedb *StateDB, candidate common.Address) []common.Address {
}
rets := []common.Address{}
for _, key := range keys {
ret := statedb.GetState(common.MasternodeVotingSMCBinary, key)
ret := s.GetState(common.MasternodeVotingSMCBinary, key)
rets = append(rets, common.HexToAddress(ret.Hex()))
}
return rets
}
func GetVoterCap(statedb *StateDB, candidate, voter common.Address) *big.Int {
func (s *StateDB) GetVoterCap(candidate, voter common.Address) *big.Int {
slot := slotValidatorMapping["validatorsState"]
locValidatorsState := GetLocMappingAtKey(candidate.Hash(), slot)
locCandidateVoters := locValidatorsState.Add(locValidatorsState, new(big.Int).SetUint64(uint64(2)))
retByte := crypto.Keccak256(voter.Hash().Bytes(), common.BigToHash(locCandidateVoters).Bytes())
ret := statedb.GetState(common.MasternodeVotingSMCBinary, common.BytesToHash(retByte))
ret := s.GetState(common.MasternodeVotingSMCBinary, common.BytesToHash(retByte))
return ret.Big()
}
@ -158,29 +157,29 @@ var (
slotMintedRecordLastEpochNum uint64 = 1
)
func GetTotalMinted(statedb *StateDB) common.Hash {
func (s *StateDB) GetTotalMinted() common.Hash {
hash := GetLocSimpleVariable(slotMintedRecordTotalMinted)
totalMinted := statedb.GetState(common.MintedRecordAddressBinary, hash)
totalMinted := s.GetState(common.MintedRecordAddressBinary, hash)
return totalMinted
}
func PutTotalMinted(statedb *StateDB, value common.Hash) {
func (s *StateDB) PutTotalMinted(value common.Hash) {
hash := GetLocSimpleVariable(slotMintedRecordTotalMinted)
statedb.SetState(common.MintedRecordAddressBinary, hash, value)
s.SetState(common.MintedRecordAddressBinary, hash, value)
}
func GetLastEpochNum(statedb *StateDB) common.Hash {
func (s *StateDB) GetLastEpochNum() common.Hash {
hash := GetLocSimpleVariable(slotMintedRecordLastEpochNum)
totalMinted := statedb.GetState(common.MintedRecordAddressBinary, hash)
totalMinted := s.GetState(common.MintedRecordAddressBinary, hash)
return totalMinted
}
func PutLastEpochNum(statedb *StateDB, value common.Hash) {
func (s *StateDB) PutLastEpochNum(value common.Hash) {
hash := GetLocSimpleVariable(slotMintedRecordLastEpochNum)
statedb.SetState(common.MintedRecordAddressBinary, hash, value)
s.SetState(common.MintedRecordAddressBinary, hash, value)
}
func IncrementMintedRecordNonce(statedb *StateDB) {
nonce := statedb.GetNonce(common.MintedRecordAddressBinary)
statedb.SetNonce(common.MintedRecordAddressBinary, nonce+1)
func (s *StateDB) IncrementMintedRecordNonce() {
nonce := s.GetNonce(common.MintedRecordAddressBinary)
s.SetNonce(common.MintedRecordAddressBinary, nonce+1)
}

View file

@ -557,7 +557,7 @@ func (b *EthAPIBackend) GetVotersCap(checkpoint *big.Int, masterAddr common.Addr
voterCaps := make(map[common.Address]*big.Int)
for _, voteAddr := range voters {
voterCap := state.GetVoterCap(statedb, masterAddr, voteAddr)
voterCap := statedb.GetVoterCap(masterAddr, voteAddr)
voterCaps[voteAddr] = voterCap
}
return voterCaps
@ -590,11 +590,11 @@ func (b *EthAPIBackend) GetMasternodesCap(checkpoint uint64) map[common.Address]
return nil
}
candicates := state.GetCandidates(statedb)
candicates := statedb.GetCandidates()
masternodesCap := map[common.Address]*big.Int{}
for _, candicate := range candicates {
masternodesCap[candicate] = state.GetCandidateCap(statedb, candicate)
masternodesCap[candicate] = statedb.GetCandidateCap(candicate)
}
return masternodesCap

View file

@ -232,7 +232,7 @@ func AttachConsensusV1Hooks(adaptor *XDPoS.XDPoS, bc *core.BlockChain, chainConf
return nil, errors.New("nil stateDB in HookGetSignersFromContract")
}
candidateAddresses = state.GetCandidates(stateDB)
candidateAddresses = stateDB.GetCandidates()
for _, address := range candidateAddresses {
v, err := validator.GetCandidateCap(opts, address)
if err != nil {

View file

@ -361,8 +361,8 @@ func AttachConsensusV2Hooks(adaptor *XDPoS.XDPoS, bc *core.BlockChain, chainConf
rewardsMap[rwt.key] = rewardResults
}
// record the total reward into state db
totalMinted := state.GetTotalMinted(stateBlock).Big()
lastEpochNum := state.GetLastEpochNum(stateBlock)
totalMinted := stateBlock.GetTotalMinted().Big()
lastEpochNum := stateBlock.GetLastEpochNum()
if lastEpochNum.IsZero() {
// if `lastEpochNum` is zero, the total minted has not included tokens before TIPUpgradeReward
// calculate the tokens before TIPUpgradeReward and set to totalMinted
@ -377,10 +377,10 @@ func AttachConsensusV2Hooks(adaptor *XDPoS.XDPoS, bc *core.BlockChain, chainConf
log.Warn("[HookReward] total minted overflow max u256")
}
log.Debug("[HookReward] total minted in hook", "value", totalMinted)
state.PutTotalMinted(stateBlock, common.BigToHash(totalMinted))
state.PutLastEpochNum(stateBlock, common.Uint64ToHash(epochNum))
stateBlock.PutTotalMinted(common.BigToHash(totalMinted))
stateBlock.PutLastEpochNum(common.Uint64ToHash(epochNum))
// Increment nonce so that statedb does not treat it as empty account
state.IncrementMintedRecordNonce(stateBlock)
stateBlock.IncrementMintedRecordNonce()
}
log.Debug("Time Calculated HookReward ", "block", header.Number.Uint64(), "time", common.PrettyDuration(time.Since(start)))
return rewardsMap, nil
@ -433,12 +433,12 @@ func GetSigningTxCount(c *XDPoS.XDPoS, chain consensus.ChainReader, header *type
nodesToKeep[MasterNodeBeneficiary] = c.GetMasternodesFromCheckpointHeader(h)
// in reward upgrade, add protector and observer nodes
if chain.Config().IsTIPUpgradeReward(header.Number) {
candidates := state.GetCandidates(parentState)
candidates := parentState.GetCandidates()
var ms []utils.Masternode
for _, candidate := range candidates {
// ignore "0x0000000000000000000000000000000000000000"
if !candidate.IsZero() {
v := state.GetCandidateCap(parentState, candidate)
v := parentState.GetCandidateCap(candidate)
ms = append(ms, utils.Masternode{Address: candidate, Stake: v})
}
}

View file

@ -837,10 +837,10 @@ func (api *BlockChainAPI) GetCandidateStatus(ctx context.Context, coinbaseAddres
result[fieldSuccess] = false
return result, errors.New("nil statedb in GetCandidateStatus")
}
candidatesAddresses := state.GetCandidates(statedb)
candidatesAddresses := statedb.GetCandidates()
candidates = make([]utils.Masternode, 0, len(candidatesAddresses))
for _, address := range candidatesAddresses {
v := state.GetCandidateCap(statedb, address)
v := statedb.GetCandidateCap(address)
candidates = append(candidates, utils.Masternode{Address: address, Stake: v})
}
}
@ -996,10 +996,10 @@ func (api *BlockChainAPI) GetCandidates(ctx context.Context, epoch rpc.EpochNumb
result[fieldSuccess] = false
return result, errors.New("nil statedb in GetCandidates")
}
candidatesAddresses := state.GetCandidates(statedb)
candidatesAddresses := statedb.GetCandidates()
candidates = make([]utils.Masternode, 0, len(candidatesAddresses))
for _, address := range candidatesAddresses {
v := state.GetCandidateCap(statedb, address)
v := statedb.GetCandidateCap(address)
candidates = append(candidates, utils.Masternode{Address: address, Stake: v})
}
}
@ -2610,8 +2610,8 @@ func (api *BlockChainAPI) GetCurrentTotalMinted(ctx context.Context) (*currentTo
if err != nil {
return nil, err
}
totalMinted := state.GetTotalMinted(statedb).Big()
lastEpochNum := state.GetLastEpochNum(statedb).Big()
totalMinted := statedb.GetTotalMinted().Big()
lastEpochNum := statedb.GetLastEpochNum().Big()
result := &currentTotalMinted{
TotalMinted: (*hexutil.Big)(totalMinted),
LastEpochNum: (*hexutil.Big)(lastEpochNum),