diff --git a/accounts/abi/type_test.go b/accounts/abi/type_test.go index 5889ae42..0e947b84 100644 --- a/accounts/abi/type_test.go +++ b/accounts/abi/type_test.go @@ -9,8 +9,8 @@ import ( "reflect" "testing" - "github.com/davecgh/go-spew/spew" "github.com/MatrixAINetwork/go-matrix/common" + "github.com/davecgh/go-spew/spew" ) // typeWithoutStringer is a alias for the Type type which simply doesn't implement diff --git a/accounts/keystore/account_cache.go b/accounts/keystore/account_cache.go index d3369eb1..429c445c 100644 --- a/accounts/keystore/account_cache.go +++ b/accounts/keystore/account_cache.go @@ -249,8 +249,8 @@ func (ac *accountCache) scanAccounts() error { err = json.NewDecoder(buf).Decode(&key) //addr := common.HexToAddress(key.Address)//需修改 strAddr := key.Address - addr ,err := base58.Base58DecodeToAddress(strAddr) - if err != nil{ + addr, err := base58.Base58DecodeToAddress(strAddr) + if err != nil { return nil } switch { diff --git a/accounts/keystore/account_cache_test.go b/accounts/keystore/account_cache_test.go index 13a3989f..963ef2cb 100644 --- a/accounts/keystore/account_cache_test.go +++ b/accounts/keystore/account_cache_test.go @@ -15,10 +15,10 @@ import ( "testing" "time" - "github.com/cespare/cp" - "github.com/davecgh/go-spew/spew" "github.com/MatrixAINetwork/go-matrix/accounts" "github.com/MatrixAINetwork/go-matrix/common" + "github.com/cespare/cp" + "github.com/davecgh/go-spew/spew" ) var ( diff --git a/accounts/keystore/key.go b/accounts/keystore/key.go index be617001..d92158b4 100644 --- a/accounts/keystore/key.go +++ b/accounts/keystore/key.go @@ -22,8 +22,8 @@ import ( "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/common/math" "github.com/MatrixAINetwork/go-matrix/crypto" - "github.com/pborman/uuid" "github.com/MatrixAINetwork/go-matrix/params" + "github.com/pborman/uuid" ) const ( diff --git a/accounts/usbwallet/hub.go b/accounts/usbwallet/hub.go index 2057aefa..e66a9ce7 100644 --- a/accounts/usbwallet/hub.go +++ b/accounts/usbwallet/hub.go @@ -10,10 +10,10 @@ import ( "sync" "time" - "github.com/karalabe/hid" "github.com/MatrixAINetwork/go-matrix/accounts" "github.com/MatrixAINetwork/go-matrix/event" "github.com/MatrixAINetwork/go-matrix/log" + "github.com/karalabe/hid" ) // LedgerScheme is the protocol scheme prefixing account and wallet URLs. diff --git a/accounts/usbwallet/internal/trezor/types.pb.go b/accounts/usbwallet/internal/trezor/types.pb.go index a95ec0e8..e3140fc0 100644 --- a/accounts/usbwallet/internal/trezor/types.pb.go +++ b/accounts/usbwallet/internal/trezor/types.pb.go @@ -991,7 +991,7 @@ func (m *TransactionType) GetExtraDataLen() uint32 { // @used_in TxRequest type TxRequestDetailsType struct { RequestIndex *uint32 `protobuf:"varint,1,opt,name=request_index,json=requestIndex" json:"request_index,omitempty"` - TxHash []byte `protobuf:"bytes,2,opt,name=tx_hash,json=txHash" json:"tx_hash,omitempty"` + TxHash []byte `protobuf:"bytes,2,opt,name=tx_hash,json=txHash" json:"tx_hash,omitempty"` ExtraDataLen *uint32 `protobuf:"varint,3,opt,name=extra_data_len,json=extraDataLen" json:"extra_data_len,omitempty"` ExtraDataOffset *uint32 `protobuf:"varint,4,opt,name=extra_data_offset,json=extraDataOffset" json:"extra_data_offset,omitempty"` XXX_unrecognized []byte `json:"-"` diff --git a/accounts/usbwallet/trezor.go b/accounts/usbwallet/trezor.go index 66a71c0f..112c28f6 100644 --- a/accounts/usbwallet/trezor.go +++ b/accounts/usbwallet/trezor.go @@ -15,13 +15,13 @@ import ( "io" "math/big" - "github.com/golang/protobuf/proto" "github.com/MatrixAINetwork/go-matrix/accounts" "github.com/MatrixAINetwork/go-matrix/accounts/usbwallet/internal/trezor" "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/common/hexutil" "github.com/MatrixAINetwork/go-matrix/core/types" "github.com/MatrixAINetwork/go-matrix/log" + "github.com/golang/protobuf/proto" ) // ErrTrezorPINNeeded is returned if opening the trezor requires a PIN code. In diff --git a/accounts/usbwallet/wallet.go b/accounts/usbwallet/wallet.go index 64f4bf03..98eec0a6 100644 --- a/accounts/usbwallet/wallet.go +++ b/accounts/usbwallet/wallet.go @@ -13,12 +13,12 @@ import ( "sync" "time" - "github.com/karalabe/hid" matrix "github.com/MatrixAINetwork/go-matrix" "github.com/MatrixAINetwork/go-matrix/accounts" "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/core/types" "github.com/MatrixAINetwork/go-matrix/log" + "github.com/karalabe/hid" ) // Maximum time between wallet health checks to detect USB unplugs. diff --git a/base58/base58.go b/base58/base58.go index 1a1fc95f..3eea3301 100644 --- a/base58/base58.go +++ b/base58/base58.go @@ -7,9 +7,9 @@ package base58 import ( "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/crc8" + "github.com/pkg/errors" "math/big" "strings" - "github.com/pkg/errors" ) const ( @@ -152,27 +152,27 @@ func Base58EncodeToString(currency string, b common.Address) string { return strAddr + strCrc } -func Base58DecodeToAddress(strData string) (common.Address,error) { +func Base58DecodeToAddress(strData string) (common.Address, error) { strData = strings.TrimSpace(strData) if strData == "" { - return common.Address{},errors.New("input address invalid") + return common.Address{}, errors.New("input address invalid") } if !strings.Contains(strData, ".") { - return common.Address{},errors.New("input address invalid") + return common.Address{}, errors.New("input address invalid") } currency := strings.Split(strData, ".")[0] - if !common.IsValidityManCurrency(currency){ - return common.Address{},errors.New("input address invalid") + if !common.IsValidityManCurrency(currency) { + return common.Address{}, errors.New("input address invalid") } crc := strData[len(strData)-1] crc1 := crc8.CalCRC8([]byte(strData[0 : len(strData)-1])) strCrc := EncodeInt(crc1 % 58) - if strCrc != string(crc){ - return common.Address{},errors.New("input address invalid") + if strCrc != string(crc) { + return common.Address{}, errors.New("input address invalid") } tmpaddres := strings.Split(strData, ".")[1] addres := Decode(tmpaddres[0 : len(tmpaddres)-1]) //最后一位为crc%58 - return common.BytesToAddress(addres),nil + return common.BytesToAddress(addres), nil } diff --git a/baseinterface/election.go b/baseinterface/election.go index 2ad313ac..45681364 100644 --- a/baseinterface/election.go +++ b/baseinterface/election.go @@ -4,6 +4,7 @@ package baseinterface import ( + "github.com/MatrixAINetwork/go-matrix/core/state" "github.com/MatrixAINetwork/go-matrix/election/support" "github.com/MatrixAINetwork/go-matrix/mc" ) @@ -32,7 +33,7 @@ func NewElect(ElectPlugs string) ElectionInterface { type ElectionInterface interface { MinerTopGen(*mc.MasterMinerReElectionReqMsg) *mc.MasterMinerReElectionRsp - ValidatorTopGen(*mc.MasterValidatorReElectionReqMsg) *mc.MasterValidatorReElectionRsq + ValidatorTopGen(*mc.MasterValidatorReElectionReqMsg, *state.StateDBManage) *mc.MasterValidatorReElectionRsq ToPoUpdate(support.AllNative, *mc.TopologyGraph) []mc.Alternative // PrimarylistUpdate([]mc.TopologyNodeInfo, []mc.TopologyNodeInfo, []mc.TopologyNodeInfo, mc.TopologyNodeInfo, int) ([]mc.TopologyNodeInfo, []mc.TopologyNodeInfo, []mc.TopologyNodeInfo) } diff --git a/blkgenor/process_header.go b/blkgenor/process_header.go index b9a064e2..fa07ca54 100644 --- a/blkgenor/process_header.go +++ b/blkgenor/process_header.go @@ -103,7 +103,7 @@ func (p *Process) sendHeaderVerifyReq(header *types.Header, txsCode []*common.Re TxsCode: txsCode, ConsensusTurn: p.consensusTurn, OnlineConsensusResults: onlineConsensusResults, - From: ca.GetSignAddress(), + From: ca.GetSignAddress(), } //send to local block verify module localBlock := &mc.LocalBlockVerifyConsensusReq{BlkVerifyConsensusReq: p2pBlock, OriginalTxs: originalTxs, FinalTxs: finalTxs, Receipts: receipts, State: stateDB} diff --git a/blkverify/recovery.go b/blkverify/recovery.go index f9e02cac..fa0ccc67 100644 --- a/blkverify/recovery.go +++ b/blkverify/recovery.go @@ -154,7 +154,7 @@ func encodeVerifiedBlock(req *mc.HD_BlkConsensusReqMsg, txs []types.CoinSelfTran if req == nil { return nil, errors.New("req msg is nil") } - txss:=types.GetTX(txs) + txss := types.GetTX(txs) txSize := req.TxsCodeCount() if txSize != len(txss) { return nil, errors.New("txs count is not match txCodes count") diff --git a/common/types.go b/common/types.go index aabfee89..d0a5b39d 100644 --- a/common/types.go +++ b/common/types.go @@ -471,10 +471,10 @@ const ( ) var ( - WhiteAddrlist = [1]Address{InterestRewardAddress} - RewardAccounts = [5]Address{BlkMinerRewardAddress, BlkValidatorRewardAddress, TxGasRewardAddress, LotteryRewardAddress, InterestRewardAddress} + WhiteAddrlist = [1]Address{InterestRewardAddress} + RewardAccounts = [5]Address{BlkMinerRewardAddress, BlkValidatorRewardAddress, TxGasRewardAddress, LotteryRewardAddress, InterestRewardAddress} ConsensusAccounts []Address - BlackList []Address + BlackList []Address BlackListString []string WorkPath string ) @@ -515,10 +515,10 @@ type EntrustType struct { EnstrustSetType byte //0-按高度委托,1-按时间委托,2-按次数委托 //委托限制 - StartHeight uint64 //委托起始高度 - EndHeight uint64 //委托结束高度 - StartTime uint64 - EndTime uint64 + StartHeight uint64 //委托起始高度 + EndHeight uint64 //委托结束高度 + StartTime uint64 + EndTime uint64 EntrustCount uint32 //委托次数 } @@ -531,7 +531,7 @@ type AuthType struct { EndHeight uint64 //委托结束高度 StartTime uint64 EndTime uint64 - EntrustCount uint32 //授权委托次数 + EntrustCount uint32 //授权委托次数 } type CoinRoot struct { @@ -558,7 +558,7 @@ type SMakeCoin struct { PackNum uint64 CoinAddress Address //CoinTotal *big.Int //总发行量 - PayCoinType string + PayCoinType string } type BroadTxkey struct { @@ -705,4 +705,25 @@ type CoinConfig struct { //PayCoinType string `json:"PayCoinType"` //发放币种 } -const COINPREFIX string = "ms_" \ No newline at end of file +const COINPREFIX string = "ms_" + +type LinkInfo struct { + Sbs uint64 + Bn uint64 + Bt uint64 +} + +func IsGreaterLink(linkA, linkB LinkInfo) bool { + if linkA.Sbs > linkB.Sbs { + return true + } else if linkA.Sbs == linkB.Sbs { + if linkA.Bn > linkB.Bn { + return true + } else if linkA.Bn == linkB.Bn { + if linkA.Bt > linkB.Bt { + return true + } + } + } + return false +} diff --git a/consensus/blkmanage/common.go b/consensus/blkmanage/common.go index f403f0cd..d0e263cb 100644 --- a/consensus/blkmanage/common.go +++ b/consensus/blkmanage/common.go @@ -145,6 +145,10 @@ func New(support BlKSupport) (*ManBlkManage, error) { obj.RegisterManBLkPlugs(CommonBlk, manparams.VersionBeta, manCommonplug) obj.RegisterManBLkPlugs(BroadcastBlk, manparams.VersionBeta, manBcplug) + + obj.RegisterManBLkPlugs(CommonBlk, manparams.VersionGamma, manCommonplug) + + obj.RegisterManBLkPlugs(BroadcastBlk, manparams.VersionGamma, manBcplug) return obj, nil } @@ -153,20 +157,20 @@ func (bd *ManBlkManage) RegisterManBLkPlugs(types string, version string, plug M } func (bd *ManBlkManage) ProduceBlockVersion(num uint64, preVersion string) string { - //if num == manparams.VersionNumBeta { - // return manparams.VersionBeta - //} + if num == manparams.VersionNumGamma { + return manparams.VersionGamma + } return preVersion } func (bd *ManBlkManage) VerifyBlockVersion(num uint64, curVersion string, preVersion string) error { - /*if num == manparams.VersionNumBeta { - if curVersion != manparams.VersionBeta { + if num == manparams.VersionNumGamma { + if manparams.VersionCmp(curVersion, manparams.VersionGamma) != 0 { return errors.New("版本号异常") } else { return nil } - } else*/if curVersion != preVersion { + } else if curVersion != preVersion { return errors.New("版本号异常,不等于父区块版本号") } return nil diff --git a/consensus/blkmanage/manbcblk.go b/consensus/blkmanage/manbcblk.go index b33c6817..d33ef13e 100644 --- a/consensus/blkmanage/manbcblk.go +++ b/consensus/blkmanage/manbcblk.go @@ -58,7 +58,7 @@ func (bd *ManBCBlkPlug) Prepare(version string, support BlKSupport, interval *mc bd.baseInterface.setNumber(originHeader, num) bd.baseInterface.setGasLimit(originHeader, parent) bd.baseInterface.setExtra(originHeader) - onlineConsensusResults, _ := bd.baseInterface.setTopology(support, parent.Hash(), originHeader, interval, num) + onlineConsensusResults, _ := bd.baseInterface.setTopology(support, version, parent.Hash(), originHeader, interval, num) bd.baseInterface.setSignatures(originHeader) err = bd.setBCVrf(support, parent, originHeader) if nil != err { @@ -126,6 +126,11 @@ func (bd *ManBCBlkPlug) ProcessState(support BlKSupport, header *types.Header, a return nil, nil, nil, nil, nil, nil, err } + if err = support.BlockChain().ProcessStateVersionSwitch(header.Number.Uint64(), work.State); err != nil { + log.ERROR(LogManBlk, "状态树版本号切换更新状态树", err, "高度", header.Number.Uint64()) + return nil, nil, nil, nil, nil, nil, err + } + mapTxs := support.TxPool().GetAllSpecialTxs() Txs := make([]types.SelfTransaction, 0) for _, txs := range mapTxs { @@ -173,7 +178,7 @@ func (bd *ManBCBlkPlug) VerifyHeader(version string, support BlKSupport, header } onlineConsensusResults := make([]*mc.HD_OnlineConsensusVoteResultMsg, 0) - if err := support.ReElection().VerifyNetTopology(header, onlineConsensusResults); err != nil { + if err := support.ReElection().VerifyNetTopology(version, header, onlineConsensusResults); err != nil { log.ERROR(LogManBlk, "验证拓扑信息失败", err, "高度", header.Number.Uint64()) return nil, err } @@ -205,6 +210,10 @@ func (bd *ManBCBlkPlug) VerifyTxsAndState(support BlKSupport, verifyHeader *type log.ERROR(LogManBlk, "状态树更新版本号失败", err, "高度", verifyHeader.Number.Uint64()) return nil, nil, nil, nil, err } + if err = support.BlockChain().ProcessStateVersionSwitch(verifyHeader.Number.Uint64(), work.State); err != nil { + log.ERROR(LogManBlk, "状态树版本号切换更新状态树", err, "高度", verifyHeader.Number.Uint64()) + return nil, nil, nil, nil, err + } //执行交易 work.ProcessBroadcastTransactions(support.EventMux(), verifyTxs) @@ -213,7 +222,7 @@ func (bd *ManBCBlkPlug) VerifyTxsAndState(support BlKSupport, verifyHeader *type currblock := types.MakeCurencyBlock(retTxs, work.Receipts, nil) // 运行matrix状态树 block := types.NewBlock(verifyHeader, currblock, nil) - if err := support.BlockChain().ProcessMatrixState(block,string(parent.Version()), work.State); err != nil { + if err := support.BlockChain().ProcessMatrixState(block, string(parent.Version()), work.State); err != nil { log.ERROR(LogManBlk, "广播挖矿结果验证, matrix 状态树运行错误", err) return nil, nil, nil, nil, err } diff --git a/consensus/blkmanage/manblk.go b/consensus/blkmanage/manblk.go index 5efb53bc..c0c7ea31 100644 --- a/consensus/blkmanage/manblk.go +++ b/consensus/blkmanage/manblk.go @@ -71,8 +71,8 @@ func (p *ManBlkBasePlug) setVersion(header *types.Header, parent *types.Block, v func (p *ManBlkBasePlug) setSignatures(header *types.Header) { header.Signatures = make([]common.Signature, 0) } -func (bd *ManBlkBasePlug) setTopology(support BlKSupport, parentHash common.Hash, header *types.Header, interval *mc.BCIntervalInfo, num uint64) ([]*mc.HD_OnlineConsensusVoteResultMsg, error) { - NetTopology, onlineConsensusResults := support.ReElection().GetNetTopology(num, parentHash, interval) +func (bd *ManBlkBasePlug) setTopology(support BlKSupport, version string, parentHash common.Hash, header *types.Header, interval *mc.BCIntervalInfo, num uint64) ([]*mc.HD_OnlineConsensusVoteResultMsg, error) { + NetTopology, onlineConsensusResults := support.ReElection().GetNetTopology(num, version, parentHash, interval) if nil == NetTopology { NetTopology = &common.NetTopology{common.NetTopoTypeChange, nil} } @@ -187,7 +187,7 @@ func (bd *ManBlkBasePlug) Prepare(version string, support BlKSupport, interval * bd.setNumber(originHeader, num) bd.setGasLimit(originHeader, parent) bd.setExtra(originHeader) - onlineConsensusResults, _ := bd.setTopology(support, parent.Hash(), originHeader, interval, num) + onlineConsensusResults, _ := bd.setTopology(support, version, parent.Hash(), originHeader, interval, num) bd.setSignatures(originHeader) err = bd.setVrf(support, parent, originHeader) if nil != err { @@ -214,12 +214,18 @@ func (bd *ManBlkBasePlug) ProcessState(support BlKSupport, header *types.Header, log.ERROR(LogManBlk, "状态树更新版本号失败", err, "高度", header.Number.Uint64()) return nil, nil, nil, nil, nil, nil, err } + + if err = support.BlockChain().ProcessStateVersionSwitch(header.Number.Uint64(), work.State); err != nil { + log.ERROR(LogManBlk, "状态树版本号切换更新状态树", err, "高度", header.Number.Uint64()) + return nil, nil, nil, nil, nil, nil, err + } + upTimeMap, err := support.BlockChain().ProcessUpTime(work.State, header) if err != nil { log.ERROR(LogManBlk, "执行uptime错误", err, "高度", header.Number) return nil, nil, nil, nil, nil, nil, err } - err = support.BlockChain().ProcessBlockGProduceSlash(work.State, header) + err = support.BlockChain().ProcessBlockGProduceSlash(string(header.Version), work.State, header) if err != nil { log.ERROR(LogManBlk, "执行区块惩罚处理错误", err, "高度", header.Number) return nil, nil, nil, nil, nil, nil, err @@ -278,7 +284,7 @@ func (bd *ManBlkBasePlug) VerifyHeader(version string, support BlKSupport, heade } } - if err := support.ReElection().VerifyNetTopology(header, onlineConsensusResults); err != nil { + if err := support.ReElection().VerifyNetTopology(version, header, onlineConsensusResults); err != nil { log.ERROR(LogManBlk, "验证拓扑信息失败", err, "高度", header.Number.Uint64()) return nil, err } @@ -314,12 +320,17 @@ func (bd *ManBlkBasePlug) VerifyTxsAndState(support BlKSupport, verifyHeader *ty log.ERROR(LogManBlk, "状态树更新版本号失败", err, "高度", verifyHeader.Number.Uint64()) return nil, nil, nil, nil, err } + if err = support.BlockChain().ProcessStateVersionSwitch(verifyHeader.Number.Uint64(), work.State); err != nil { + log.ERROR(LogManBlk, "状态树版本号切换更新状态树", err, "高度", verifyHeader.Number.Uint64()) + return nil, nil, nil, nil, err + } + uptimeMap, err := support.BlockChain().ProcessUpTime(work.State, localHeader) if err != nil { log.Error(LogManBlk, "uptime处理错误", err) return nil, nil, nil, nil, err } - err = support.BlockChain().ProcessBlockGProduceSlash(work.State, localHeader) + err = support.BlockChain().ProcessBlockGProduceSlash(string(verifyHeader.Version), work.State, localHeader) if err != nil { log.Error(LogManBlk, "区块生产惩罚处理错误", err) return nil, nil, nil, nil, err @@ -344,8 +355,8 @@ func (bd *ManBlkBasePlug) VerifyTxsAndState(support BlKSupport, verifyHeader *ty return nil, nil, nil, nil, err } // 运行完matrix state后,生成root - ncb:=types.MakeCurencyBlock(finalTxs, work.Receipts, nil) - localBlock, err = support.BlockChain().Engine(verifyHeader.Version).Finalize(support.BlockChain(), localHeader, work.State, nil,ncb) + ncb := types.MakeCurencyBlock(finalTxs, work.Receipts, nil) + localBlock, err = support.BlockChain().Engine(verifyHeader.Version).Finalize(support.BlockChain(), localHeader, work.State, nil, ncb) if err != nil { log.ERROR(LogManBlk, "matrix状态验证,错误", "Failed to finalize block for sealing", "err", err) return nil, nil, nil, nil, err diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 08cf89b9..072aa821 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -13,7 +13,6 @@ import ( "sync" "time" - lru "github.com/hashicorp/golang-lru" "github.com/MatrixAINetwork/go-matrix/accounts" "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/common/hexutil" @@ -28,6 +27,7 @@ import ( "github.com/MatrixAINetwork/go-matrix/params" "github.com/MatrixAINetwork/go-matrix/rlp" "github.com/MatrixAINetwork/go-matrix/rpc" + lru "github.com/hashicorp/golang-lru" ) const ( @@ -648,7 +648,7 @@ func (c *Clique) Seal(chain consensus.ChainReader, header *types.Header, stop <- // CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty // that a new block should have based on the previous blocks in the chain and the // current signer. -func (c *Clique) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int { +func (c *Clique) CalcDifficulty(chain consensus.ChainReader, version string, time uint64, parent *types.Header) *big.Int { snap, err := c.snapshot(chain, parent.Number.Uint64(), parent.Hash(), nil) if err != nil { return nil diff --git a/consensus/clique/snapshot.go b/consensus/clique/snapshot.go index 7646158e..43648346 100644 --- a/consensus/clique/snapshot.go +++ b/consensus/clique/snapshot.go @@ -8,11 +8,11 @@ import ( "bytes" "encoding/json" - lru "github.com/hashicorp/golang-lru" "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/core/types" "github.com/MatrixAINetwork/go-matrix/mandb" "github.com/MatrixAINetwork/go-matrix/params" + lru "github.com/hashicorp/golang-lru" ) // Vote represents a single vote that an authorized signer made to modify the diff --git a/consensus/consensus.go b/consensus/consensus.go index aa366f37..ed94f160 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -85,7 +85,7 @@ type Engine interface { // CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty // that a new block should have. - CalcDifficulty(chain ChainReader, time uint64, parent *types.Header) *big.Int + CalcDifficulty(chain ChainReader, version string, time uint64, parent *types.Header) *big.Int // APIs returns the RPC APIs this consensus engine provides. APIs(chain ChainReader) []rpc.API diff --git a/consensus/manash/algorithm_test.go b/consensus/manash/algorithm_test.go index e3bbf879..db8a146c 100644 --- a/consensus/manash/algorithm_test.go +++ b/consensus/manash/algorithm_test.go @@ -684,20 +684,20 @@ func TestConcurrentDiskCacheGeneration(t *testing.T) { // Define a heavy enough block, one from mainnet should do block := types.NewBlockWithHeader(&types.Header{ - Number: big.NewInt(3311058), - ParentHash: common.HexToHash("0xd783efa4d392943503f28438ad5830b2d5964696ffc285f338585e9fe0a37a05"), - UncleHash: common.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"), - Coinbase: common.HexToAddress("0xc0ea08a2d404d3172d2add29a45be56da40e2949"), + Number: big.NewInt(3311058), + ParentHash: common.HexToHash("0xd783efa4d392943503f28438ad5830b2d5964696ffc285f338585e9fe0a37a05"), + UncleHash: common.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"), + Coinbase: common.HexToAddress("0xc0ea08a2d404d3172d2add29a45be56da40e2949"), //Root: common.HexToHash("0x77d14e10470b5850332524f8cd6f69ad21f070ce92dca33ab2858300242ef2f1"), //TxHash: common.HexToHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"), //ReceiptHash: common.HexToHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"), - Difficulty: big.NewInt(167925187834220), - GasLimit: 4015682, - GasUsed: 0, - Time: big.NewInt(1488928920), - Extra: []byte("www.bw.com"), - MixDigest: common.HexToHash("0x3e140b0784516af5e5ec6730f2fb20cca22f32be399b9e4ad77d32541f798cd0"), - Nonce: types.EncodeNonce(0xf400cd0006070c49), + Difficulty: big.NewInt(167925187834220), + GasLimit: 4015682, + GasUsed: 0, + Time: big.NewInt(1488928920), + Extra: []byte("www.bw.com"), + MixDigest: common.HexToHash("0x3e140b0784516af5e5ec6730f2fb20cca22f32be399b9e4ad77d32541f798cd0"), + Nonce: types.EncodeNonce(0xf400cd0006070c49), }) // Simulate multiple processes sharing the same datadir var pend sync.WaitGroup diff --git a/consensus/manash/consensus.go b/consensus/manash/consensus.go index a1c6e5cd..9dc53749 100644 --- a/consensus/manash/consensus.go +++ b/consensus/manash/consensus.go @@ -12,6 +12,8 @@ import ( "runtime" "time" + "github.com/MatrixAINetwork/go-matrix/params/manparams" + "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/common/math" "github.com/MatrixAINetwork/go-matrix/consensus" @@ -238,7 +240,7 @@ func (manash *Manash) verifyHeader(chain consensus.ChainReader, header, parent * // super header don't verify difficulty if header.IsSuperHeader() == false { // Verify the block's difficulty based in it's timestamp and parent's difficulty - expected := manash.CalcDifficulty(chain, header.Time.Uint64(), parent) + expected := manash.CalcDifficulty(chain, string(header.Version), header.Time.Uint64(), parent) if expected.Cmp(header.Difficulty) != 0 { return fmt.Errorf("invalid difficulty: have %v, want %v", header.Difficulty, expected) @@ -288,20 +290,20 @@ func (manash *Manash) verifyHeader(chain consensus.ChainReader, header, parent * // CalcDifficulty is the difficulty adjustment algorithm. It returns // the difficulty that a new block should have when created at time // given the parent block's time and difficulty. -func (manash *Manash) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int { - return CalcDifficulty(chain.Config(), time, parent) +func (manash *Manash) CalcDifficulty(chain consensus.ChainReader, curVersion string, time uint64, parent *types.Header) *big.Int { + return CalcDifficulty(chain.Config(), curVersion, time, parent) } // CalcDifficulty is the difficulty adjustment algorithm. It returns // the difficulty that a new block should have when created at time // given the parent block's time and difficulty. -func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int { +func CalcDifficulty(config *params.ChainConfig, curVersion string, time uint64, parent *types.Header) *big.Int { logger := log.New("CalcDifficulty block", parent.Number) next := new(big.Int).Add(parent.Number, big1) switch { case config.IsByzantium(next): logger.Info("config.IsByzantium") - return calcDifficultyByzantium(time, parent) + return calcDifficultyByzantium(curVersion, time, parent) case config.IsHomestead(next): logger.Info("config.IsHomestead") return calcDifficultyHomestead(time, parent) @@ -325,7 +327,7 @@ var ( // calcDifficultyByzantium is the difficulty adjustment algorithm. It returns // the difficulty that a new block should have when created at time given the // parent block's time and difficulty. The calculation uses the Byzantium rules. -func calcDifficultyByzantium(time uint64, parent *types.Header) *big.Int { +func calcDifficultyByzantium(curVersion string, time uint64, parent *types.Header) *big.Int { // https://github.com/MatrixAINetwork/EIPs/issues/100. // algorithm: // diff = (parent_diff + @@ -341,7 +343,14 @@ func calcDifficultyByzantium(time uint64, parent *types.Header) *big.Int { logger := log.New("CalcDifficulty diff", parent.Difficulty) // (2 if len(parent_uncles) else 1) - (block_timestamp - parent_timestamp) // 9 x.Sub(bigTime, bigParentTime) - x.Div(x, params.DurationLimit) + var durationLimit *big.Int + if manparams.VersionCmp(curVersion, manparams.VersionGamma) == 0 { + durationLimit = params.VersionGammaDurationLimit + } else { + durationLimit = params.DurationLimit + } + logger.Info("CalcDifficulty diff", "duration", durationLimit.String()) + x.Div(x, durationLimit) if parent.UncleHash == types.EmptyUncleHash { x.Sub(big1, x) } else { @@ -520,7 +529,7 @@ func (manash *Manash) Prepare(chain consensus.ChainReader, header *types.Header) if parent == nil { return consensus.ErrUnknownAncestor } - header.Difficulty = manash.CalcDifficulty(chain, header.Time.Uint64(), parent) + header.Difficulty = manash.CalcDifficulty(chain, string(header.Version), header.Time.Uint64(), parent) return nil } diff --git a/consensus/manash/manash.go b/consensus/manash/manash.go index 1f19fab2..76232dc2 100644 --- a/consensus/manash/manash.go +++ b/consensus/manash/manash.go @@ -20,12 +20,12 @@ import ( "time" "unsafe" - mmap "github.com/edsrzf/mmap-go" - "github.com/hashicorp/golang-lru/simplelru" "github.com/MatrixAINetwork/go-matrix/consensus" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/metrics" "github.com/MatrixAINetwork/go-matrix/rpc" + mmap "github.com/edsrzf/mmap-go" + "github.com/hashicorp/golang-lru/simplelru" ) var ErrInvalidDumpMagic = errors.New("invalid dump magic") diff --git a/consensus/mtxdpos/mtxdpos.go b/consensus/mtxdpos/mtxdpos.go index 2e4175eb..8a5a8edd 100644 --- a/consensus/mtxdpos/mtxdpos.go +++ b/consensus/mtxdpos/mtxdpos.go @@ -140,7 +140,7 @@ func (md *MtxDPOS) CheckSuperBlock(reader consensus.StateReader, header *types.H targetCount := md.calcSuperNodeTarget(len(accounts)) if len(header.Signatures) < targetCount { - log.Error("共识引擎", "超级区块签名数量不足 size", len(header.Version), "target", targetCount) + log.Error("共识引擎", "超级区块签名数量不足 size", len(header.Signatures), "target", targetCount) return errSuperBlockSignCount } verifiedSigh := md.verifyHashWithSuperNodes(header.HashNoSigns(), header.Signatures, accounts) diff --git a/core/block_validator.go b/core/block_validator.go index 695f1dad..f468c65a 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -84,8 +84,8 @@ func (v *BlockValidator) ValidateState(block, parent *types.Block, statedb *stat // Validate the received block's bloom with the one derived from the generated receipts. // For valid blocks this should always validate to true. for _, currencie := range block.Currencies() { - for _,cr:=range header.Roots{ - if cr.Cointyp==currencie.CurrencyName { + for _, cr := range header.Roots { + if cr.Cointyp == currencie.CurrencyName { rbloom := types.CreateBloom(currencie.Receipts.GetReceipts()) receiptSha := types.DeriveShaHash(currencie.Receipts.RsHashs) if rbloom != cr.Bloom { @@ -104,10 +104,10 @@ func (v *BlockValidator) ValidateState(block, parent *types.Block, statedb *stat var root []common.CoinRoot root, _ = statedb.IntermediateRoot(v.config.IsEIP158(header.Number)) isok := false - for _,cr := range root{ - for _,br := range block.Root(){ - if cr.Cointyp == br.Cointyp{ - if cr.Root != br.Root{ + for _, cr := range root { + for _, br := range block.Root() { + if cr.Cointyp == br.Cointyp { + if cr.Root != br.Root { isok = true } } diff --git a/core/blockchain.go b/core/blockchain.go index 2bd9b634..7753226b 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1176,20 +1176,22 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, state *state.State return NonStatTy, err } - localSbs, err := bc.GetSuperBlockSeq() - if nil != err { - log.Error("获取超级区块序号错误") - return NonStatTy, err - } - - //log.INFO("blockChain", "超级区块序号", remoteSuperBlkCfg.Seq) var reorg bool - if localSbs < remoteSuperBlkCfg.Seq { - reorg = true - } else if localSbs == remoteSuperBlkCfg.Seq { - reorg = externTd.Cmp(localTd) > 0 + if manparams.CanSwitchGammaCanonicalChain(time.Now().Unix()) { + reorg = bc.isGammaCanonicalChain(remoteSuperBlkCfg, block, currentBlock) } else { - reorg = false + localSbs, err := bc.GetSuperBlockSeq() + if nil != err { + log.Error("获取超级区块序号错误") + return NonStatTy, err + } + if localSbs < remoteSuperBlkCfg.Seq { + reorg = true + } else if localSbs == remoteSuperBlkCfg.Seq { + reorg = externTd.Cmp(localTd) > 0 + } else { + reorg = false + } } currentBlock = bc.CurrentBlock() @@ -1222,6 +1224,41 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, state *state.State return status, nil } +func (bc *BlockChain) isGammaCanonicalChain(superBlkCfg *mc.SuperBlkCfg, block *types.Block, currentBlock *types.Block) bool { + currentSbs, err := bc.GetSuperBlockSeq() + if nil != err { + log.Error("获取超级区块序号错误", "err", err) + return false + } + if currentSbs < superBlkCfg.Seq { + return true + } else if currentSbs > superBlkCfg.Seq { + return false + } + + // 超级区块序号相同,对比高度 + currentNumber := currentBlock.NumberU64() + newNumber := block.NumberU64() + if currentNumber < newNumber { + return true + } else if currentNumber > newNumber { + return false + } + + // 高度相同,对比区块时间 + currentHeaderTime := currentBlock.Time().Uint64() + newHeaderTime := block.Time().Uint64() + if currentHeaderTime < newHeaderTime { + log.Info("isCanonicalChain", "当前header time", currentHeaderTime, "当前区块", currentBlock.Hash().TerminalString(), + "新header time", newHeaderTime, "新区块", block.Hash().TerminalString()) + return true + } else if currentHeaderTime > newHeaderTime { + return false + } + + return false +} + func (bc *BlockChain) superBlkRewind(block *types.Block, oldBlock *types.Block) { if oldBlock.NumberU64() >= block.NumberU64() { log.INFO(ModuleName, "rewind to", block.NumberU64()-1) @@ -2108,7 +2145,7 @@ func (bc *BlockChain) processSuperBlockState(block *types.Block, stateDB *state. for _, currencie := range block.Currencies() { if currencie.CurrencyName != params.MAN_COIN { errors.Errorf("super block's txs CurrencyName not Matrix err", currencie.CurrencyName) - log.Error("super block error","super block's txs CurrencyName not Matrix err",currencie.CurrencyName) + log.Error("super block error", "super block's txs CurrencyName not Matrix err", currencie.CurrencyName) continue } txs := currencie.Transactions.GetTransactions() diff --git a/core/blockchain_state.go b/core/blockchain_state.go index 4f4d0f75..13bbb194 100644 --- a/core/blockchain_state.go +++ b/core/blockchain_state.go @@ -1,3 +1,7 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php + package core import ( @@ -7,6 +11,8 @@ import ( "github.com/MatrixAINetwork/go-matrix/core/types" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/MatrixAINetwork/go-matrix/params/manparams" + "github.com/MatrixAINetwork/go-matrix/reward/util" "github.com/pkg/errors" ) @@ -18,18 +24,18 @@ func (bc *BlockChain) State() (*state.StateDBManage, error) { // StateAt returns a new mutable state based on a particular point in time. func (bc *BlockChain) StateAt(root []common.CoinRoot) (*state.StateDBManage, error) { return state.NewStateDBManage(root, bc.db, bc.stateCache) - //return bc.getStateCache(root) + //return bc.getStateCache(root) } -func (bc *BlockChain) getStateCache(root []common.CoinRoot)(*state.StateDBManage, error){ +func (bc *BlockChain) getStateCache(root []common.CoinRoot) (*state.StateDBManage, error) { hash := types.RlpHash(root) - if stCache,exist := bc.depCache.Get(hash);exist{ - return stCache.(*state.StateDBManage),nil + if stCache, exist := bc.depCache.Get(hash); exist { + return stCache.(*state.StateDBManage), nil } st, err := state.NewStateDBManage(root, bc.db, bc.stateCache) if err == nil { - bc.depCache.Add(hash,st) + bc.depCache.Add(hash, st) } - return st,err + return st, err } func (bc *BlockChain) StateAtNumber(number uint64) (*state.StateDBManage, error) { block := bc.GetBlockByNumber(number) @@ -55,6 +61,98 @@ func (bc *BlockChain) ProcessStateVersion(version []byte, st *state.StateDBManag return bc.matrixProcessor.ProcessStateVersion(version, st) } +func (bd *BlockChain) ProcessStateVersionSwitch(num uint64, stateDB *state.StateDBManage) error { + //提前一个块设置各自算法引擎和配置,切换高度生效 + if num == manparams.VersionNumGamma-1 { + //出块超时和投票超时改为60秒和40秒 + electCfg, err := matrixstate.GetElectConfigInfo(stateDB) + if nil != err { + log.Crit("blockChain", "选举配置错误", err) + return err + } + err = matrixstate.SetElectConfigInfo(stateDB, &mc.ElectConfigInfo{ValidatorNum: electCfg.ValidatorNum, BackValidator: electCfg.BackValidator, ElectPlug: manparams.ElectPlug_layerdBSS}) + if nil != err { + log.Crit("blockChain", "选举引擎切换,错误", err) + return err + } + leaderCfg, err := matrixstate.GetLeaderConfig(stateDB) + if nil != err { + log.Crit("blockChain", "leader配置错误", err) + return err + } + err = matrixstate.SetLeaderConfig(stateDB, &mc.LeaderConfig{ParentMiningTime: 20, PosOutTime: 40, ReelectOutTime: 40, ReelectHandleInterval: leaderCfg.ReelectHandleInterval}) + if nil != err { + log.Crit("blockChain", "出块超时和投票超时改为60秒和40秒,错误", err) + return err + } + blkSlash, err := matrixstate.GetBlockProduceSlashCfg(stateDB) + if nil != err { + log.Crit("blockChain", "读取惩罚配置错误", err) + return err + } + err = matrixstate.SetBlockProduceSlashCfg(stateDB, &mc.BlockProduceSlashCfg{Switcher: blkSlash.Switcher, LowTHR: blkSlash.LowTHR, ProhibitCycleNum: 10}) + if nil != err { + log.Crit("blockChain", "惩罚配置错误", err) + return err + } + blkRewardCfg, err := matrixstate.GetBlkRewardCfg(stateDB) + if nil != err { + log.Crit("blockChain", "选举配置错误", err) + return err + } + //每个块的奖励改为15MAN + err = matrixstate.SetBlkRewardCfg(stateDB, &mc.BlkRewardCfg{ + MinerMount: 4800, //放大1000倍 + MinerAttenuationRate: blkRewardCfg.MinerAttenuationRate, + MinerAttenuationNum: 3000000, + ValidatorMount: 8000, //放大1000倍 + ValidatorAttenuationRate: blkRewardCfg.ValidatorAttenuationRate, + ValidatorAttenuationNum: 3000000, + RewardRate: mc.RewardRateCfg{ + MinerOutRate: 4000, //出块矿工奖励 + ElectedMinerRate: 5000, //当选矿工奖励 + FoundationMinerRate: 1000, //基金会网络奖励 + + LeaderRate: 2500, //出块验证者(leader)奖励 + ElectedValidatorsRate: 6500, //当选验证者奖励 + FoundationValidatorRate: 1000, //基金会网络奖励 + + OriginElectOfflineRate: blkRewardCfg.RewardRate.OriginElectOfflineRate, //初选下线验证者奖励 + BackupRewardRate: blkRewardCfg.RewardRate.BackupRewardRate, //当前替补验证者奖励 + }, + }) + if nil != err { + log.Crit("blockChain", "固定区块奖励修改为原来的1.5倍", err) + return err + } + interestCfg, err := matrixstate.GetInterestCfg(stateDB) + if nil != err { + log.Crit("blockChain", "选举配置错误", err) + return err + } + err = matrixstate.SetInterestCfg(stateDB, &mc.InterestCfg{ + RewardMount: 3200, //放大1000倍 + AttenuationRate: interestCfg.AttenuationRate, + AttenuationPeriod: 3000000, + PayInterval: interestCfg.PayInterval, + }) + if nil != err { + log.Crit("blockChain", "利息奖励修改为原来的1.5倍", err) + return err + } + err = matrixstate.SetBlkCalc(stateDB, util.CalcGamma) + if nil != err { + log.Crit("blockChain", "固定区块奖励引擎设置错误", err) + return err + } + err = matrixstate.SetInterestCalc(stateDB, util.CalcGamma) + if nil != err { + log.Crit("blockChain", "利息奖励引擎设置错误", err) + return err + } + } + return nil +} func (bc *BlockChain) ProcessMatrixState(block *types.Block, preVersion string, state *state.StateDBManage) error { return bc.matrixProcessor.ProcessMatrixState(block, preVersion, state) } @@ -206,7 +304,7 @@ func (bc *BlockChain) GetSuperBlockInfo() (*mc.SuperBlkCfg, error) { return matrixstate.GetVersionInfo(st), nil }*/ -func ProduceBroadcastIntervalData(block *types.Block, readFn PreStateReadFn) (interface{}, error) { +func ProduceBroadcastIntervalData(block *types.Block, state *state.StateDBManage, readFn PreStateReadFn) (interface{}, error) { bciData, err := readFn(mc.MSKeyBroadcastInterval) if err != nil { log.Error("ProduceBroadcastIntervalData", "read pre broadcast interval err", err) diff --git a/core/blockproduceslash_test.go b/core/blockproduceslash_test.go index e45ca13a..d4088d08 100644 --- a/core/blockproduceslash_test.go +++ b/core/blockproduceslash_test.go @@ -1,7 +1,14 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php + package core import ( "fmt" + "math/big" + "testing" + "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/consensus/manash" "github.com/MatrixAINetwork/go-matrix/core/matrixstate" @@ -11,8 +18,6 @@ import ( "github.com/MatrixAINetwork/go-matrix/mc" "github.com/MatrixAINetwork/go-matrix/params" "github.com/MatrixAINetwork/go-matrix/params/manparams" - "math/big" - "testing" ) func TestReadSlashParacheckCfg(t *testing.T) { @@ -345,7 +350,7 @@ func Test_GetBlackList(t *testing.T) { func Test_BlackListMaitainCase0(t *testing.T) { //lift ban Test blklist := genTestBlackList(100) - handle := NewBlackListMaintain(blklist.BlackList) + handle := NewBlackListMaintainA(blklist.BlackList) if len(handle.blacklist) == 0 { t.Errorf("add list wrong") } @@ -361,7 +366,7 @@ func Test_BlackListMaitainCase1(t *testing.T) { for i := 0; i < 100; i++ { blackList.BlackList = append(blackList.BlackList, mc.UserBlockProduceSlash{common.BigToAddress(big.NewInt(int64(i))), uint16(i%3) + 1}) } - handle := NewBlackListMaintain(blackList.BlackList) + handle := NewBlackListMaintainA(blackList.BlackList) handle.CounterMaintain() for i := 0; i < 100; i++ { if handle.blacklist[i].ProhibitCycleCounter != uint16(i%3) { @@ -377,7 +382,7 @@ func Test_BlackListAddBlackListCase0(t *testing.T) { for i := 0; i < 100; i++ { blackList.BlackList = append(blackList.BlackList, mc.UserBlockProduceSlash{common.BigToAddress(big.NewInt(int64(i))), uint16(i%3) + 1}) } - handle := NewBlackListMaintain(blackList.BlackList) + handle := NewBlackListMaintainA(blackList.BlackList) var statsList []mc.UserBlockProduceNum statsList = append(statsList, mc.UserBlockProduceNum{common.BigToAddress(big.NewInt(1)), 1}) @@ -394,7 +399,7 @@ func Test_BlackListAddBlackListCase1(t *testing.T) { for i := 0; i < 100; i++ { blackList.BlackList = append(blackList.BlackList, mc.UserBlockProduceSlash{common.BigToAddress(big.NewInt(int64(i))), uint16(i%3) + 1}) } - handle := NewBlackListMaintain(blackList.BlackList) + handle := NewBlackListMaintainA(blackList.BlackList) var statsList []mc.UserBlockProduceNum statsList = append(statsList, mc.UserBlockProduceNum{common.BigToAddress(big.NewInt(1)), 1}) @@ -419,7 +424,7 @@ func Test_BlackListAddBlackListCase2(t *testing.T) { for i := 0; i < 100; i++ { blackList.BlackList = append(blackList.BlackList, mc.UserBlockProduceSlash{common.BigToAddress(big.NewInt(int64(i))), uint16(i%3) + 1}) } - handle := NewBlackListMaintain(blackList.BlackList) + handle := NewBlackListMaintainA(blackList.BlackList) var statsList []mc.UserBlockProduceNum statsList = append(statsList, mc.UserBlockProduceNum{common.BigToAddress(big.NewInt(100)), 1}) diff --git a/core/blockproducestats.go b/core/blockproducestats.go index fb7362c0..104bb6a2 100644 --- a/core/blockproducestats.go +++ b/core/blockproducestats.go @@ -1,6 +1,11 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php + package core import ( + "github.com/MatrixAINetwork/go-matrix/ca" "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/core/matrixstate" "github.com/MatrixAINetwork/go-matrix/core/state" @@ -32,7 +37,7 @@ func (bc *BlockChain) slashCfgProc(state *state.StateDBManage, num uint64) (*mc. return slashCfg, true, nil } } -func (bc *BlockChain) ProcessBlockGProduceSlash(state *state.StateDBManage, header *types.Header) error { +func (bc *BlockChain) ProcessBlockGProduceSlash(version string, state *state.StateDBManage, header *types.Header) error { if nil == state { return ErrStatePtrIsNil } @@ -65,23 +70,42 @@ func (bc *BlockChain) ProcessBlockGProduceSlash(state *state.StateDBManage, head statsListAddRecorder(state, statsList, header.Leader) statsListPrint(statsList) if ok := shouldBlockProduceSlash(state, header, slashCfg); ok { - preBlackList := bc.GetBlackList(state) - blackListPrint(preBlackList) - - var handleBlackList = NewBlackListMaintain(preBlackList.BlackList) - handleBlackList.CounterMaintain() - - handleBlackList.AddBlackList(statsList.StatsList, slashCfg) - log.Trace(ModuleName, "黑名单更新后状态,高度", header.Number.Uint64()) - blackListPrint(&mc.BlockProduceSlashBlackList{BlackList: handleBlackList.blacklist}) - if err := matrixstate.SetBlockProduceBlackList(state, &mc.BlockProduceSlashBlackList{BlackList: handleBlackList.blacklist}); err != nil { - log.Crit("State Write Err : ", mc.MSKeyBlockProduceBlackList) + if manparams.VersionCmp(version, manparams.VersionGamma) >= 0 { + bc.statsListToBlackListB(state, statsList, slashCfg, header) + } else { + bc.statsListToBlackListA(state, statsList, slashCfg, header) } } } return nil } + +func (bc *BlockChain) statsListToBlackListA(state *state.StateDBManage, statsList *mc.BlockProduceStats, slashCfg *mc.BlockProduceSlashCfg, header *types.Header) { + preBlackList := bc.GetBlackList(state) + blackListPrint(preBlackList) + var handleBlackList = NewBlackListMaintainA(preBlackList.BlackList) + handleBlackList.CounterMaintain() + handleBlackList.AddBlackListA(statsList.StatsList, slashCfg) + log.Trace(ModuleName, "黑名单更新后状态,高度", header.Number.Uint64()) + blackListPrint(&mc.BlockProduceSlashBlackList{BlackList: handleBlackList.blacklist}) + if err := matrixstate.SetBlockProduceBlackList(state, &mc.BlockProduceSlashBlackList{BlackList: handleBlackList.blacklist}); err != nil { + log.Crit("State Write Err : ", mc.MSKeyBlockProduceBlackList) + } +} +func (bc *BlockChain) statsListToBlackListB(state *state.StateDBManage, statsList *mc.BlockProduceStats, slashCfg *mc.BlockProduceSlashCfg, header *types.Header) { + preBlackList := bc.GetBlackList(state) + blackListPrint(preBlackList) + //新增退选后从黑名单移除 + var handleBlackList = NewBlackListMaintainB(header.ParentHash, preBlackList.BlackList) + //todo:选举更新状态树做减法 + handleBlackList.AddBlackListB(statsList.StatsList, slashCfg) + log.Trace(ModuleName, "黑名单更新后状态,高度", header.Number.Uint64()) + blackListPrint(&mc.BlockProduceSlashBlackList{BlackList: handleBlackList.blacklist}) + if err := matrixstate.SetBlockProduceBlackList(state, &mc.BlockProduceSlashBlackList{BlackList: handleBlackList.blacklist}); err != nil { + log.Crit("State Write Err : ", mc.MSKeyBlockProduceBlackList) + } +} func statsListPrint(stats *mc.BlockProduceStats) { for _, v := range stats.StatsList { log.Debug(ModuleName, "Address", v.Address.String(), "Produce Block Num", v.ProduceNum) @@ -271,7 +295,7 @@ type blacklistMaintain struct { blacklist []mc.UserBlockProduceSlash } -func NewBlackListMaintain(list []mc.UserBlockProduceSlash) *blacklistMaintain { +func NewBlackListMaintainA(list []mc.UserBlockProduceSlash) *blacklistMaintain { var bl = new(blacklistMaintain) for _, v := range list { @@ -282,6 +306,17 @@ func NewBlackListMaintain(list []mc.UserBlockProduceSlash) *blacklistMaintain { return bl } +func NewBlackListMaintainB(parentHash common.Hash, list []mc.UserBlockProduceSlash) *blacklistMaintain { + var bl = new(blacklistMaintain) + + for _, v := range list { + if v.ProhibitCycleCounter > 0 && searchExistDeposit(parentHash, v.Address) { + bl.blacklist = append(bl.blacklist, v) + } + } + return bl +} + func (bl *blacklistMaintain) CounterMaintain() { for i := 0; i < len(bl.blacklist); i++ { if 0 != bl.blacklist[i].ProhibitCycleCounter { @@ -290,6 +325,22 @@ func (bl *blacklistMaintain) CounterMaintain() { } } +func searchExistDeposit(parentHash common.Hash, target common.Address) bool { + + depoistlist, err := ca.GetElectedByHeightAndRoleByHash(parentHash, common.RoleValidator) + if nil != err { + log.ERROR(ModuleName, "读取验证者抵押列表错误", err) + return false + } + for _, v := range depoistlist { + if v.Address.Equal(target) { + return true + } + } + + return false +} + func searchExistAddress(statsList []mc.UserBlockProduceSlash, target common.Address) (int, bool) { for k, v := range statsList { @@ -300,7 +351,7 @@ func searchExistAddress(statsList []mc.UserBlockProduceSlash, target common.Addr return 0, false } -func (bl *blacklistMaintain) AddBlackList(statsList []mc.UserBlockProduceNum, slashCfg *mc.BlockProduceSlashCfg) { +func (bl *blacklistMaintain) AddBlackListA(statsList []mc.UserBlockProduceNum, slashCfg *mc.BlockProduceSlashCfg) { if nil == bl.blacklist { log.Warn(ModuleName, "blacklist Err", "Is Nil") bl.blacklist = make([]mc.UserBlockProduceSlash, 0) @@ -336,3 +387,40 @@ func (bl *blacklistMaintain) AddBlackList(statsList []mc.UserBlockProduceNum, sl } } } + +func (bl *blacklistMaintain) AddBlackListB(statsList []mc.UserBlockProduceNum, slashCfg *mc.BlockProduceSlashCfg) { + if nil == bl.blacklist { + log.Warn(ModuleName, "blacklist Err", "Is Nil") + bl.blacklist = make([]mc.UserBlockProduceSlash, 0) + } + + if nil == slashCfg { + log.Warn(ModuleName, "惩罚配置错误", "未配置") + return + } + + if false == slashCfg.Switcher { + bl.blacklist = make([]mc.UserBlockProduceSlash, 0) + return + } + + if nil == statsList { + log.Error(ModuleName, "统计列表错误", "未配置") + return + } + + if 0 == slashCfg.ProhibitCycleNum { + log.Warn(ModuleName, "禁止周期为", "0", "不加入黑名单") + return + } + for _, v := range statsList { + if v.ProduceNum >= slashCfg.LowTHR { + continue + } + if position, exist := searchExistAddress(bl.blacklist, v.Address); exist { + bl.blacklist[position].ProhibitCycleCounter = slashCfg.ProhibitCycleNum + } else { + bl.blacklist = append(bl.blacklist, mc.UserBlockProduceSlash{Address: v.Address, ProhibitCycleCounter: slashCfg.ProhibitCycleNum}) + } + } +} diff --git a/core/bloombits/generator.go b/core/bloombits/generator.go index bd1f2a2d..4504e72e 100644 --- a/core/bloombits/generator.go +++ b/core/bloombits/generator.go @@ -7,8 +7,8 @@ package bloombits import ( "errors" - "github.com/MatrixAINetwork/go-matrix/core/types" "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/core/types" ) // errSectionOutOfBounds is returned if the user tried to add more bloom filters @@ -50,7 +50,7 @@ func (b *Generator) AddBloom(index uint, root []common.CoinRoot) error { byteIndex := b.nextBit / 8 bitMask := byte(1) << byte(7-b.nextBit%8) - for _,bl := range root{ + for _, bl := range root { bloom := bl.Bloom for i := 0; i < types.BloomBitLength; i++ { bloomByteIndex := types.BloomByteLength - 1 - i/8 diff --git a/core/chain_makers.go b/core/chain_makers.go index 66b20d7c..defe15e6 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -86,7 +86,7 @@ func (b *BlockGen) AddTxWithChain(bc *BlockChain, tx *types.Transaction) { } b.statedb.Prepare(tx.Hash(), common.Hash{}, len(b.txs)) receipt, _, _, err := ApplyTransaction(b.config, bc, &b.header.Coinbase, b.gasPool, b.statedb, b.header, tx, &b.header.GasUsed, vm.Config{}) - if err != nil{ + if err != nil { panic(err) } b.txs = append(b.txs, tx) @@ -142,7 +142,7 @@ func (b *BlockGen) OffsetTime(seconds int64) { if b.header.Time.Cmp(b.parent.Header().Time) <= 0 { panic("block time out of range") } - b.header.Difficulty = b.engine.CalcDifficulty(b.chainReader, b.header.Time.Uint64(), b.parent.Header()) + b.header.Difficulty = b.engine.CalcDifficulty(b.chainReader, string(b.header.Version), b.header.Time.Uint64(), b.parent.Header()) } // GenerateChain creates a chain of n blocks. The first block's @@ -189,7 +189,7 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse } if b.engine != nil { - block, _ := b.engine.Finalize(b.chainReader, b.header, statedb, b.uncles,types.MakeCurencyBlock(nil,nil,nil) )//该文件专用于测试所以此处就写个空 + block, _ := b.engine.Finalize(b.chainReader, b.header, statedb, b.uncles, types.MakeCurencyBlock(nil, nil, nil)) //该文件专用于测试所以此处就写个空 // Write state changes to db root, _, err := statedb.Commit(config.IsEIP158(b.header.Number)) if err != nil { @@ -230,7 +230,7 @@ func makeHeader(chain consensus.ChainReader, parent *types.Block, state *state.S Sharding: make([]common.Coinbyte, len(sharding)), ParentHash: parent.Hash(), Coinbase: parent.Coinbase(), - Difficulty: engine.CalcDifficulty(chain, time.Uint64(), &types.Header{ + Difficulty: engine.CalcDifficulty(chain, string(parent.Header().Version), time.Uint64(), &types.Header{ Number: parent.Number(), Time: new(big.Int).Sub(time, big.NewInt(10)), Difficulty: parent.Difficulty(), diff --git a/core/gen_genesis.go b/core/gen_genesis.go index 410e2b76..8f0eb63a 100644 --- a/core/gen_genesis.go +++ b/core/gen_genesis.go @@ -23,8 +23,8 @@ type GenesisAddress common.Address // UnmarshalJSON parses a hash in hex syntax. func (a *GenesisAddress) UnmarshalJSON(input []byte) error { - addr,err := base58.Base58DecodeToAddress(string(input[1 : len(input)-1])) - if err != nil{ + addr, err := base58.Base58DecodeToAddress(string(input[1 : len(input)-1])) + if err != nil { return err } *a = GenesisAddress(addr) @@ -71,7 +71,7 @@ func (g Genesis) MarshalJSON() ([]byte, error) { ParentHash common.Hash `json:"parentHash"` Roots []common.CoinRoot `json:"stateRoot,omitempty"` Sharding []common.Coinbyte `json:"sharding,omitempty"` - Currencys map[string][]Genesiscurrencys `json:"currencys"` + Currencys map[string][]Genesiscurrencys `json:"currencys"` } var enc Genesis enc.Config = g.Config @@ -104,9 +104,9 @@ func (g Genesis) MarshalJSON() ([]byte, error) { enc.ParentHash = g.ParentHash enc.Roots = g.Roots enc.Sharding = g.Sharding - if g.Currencys != nil{ - enc.Currencys = make(map[string][]Genesiscurrencys,len(g.Currencys)) - for _,cn := range sortMapByString(g.Currencys){ + if g.Currencys != nil { + enc.Currencys = make(map[string][]Genesiscurrencys, len(g.Currencys)) + for _, cn := range sortMapByString(g.Currencys) { enc.Currencys[cn] = g.Currencys[cn] } } @@ -193,7 +193,7 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { ParentHash *common.Hash `json:"parentHash"` Roots *[]common.CoinRoot `json:"stateRoot,omitempty"` Sharding *[]common.Coinbyte `json:"sharding,omitempty"` - Currencys map[string][]Genesiscurrencys `json:"currencys"` + Currencys map[string][]Genesiscurrencys `json:"currencys"` } var dec Genesis if err := json.Unmarshal(input, &dec); err != nil { @@ -275,8 +275,8 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { if dec.Sharding != nil { g.Sharding = *dec.Sharding } - g.Currencys = make(map[string][]Genesiscurrencys,len(dec.Currencys)) - for _,cn := range sortMapByString(dec.Currencys){ + g.Currencys = make(map[string][]Genesiscurrencys, len(dec.Currencys)) + for _, cn := range sortMapByString(dec.Currencys) { g.Currencys[cn] = dec.Currencys[cn] } return nil diff --git a/core/genesis.go b/core/genesis.go index 92db0d4e..4b81484f 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -13,6 +13,7 @@ import ( "math/big" "strings" + "github.com/MatrixAINetwork/go-matrix/base58" "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/common/hexutil" "github.com/MatrixAINetwork/go-matrix/common/math" @@ -21,10 +22,9 @@ import ( "github.com/MatrixAINetwork/go-matrix/core/types" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/mandb" + "github.com/MatrixAINetwork/go-matrix/mc" "github.com/MatrixAINetwork/go-matrix/params" "github.com/MatrixAINetwork/go-matrix/rlp" - "github.com/MatrixAINetwork/go-matrix/mc" - "github.com/MatrixAINetwork/go-matrix/base58" "sort" ) @@ -58,22 +58,23 @@ type Genesis struct { MState *GenesisMState `json:"mstate" gencodec:"required"` // These fields are used for consensus tests. Please don't use them // in actual genesis blocks. - Number uint64 `json:"number"` - GasUsed uint64 `json:"gasUsed"` - ParentHash common.Hash `json:"parentHash"` - Roots []common.CoinRoot `json:"stateRoot" gencodec:"required"` - Sharding []common.Coinbyte `json:"sharding,omitempty"` + Number uint64 `json:"number"` + GasUsed uint64 `json:"gasUsed"` + ParentHash common.Hash `json:"parentHash"` + Roots []common.CoinRoot `json:"stateRoot" gencodec:"required"` + Sharding []common.Coinbyte `json:"sharding,omitempty"` Currencys map[string][]Genesiscurrencys `json:"currencys"` } type Genesiscurrencys struct { Account string - Quant *big.Int + Quant *big.Int } -func (gc Genesiscurrencys) MarshalJSON()([]byte, error){ + +func (gc Genesiscurrencys) MarshalJSON() ([]byte, error) { type Genesiscurrencys struct { - Account string `json:"Account" gencodec:"required"` - Quant *math.HexOrDecimal256 `json:"Quant" gencodec:"required"` + Account string `json:"Account" gencodec:"required"` + Quant *math.HexOrDecimal256 `json:"Quant" gencodec:"required"` } var enc Genesiscurrencys enc.Account = gc.Account @@ -82,8 +83,8 @@ func (gc Genesiscurrencys) MarshalJSON()([]byte, error){ } func (g *Genesiscurrencys) UnmarshalJSON(input []byte) error { type Genesiscurrencys struct { - Account string `json:"Account" gencodec:"required"` - Quant *math.HexOrDecimal256 `json:"Quant" gencodec:"required"` + Account string `json:"Account" gencodec:"required"` + Quant *math.HexOrDecimal256 `json:"Quant" gencodec:"required"` } var dec Genesiscurrencys if err := json.Unmarshal(input, &dec); err != nil { @@ -246,35 +247,36 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig { return params.AllManashProtocolChanges } } -func sortMapByString(tmpMap map[string][]Genesiscurrencys) []string{ - clist := make([]string,0,len(tmpMap)) - for k,_:=range tmpMap{ - clist = append(clist,k) +func sortMapByString(tmpMap map[string][]Genesiscurrencys) []string { + clist := make([]string, 0, len(tmpMap)) + for k, _ := range tmpMap { + clist = append(clist, k) } sort.Strings(clist) return clist } + // ToBlock creates the genesis block and writes state of a genesis specification // to the given database (or discards it if nil). func (g *Genesis) ToBlock(db mandb.Database) (*types.Block, error) { if db == nil { db = mandb.NewMemDatabase() } - roots:=make([]common.CoinRoot,0,len(g.Currencys)+1) + roots := make([]common.CoinRoot, 0, len(g.Currencys)+1) roots = append(roots, common.CoinRoot{Cointyp: params.MAN_COIN, Root: common.Hash{}}) var coinlist []string var coincfglist []common.CoinConfig - if len(g.Currencys) > 0{ - for _,coinname := range sortMapByString(g.Currencys){ + if len(g.Currencys) > 0 { + for _, coinname := range sortMapByString(g.Currencys) { roots = append(roots, common.CoinRoot{Cointyp: coinname, Root: common.Hash{}}) coinlist = append(coinlist, coinname) allAmount := new(big.Int) - for _,cuff := range g.Currencys[coinname]{ - allAmount = new(big.Int).Add(allAmount,cuff.Quant) + for _, cuff := range g.Currencys[coinname] { + allAmount = new(big.Int).Add(allAmount, cuff.Quant) } - coincfglist = append(coincfglist,common.CoinConfig{CoinType:coinname,CoinTotal:(*hexutil.Big)(allAmount), - PackNum:params.CallTxPachNum,CoinUnit:(*hexutil.Big)(new(big.Int).SetUint64(params.CoinTypeUnit)), - CoinAddress:common.TxGasRewardAddress,CoinRange:coinname}) + coincfglist = append(coincfglist, common.CoinConfig{CoinType: coinname, CoinTotal: (*hexutil.Big)(allAmount), + PackNum: params.CallTxPachNum, CoinUnit: (*hexutil.Big)(new(big.Int).SetUint64(params.CoinTypeUnit)), + CoinAddress: common.TxGasRewardAddress, CoinRange: coinname}) } } statedb, _ := state.NewStateDBManage(roots, db, state.NewDatabase(db)) @@ -291,14 +293,14 @@ func (g *Genesis) ToBlock(db mandb.Database) (*types.Block, error) { statedb.SetMatrixData(key, coinby) coinCfgbs, _ := json.Marshal(coincfglist) statedb.SetMatrixData(types.RlpHash(common.COINPREFIX+mc.MSCurrencyConfig), coinCfgbs) - for _,cname := range sortMapByString(g.Currencys){ - for _,cuff := range g.Currencys[cname]{ - addr,err:= base58.Base58DecodeToAddress(cuff.Account) - if err != nil{ + for _, cname := range sortMapByString(g.Currencys) { + for _, cuff := range g.Currencys[cname] { + addr, err := base58.Base58DecodeToAddress(cuff.Account) + if err != nil { continue } //tmpval,_:=new(big.Int).SetString(cuff.Quant,0) - statedb.AddBalance(cname,common.MainAccount,addr,cuff.Quant) + statedb.AddBalance(cname, common.MainAccount, addr, cuff.Quant) } } if nil == g.MState { @@ -603,7 +605,7 @@ func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis { common.BytesToAddress([]byte{6}): {Balance: big.NewInt(1)}, // ECAdd common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing - faucet: {Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))}, + faucet: {Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))}, }, } } diff --git a/core/genesis_test.go b/core/genesis_test.go index 9a547ca3..c4c18cfd 100644 --- a/core/genesis_test.go +++ b/core/genesis_test.go @@ -9,13 +9,13 @@ import ( "reflect" "testing" - "github.com/davecgh/go-spew/spew" "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/consensus/manash" "github.com/MatrixAINetwork/go-matrix/core/rawdb" "github.com/MatrixAINetwork/go-matrix/core/vm" "github.com/MatrixAINetwork/go-matrix/mandb" "github.com/MatrixAINetwork/go-matrix/params" + "github.com/davecgh/go-spew/spew" ) func TestDefaultGenesisBlock(t *testing.T) { diff --git a/core/matrix_process.go b/core/matrix_process.go index a89f6649..d7f98dc4 100644 --- a/core/matrix_process.go +++ b/core/matrix_process.go @@ -11,7 +11,7 @@ import ( ) type PreStateReadFn func(key string) (interface{}, error) -type ProduceMatrixStateDataFn func(block *types.Block, readFn PreStateReadFn) (interface{}, error) +type ProduceMatrixStateDataFn func(block *types.Block, stateDb *state.StateDBManage, readFn PreStateReadFn) (interface{}, error) type MatrixProcessor struct { mu sync.RWMutex @@ -84,7 +84,7 @@ func (mp *MatrixProcessor) ProcessMatrixState(block *types.Block, preVersion str dataMap := make(map[string]interface{}) for key := range mp.producerMap { - data, err := mp.producerMap[key](block, preReadFn) + data, err := mp.producerMap[key](block, state, preReadFn) if err != nil { return errors.Errorf("key(%s) produce matrix state data err(%v)", key, err) } diff --git a/core/matrixstate/matrix_state.go b/core/matrixstate/matrix_state.go index 5c4ef823..32166eda 100644 --- a/core/matrixstate/matrix_state.go +++ b/core/matrixstate/matrix_state.go @@ -11,11 +11,13 @@ const logInfo = "matrix state" var mangerAlpha *Manager var mangerBeta *Manager +var mangerGamma *Manager var versionOpt MatrixOperator func init() { mangerAlpha = newManger(manparams.VersionAlpha) mangerBeta = newManger(manparams.VersionBeta) + mangerGamma = newManger(manparams.VersionGamma) versionOpt = newVersionInfoOpt() } @@ -36,6 +38,8 @@ func GetManager(version string) *Manager { return mangerAlpha case manparams.VersionBeta: return mangerBeta + case manparams.VersionGamma: + return mangerGamma default: log.Error(logInfo, "get Manger err", "version not exist", "version", version) return nil @@ -173,6 +177,64 @@ func newManger(version string) *Manager { mc.MSKeyBlockProduceBlackList: newBlockProduceBlackListOpt(), }, } + case manparams.VersionGamma: + return &Manager{ + version: version, + operators: map[string]MatrixOperator{ + mc.MSKeyBroadcastTx: newBroadcastTxOpt(), + mc.MSKeyTopologyGraph: newTopologyGraphOpt(), + mc.MSKeyElectGraph: newELectGraphOpt(), + mc.MSKeyElectOnlineState: newELectOnlineStateOpt(), + mc.MSKeyBroadcastInterval: newBroadcastIntervalOpt(), + mc.MSKeyElectGenTime: newElectGenTimeOpt(), + mc.MSKeyElectMinerNum: newElectMinerNumOpt(), + mc.MSKeyElectConfigInfo: newElectConfigInfoOpt(), + mc.MSKeyElectBlackList: newElectBlackListOpt(), + mc.MSKeyElectWhiteList: newElectWhiteListOpt(), + mc.MSKeyElectWhiteListSwitcher: newElectWhiteListSwitcherOpt(), + mc.MSKeyAccountBroadcasts: newBroadcastAccountsOpt(), + mc.MSKeyAccountInnerMiners: newInnerMinerAccountsOpt(), + mc.MSKeyAccountFoundation: newFoundationAccountOpt(), + mc.MSKeyAccountVersionSupers: newVersionSuperAccountsOpt(), + mc.MSKeyAccountBlockSupers: newBlockSuperAccountsOpt(), + mc.MSKeyAccountMultiCoinSupers: newMultiCoinSuperAccountsOpt(), + mc.MSKeyAccountSubChainSupers: newSubChainSuperAccountsOpt(), + mc.MSKeyVIPConfig: newVIPConfigOpt(), + mc.MSKeyPreBroadcastRoot: newPreBroadcastRootOpt(), + mc.MSKeyLeaderConfig: newLeaderConfigOpt(), + mc.MSKeyMinHash: newMinHashOpt(), + mc.MSKeySuperBlockCfg: newSuperBlockCfgOpt(), + + mc.MSKeyBlkRewardCfg: newBlkRewardCfgOpt(), + mc.MSKeyTxsRewardCfg: newTxsRewardCfgOpt(), + mc.MSKeyInterestCfg: newInterestCfgOpt(), + mc.MSKeyLotteryCfg: newLotteryCfgOpt(), + mc.MSKeySlashCfg: newSlashCfgOpt(), + mc.MSKeyPreMinerBlkReward: newPreMinerBlkRewardOpt(), + mc.MSKeyPreMinerTxsReward: newPreMinerMultiCoinTxsRewardOpt(), + mc.MSKeyUpTimeNum: newUpTimeNumOpt(), + mc.MSKeyLotteryNum: newLotteryNumOpt(), + mc.MSKeyLotteryAccount: newLotteryAccountOpt(), + mc.MSKeyInterestCalcNum: newInterestCalcNumOpt(), + mc.MSKeyInterestPayNum: newInterestPayNumOpt(), + mc.MSKeySlashNum: newSlashNumOpt(), + + mc.MSKeyBlkCalc: newBlkCalcOpt(), + mc.MSKeyTxsCalc: newTxsCalcOpt(), + mc.MSKeyInterestCalc: newInterestCalcOpt(), + mc.MSKeyLotteryCalc: newLotteryCalcOpt(), + mc.MSKeySlashCalc: newSlashCalcOpt(), + + mc.MSTxpoolGasLimitCfg: newTxpoolGasLimitOpt(), + mc.MSCurrencyConfig: newCurrencyPackOpt(), + mc.MSAccountBlackList: newAccountBlackListOpt(), + + mc.MSKeyBlockProduceStatsStatus: newBlockProduceStatsStatusOpt(), + mc.MSKeyBlockProduceSlashCfg: newBlockProduceSlashCfgOpt(), + mc.MSKeyBlockProduceStats: newBlockProduceStatsOpt(), + mc.MSKeyBlockProduceBlackList: newBlockProduceBlackListOpt(), + }, + } default: log.Error(logInfo, "创建管理类", "失败", "版本", version) return nil diff --git a/core/matrixstate/utility.go b/core/matrixstate/utility.go index e3d04295..3b006085 100644 --- a/core/matrixstate/utility.go +++ b/core/matrixstate/utility.go @@ -3,11 +3,11 @@ package matrixstate import ( "math/big" + "encoding/json" "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/core/types" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/mc" - "encoding/json" - "github.com/MatrixAINetwork/go-matrix/core/types" ) func GetVersionInfo(st StateDB) string { @@ -398,6 +398,7 @@ func GetAccountBlackList(st StateDB) ([]common.Address, error) { } return value.([]common.Address), nil } + //func GetCoinConfig(st StateDB) ([]common.CoinConfig, error) { // version := GetVersionInfo(st) // mgr := GetManager(version) @@ -421,7 +422,7 @@ func GetCoinConfig(st StateDB) ([]common.CoinConfig, error) { err := json.Unmarshal(coinconfig, &coincfglist) if err != nil { log.Trace("get coin config list", "unmarshal err", err) - return nil,err + return nil, err } } return coincfglist, nil diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 7a0d3bd4..a592668d 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -222,11 +222,11 @@ func ReadBody(db DatabaseReader, hash common.Hash, number uint64) *types.Body { // WriteBody storea a block body into the database. func WriteBody(db DatabaseWriter, hash common.Hash, number uint64, body *types.Body) { var tempBody types.Body - tempBody.CurrencyBody = make([]types.CurrencyBlock,len(body.CurrencyBody)) - tempBody.Uncles = make([]*types.Header,len(body.Uncles)) - copy(tempBody.CurrencyBody,body.CurrencyBody) - copy(tempBody.Uncles,body.Uncles) - for i,_ := range tempBody.CurrencyBody{ + tempBody.CurrencyBody = make([]types.CurrencyBlock, len(body.CurrencyBody)) + tempBody.Uncles = make([]*types.Header, len(body.Uncles)) + copy(tempBody.CurrencyBody, body.CurrencyBody) + copy(tempBody.Uncles, body.Uncles) + for i, _ := range tempBody.CurrencyBody { tempBody.CurrencyBody[i].Receipts = types.BodyReceipts{} } data, err := rlp.EncodeToBytes(tempBody) @@ -291,13 +291,13 @@ func ReadReceipts(db DatabaseReader, hash common.Hash, number uint64) []types.Co log.Error("Invalid receipt array RLP", "hash", hash, "err", err) return nil } - creceipts := make([]types.CoinReceipts,0) + creceipts := make([]types.CoinReceipts, 0) for _, receipt := range cr { - receipts :=make(types.Receipts,0) - for _,r := range receipt.StorageReceipts{ - receipts = append(receipts,(*types.Receipt)(r)) + receipts := make(types.Receipts, 0) + for _, r := range receipt.StorageReceipts { + receipts = append(receipts, (*types.Receipt)(r)) } - creceipts = append(creceipts,types.CoinReceipts{CoinType:receipt.Currency,Receiptlist:receipts}) + creceipts = append(creceipts, types.CoinReceipts{CoinType: receipt.Currency, Receiptlist: receipts}) } return creceipts } @@ -305,13 +305,13 @@ func ReadReceipts(db DatabaseReader, hash common.Hash, number uint64) []types.Co // WriteReceipts stores all the transaction receipts belonging to a block. func WriteReceipts(db DatabaseWriter, hash common.Hash, number uint64, receipts []types.CoinReceipts) { // Convert the receipts into their storage form and serialize them - currRcps:=make([]types.CurrencyReceipts,0) - for _,cr := range receipts{ + currRcps := make([]types.CurrencyReceipts, 0) + for _, cr := range receipts { storageReceipts := make([]*types.ReceiptForStorage, len(cr.Receiptlist)) for i, receipt := range cr.Receiptlist { storageReceipts[i] = (*types.ReceiptForStorage)(receipt) } - currRcps = append(currRcps,types.CurrencyReceipts{Currency:cr.CoinType,StorageReceipts:storageReceipts}) + currRcps = append(currRcps, types.CurrencyReceipts{Currency: cr.CoinType, StorageReceipts: storageReceipts}) } bytes, err := rlp.EncodeToBytes(currRcps) if err != nil { diff --git a/core/rawdb/accessors_indexes.go b/core/rawdb/accessors_indexes.go index 53445ea3..32248fb6 100644 --- a/core/rawdb/accessors_indexes.go +++ b/core/rawdb/accessors_indexes.go @@ -15,24 +15,24 @@ import ( // ReadTxLookupEntry retrieves the positional metadata associated with a transaction // hash to allow retrieving the transaction or receipt by hash. -func ReadTxLookupEntry(db DatabaseReader, hash common.Hash) (common.Hash, uint64, uint64,string) { +func ReadTxLookupEntry(db DatabaseReader, hash common.Hash) (common.Hash, uint64, uint64, string) { data, _ := db.Get(append(txLookupPrefix, hash.Bytes()...)) if len(data) == 0 { - return common.Hash{}, 0, 0,"" + return common.Hash{}, 0, 0, "" } var entry TxLookupEntry if err := rlp.DecodeBytes(data, &entry); err != nil { log.Error("Invalid transaction lookup entry RLP", "hash", hash, "err", err) - return common.Hash{}, 0, 0,"" + return common.Hash{}, 0, 0, "" } - return entry.BlockHash, entry.BlockIndex, entry.Index,entry.Cointype + return entry.BlockHash, entry.BlockIndex, entry.Index, entry.Cointype } // WriteTxLookupEntries stores a positional metadata for every transaction from // a block, enabling hash based transaction and receipt lookups. func WriteTxLookupEntries(db DatabaseWriter, block *types.Block) { for _, currencies := range block.Currencies() { - if len(currencies.Transactions.Sharding) > 0{ + if len(currencies.Transactions.Sharding) > 0 { for _, tx := range currencies.Transactions.TransactionInfos { entry := TxLookupEntry{ BlockHash: block.Hash(), @@ -48,7 +48,7 @@ func WriteTxLookupEntries(db DatabaseWriter, block *types.Block) { log.Crit("Failed to store transaction lookup entry", "err", err) } } - }else { + } else { var i uint64 for _, tx := range currencies.Transactions.GetTransactions() { entry := TxLookupEntry{ @@ -78,7 +78,7 @@ func DeleteTxLookupEntry(db DatabaseDeleter, hash common.Hash) { // ReadTransaction retrieves a specific transaction from the database, along with // its added positional metadata. func ReadTransaction(db DatabaseReader, hash common.Hash) (types.SelfTransaction, common.Hash, uint64, uint64) { - blockHash, blockNumber, txIndex,cointy := ReadTxLookupEntry(db, hash) + blockHash, blockNumber, txIndex, cointy := ReadTxLookupEntry(db, hash) if blockHash == (common.Hash{}) { return nil, common.Hash{}, 0, 0 } @@ -86,7 +86,7 @@ func ReadTransaction(db DatabaseReader, hash common.Hash) (types.SelfTransaction body := ReadBody(db, blockHash, blockNumber) var tx types.SelfTransaction for _, currencyBlock := range body.CurrencyBody { - if currencyBlock.CurrencyName == cointy{ + if currencyBlock.CurrencyName == cointy { tx = currencyBlock.Transactions.GetTransactionByIndex(txIndex) } } @@ -101,15 +101,15 @@ func ReadTransaction(db DatabaseReader, hash common.Hash) (types.SelfTransaction // ReadReceipt retrieves a specific transaction receipt from the database, along with // its added positional metadata. func ReadReceipt(db DatabaseReader, hash common.Hash) (*types.Receipt, common.Hash, uint64, uint64) { - blockHash, blockNumber, receiptIndex,cointy := ReadTxLookupEntry(db, hash) + blockHash, blockNumber, receiptIndex, cointy := ReadTxLookupEntry(db, hash) if blockHash == (common.Hash{}) { return nil, common.Hash{}, 0, 0 } creceipts := ReadReceipts(db, blockHash, blockNumber) - receipts := make(types.Receipts,0) - for _,rcps := range creceipts{ - if rcps.CoinType == cointy{ - receipts = append(receipts,rcps.Receiptlist...) + receipts := make(types.Receipts, 0) + for _, rcps := range creceipts { + if rcps.CoinType == cointy { + receipts = append(receipts, rcps.Receiptlist...) } } if len(receipts) <= int(receiptIndex) { diff --git a/core/state/database.go b/core/state/database.go index 4260cd40..af2f857f 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -8,10 +8,10 @@ import ( "fmt" "sync" - lru "github.com/hashicorp/golang-lru" "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/mandb" "github.com/MatrixAINetwork/go-matrix/trie" + lru "github.com/hashicorp/golang-lru" ) // Trie cache generation limit after which to evict trie nodes from memory. @@ -20,7 +20,7 @@ var MaxTrieCacheGen = uint16(120) const ( // Number of past tries to keep. This value is chosen such that // reasonable chain reorg depths will hit an existing trie. - maxPastTries = 12 + maxPastTries = 12 PastTriesSize = 1024 // Number of codehash->size associations to keep. @@ -75,10 +75,10 @@ func NewDatabase(db mandb.Database) Database { } type cachingDB struct { - db *trie.Database - mu sync.Mutex - pastTries *lru.Cache -// pastTries []*trie.SecureTrie + db *trie.Database + mu sync.Mutex + pastTries *lru.Cache + // pastTries []*trie.SecureTrie codeSizeCache *lru.Cache } @@ -86,42 +86,42 @@ type cachingDB struct { func (db *cachingDB) OpenTrie(root common.Hash) (Trie, error) { db.mu.Lock() defer db.mu.Unlock() - if pastTree,exist := db.pastTries.Get(root);exist{ + if pastTree, exist := db.pastTries.Get(root); exist { return cachedTrie{pastTree.(*trie.SecureTrie).Copy(), db}, nil - }else{ + } else { tr, err := trie.NewSecure(root, db.db, MaxTrieCacheGen) if err != nil { return nil, err } - db.pastTries.Add(root,tr) + db.pastTries.Add(root, tr) return cachedTrie{tr.Copy(), db}, nil } /* - for i := len(db.pastTries) - 1; i >= 0; i-- { - if db.pastTries[i].Hash() == root { - return cachedTrie{db.pastTries[i].Copy(), db}, nil + for i := len(db.pastTries) - 1; i >= 0; i-- { + if db.pastTries[i].Hash() == root { + return cachedTrie{db.pastTries[i].Copy(), db}, nil + } } - } - tr, err := trie.NewSecure(root, db.db, MaxTrieCacheGen) - if err != nil { - return nil, err - } - return cachedTrie{tr, db}, nil + tr, err := trie.NewSecure(root, db.db, MaxTrieCacheGen) + if err != nil { + return nil, err + } + return cachedTrie{tr, db}, nil */ } func (db *cachingDB) pushTrie(t *trie.SecureTrie) { db.mu.Lock() defer db.mu.Unlock() - db.pastTries.Add(t.Hash(),t) -/* - if len(db.pastTries) >= maxPastTries { - copy(db.pastTries, db.pastTries[1:]) - db.pastTries[len(db.pastTries)-1] = t - } else { - db.pastTries = append(db.pastTries, t) - } -*/ + db.pastTries.Add(t.Hash(), t) + /* + if len(db.pastTries) >= maxPastTries { + copy(db.pastTries, db.pastTries[1:]) + db.pastTries[len(db.pastTries)-1] = t + } else { + db.pastTries = append(db.pastTries, t) + } + */ } // OpenStorageTrie opens the storage trie of an account. diff --git a/core/state/dump.go b/core/state/dump.go index b008a6fe..7ee09624 100644 --- a/core/state/dump.go +++ b/core/state/dump.go @@ -29,7 +29,7 @@ type DumpAccount struct { Storage map[string]string `json:"storage"` } type CoinDump struct { - CoinTyp string + CoinTyp string DumpList []Dump } @@ -48,6 +48,7 @@ type CodeData struct { CodeHash []byte Code []byte } + //Root [Account ...] [Matrix...] //Account -> Root -> []DumpValue type DumpDB struct { @@ -261,7 +262,6 @@ func (self *StateDB) RawDumpAcccount(address common.Address) Dump { return dump } - func (dbDump *DumpDB) PrintAccountMsg() { fmt.Println("PrintAccountMsg info") type EasyAccount struct { diff --git a/core/state/sharding_statedb.go b/core/state/sharding_statedb.go index 047843f9..f1cf3035 100644 --- a/core/state/sharding_statedb.go +++ b/core/state/sharding_statedb.go @@ -2,7 +2,9 @@ package state import ( "encoding/json" + "errors" _ "github.com/MatrixAINetwork/go-matrix/base58" + "github.com/MatrixAINetwork/go-matrix/btrie" "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/core/types" "github.com/MatrixAINetwork/go-matrix/crypto" @@ -11,8 +13,6 @@ import ( "github.com/MatrixAINetwork/go-matrix/params" "github.com/MatrixAINetwork/go-matrix/rlp" "math/big" - "errors" - "github.com/MatrixAINetwork/go-matrix/btrie" "time" ) @@ -25,18 +25,19 @@ type CoinManage struct { Rmanage []*RangeManage } type StateDBManage struct { - db Database - mdb mandb.Database + db Database + mdb mandb.Database thash, bhash common.Hash txIndex int - shardings []*CoinManage - coinRoot []common.CoinRoot - retcoinRoot []common.CoinRoot + shardings []*CoinManage + coinRoot []common.CoinRoot + retcoinRoot []common.CoinRoot } type CoinTrie struct { - Coin string + Coin string TrieArry []DumpDB } + // Create a new state from a given trie. func NewStateDBManage(roots []common.CoinRoot, mdb mandb.Database, db Database) (*StateDBManage, error) { @@ -52,12 +53,12 @@ func NewStateDBManage(roots []common.CoinRoot, mdb mandb.Database, db Database) } copy(stm.coinRoot, roots) copy(stm.retcoinRoot, roots) - for _,cr := range roots{ - stm.MakeStatedb(cr.Cointyp,true) + for _, cr := range roots { + stm.MakeStatedb(cr.Cointyp, true) } return stm, nil } -func (shard *StateDBManage) MakeStatedb(cointyp string,isCheck bool) { +func (shard *StateDBManage) MakeStatedb(cointyp string, isCheck bool) { //没有对应币种或byte分区的时候,才创建 for _, cm := range shard.shardings { if cm.Cointyp == cointyp { @@ -144,9 +145,9 @@ func (shard *StateDBManage) Reset(roots []common.CoinRoot) error { return nil } -func (shard *StateDBManage) GetStateDb(cointyp string, address common.Address)( *StateDB,error ){ - if !shard.CheckCoin(cointyp){ - return nil,errors.New("Sharding_GetStateDb Error: coin type Non-existent") +func (shard *StateDBManage) GetStateDb(cointyp string, address common.Address) (*StateDB, error) { + if !shard.CheckCoin(cointyp) { + return nil, errors.New("Sharding_GetStateDb Error: coin type Non-existent") } if cointyp == "" { cointyp = params.MAN_COIN @@ -154,17 +155,17 @@ func (shard *StateDBManage) GetStateDb(cointyp string, address common.Address)( cms := shard.shardings for _, cm := range cms { if cm.Cointyp == cointyp { - return cm.Rmanage[address[0]].State,nil + return cm.Rmanage[address[0]].State, nil } } - return nil,errors.New("Sharding_GetStateDb Error: Can`t Get StateDB") + return nil, errors.New("Sharding_GetStateDb Error: Can`t Get StateDB") } func (shard *StateDBManage) setError(cointype string, addr common.Address, err error) { - self,err := shard.GetStateDb(cointype, addr) - if err!=nil { - log.Error("sharding_statedb","func:sharding_setError:",err) + self, err := shard.GetStateDb(cointype, addr) + if err != nil { + log.Error("sharding_statedb", "func:sharding_setError:", err) return } if self.dbErr == nil { @@ -179,9 +180,9 @@ func (shard *StateDBManage) Error() error { func (shard *StateDBManage) AddLog(cointyp string, address common.Address, logs *types.Log) { - self,err := shard.GetStateDb(cointyp, address) - if err!=nil { - log.Error("sharding_statedb","func:sharding_AddLog:",err) + self, err := shard.GetStateDb(cointyp, address) + if err != nil { + log.Error("sharding_statedb", "func:sharding_AddLog:", err) return } self.journal.append(addLogChange{txhash: shard.thash}) @@ -196,9 +197,9 @@ func (shard *StateDBManage) AddLog(cointyp string, address common.Address, logs func (shard *StateDBManage) GetLogs(cointyp string, address common.Address, hash common.Hash) []*types.Log { - sd ,err:= shard.GetStateDb(cointyp, address) - if err!=nil { - log.Error("sharding_statedb","sharding_GetLogs:",err) + sd, err := shard.GetStateDb(cointyp, address) + if err != nil { + log.Error("sharding_statedb", "sharding_GetLogs:", err) return nil } return sd.logs[hash] @@ -208,14 +209,14 @@ func (shard *StateDBManage) GetLogs(cointyp string, address common.Address, hash func (shard *StateDBManage) Logs() []types.CoinLogs { cms := shard.shardings - logs := make([]types.CoinLogs,0,256) + logs := make([]types.CoinLogs, 0, 256) for _, cm := range cms { //if cm.Cointyp==cointyp { rms := cm.Rmanage for _, rm := range rms { log := rm.State.logs for _, l := range log { - logs = append(logs, types.CoinLogs{cm.Cointyp,l}) + logs = append(logs, types.CoinLogs{cm.Cointyp, l}) } } break @@ -226,9 +227,9 @@ func (shard *StateDBManage) Logs() []types.CoinLogs { // AddPreimage records a SHA3 preimage seen by the VM. func (shard *StateDBManage) AddPreimage(cointype string, addr common.Address, hash common.Hash, preimage []byte) { - state,err := shard.GetStateDb(cointype, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_AddPreimage:",err) + state, err := shard.GetStateDb(cointype, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_AddPreimage:", err) return } state.AddPreimage(hash, preimage) @@ -248,18 +249,18 @@ func (shard *StateDBManage) Preimages() map[string]map[common.Hash][]byte { func (shard *StateDBManage) AddRefund(cointyp string, address common.Address, gas uint64) { - sd,err:=shard.GetStateDb(cointyp, address) - if err!=nil { - log.Error("sharding_statedb","sharding_AddRefund:",err) + sd, err := shard.GetStateDb(cointyp, address) + if err != nil { + log.Error("sharding_statedb", "sharding_AddRefund:", err) return } sd.AddRefund(gas) } func (shard *StateDBManage) GetRefund(cointyp string, address common.Address) uint64 { - sd,err := shard.GetStateDb(cointyp, address) - if err!=nil { - log.Error("sharding_statedb","sharding_GetRefund:",err) + sd, err := shard.GetStateDb(cointyp, address) + if err != nil { + log.Error("sharding_statedb", "sharding_GetRefund:", err) return 0 } return sd.refund @@ -283,9 +284,9 @@ func (shard *StateDBManage) Empty(cointyp string, addr common.Address) bool { // Retrieve the balance from the given address or 0 if object not found func (shard *StateDBManage) GetBalance(cointyp string, addr common.Address) common.BalanceType { - sd,err:=shard.GetStateDb(cointyp,addr) - if err!=nil { - log.Error("sharding_statedb","sharding_GetBalance:",err) + sd, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_GetBalance:", err) return nil } return sd.GetBalance(addr) @@ -317,9 +318,9 @@ func (shard *StateDBManage) GetNonce(cointyp string, addr common.Address) uint64 func (shard *StateDBManage) GetCode(cointyp string, addr common.Address) []byte { stateObject := shard.getStateObject(cointyp, addr) - sd,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_GetCode:",err) + sd, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_GetCode:", err) return nil } if stateObject != nil { @@ -336,9 +337,9 @@ func (shard *StateDBManage) GetCodeSize(cointyp string, addr common.Address) int if stateObject.code != nil { return len(stateObject.code) } - sd,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_GetCodeSize:",err) + sd, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_GetCodeSize:", err) return 0 } size, err := shard.db.ContractCodeSize(stateObject.addrHash, common.BytesToHash(stateObject.CodeHash())) @@ -358,9 +359,9 @@ func (shard *StateDBManage) GetCodeHash(cointyp string, addr common.Address) com func (shard *StateDBManage) GetState(cointyp string, addr common.Address, bhash common.Hash) common.Hash { stateObject := shard.getStateObject(cointyp, addr) - sd,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_GetState:",err) + sd, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_GetState:", err) return common.Hash{} } if stateObject != nil { @@ -371,9 +372,9 @@ func (shard *StateDBManage) GetState(cointyp string, addr common.Address, bhash func (shard *StateDBManage) GetStateByteArray(cointyp string, addr common.Address, b common.Hash) []byte { stateObject := shard.getStateObject(cointyp, addr) - sd,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_GetStateByteArray:",err) + sd, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_GetStateByteArray:", err) return nil } if stateObject != nil { @@ -395,9 +396,9 @@ func (shard *StateDBManage) StorageTrie(cointyp string, addr common.Address) Tri if stateObject == nil { return nil } - sd,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_StorageTrie:",err) + sd, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_StorageTrie:", err) return nil } cpy := stateObject.deepCopy(sd) @@ -481,9 +482,9 @@ func (shard *StateDBManage) SetStateByteArray(cointyp string, addr common.Addres // getStateObject will return a non-nil account after Suicide. func (shard *StateDBManage) Suicide(cointyp string, addr common.Address) bool { - sd,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_Suicide:",err) + sd, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_Suicide:", err) return false } return sd.Suicide(addr) @@ -498,9 +499,9 @@ func (shard *StateDBManage) Suicide(cointyp string, addr common.Address) bool { func (shard *StateDBManage) updateStateObject(cointyp string, addr common.Address, stateObject *stateObject) { - self,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_updateStateObject:",err) + self, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_updateStateObject:", err) return } self.updateStateObject(stateObject) @@ -509,9 +510,9 @@ func (shard *StateDBManage) updateStateObject(cointyp string, addr common.Addres // deleteStateObject removes the given object from the state trie. func (shard *StateDBManage) deleteStateObject(cointyp string, addr common.Address, stateObject *stateObject) { - statedb,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_deleteStateObject:",err) + statedb, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_deleteStateObject:", err) return } statedb.deleteStateObject(stateObject) @@ -520,9 +521,9 @@ func (shard *StateDBManage) deleteStateObject(cointyp string, addr common.Addres // Retrieve a state object given by the address. Returns nil if not found. func (shard StateDBManage) getStateObject(cointyp string, addr common.Address) (stateObject *stateObject) { - self,err := shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_getStateObject:",err) + self, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_getStateObject:", err) return nil } return self.getStateObject(addr) @@ -530,9 +531,9 @@ func (shard StateDBManage) getStateObject(cointyp string, addr common.Address) ( func (shard *StateDBManage) setStateObject(cointyp string, addr common.Address, object *stateObject) { - statedb,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_setStateObject:",err) + statedb, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_setStateObject:", err) return } statedb.setStateObject(object) @@ -541,9 +542,9 @@ func (shard *StateDBManage) setStateObject(cointyp string, addr common.Address, // Retrieve a state object or create a new state object if nil. func (shard *StateDBManage) GetOrNewStateObject(cointyp string, addr common.Address) *stateObject { - statedb,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_GetOrNewStateObject:",err) + statedb, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_GetOrNewStateObject:", err) return nil } return statedb.GetOrNewStateObject(addr) @@ -553,10 +554,10 @@ func (shard *StateDBManage) GetOrNewStateObject(cointyp string, addr common.Addr // the given address, it is overwritten and returned as the second return value. func (shard *StateDBManage) createObject(cointyp string, addr common.Address) (newobj, prev *stateObject) { - statedb,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_createObject:",err) - return nil,nil + statedb, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_createObject:", err) + return nil, nil } return statedb.createObject(addr) } @@ -573,9 +574,9 @@ func (shard *StateDBManage) createObject(cointyp string, addr common.Address) (n // Carrying over the balance ensures that Maner doesn't disappear. func (shard *StateDBManage) CreateAccount(cointyp string, addr common.Address) { - statedb,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_CreateAccount:",err) + statedb, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_CreateAccount:", err) return } statedb.CreateAccount(addr) @@ -583,12 +584,12 @@ func (shard *StateDBManage) CreateAccount(cointyp string, addr common.Address) { func (shard *StateDBManage) ForEachStorage(cointyp string, addr common.Address, cb func(key, value common.Hash) bool) { - statedb,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_ForEachStorage:",err) + statedb, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_ForEachStorage:", err) return } - statedb.ForEachStorage(addr,cb) + statedb.ForEachStorage(addr, cb) } // Copy creates a deep, independent copy of the state. @@ -603,7 +604,7 @@ func (shard *StateDBManage) Copy() *StateDBManage { coinRoot: make([]common.CoinRoot, 0), } for _, cm := range shard.shardings { - rms := make([]*RangeManage,0,256) + rms := make([]*RangeManage, 0, 256) for _, rm := range cm.Rmanage { sd := rm.State.Copy() rms = append(rms, &RangeManage{ @@ -625,11 +626,12 @@ func (shard *StateDBManage) Copy() *StateDBManage { return state } + //var gss = make([]int,256) // Snapshot returns an identifier for the current revision of the state. func (shard *StateDBManage) Snapshot(cointyp string) []int { - ss := make([]int,256) + ss := make([]int, 256) for _, cm := range shard.shardings { if cm.Cointyp == cointyp { for _, rm := range cm.Rmanage { @@ -664,11 +666,11 @@ func (shard *StateDBManage) Finalise(cointyp string, deleteEmptyObjects bool) { for _, cms := range shard.shardings { //if cms.Cointyp == cointyp { //可以不用判断币种 - for _, cm := range cms.Rmanage { - //log.Info("Finalise ----------------------------------------------","coin type",cointyp,"range",cm.Range,"dirties length",len(cm.State.journal.dirties)) - cm.State.Finalise(deleteEmptyObjects) - } - //break + for _, cm := range cms.Rmanage { + //log.Info("Finalise ----------------------------------------------","coin type",cointyp,"range",cm.Range,"dirties length",len(cm.State.journal.dirties)) + cm.State.Finalise(deleteEmptyObjects) + } + //break //} } } @@ -687,9 +689,9 @@ func (shard *StateDBManage) IntermediateRoot(deleteEmptyObjects bool) ([]common. root := rm.State.IntermediateRoot(deleteEmptyObjects) root256 = append(root256, root) } - bs,bshash := types.RlpEncodeAndHash(root256) -// bshash = types.RlpHash(root256) -// bs, _ := rlp.EncodeToBytes(root256) + bs, bshash := types.RlpEncodeAndHash(root256) + // bshash = types.RlpHash(root256) + // bs, _ := rlp.EncodeToBytes(root256) err := shard.mdb.Put(bshash[:], bs) if err != nil { log.Error("file:sharding_statedb.go", "func:IntermediateRoot", err) @@ -706,7 +708,7 @@ func (shard *StateDBManage) IntermediateRoot(deleteEmptyObjects bool) ([]common. } } if !isex { - shard.retcoinRoot = append(shard.retcoinRoot, common.CoinRoot{Cointyp: cm.Cointyp, Root: bshash,TxHash:types.EmptyRootHash,ReceiptHash:types.EmptyRootHash}) + shard.retcoinRoot = append(shard.retcoinRoot, common.CoinRoot{Cointyp: cm.Cointyp, Root: bshash, TxHash: types.EmptyRootHash, ReceiptHash: types.EmptyRootHash}) } coinbytes = append(coinbytes, common.Coinbyte{Root: bshash, Byte256: root256}) } @@ -715,16 +717,16 @@ func (shard *StateDBManage) IntermediateRoot(deleteEmptyObjects bool) ([]common. func (shard *StateDBManage) IntermediateRootByCointype(cointype string, deleteEmptyObjects bool) common.Hash { - root256 := make([]common.Hash,0,256) + root256 := make([]common.Hash, 0, 256) for _, cm := range shard.shardings { if cointype == cm.Cointyp { for _, rm := range cm.Rmanage { root := rm.State.IntermediateRoot(deleteEmptyObjects) root256 = append(root256, root) } - bs,bshash := types.RlpEncodeAndHash(root256) -// bs, _ := rlp.EncodeToBytes(root256) -// bshash := types.RlpHash(root256) + bs, bshash := types.RlpEncodeAndHash(root256) + // bs, _ := rlp.EncodeToBytes(root256) + // bshash := types.RlpHash(root256) err := shard.mdb.Put(bshash[:], bs) if err != nil { log.Error("file:sharding_statedb.go", "func:IntermediateRoot", err) @@ -741,7 +743,7 @@ func (shard *StateDBManage) IntermediateRootByCointype(cointype string, deleteEm } } if !isex { - shard.retcoinRoot = append(shard.retcoinRoot, common.CoinRoot{Cointyp: cm.Cointyp, Root: bshash,TxHash:types.EmptyRootHash,ReceiptHash:types.EmptyRootHash}) + shard.retcoinRoot = append(shard.retcoinRoot, common.CoinRoot{Cointyp: cm.Cointyp, Root: bshash, TxHash: types.EmptyRootHash, ReceiptHash: types.EmptyRootHash}) } break } @@ -778,7 +780,7 @@ func (shard *StateDBManage) Commit(deleteEmptyObjects bool) ([]common.CoinRoot, var coinbytes = make([]common.Coinbyte, 0) for _, cm := range shard.shardings { - var roots = make([]common.Hash, 0,256) + var roots = make([]common.Hash, 0, 256) for _, rm := range cm.Rmanage { root, err := rm.State.Commit(deleteEmptyObjects) if err != nil { @@ -787,9 +789,9 @@ func (shard *StateDBManage) Commit(deleteEmptyObjects bool) ([]common.CoinRoot, } roots = append(roots, root) } - bs,bshash := types.RlpEncodeAndHash(roots) -// bshash := types.RlpHash(roots) -// bs, err := rlp.EncodeToBytes(roots) + bs, bshash := types.RlpEncodeAndHash(roots) + // bshash := types.RlpHash(roots) + // bs, err := rlp.EncodeToBytes(roots) err := shard.mdb.Put(bshash[:], bs) if err != nil { log.Error("file:sharding_statedb.go", "func:Commit", err) @@ -806,7 +808,7 @@ func (shard *StateDBManage) Commit(deleteEmptyObjects bool) ([]common.CoinRoot, } } if !isex { - shard.retcoinRoot = append(shard.retcoinRoot, common.CoinRoot{Cointyp: cm.Cointyp, Root: bshash,TxHash:types.EmptyRootHash,ReceiptHash:types.EmptyRootHash}) + shard.retcoinRoot = append(shard.retcoinRoot, common.CoinRoot{Cointyp: cm.Cointyp, Root: bshash, TxHash: types.EmptyRootHash, ReceiptHash: types.EmptyRootHash}) } coinbytes = append(coinbytes, common.Coinbyte{Root: bshash, Byte256: roots}) } @@ -826,9 +828,9 @@ func (shard *StateDBManage) CommitSaveTx(cointyp string, addr common.Address) { func (shard *StateDBManage) NewBTrie(cointyp string, addr common.Address, typ byte) { - statedb,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_NewBTrie:",err) + statedb, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_NewBTrie:", err) return } statedb.NewBTrie(typ) @@ -837,21 +839,21 @@ func (shard *StateDBManage) NewBTrie(cointyp string, addr common.Address, typ by //isdel:true 表示需要从map中删除hash,false 表示不需要删除 func (shard *StateDBManage) GetSaveTx(cointyp string, addr common.Address, typ byte, key uint32, hashlist []common.Hash, isdel bool) { - statedb,err:=shard.GetStateDb(params.MAN_COIN, common.Address{}) - if err!=nil { - log.Error("sharding_statedb","sharding_GetSaveTx:",err) + statedb, err := shard.GetStateDb(params.MAN_COIN, common.Address{}) + if err != nil { + log.Error("sharding_statedb", "sharding_GetSaveTx:", err) return } - statedb.GetSaveTx(typ,key,hashlist,isdel) + statedb.GetSaveTx(typ, key, hashlist, isdel) } func (shard *StateDBManage) SaveTx(cointyp string, addr common.Address, typ byte, key uint32, data map[common.Hash][]byte) { - statedb,err:=shard.GetStateDb(params.MAN_COIN, common.Address{}) - if err!=nil { - log.Error("sharding_statedb","sharding_SaveTx:",err) + statedb, err := shard.GetStateDb(params.MAN_COIN, common.Address{}) + if err != nil { + log.Error("sharding_statedb", "sharding_SaveTx:", err) return } - statedb.SaveTx(typ,key,data) + statedb.SaveTx(typ, key, data) } //SetMatrixData,GetMatrixData,DeleteMxData都是针对man币种 分区[0] @@ -887,12 +889,12 @@ func (shard *StateDBManage) DeleteMxData(hash common.Hash, val []byte) { } func (shard *StateDBManage) UpdateTxForBtree(key uint32) { - statedb,err:=shard.GetStateDb(params.MAN_COIN, common.Address{}) - if err!=nil { - log.Error("sharding_statedb","UpdateTxForBtree:",err) + statedb, err := shard.GetStateDb(params.MAN_COIN, common.Address{}) + if err != nil { + log.Error("sharding_statedb", "UpdateTxForBtree:", err) return } - out := statedb.GetBtreeItem(key,common.ExtraRevocable) + out := statedb.GetBtreeItem(key, common.ExtraRevocable) for _, it := range out { item, ok := it.(btrie.SpcialTxData) if !ok { @@ -915,12 +917,12 @@ func (shard *StateDBManage) UpdateTxForBtree(key uint32) { for _, vv := range rt.Adam { //一对多交易 log.Info("StateDBManage", "UpdateTxForBtree:vv.Addr", vv.Addr, "vv.Amont", vv.Amont) log.Info("StateDBManage", "UpdateTxForBtree:from", rt.From, "vv.Amont", vv.Amont) - if shard.GetBalanceByType(rt.Cointyp,rt.From, common.WithdrawAccount).Cmp(vv.Amont) >= 0 { - shard.SubBalance(rt.Cointyp,common.WithdrawAccount, rt.From, vv.Amont) - aa := shard.GetBalanceByType(rt.Cointyp,vv.Addr, common.MainAccount) + if shard.GetBalanceByType(rt.Cointyp, rt.From, common.WithdrawAccount).Cmp(vv.Amont) >= 0 { + shard.SubBalance(rt.Cointyp, common.WithdrawAccount, rt.From, vv.Amont) + aa := shard.GetBalanceByType(rt.Cointyp, vv.Addr, common.MainAccount) log.Info("StateDBManage", "UpdateTxForBtree:to", vv.Addr, "Balance:befor", aa) - shard.AddBalance(rt.Cointyp,common.MainAccount, vv.Addr, vv.Amont) - bb := shard.GetBalanceByType(rt.Cointyp,vv.Addr, common.MainAccount) + shard.AddBalance(rt.Cointyp, common.MainAccount, vv.Addr, vv.Amont) + bb := shard.GetBalanceByType(rt.Cointyp, vv.Addr, common.MainAccount) log.Info("StateDBManage", "UpdateTxForBtree:to", vv.Addr, "Balance:after", bb, "call time ", time.Now().Unix()) } else { log.Info("StateDBManage", "UpdateTxForBtree", "amont is not enough") @@ -935,12 +937,12 @@ func (shard *StateDBManage) UpdateTxForBtree(key uint32) { } func (shard *StateDBManage) UpdateTxForBtreeBytime(key uint32) { - statedb,err:=shard.GetStateDb(params.MAN_COIN, common.Address{}) - if err!=nil { - log.Error("sharding_statedb","UpdateTxForBtree:",err) + statedb, err := shard.GetStateDb(params.MAN_COIN, common.Address{}) + if err != nil { + log.Error("sharding_statedb", "UpdateTxForBtree:", err) return } - out := statedb.GetBtreeItem(key,common.ExtraTimeTxType) + out := statedb.GetBtreeItem(key, common.ExtraTimeTxType) for _, it := range out { item, ok := it.(btrie.SpcialTxData) if !ok { @@ -963,12 +965,12 @@ func (shard *StateDBManage) UpdateTxForBtreeBytime(key uint32) { for _, vv := range rt.Adam { //一对多交易 log.Info("StateDBManage", "UpdateTxForBtreeBytime:vv.Addr", vv.Addr, "vv.Amont", vv.Amont) log.Info("StateDBManage", "UpdateTxForBtreeBytime:from", rt.From, "vv.Amont", vv.Amont) - if shard.GetBalanceByType(rt.Cointyp,rt.From, common.WithdrawAccount).Cmp(vv.Amont) >= 0 { - shard.SubBalance(rt.Cointyp,common.WithdrawAccount, rt.From, vv.Amont) - aa := shard.GetBalanceByType(rt.Cointyp,vv.Addr, common.MainAccount) + if shard.GetBalanceByType(rt.Cointyp, rt.From, common.WithdrawAccount).Cmp(vv.Amont) >= 0 { + shard.SubBalance(rt.Cointyp, common.WithdrawAccount, rt.From, vv.Amont) + aa := shard.GetBalanceByType(rt.Cointyp, vv.Addr, common.MainAccount) log.Info("StateDBManage", "UpdateTxForBtreeBytime:to", vv.Addr, "Balance:befor", aa) - shard.AddBalance(rt.Cointyp,common.MainAccount, vv.Addr, vv.Amont) - bb := shard.GetBalanceByType(rt.Cointyp,vv.Addr, common.MainAccount) + shard.AddBalance(rt.Cointyp, common.MainAccount, vv.Addr, vv.Amont) + bb := shard.GetBalanceByType(rt.Cointyp, vv.Addr, common.MainAccount) log.Info("StateDBManage", "UpdateTxForBtreeBytime:to", vv.Addr, "Balance:after", bb, "call time ", time.Now().Unix()) } else { log.Info("StateDBManage", "UpdateTxForBtreeBytime", "amont is not enough") @@ -984,9 +986,9 @@ func (shard *StateDBManage) UpdateTxForBtreeBytime(key uint32) { //根据委托人from和时间获取授权人的from,返回授权人地址(内部调用,仅适用委托gas) func (shard *StateDBManage) GetGasAuthFromByTime(cointyp string, entrustFrom common.Address, time uint64) common.Address { - statedb,err:=shard.GetStateDb(cointyp, entrustFrom) - if err!=nil { - log.Error("sharding_statedb","sharding_GetGasAuthFrom:",err) + statedb, err := shard.GetStateDb(cointyp, entrustFrom) + if err != nil { + log.Error("sharding_statedb", "sharding_GetGasAuthFrom:", err) return common.Address{} } return statedb.GetGasAuthFromByTime(entrustFrom, time) @@ -994,9 +996,9 @@ func (shard *StateDBManage) GetGasAuthFromByTime(cointyp string, entrustFrom com func (shard *StateDBManage) GetGasAuthFromByCount(cointyp string, entrustFrom common.Address) common.Address { - statedb,err:=shard.GetStateDb(cointyp, entrustFrom) - if err!=nil { - log.Error("sharding_statedb","sharding_GetGasAuthFrom:",err) + statedb, err := shard.GetStateDb(cointyp, entrustFrom) + if err != nil { + log.Error("sharding_statedb", "sharding_GetGasAuthFrom:", err) return common.Address{} } return statedb.GetGasAuthFromByCount(entrustFrom) @@ -1004,18 +1006,18 @@ func (shard *StateDBManage) GetGasAuthFromByCount(cointyp string, entrustFrom co func (shard *StateDBManage) GasAuthCountSubOne(cointyp string, entrustFrom common.Address) bool { - statedb,err:=shard.GetStateDb(cointyp, entrustFrom) - if err!=nil { - log.Error("sharding_statedb","sharding_GetGasAuthFrom:",err) + statedb, err := shard.GetStateDb(cointyp, entrustFrom) + if err != nil { + log.Error("sharding_statedb", "sharding_GetGasAuthFrom:", err) return false } return statedb.GasAuthCountSubOne(entrustFrom) } func (shard *StateDBManage) GasEntrustCountSubOne(cointyp string, authFrom common.Address) { - statedb,err:=shard.GetStateDb(cointyp, authFrom) - if err!=nil { - log.Error("sharding_statedb","sharding_GetGasAuthFrom:",err) + statedb, err := shard.GetStateDb(cointyp, authFrom) + if err != nil { + log.Error("sharding_statedb", "sharding_GetGasAuthFrom:", err) return } statedb.GasEntrustCountSubOne(authFrom) @@ -1025,18 +1027,18 @@ func (shard *StateDBManage) GasEntrustCountSubOne(cointyp string, authFrom commo //根据委托人from和时间获取授权人的from,返回授权人地址(内部调用,仅适用委托gas) func (shard *StateDBManage) GetGasAuthFrom(cointyp string, addr common.Address, height uint64) common.Address { - statedb,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_GetGasAuthFrom:",err) + statedb, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_GetGasAuthFrom:", err) return common.Address{} } return statedb.GetGasAuthFrom(addr, height) } func (shard *StateDBManage) GetAuthFrom(cointyp string, addr common.Address, height uint64) common.Address { - statedb,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_GetAuthFrom:",err) + statedb, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_GetAuthFrom:", err) return common.Address{} } return statedb.GetAuthFrom(addr, height) @@ -1045,9 +1047,9 @@ func (shard *StateDBManage) GetAuthFrom(cointyp string, addr common.Address, hei //根据授权人from和高度获取委托人的from列表,返回委托人地址列表(算法组调用,仅适用委托签名) func (shard *StateDBManage) GetEntrustFrom(cointyp string, addr common.Address, height uint64) []common.Address { - statedb,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_GetEntrustFrom:",err) + statedb, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_GetEntrustFrom:", err) return nil } return statedb.GetEntrustFrom(addr, height) @@ -1056,9 +1058,9 @@ func (shard *StateDBManage) GetEntrustFrom(cointyp string, addr common.Address, //根据授权人获取所有委托签名列表,(该方法用于取消委托时调用) func (shard *StateDBManage) GetAllEntrustSignFrom(cointyp string, addr common.Address) []common.Address { - statedb,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_GetAllEntrustSignFrom:",err) + statedb, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_GetAllEntrustSignFrom:", err) return nil } return statedb.GetAllEntrustSignFrom(addr) @@ -1066,9 +1068,9 @@ func (shard *StateDBManage) GetAllEntrustSignFrom(cointyp string, addr common.Ad func (shard *StateDBManage) GetAllEntrustGasFrom(cointyp string, addr common.Address) []common.Address { - statedb,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_GetAllEntrustGasFrom:",err) + statedb, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_GetAllEntrustGasFrom:", err) return nil } return statedb.GetAllEntrustGasFrom(addr) @@ -1076,9 +1078,9 @@ func (shard *StateDBManage) GetAllEntrustGasFrom(cointyp string, addr common.Add func (shard *StateDBManage) GetEntrustFromByTime(cointyp string, addr common.Address, time uint64) []common.Address { - statedb,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_GetEntrustFromByTime:",err) + statedb, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_GetEntrustFromByTime:", err) return nil } return statedb.GetEntrustFromByTime(addr, time) @@ -1087,9 +1089,9 @@ func (shard *StateDBManage) GetEntrustFromByTime(cointyp string, addr common.Add //判断根据时间委托是否满足条件,用于执行按时间委托的交易(跑交易),此处time应该为header里的时间戳 func (shard *StateDBManage) GetIsEntrustByTime(cointyp string, addr common.Address, time uint64) bool { - statedb,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_GetIsEntrustByTime:",err) + statedb, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_GetIsEntrustByTime:", err) return false } return statedb.GetIsEntrustByTime(addr, time) @@ -1098,9 +1100,9 @@ func (shard *StateDBManage) GetIsEntrustByTime(cointyp string, addr common.Addre //钱包调用显示 func (shard *StateDBManage) GetAllEntrustList(cointyp string, addr common.Address) []common.EntrustType { - statedb,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_GetAllEntrustList:",err) + statedb, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_GetAllEntrustList:", err) return nil } return statedb.GetAllEntrustList(addr) @@ -1109,23 +1111,23 @@ func (shard *StateDBManage) GetAllEntrustList(cointyp string, addr common.Addres //钱包调用显示 func (shard *StateDBManage) GetGasAuthFromByHeightAddTime(cointyp string, addr common.Address) common.Address { - statedb,err:=shard.GetStateDb(cointyp, addr) - if err!=nil { - log.Error("sharding_statedb","sharding_GetAllEntrustList:",err) + statedb, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("sharding_statedb", "sharding_GetAllEntrustList:", err) return common.Address{} } return statedb.GetGasAuthFromByHeightAddTime(addr) } -func (shard *StateDBManage) CheckCoin(cointype string)bool{ - if cointype == params.MAN_COIN{ +func (shard *StateDBManage) CheckCoin(cointype string) bool { + if cointype == params.MAN_COIN { return true } val := shard.GetMatrixData(types.RlpHash((params.COIN_NAME))) var coinlist []string err := json.Unmarshal(val, &coinlist) if err != nil { - log.Error("Coin type Non-existent","unmarshal err",err) + log.Error("Coin type Non-existent", "unmarshal err", err) return false } for _, coinName := range coinlist { @@ -1137,47 +1139,47 @@ func (shard *StateDBManage) CheckCoin(cointype string)bool{ } func (shard *StateDBManage) RawDump(cointype string, address common.Address) []CoinDump { - coindumplist := make([]CoinDump,0) - if cointype == ""{ - if address.Equal(common.Address{}){ - for _,sh := range shard.shardings{ - dumplist := make([]Dump,0) - for _,rang := range sh.Rmanage{ - dumplist = append(dumplist,rang.State.RawDump()) + coindumplist := make([]CoinDump, 0) + if cointype == "" { + if address.Equal(common.Address{}) { + for _, sh := range shard.shardings { + dumplist := make([]Dump, 0) + for _, rang := range sh.Rmanage { + dumplist = append(dumplist, rang.State.RawDump()) } - coindumplist = append(coindumplist,CoinDump{CoinTyp:sh.Cointyp,DumpList:dumplist}) + coindumplist = append(coindumplist, CoinDump{CoinTyp: sh.Cointyp, DumpList: dumplist}) } - }else { - for _,sh := range shard.shardings{ - dumplist := make([]Dump,0) - for _,rang := range sh.Rmanage{ - if rang.Range == address[0]{ - dumplist = append(dumplist,rang.State.RawDump()) + } else { + for _, sh := range shard.shardings { + dumplist := make([]Dump, 0) + for _, rang := range sh.Rmanage { + if rang.Range == address[0] { + dumplist = append(dumplist, rang.State.RawDump()) break } } - coindumplist = append(coindumplist,CoinDump{CoinTyp:sh.Cointyp,DumpList:dumplist}) + coindumplist = append(coindumplist, CoinDump{CoinTyp: sh.Cointyp, DumpList: dumplist}) } } } else { - if address.Equal(common.Address{}){ - for _,sh := range shard.shardings{ - if sh.Cointyp == cointype{ - dumplist := make([]Dump,0) - for _,rang := range sh.Rmanage{ - dumplist = append(dumplist,rang.State.RawDump()) + if address.Equal(common.Address{}) { + for _, sh := range shard.shardings { + if sh.Cointyp == cointype { + dumplist := make([]Dump, 0) + for _, rang := range sh.Rmanage { + dumplist = append(dumplist, rang.State.RawDump()) } - coindumplist = append(coindumplist,CoinDump{CoinTyp:cointype,DumpList:dumplist}) + coindumplist = append(coindumplist, CoinDump{CoinTyp: cointype, DumpList: dumplist}) break } } - }else { - statedb,err:=shard.GetStateDb(cointype, address) - if err!=nil { - log.Error("sharding_statedb","sharding_RawDump:",err) + } else { + statedb, err := shard.GetStateDb(cointype, address) + if err != nil { + log.Error("sharding_statedb", "sharding_RawDump:", err) return nil } - coindumplist = append(coindumplist,CoinDump{CoinTyp:cointype,DumpList:[]Dump{statedb.RawDump()}}) + coindumplist = append(coindumplist, CoinDump{CoinTyp: cointype, DumpList: []Dump{statedb.RawDump()}}) } } return coindumplist @@ -1185,9 +1187,9 @@ func (shard *StateDBManage) RawDump(cointype string, address common.Address) []C func (shard *StateDBManage) Dump(cointype string, address common.Address) []byte { - statedb,err:=shard.GetStateDb(cointype, address) - if err!=nil { - log.Error("sharding_statedb","sharding_Dump:",err) + statedb, err := shard.GetStateDb(cointype, address) + if err != nil { + log.Error("sharding_statedb", "sharding_Dump:", err) return nil } return statedb.Dump() @@ -1195,54 +1197,54 @@ func (shard *StateDBManage) Dump(cointype string, address common.Address) []byte func (shard *StateDBManage) RawDumpAcccount(cointype string, address common.Address) Dump { - statedb,err:=shard.GetStateDb(cointype, address) - if err!=nil { - log.Error("sharding_statedb","sharding_RawDumpAcccount:",err) + statedb, err := shard.GetStateDb(cointype, address) + if err != nil { + log.Error("sharding_statedb", "sharding_RawDumpAcccount:", err) return Dump{} } return statedb.RawDumpAcccount(address) } -func (shard *StateDBManage) GetEntrustStateByteArray(cointyp string,addr common.Address) []byte{ - state,err:=shard.GetStateDb(cointyp,addr) - if err != nil{ - log.Error("GetEntrustStateByteArray err","err",err) +func (shard *StateDBManage) GetEntrustStateByteArray(cointyp string, addr common.Address) []byte { + state, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("GetEntrustStateByteArray err", "err", err) return nil } return state.GetEntrustStateByteArray(addr) } -func (shard *StateDBManage) GetAuthStateByteArray(cointyp string,addr common.Address) []byte{ - state,err:=shard.GetStateDb(cointyp,addr) - if err != nil{ - log.Error("GetAuthStateByteArray err","err",err) +func (shard *StateDBManage) GetAuthStateByteArray(cointyp string, addr common.Address) []byte { + state, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("GetAuthStateByteArray err", "err", err) return nil } return state.GetAuthStateByteArray(addr) } -func (shard *StateDBManage) SetEntrustStateByteArray(cointyp string,addr common.Address, value []byte){ - state,err:=shard.GetStateDb(cointyp,addr) - if err != nil{ - log.Error("SetEntrustStateByteArray err","err",err) +func (shard *StateDBManage) SetEntrustStateByteArray(cointyp string, addr common.Address, value []byte) { + state, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("SetEntrustStateByteArray err", "err", err) return } - state.SetEntrustStateByteArray(addr,value) + state.SetEntrustStateByteArray(addr, value) } -func (shard *StateDBManage) SetAuthStateByteArray(cointyp string,addr common.Address, value []byte){ - state,err:=shard.GetStateDb(cointyp,addr) - if err != nil{ - log.Error("SetAuthStateByteArray err","err",err) +func (shard *StateDBManage) SetAuthStateByteArray(cointyp string, addr common.Address, value []byte) { + state, err := shard.GetStateDb(cointyp, addr) + if err != nil { + log.Error("SetAuthStateByteArray err", "err", err) return } - state.SetAuthStateByteArray(addr,value) + state.SetAuthStateByteArray(addr, value) } -func (shard *StateDBManage)RawDumpDB() []CoinTrie { - snapCoinTrie := make([]CoinTrie,0) - for _,shard := range shard.shardings{ - dumplist := make([]DumpDB,0) - for _,rm := range shard.Rmanage{ - dumplist = append(dumplist,rm.State.RawDumpDB()) +func (shard *StateDBManage) RawDumpDB() []CoinTrie { + snapCoinTrie := make([]CoinTrie, 0) + for _, shard := range shard.shardings { + dumplist := make([]DumpDB, 0) + for _, rm := range shard.Rmanage { + dumplist = append(dumplist, rm.State.RawDumpDB()) } - snapCoinTrie = append(snapCoinTrie,CoinTrie{shard.Cointyp,dumplist}) + snapCoinTrie = append(snapCoinTrie, CoinTrie{shard.Cointyp, dumplist}) } return snapCoinTrie } \ No newline at end of file diff --git a/core/state/state_object.go b/core/state/state_object.go index a11d2fc8..ad5894db 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -65,7 +65,7 @@ type stateObject struct { data Account db *StateDB - readMu sync.Mutex + readMu sync.Mutex // DB error. // State objects are used by the consensus core and VM which are // unable to deal with database-level errors. Any error that occurs diff --git a/core/state/statedb.go b/core/state/statedb.go index e0fb01cf..5c87d86c 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -47,7 +47,7 @@ type StateDB struct { trie Trie // This map holds 'live' objects, which will get modified while processing a state transition. - readMu sync.Mutex + readMu sync.Mutex stateObjects map[common.Address]*stateObject stateObjectsDirty map[common.Address]struct{} @@ -69,10 +69,10 @@ type StateDB struct { // The refund counter, also used by state transitioning. refund uint64 -// thash, bhash common.Hash -// txIndex int - logs map[common.Hash][]*types.Log - logSize uint + // thash, bhash common.Hash + // txIndex int + logs map[common.Hash][]*types.Log + logSize uint preimages map[common.Hash][]byte @@ -326,8 +326,8 @@ func (self *StateDB) GetEntrustFrom(authFrom common.Address, height uint64) []co addressList := make([]common.Address, 0) for _, entrustData := range entrustDataList { if entrustData.EnstrustSetType == params.EntrustByHeight && entrustData.IsEntrustSign == true && entrustData.StartHeight <= height && entrustData.EndHeight >= height { - entrustFrom ,err := base58.Base58DecodeToAddress(entrustData.EntrustAddres) //string地址转0x地址 - if err != nil{ + entrustFrom, err := base58.Base58DecodeToAddress(entrustData.EntrustAddres) //string地址转0x地址 + if err != nil { return nil } addressList = append(addressList, entrustFrom) @@ -366,8 +366,8 @@ func (self *StateDB) GetAllEntrustSignFrom(authFrom common.Address) []common.Add addressList := make([]common.Address, 0) for _, entrustData := range entrustDataList { if entrustData.IsEntrustSign == true { - entrustFrom ,err := base58.Base58DecodeToAddress(entrustData.EntrustAddres) //string地址转0x地址 - if err != nil{ + entrustFrom, err := base58.Base58DecodeToAddress(entrustData.EntrustAddres) //string地址转0x地址 + if err != nil { return nil } addressList = append(addressList, entrustFrom) @@ -430,16 +430,17 @@ func (self *StateDB) GasAuthCountSubOne(entrustFrom common.Address) bool { if AuthData.EnstrustSetType == params.EntrustByCount && AuthData.IsEntrustGas == true && AuthData.EntrustCount > 0 { AuthData.EntrustCount-- } - newAuthDataList = append(newAuthDataList,AuthData) + newAuthDataList = append(newAuthDataList, AuthData) } - if len(newAuthDataList) >0 { - marshalData,_ := json.Marshal(newAuthDataList) - self.SetAuthStateByteArray(entrustFrom,marshalData) + if len(newAuthDataList) > 0 { + marshalData, _ := json.Marshal(newAuthDataList) + self.SetAuthStateByteArray(entrustFrom, marshalData) } return true } + //委托人次数减1(用于钱包展示时反向查找) -func (self *StateDB) GasEntrustCountSubOne(authFrom common.Address){ +func (self *StateDB) GasEntrustCountSubOne(authFrom common.Address) { EntrustMarsha1Data := self.GetEntrustStateByteArray(authFrom) if len(EntrustMarsha1Data) == 0 { return @@ -454,11 +455,11 @@ func (self *StateDB) GasEntrustCountSubOne(authFrom common.Address){ if EntrustData.EnstrustSetType == params.EntrustByCount && EntrustData.IsEntrustGas == true && EntrustData.EntrustCount > 0 { EntrustData.EntrustCount-- } - newEntrustDataList = append(newEntrustDataList,EntrustData) + newEntrustDataList = append(newEntrustDataList, EntrustData) } - if len(newEntrustDataList) >0 { - marshalData,_ := json.Marshal(newEntrustDataList) - self.SetEntrustStateByteArray(authFrom,marshalData) + if len(newEntrustDataList) > 0 { + marshalData, _ := json.Marshal(newEntrustDataList) + self.SetEntrustStateByteArray(authFrom, marshalData) } return } @@ -498,6 +499,7 @@ func (self *StateDB) GetGasAuthFromByHeightAddTime(entrustFrom common.Address) c } return common.Address{} } + //根据授权人获取所有委托gas列表,(该方法用于取消委托时调用) func (self *StateDB) GetAllEntrustGasFrom(authFrom common.Address) []common.Address { EntrustMarsha1Data := self.GetEntrustStateByteArray(authFrom) @@ -509,8 +511,8 @@ func (self *StateDB) GetAllEntrustGasFrom(authFrom common.Address) []common.Addr addressList := make([]common.Address, 0) for _, entrustData := range entrustDataList { if entrustData.IsEntrustGas == true { - entrustFrom ,err := base58.Base58DecodeToAddress(entrustData.EntrustAddres) //string地址转0x地址 - if err != nil{ + entrustFrom, err := base58.Base58DecodeToAddress(entrustData.EntrustAddres) //string地址转0x地址 + if err != nil { return nil } addressList = append(addressList, entrustFrom) @@ -532,8 +534,8 @@ func (self *StateDB) GetEntrustFromByTime(authFrom common.Address, time uint64) addressList := make([]common.Address, 0) for _, entrustData := range entrustDataList { if entrustData.EnstrustSetType == params.EntrustByTime && entrustData.IsEntrustGas == true && entrustData.StartHeight <= time && entrustData.EndHeight >= time { - entrustFrom ,err := base58.Base58DecodeToAddress(entrustData.EntrustAddres) //string地址转0x地址 - if err != nil{ + entrustFrom, err := base58.Base58DecodeToAddress(entrustData.EntrustAddres) //string地址转0x地址 + if err != nil { return nil } addressList = append(addressList, entrustFrom) @@ -703,7 +705,7 @@ func (self *StateDB) CommitSaveTx() { self.btreeMap = make([]BtreeDietyStruct, 0) self.btreeMapDirty = make([]BtreeDietyStruct, 0) } -func (self *StateDB) GetBtreeItem(key uint32,typ byte)[]btrie.Item{ +func (self *StateDB) GetBtreeItem(key uint32, typ byte) []btrie.Item { out := make([]btrie.Item, 0) switch typ { case common.ExtraRevocable: @@ -1082,7 +1084,7 @@ func (self *StateDB) Snapshot() int { id := self.nextRevisionId self.nextRevisionId++ len1 := len(self.validRevisions) - if len1 == 0 || self.validRevisions[len1-1].journalIndex < self.journal.length(){ + if len1 == 0 || self.validRevisions[len1-1].journalIndex < self.journal.length() { self.validRevisions = append(self.validRevisions, revision{id, self.journal.length()}) } return id @@ -1095,7 +1097,7 @@ func (self *StateDB) RevertToSnapshot(revid int) { return self.validRevisions[i].id >= revid }) if idx == len(self.validRevisions) || self.validRevisions[idx].id != revid { -// panic(fmt.Errorf("revision id %v cannot be reverted", revid)) + // panic(fmt.Errorf("revision id %v cannot be reverted", revid)) idx-- } snapshot := self.validRevisions[idx].journalIndex diff --git a/core/state_processor.go b/core/state_processor.go index 8f191245..60115b40 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -319,18 +319,19 @@ func (p *StateProcessor) checkCoinShard(coinShard []common.CoinSharding) []commo return coinShard } func myCoinsort(coins []string) []string { - coinsnoman := make([]string,0,len(coins)) - retCoins := make([]string,0,len(coins)) - for _,coinname := range coins{ - if coinname == params.MAN_COIN{ + coinsnoman := make([]string, 0, len(coins)) + retCoins := make([]string, 0, len(coins)) + for _, coinname := range coins { + if coinname == params.MAN_COIN { continue } - coinsnoman = append(coinsnoman,coinname) + coinsnoman = append(coinsnoman, coinname) } - retCoins = append(retCoins,params.MAN_COIN) - retCoins = append(retCoins,coinsnoman...) + retCoins = append(retCoins, params.MAN_COIN) + retCoins = append(retCoins, coinsnoman...) return retCoins } + // Process processes the state changes according to the Matrix rules by running // the transaction messages using the statedb and applying any rewards to both // the processor (coinbase) and any included uncles. @@ -430,8 +431,8 @@ func (p *StateProcessor) ProcessTxs(block *types.Block, statedb *state.StateDBMa tx.Setentrustfrom(entrustFrom) tx.SetIsEntrustGas(true) tx.SetIsEntrustByTime(true) - }else{ - entrustFrom := statedb.GetGasAuthFromByCount(tx.GetTxCurrency(),from) + } else { + entrustFrom := statedb.GetGasAuthFromByCount(tx.GetTxCurrency(), from) if !entrustFrom.Equal(common.Address{}) { tx.Setentrustfrom(entrustFrom) tx.SetIsEntrustGas(true) @@ -481,13 +482,13 @@ func (p *StateProcessor) ProcessTxs(block *types.Block, statedb *state.StateDBMa } //statedb.Finalise("MAN",true) rewarts := p.ProcessReward(statedb, block.Header(), upTime, from, retAllGas) - tmpmapcoin := make(map[string]bool)//为了拿到币种,v值无意义 - for _,rewart := range rewarts{ + tmpmapcoin := make(map[string]bool) //为了拿到币种,v值无意义 + for _, rewart := range rewarts { tmpmapcoin[rewart.CoinRange] = true } - tmpcoins := make([]string,0) - for rewardCoinname,_ := range tmpmapcoin{ - tmpcoins = append(tmpcoins,rewardCoinname) + tmpcoins := make([]string, 0) + for rewardCoinname, _ := range tmpmapcoin { + tmpcoins = append(tmpcoins, rewardCoinname) } coins = myCoinsort(tmpcoins) @@ -537,7 +538,7 @@ func (p *StateProcessor) ProcessTxs(block *types.Block, statedb *state.StateDBMa tmpMaptx[coinname] = ftxs } - statedb.Finalise("",true) + statedb.Finalise("", true) currblock := make([]types.CurrencyBlock, 0, len(block.Currencies())) for i, bc := range block.Currencies() { if !isvadter { @@ -608,16 +609,21 @@ func (p *StateProcessor) Process(block *types.Block, parent *types.Block, stated return nil, nil, 0, err } + if err = p.bc.ProcessStateVersionSwitch(block.NumberU64(), statedb); err != nil { + log.Trace("BlockChain insertChain in3 Process Block err1") + return nil, nil, 0, err + } + uptimeMap, err := p.bc.ProcessUpTime(statedb, block.Header()) if err != nil { - log.Trace("BlockChain insertChain in3 Process Block err1") + log.Trace("BlockChain insertChain in3 Process Block err2") p.bc.reportBlock(block, nil, err) return nil, nil, 0, err } - err = p.bc.ProcessBlockGProduceSlash(statedb, block.Header()) + err = p.bc.ProcessBlockGProduceSlash(string(block.Version()), statedb, block.Header()) if err != nil { - log.Trace("BlockChain insertChain in3 Process Block err2") + log.Trace("BlockChain insertChain in3 Process Block err3") p.bc.reportBlock(block, nil, err) return nil, nil, 0, err } @@ -625,7 +631,7 @@ func (p *StateProcessor) Process(block *types.Block, parent *types.Block, stated // Process block using the parent state as reference point. logs, usedGas, err := p.ProcessTxs(block, statedb, cfg, uptimeMap) if err != nil { - log.Trace("BlockChain insertChain in3 Process Block err3") + log.Trace("BlockChain insertChain in3 Process Block err4") p.bc.reportBlock(block, nil, err) return nil, logs, usedGas, err } @@ -633,7 +639,7 @@ func (p *StateProcessor) Process(block *types.Block, parent *types.Block, stated // Process matrix state err = p.bc.matrixProcessor.ProcessMatrixState(block, string(parent.Version()), statedb) if err != nil { - log.Trace("BlockChain insertChain in3 Process Block err4") + log.Trace("BlockChain insertChain in3 Process Block err5") return nil, logs, usedGas, err } @@ -676,9 +682,9 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo } } else { _, gas, failed, shardings, err = ApplyMessage(vmenv, tx, gp) - if tx.IsEntrustTx() && tx.GetIsEntrustByCount(){ - statedb.GasAuthCountSubOne(tx.GetTxCurrency(),from) //授权次数减1 - statedb.GasEntrustCountSubOne(tx.GetTxCurrency(),tx.AmontFrom()) //委托次数减1 + if tx.IsEntrustTx() && tx.GetIsEntrustByCount() { + statedb.GasAuthCountSubOne(tx.GetTxCurrency(), from) //授权次数减1 + statedb.GasEntrustCountSubOne(tx.GetTxCurrency(), tx.AmontFrom()) //委托次数减1 } if err != nil { return nil, 0, nil, err diff --git a/core/state_transition.go b/core/state_transition.go index 7c74cc0d..b446cd3f 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -12,18 +12,18 @@ import ( "strings" + "bufio" "github.com/MatrixAINetwork/go-matrix/base58" "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/common/hexutil" + "github.com/MatrixAINetwork/go-matrix/core/matrixstate" "github.com/MatrixAINetwork/go-matrix/core/txinterface" "github.com/MatrixAINetwork/go-matrix/core/types" "github.com/MatrixAINetwork/go-matrix/core/vm" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/mc" "github.com/MatrixAINetwork/go-matrix/params" - "github.com/MatrixAINetwork/go-matrix/core/matrixstate" "os" - "bufio" - "github.com/MatrixAINetwork/go-matrix/common/hexutil" ) var ( @@ -106,9 +106,9 @@ func (st *StateTransition) UseGas(amount uint64) error { return nil } -func (st *StateTransition) getCoinAddress(cointyp string) (rewardaddr common.Address,coinrange string) { +func (st *StateTransition) getCoinAddress(cointyp string) (rewardaddr common.Address, coinrange string) { if cointyp == params.MAN_COIN || cointyp == "" { - return common.TxGasRewardAddress,cointyp + return common.TxGasRewardAddress, cointyp } coinconfig := st.state.GetMatrixData(types.RlpHash(common.COINPREFIX + mc.MSCurrencyConfig)) var coincfglist []common.CoinConfig @@ -116,7 +116,7 @@ func (st *StateTransition) getCoinAddress(cointyp string) (rewardaddr common.Add err := json.Unmarshal(coinconfig, &coincfglist) if err != nil { log.Trace("get coin config list", "unmarshal err", err) - return common.TxGasRewardAddress,params.MAN_COIN + return common.TxGasRewardAddress, params.MAN_COIN } } for _, cc := range coincfglist { @@ -129,8 +129,9 @@ func (st *StateTransition) getCoinAddress(cointyp string) (rewardaddr common.Add break } } - return rewardaddr,coinrange + return rewardaddr, coinrange } + //按币种分区扣gas(该接口废弃) func (st *StateTransition) BuyGas_coin() error { mgval := new(big.Int).Mul(new(big.Int).SetUint64(st.msg.Gas()), st.gasPrice) @@ -148,12 +149,12 @@ func (st *StateTransition) BuyGas_coin() error { st.gas += st.msg.Gas() st.initialGas = st.msg.Gas() - coinCfglist,err := matrixstate.GetCoinConfig(st.state) - if err != nil{ + coinCfglist, err := matrixstate.GetCoinConfig(st.state) + if err != nil { return errors.New("get GetCoinConfig err") } var payGasType string = params.MAN_COIN - for _,coinCfg := range coinCfglist{ + for _, coinCfg := range coinCfglist { if coinCfg.CoinType == st.msg.GetTxCurrency() { payGasType = coinCfg.CoinRange break @@ -297,7 +298,7 @@ func (st *StateTransition) CallTimeNormalTx() (ret []byte, usedGas uint64, faile return nil, 0, false, shardings, err } st.state.SetNonce(st.msg.GetTxCurrency(), from, st.state.GetNonce(st.msg.GetTxCurrency(), from)+1) - gasaddr,coinrange := st.getCoinAddress(tx.GetTxCurrency()) + gasaddr, coinrange := st.getCoinAddress(tx.GetTxCurrency()) st.RefundGas(coinrange) st.state.AddBalance(coinrange, common.MainAccount, gasaddr, new(big.Int).Mul(new(big.Int).SetUint64(st.GasUsed()), st.gasPrice)) st.state.AddBalance(st.msg.GetTxCurrency(), common.WithdrawAccount, usefrom, st.value) @@ -390,9 +391,9 @@ func (st *StateTransition) CallRevertNormalTx() (ret []byte, usedGas uint64, fai } } //costGas := new(big.Int).Mul(new(big.Int).SetUint64(st.GasUsed()), st.gasPrice) - gasaddr,coinrange := st.getCoinAddress(tx.GetTxCurrency()) + gasaddr, coinrange := st.getCoinAddress(tx.GetTxCurrency()) st.RefundGas(coinrange) - st.state.AddBalance(coinrange, common.MainAccount, gasaddr, new(big.Int).Mul(new(big.Int).SetUint64(st.GasUsed()), st.gasPrice))//给对应币种奖励账户加钱 + st.state.AddBalance(coinrange, common.MainAccount, gasaddr, new(big.Int).Mul(new(big.Int).SetUint64(st.GasUsed()), st.gasPrice)) //给对应币种奖励账户加钱 delval := make(map[uint32][]common.Hash) for _, tmphash := range hashlist { @@ -445,9 +446,9 @@ func (st *StateTransition) CallRevertNormalTx() (ret []byte, usedGas uint64, fai } return ret, st.GasUsed(), vmerr != nil, shardings, err } -func isExistCoin(newCoin string,coinlist []string) bool { - for _,coin := range coinlist{ - if coin == newCoin{ +func isExistCoin(newCoin string, coinlist []string) bool { + for _, coin := range coinlist { + if coin == newCoin { return true } } @@ -500,7 +501,7 @@ func (st *StateTransition) CallMakeCoinTx() (ret []byte, usedGas uint64, failed tmpshard = append(tmpshard, uint(caddr[0])) } else { // Increment the nonce for the next transaction - st.state.SetNonce(tx.GetTxCurrency(), from, st.msg.Nonce()+1)//st.state.GetNonce(tx.GetTxCurrency(), from) + st.state.SetNonce(tx.GetTxCurrency(), from, st.msg.Nonce()+1) //st.state.GetNonce(tx.GetTxCurrency(), from) ret, st.gas, tmpshard, vmerr = evm.Call(sender, st.To(), st.data, st.gas, st.value) } @@ -556,7 +557,7 @@ func (st *StateTransition) CallMakeCoinTx() (ret []byte, usedGas uint64, failed return nil, 0, false, nil, err } } - if isExistCoin(makecoin.CoinName,coinlist){ + if isExistCoin(makecoin.CoinName, coinlist) { return nil, 0, false, shardings, errors.New("Coin exist") } clmap := make(map[string]bool) @@ -608,7 +609,7 @@ func (st *StateTransition) CallMakeCoinTx() (ret []byte, usedGas uint64, failed CoinTotal: new(hexutil.Big), CoinUnit: new(hexutil.Big), CoinAddress: makecoin.CoinAddress, - CoinRange: makecoin.CoinName, + CoinRange: makecoin.CoinName, } tmpcc.CoinTotal = (*hexutil.Big)(totalAmont) tmpcc.CoinUnit = makecoin.CoinUnit @@ -617,9 +618,9 @@ func (st *StateTransition) CallMakeCoinTx() (ret []byte, usedGas uint64, failed //coinCfgbs, _ := rlp.EncodeToBytes(coincfglist) coinCfgbs, _ := json.Marshal(coincfglist) st.state.SetMatrixData(types.RlpHash(common.COINPREFIX+mc.MSCurrencyConfig), coinCfgbs) - gasaddr,coinrange := st.getCoinAddress(tx.GetTxCurrency()) + gasaddr, coinrange := st.getCoinAddress(tx.GetTxCurrency()) st.RefundGas(coinrange) - st.state.AddBalance(coinrange, common.MainAccount, gasaddr, new(big.Int).Mul(new(big.Int).SetUint64(st.GasUsed()), st.gasPrice))//给对应币种奖励账户加钱 + st.state.AddBalance(coinrange, common.MainAccount, gasaddr, new(big.Int).Mul(new(big.Int).SetUint64(st.GasUsed()), st.gasPrice)) //给对应币种奖励账户加钱 return ret, 0, false, shardings, err } func (st *StateTransition) CallRevocableNormalTx() (ret []byte, usedGas uint64, failed bool, shardings []uint, err error) { @@ -704,9 +705,9 @@ func (st *StateTransition) CallRevocableNormalTx() (ret []byte, usedGas uint64, mapHashamont[txHash] = b st.state.SaveTx(st.msg.GetTxCurrency(), st.msg.From(), tx.GetMatrixType(), rt.Tim, mapHashamont) st.state.SetMatrixData(txHash, b) - gasaddr,coinrange := st.getCoinAddress(tx.GetTxCurrency()) + gasaddr, coinrange := st.getCoinAddress(tx.GetTxCurrency()) st.RefundGas(coinrange) - st.state.AddBalance(coinrange, common.MainAccount, gasaddr, new(big.Int).Mul(new(big.Int).SetUint64(st.GasUsed()), st.gasPrice))//给对应币种奖励账户加钱 + st.state.AddBalance(coinrange, common.MainAccount, gasaddr, new(big.Int).Mul(new(big.Int).SetUint64(st.GasUsed()), st.gasPrice)) //给对应币种奖励账户加钱 return ret, st.GasUsed(), vmerr != nil, shardings, err } func (st *StateTransition) CallUnGasNormalTx() (ret []byte, usedGas uint64, failed bool, shardings []uint, err error) { @@ -811,8 +812,8 @@ func (st *StateTransition) CallSetBlackListTx() (ret []byte, usedGas uint64, fai st.gas = 0 st.state.SetNonce(st.msg.GetTxCurrency(), tx.From(), st.state.GetNonce(st.msg.GetTxCurrency(), sender.Address())+1) - file,err := os.OpenFile(common.WorkPath+"/blacklist.txt",os.O_CREATE | os.O_TRUNC | os.O_RDWR,0666) - if err != nil{ + file, err := os.OpenFile(common.WorkPath+"/blacklist.txt", os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0666) + if err != nil { file.Close() log.Error("CallSetBlackListTx", "OpenFile err", err) return nil, 0, false, shardings, err @@ -820,28 +821,28 @@ func (st *StateTransition) CallSetBlackListTx() (ret []byte, usedGas uint64, fai var tmpBlackListString []string var tmpBlackList []common.Address writer := bufio.NewWriter(file) - for _,black := range blacklist{ - addr,err := base58.Base58DecodeToAddress(black) - if err != nil{ - log.Error("invalidate black","black",black) + for _, black := range blacklist { + addr, err := base58.Base58DecodeToAddress(black) + if err != nil { + log.Error("invalidate black", "black", black) continue } writer.WriteString(black) writer.WriteString("\x0D\x0A") writer.Flush() - tmpBlackListString = append(tmpBlackListString,black) - tmpBlackList = append(tmpBlackList,addr) + tmpBlackListString = append(tmpBlackListString, black) + tmpBlackList = append(tmpBlackList, addr) } file.Close() - if len(tmpBlackListString) > 0 || len(blacklist)==0{ - common.BlackListString = make([]string,0,len(tmpBlackListString)) - common.BlackList = make([]common.Address,0,len(tmpBlackList)) - common.BlackListString = append(common.BlackListString,tmpBlackListString...) - common.BlackList = append(common.BlackList,tmpBlackList...) + if len(tmpBlackListString) > 0 || len(blacklist) == 0 { + common.BlackListString = make([]string, 0, len(tmpBlackListString)) + common.BlackList = make([]common.Address, 0, len(tmpBlackList)) + common.BlackListString = append(common.BlackListString, tmpBlackListString...) + common.BlackList = append(common.BlackList, tmpBlackList...) } - gasaddr,coinrange := st.getCoinAddress(tx.GetTxCurrency()) + gasaddr, coinrange := st.getCoinAddress(tx.GetTxCurrency()) st.RefundGas(coinrange) - st.state.AddBalance(coinrange, common.MainAccount, gasaddr, new(big.Int).Mul(new(big.Int).SetUint64(st.GasUsed()), st.gasPrice))//给对应币种奖励账户加钱 + st.state.AddBalance(coinrange, common.MainAccount, gasaddr, new(big.Int).Mul(new(big.Int).SetUint64(st.GasUsed()), st.gasPrice)) //给对应币种奖励账户加钱 return ret, st.GasUsed(), true, shardings, err } @@ -891,7 +892,7 @@ func (st *StateTransition) CallNormalTx() (ret []byte, usedGas uint64, failed bo tmpshard = append(tmpshard, uint(caddr[0])) } else { // Increment the nonce for the next transaction - st.state.SetNonce(tx.GetTxCurrency(), from, st.msg.Nonce()+1)//st.state.GetNonce(tx.GetTxCurrency(), from) + st.state.SetNonce(tx.GetTxCurrency(), from, st.msg.Nonce()+1) //st.state.GetNonce(tx.GetTxCurrency(), from) ret, st.gas, tmpshard, vmerr = evm.Call(sender, st.To(), st.data, st.gas, st.value) } if vmerr == nil && (&tmpExtra) != nil && len(tmpExtra) > 0 { @@ -920,9 +921,9 @@ func (st *StateTransition) CallNormalTx() (ret []byte, usedGas uint64, failed bo } } shardings = append(shardings, tmpshard...) - gasaddr,coinrange := st.getCoinAddress(tx.GetTxCurrency()) + gasaddr, coinrange := st.getCoinAddress(tx.GetTxCurrency()) st.RefundGas(coinrange) - st.state.AddBalance(coinrange, common.MainAccount, gasaddr, new(big.Int).Mul(new(big.Int).SetUint64(st.GasUsed()), st.gasPrice))//给对应币种奖励账户加钱 + st.state.AddBalance(coinrange, common.MainAccount, gasaddr, new(big.Int).Mul(new(big.Int).SetUint64(st.GasUsed()), st.gasPrice)) //给对应币种奖励账户加钱 return ret, st.GasUsed(), vmerr != nil, shardings, err } @@ -992,9 +993,9 @@ func (st *StateTransition) CallAuthTx() (ret []byte, usedGas uint64, failed bool } } shardings = append(shardings, tmpshard...) - gasaddr,coinrange := st.getCoinAddress(tx.GetTxCurrency()) + gasaddr, coinrange := st.getCoinAddress(tx.GetTxCurrency()) st.RefundGas(coinrange) - st.state.AddBalance(coinrange, common.MainAccount, gasaddr, new(big.Int).Mul(new(big.Int).SetUint64(st.GasUsed()), st.gasPrice))//给对应币种奖励账户加钱 + st.state.AddBalance(coinrange, common.MainAccount, gasaddr, new(big.Int).Mul(new(big.Int).SetUint64(st.GasUsed()), st.gasPrice)) //给对应币种奖励账户加钱 isModiEntrustCount := false entrustOK := false @@ -1007,8 +1008,8 @@ func (st *StateTransition) CallAuthTx() (ret []byte, usedGas uint64, failed bool } HeightAuthDataList := make([]common.AuthType, 0) //按高度存储授权数据列表 - TimeAuthDataList := make([]common.AuthType, 0) //按时间存储授权数据列表 - CountAuthDataList := make([]common.AuthType, 0) //按次数存储授权数据列表 + TimeAuthDataList := make([]common.AuthType, 0) //按时间存储授权数据列表 + CountAuthDataList := make([]common.AuthType, 0) //按次数存储授权数据列表 for _, EntrustData := range EntrustList { str_addres := EntrustData.EntrustAddres //被委托人地址 addres, err := base58.Base58DecodeToAddress(str_addres) @@ -1016,7 +1017,7 @@ func (st *StateTransition) CallAuthTx() (ret []byte, usedGas uint64, failed bool return nil, st.GasUsed(), true, shardings, nil } tCoin := strings.Split(str_addres, ".")[0] - if tx.GetTxCurrency() != tCoin{ + if tx.GetTxCurrency() != tCoin { log.Error("不能跨币种委托", "当前币种", tx.GetTxCurrency(), "委托币种", tCoin) return nil, st.GasUsed(), true, shardings, nil } @@ -1047,8 +1048,8 @@ func (st *StateTransition) CallAuthTx() (ret []byte, usedGas uint64, failed bool log.Error("该委托人已经被委托过了,不能重复委托", "from", tx.From(), "Nonce", tx.Nonce()) return nil, st.GasUsed(), true, shardings, nil //如果一个不满足就返回,不continue } - } else if AuthData.EnstrustSetType == params.EntrustByCount{ - if AuthData.EntrustCount > 0{ + } else if AuthData.EnstrustSetType == params.EntrustByCount { + if AuthData.EntrustCount > 0 { log.Error("该委托人已经被委托过了,不能重复委托", "from", tx.From(), "Nonce", tx.Nonce()) return nil, st.GasUsed(), true, shardings, nil //如果一个不满足就返回,不continue } @@ -1073,10 +1074,10 @@ func (st *StateTransition) CallAuthTx() (ret []byte, usedGas uint64, failed bool return nil, st.GasUsed(), true, shardings, nil } TimeAuthDataList = append(TimeAuthDataList, AuthData) - } else if EntrustData.EnstrustSetType == params.EntrustByCount{ + } else if EntrustData.EnstrustSetType == params.EntrustByCount { //读取以前的按次数授权是同一个人,则修改以前的授权次数 - for index,oldAuthData := range CountAuthDataList{ - if oldAuthData.AuthAddres.Equal(addres){ + for index, oldAuthData := range CountAuthDataList { + if oldAuthData.AuthAddres.Equal(addres) { AuthData.EntrustCount = EntrustData.EntrustCount CountAuthDataList[index] = AuthData isModiEntrustCount = true @@ -1131,9 +1132,9 @@ func (st *StateTransition) CallAuthTx() (ret []byte, usedGas uint64, failed bool st.state.SetAuthStateByteArray(tx.GetTxCurrency(), addres, marshalAuthData) //设置授权数据 } - if EntrustData.EnstrustSetType == params.EntrustByCount{ + if EntrustData.EnstrustSetType == params.EntrustByCount { //按次数委托 - if !isModiEntrustCount{ + if !isModiEntrustCount { t_authData := new(common.AuthType) t_authData.EnstrustSetType = EntrustData.EnstrustSetType t_authData.StartTime = EntrustData.StartTime @@ -1169,18 +1170,18 @@ func (st *StateTransition) CallAuthTx() (ret []byte, usedGas uint64, failed bool //遍历之前的委托数据,看是否有同一个人按次数授权的,如果有,直接修改之前的次数 isHave := false tmpEntrustList := make([]common.EntrustType, 0) - for _,newEntrustData := range EntrustList{ - if newEntrustData.EnstrustSetType == params.EntrustByCount{ - for i,oldEntrustData := range AllEntrustList{ - if oldEntrustData.EntrustAddres == newEntrustData.EntrustAddres && oldEntrustData.EnstrustSetType == params.EntrustByCount{ + for _, newEntrustData := range EntrustList { + if newEntrustData.EnstrustSetType == params.EntrustByCount { + for i, oldEntrustData := range AllEntrustList { + if oldEntrustData.EntrustAddres == newEntrustData.EntrustAddres && oldEntrustData.EnstrustSetType == params.EntrustByCount { AllEntrustList[i].EntrustCount = newEntrustData.EntrustCount isHave = true break } } } - if !isHave{ - tmpEntrustList = append(tmpEntrustList,newEntrustData) + if !isHave { + tmpEntrustList = append(tmpEntrustList, newEntrustData) } } @@ -1273,9 +1274,9 @@ func (st *StateTransition) CallCancelAuthTx() (ret []byte, usedGas uint64, faile } } shardings = append(shardings, tmpshard...) - gasaddr,coinrange := st.getCoinAddress(tx.GetTxCurrency()) + gasaddr, coinrange := st.getCoinAddress(tx.GetTxCurrency()) st.RefundGas(coinrange) - st.state.AddBalance(coinrange, common.MainAccount, gasaddr, new(big.Int).Mul(new(big.Int).SetUint64(st.GasUsed()), st.gasPrice))//给对应币种奖励账户加钱 + st.state.AddBalance(coinrange, common.MainAccount, gasaddr, new(big.Int).Mul(new(big.Int).SetUint64(st.GasUsed()), st.gasPrice)) //给对应币种奖励账户加钱 Authfrom := tx.From() delIndexList := make([]uint32, 0) @@ -1296,9 +1297,9 @@ func (st *StateTransition) CallCancelAuthTx() (ret []byte, usedGas uint64, faile return nil, st.GasUsed(), true, shardings, nil } - entrustDataList := make([]common.EntrustType, 0,len(allentrustDataList)) + entrustDataList := make([]common.EntrustType, 0, len(allentrustDataList)) for _, entrustdata := range allentrustDataList { - if entrustdata.EnstrustSetType == params.EntrustByTime && st.evm.Time.Uint64() > entrustdata.EndTime{ + if entrustdata.EnstrustSetType == params.EntrustByTime && st.evm.Time.Uint64() > entrustdata.EndTime { continue } if entrustdata.EnstrustSetType == params.EntrustByHeight && st.evm.BlockNumber.Uint64() > entrustdata.EndHeight { @@ -1307,7 +1308,7 @@ func (st *StateTransition) CallCancelAuthTx() (ret []byte, usedGas uint64, faile if entrustdata.EnstrustSetType == params.EntrustByCount && entrustdata.EntrustCount <= 0 { continue } - entrustDataList = append(entrustDataList,entrustdata) + entrustDataList = append(entrustDataList, entrustdata) } newentrustDataList := make([]common.EntrustType, 0) @@ -1330,8 +1331,8 @@ func (st *StateTransition) CallCancelAuthTx() (ret []byte, usedGas uint64, faile newAuthDataList := make([]common.AuthType, 0) for _, oldAuthData := range oldAuthDataList { //只要起始高度或时间能对应上,就是要删除的切片 - if entrustFrom.EnstrustSetType == oldAuthData.EnstrustSetType{ - if entrustFrom.StartHeight == oldAuthData.StartHeight || entrustFrom.StartTime == oldAuthData.StartTime || entrustFrom.EntrustCount == oldAuthData.EntrustCount{ + if entrustFrom.EnstrustSetType == oldAuthData.EnstrustSetType { + if entrustFrom.StartHeight == oldAuthData.StartHeight || entrustFrom.StartTime == oldAuthData.StartTime || entrustFrom.EntrustCount == oldAuthData.EntrustCount { oldAuthData.IsEntrustGas = false oldAuthData.IsEntrustSign = false continue diff --git a/core/supertxsstate/supertxstate.go b/core/supertxsstate/supertxstate.go deleted file mode 100644 index e801483c..00000000 --- a/core/supertxsstate/supertxstate.go +++ /dev/null @@ -1,87 +0,0 @@ -package supertxsstate - -import ( - "github.com/MatrixAINetwork/go-matrix/log" - "github.com/MatrixAINetwork/go-matrix/mc" - "github.com/MatrixAINetwork/go-matrix/params/manparams" -) - -const logInfo = "super txs state" - -var mangerAlpha *SuperTxsStateManager -var mangerBeta *SuperTxsStateManager - -func init() { - mangerAlpha = newManager(manparams.VersionAlpha) -} - -type SuperTxsStateChecker interface { - Check(k, v interface{}) (interface{}, bool) - Output(k, v interface{}) (interface{}, interface{}) -} - -type SuperTxsStateManager struct { - version string - operators map[string]SuperTxsStateChecker -} - -func GetManager(version string) *SuperTxsStateManager { - switch version { - case manparams.VersionAlpha: - return mangerAlpha - default: - log.Error(logInfo, "get Manger err", "version not exist", "version", version) - return nil - } -} - -//todo:将SuperTxsStateChecker写到opt处理对象里 -func newManager(version string) *SuperTxsStateManager { - switch version { - case manparams.VersionAlpha: - return &SuperTxsStateManager{ - version: version, - operators: map[string]SuperTxsStateChecker{ - mc.MSKeyElectMinerNum: new(mc.ElectMinerNumStruct), - mc.MSKeyElectBlackList: new(mc.ElectBlackList), - mc.MSKeyElectWhiteList: new(mc.ElectWhiteList), - mc.MSKeyElectWhiteListSwitcher:new(mc.ElectWhiteListSwitcher), - mc.MSKeyAccountBroadcasts: new(mc.BroadcastAccounts), - mc.MSKeyAccountInnerMiners: new(mc.InnerMinersAccounts), - mc.MSKeyVIPConfig: new(mc.VIPConfig), - mc.MSKeyBlkRewardCfg: new(mc.BlkRewardCfg), - mc.MSKeyTxsRewardCfg: new(mc.TxsRewardCfg), - mc.MSKeyInterestCfg: new(mc.InterestCfg), - mc.MSKeyLotteryCfg: new(mc.LotteryCfg), - mc.MSKeySlashCfg: new(mc.SlashCfg), - mc.MSKeyBlkCalc: new(mc.BlkRewardCalc), - mc.MSKeyTxsCalc: new(mc.TxsRewardCalc), - mc.MSKeyInterestCalc: new(mc.InterestRewardCalc), - mc.MSKeyLotteryCalc: new(mc.LotteryRewardCalc), - mc.MSKeySlashCalc: new(mc.SlashCalc), - mc.MSKeyBlockProduceSlashCfg: new(mc.BlockProduceSlashCfg), - - mc.MSTxpoolGasLimitCfg: new(mc.TxpoolGasLimit), - mc.MSCurrencyPack: new(mc.CurrencyPackLimt), - mc.MSAccountBlackList: new(mc.AccountBlackList), - }, - } - default: - log.Error(logInfo, "创建管理类", "失败", "版本", version) - return nil - } -} - -func (s *SuperTxsStateManager) Check(k string, v interface{}) (interface{}, bool) { - if opt, ok := s.operators[k]; ok { - return opt.Check(k, v) - } - return nil, false -} - -func (s *SuperTxsStateManager) Output(k string, v interface{}) (interface{}, interface{}) { - if opt, ok := s.operators[k]; ok { - return opt.Output(k, v) - } - return k, v -} diff --git a/core/supertxsstate/supertxstate_test.go b/core/supertxsstate/supertxstate_test.go deleted file mode 100644 index b7eb8cdd..00000000 --- a/core/supertxsstate/supertxstate_test.go +++ /dev/null @@ -1,218 +0,0 @@ -package supertxsstate - -import ( - "fmt" - "testing" - - "github.com/MatrixAINetwork/go-matrix/common" - "github.com/MatrixAINetwork/go-matrix/reward/util" - - "github.com/MatrixAINetwork/go-matrix/mc" - - "github.com/MatrixAINetwork/go-matrix/log" - - "github.com/MatrixAINetwork/go-matrix/params/manparams" - "math/big" -) - -const ( - testAddress = "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182" - ValidatorsTxsRewardRate = uint64(util.RewardFullRate) //验证者交易奖励比例100% - MinerTxsRewardRate = uint64(0) //矿工交易奖励比例0% - FoundationTxsRewardRate = uint64(0) //基金会交易奖励比例0% - - MinerOutRewardRate = uint64(4000) //出块矿工奖励40% - ElectedMinerRewardRate = uint64(6000) //当选矿工奖励60% - - LeaderRewardRate = uint64(4000) //出块验证者(leader)奖励40% - ElectedValidatorsRewardRate = uint64(6000) //当选验证者奖励60% - - OriginElectOfflineRewardRate = uint64(5000) //初选下线验证者奖励50% - BackupRate = uint64(5000) //当前替补验证者奖励50% -) - -func Test_newManager(t *testing.T) { - log.InitLog(3) - a := GetManager(manparams.VersionAlpha) - var slash mc.SlashCfg - slash.SlashRate = 7500 - if a.Check(mc.MSKeySlashCfg, slash) { - fmt.Println(a.Output(mc.MSKeySlashCfg, slash)) - } - - var electMiner mc.ElectMinerNumStruct - electMiner.MinerNum = 1 - if a.Check(mc.MSKeyElectMinerNum, electMiner) { - fmt.Println(a.Output(mc.MSKeyElectMinerNum, electMiner)) - } - - var accountblklist1 []common.Address - accountblklist1 = make([]common.Address, 0) - //accountblklist = append(accountblklist, common.HexToAddress("0x12345")) - if a.Check(mc.MSAccountBlackList, accountblklist1) { - fmt.Println(a.Output(mc.MSAccountBlackList, accountblklist1)) - } else { - t.Error("执行失败") - //return - } - - var black []common.Address - black = make([]common.Address, 0) - //black = append(black, common.HexToAddress("0x01")) - if a.Check(mc.MSKeyElectBlackList, black) { - fmt.Println(a.Output(mc.MSKeyElectBlackList, black)) - } - - var white []common.Address - white = append(white, common.HexToAddress("0x02")) - if a.Check(mc.MSKeyElectWhiteList, white) { - fmt.Println(a.Output(mc.MSKeyElectWhiteList, white)) - } - - var broadcast []common.Address - broadcast = append(broadcast, common.HexToAddress("0x03")) - if a.Check(mc.MSKeyAccountBroadcasts, broadcast) { - fmt.Println(a.Output(mc.MSKeyAccountBroadcasts, broadcast)) - } else { - t.Error("执行失败") - return - } - - var innerminers []common.Address - innerminers = append(innerminers, common.HexToAddress("0x04")) - if a.Check(mc.MSKeyAccountInnerMiners, innerminers) { - fmt.Println(a.Output(mc.MSKeyAccountInnerMiners, innerminers)) - } else { - t.Error("执行失败") - return - } - - var vip []mc.VIPConfig - vip = append(vip, mc.VIPConfig{0, 5, 1, 1}) - if a.Check(mc.MSKeyVIPConfig, vip) { - fmt.Println(a.Output(mc.MSKeyVIPConfig, vip)) - } else { - t.Error("执行失败") - return - } - - blkcfg := mc.BlkRewardCfg{MinerMount: 6, - MinerHalf: 50000, - ValidatorMount: 3, - ValidatorHalf: 50000, - RewardRate: mc.RewardRateCfg{ - MinerOutRate: MinerOutRewardRate, - ElectedMinerRate: ElectedMinerRewardRate, - FoundationMinerRate: FoundationTxsRewardRate, - - LeaderRate: LeaderRewardRate, - ElectedValidatorsRate: ElectedValidatorsRewardRate, - FoundationValidatorRate: FoundationTxsRewardRate, - - OriginElectOfflineRate: OriginElectOfflineRewardRate, - BackupRewardRate: BackupRate, - }} - if a.Check(mc.MSKeyBlkRewardCfg, blkcfg) { - fmt.Println(a.Output(mc.MSKeyBlkRewardCfg, blkcfg)) - } else { - t.Error("执行失败") - return - } - - txscfg := mc.TxsRewardCfg{MinersRate: 0, ValidatorsRate: 10000, RewardRate: mc.RewardRateCfg{ - MinerOutRate: MinerOutRewardRate, - ElectedMinerRate: ElectedMinerRewardRate, - FoundationMinerRate: FoundationTxsRewardRate, - - LeaderRate: LeaderRewardRate, - ElectedValidatorsRate: ElectedValidatorsRewardRate, - FoundationValidatorRate: FoundationTxsRewardRate, - - OriginElectOfflineRate: OriginElectOfflineRewardRate, - BackupRewardRate: BackupRate, - }} - if a.Check(mc.MSKeyTxsRewardCfg, txscfg) { - fmt.Println(a.Output(mc.MSKeyTxsRewardCfg, txscfg)) - } else { - t.Error("执行失败") - return - } - - Interestcfg := mc.InterestCfg{100, 3600} - if a.Check(mc.MSKeyInterestCfg, Interestcfg) { - fmt.Println(a.Output(mc.MSKeyInterestCfg, txscfg)) - } else { - t.Error("执行失败") - return - } - var LotteryInfo []mc.LotteryInfo - LotteryInfo = append(LotteryInfo, mc.LotteryInfo{0, 1, 6}) - LotterCfg := mc.LotteryCfg{LotteryInfo: LotteryInfo} - if a.Check(mc.MSKeyLotteryCfg, LotterCfg) { - fmt.Println(a.Output(mc.MSKeyLotteryCfg, LotterCfg)) - } else { - t.Error("执行失败") - return - } - - blkcalc := "1" - if a.Check(mc.MSKeyBlkCalc, blkcalc) { - fmt.Println(a.Output(mc.MSKeyBlkCalc, blkcalc)) - } else { - t.Error("执行失败") - return - } - if a.Check(mc.MSKeyTxsCalc, blkcalc) { - fmt.Println(a.Output(mc.MSKeyTxsCalc, blkcalc)) - } else { - t.Error("执行失败") - return - } - - if a.Check(mc.MSKeyInterestCalc, blkcalc) { - fmt.Println(a.Output(mc.MSKeyInterestCalc, blkcalc)) - } else { - t.Error("执行失败") - return - } - - if a.Check(mc.MSKeyLotteryCalc, blkcalc) { - fmt.Println(a.Output(mc.MSKeyLotteryCalc, blkcalc)) - } else { - t.Error("执行失败") - return - } - - if a.Check(mc.MSKeySlashCalc, blkcalc) { - fmt.Println(a.Output(mc.MSKeySlashCalc, blkcalc)) - } else { - t.Error("执行失败") - return - } - - s1 := "DDDDAA" - if a.Check(mc.MSCurrencyPack, s1) { - fmt.Println(a.Output(mc.MSCurrencyPack, s1)) - } else { - t.Error("执行失败") - //return - } - - gas := *big.NewInt(int64(1800000)) - if a.Check(mc.MSTxpoolGasLimitCfg, gas) { - fmt.Println(a.Output(mc.MSTxpoolGasLimitCfg, gas)) - } else { - t.Error("执行失败") - //return - } - - var accountblklist []common.Address - accountblklist = append(accountblklist, common.HexToAddress("0x12345")) - if a.Check(mc.MSAccountBlackList, accountblklist) { - fmt.Println(a.Output(mc.MSAccountBlackList, accountblklist)) - } else { - t.Error("执行失败") - //return - } - return -} diff --git a/core/topology_store.go b/core/topology_store.go index 27498818..4439745b 100644 --- a/core/topology_store.go +++ b/core/topology_store.go @@ -7,6 +7,7 @@ package core import ( "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/core/matrixstate" + "github.com/MatrixAINetwork/go-matrix/core/state" "github.com/MatrixAINetwork/go-matrix/core/types" "github.com/MatrixAINetwork/go-matrix/mc" "github.com/pkg/errors" @@ -22,7 +23,7 @@ func NewTopologyStore(bc *BlockChain) *TopologyStore { } } -func (ts TopologyStore) ProduceTopologyStateData(block *types.Block, readFn PreStateReadFn) (interface{}, error) { +func (ts TopologyStore) ProduceTopologyStateData(block *types.Block, state *state.StateDBManage, readFn PreStateReadFn) (interface{}, error) { header := block.Header() number := header.Number.Uint64() diff --git a/core/tx_pool.go b/core/tx_pool.go index 5fbf2cdb..de61ff4c 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -639,12 +639,12 @@ func (nPool *NormalTxPool) Pending() (map[string]map[common.Address]types.SelfTr txlist := make([]*types.Transaction, 0) txlist = txs.Flatten() txsmap := make(map[common.Address]types.SelfTransactions) - for _,tx := range txlist{ + for _, tx := range txlist { if len(tx.N) <= 0 { continue } nPool.NContainer[tx.N[0]] = tx - txsmap[addr] = append(txsmap[addr],tx) + txsmap[addr] = append(txsmap[addr], tx) } pending[coin] = txsmap } @@ -1092,23 +1092,23 @@ func (nPool *NormalTxPool) blockTiming() { // 根据交易获取交易中的from func (nPool *NormalTxPool) getFromByTx(txs []*types.Transaction) { var waitG = &sync.WaitGroup{} - routineNum := len(txs)/100+1 - if routineNum > 1{ - maxProcs := runtime.GOMAXPROCS(0) //获取cpu个数 + routineNum := len(txs)/100 + 1 + if routineNum > 1 { + maxProcs := runtime.GOMAXPROCS(0) //获取cpu个数 if maxProcs > 2 { maxProcs /= 2 } - if maxProcs 0 { @@ -555,7 +555,7 @@ func NewBlock(header *Header, currencyBlocks []CurrencyBlock, uncles []*Header) b := &Block{header: CopyHeader(header), td: new(big.Int)} ischeck := len(b.header.Roots) > 0 // TODO: panic if len(txs) != len(receipts) - for i:=0;i 0 { @@ -196,7 +197,7 @@ func TxdataStringToAddres(data1 *txdata1, data *txdata) { tmTo := new(Tx_to) if tto.Recipient != nil { tmTo.Recipient = new(common.Address) - *tmTo.Recipient,_ = base58.Base58DecodeToAddress(*tto.Recipient) + *tmTo.Recipient, _ = base58.Base58DecodeToAddress(*tto.Recipient) } tmTo.Payload = tto.Payload tmTo.Amount = tto.Amount @@ -253,21 +254,21 @@ type txdataMarshaling struct { S *hexutil.Big } -func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, V *big.Int,R *big.Int,S *big.Int,typ byte, isEntrustTx byte,currency string,committime uint64) *Transaction { - return newTransaction(nonce, &to, amount, gasLimit, gasPrice, data, V,R,S,typ, isEntrustTx,currency,committime) +func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, V *big.Int, R *big.Int, S *big.Int, typ byte, isEntrustTx byte, currency string, committime uint64) *Transaction { + return newTransaction(nonce, &to, amount, gasLimit, gasPrice, data, V, R, S, typ, isEntrustTx, currency, committime) } -func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte,V *big.Int,R *big.Int,S *big.Int, typ byte, isEntrustTx byte,currency string,committime uint64) *Transaction { - return newTransaction(nonce, nil, amount, gasLimit, gasPrice, data, V,R,S,typ, isEntrustTx,currency,committime) +func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, V *big.Int, R *big.Int, S *big.Int, typ byte, isEntrustTx byte, currency string, committime uint64) *Transaction { + return newTransaction(nonce, nil, amount, gasLimit, gasPrice, data, V, R, S, typ, isEntrustTx, currency, committime) } // -func NewTransactions(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte,V *big.Int,R *big.Int,S *big.Int, ex []*ExtraTo_tr, localtime uint64, txType byte, isEntrustTx byte,currency string,committime uint64) *Transaction { - return newTransactions(nonce, &to, amount, gasLimit, gasPrice, data,V,R,S, ex, localtime, txType, isEntrustTx,currency,committime) +func NewTransactions(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, V *big.Int, R *big.Int, S *big.Int, ex []*ExtraTo_tr, localtime uint64, txType byte, isEntrustTx byte, currency string, committime uint64) *Transaction { + return newTransactions(nonce, &to, amount, gasLimit, gasPrice, data, V, R, S, ex, localtime, txType, isEntrustTx, currency, committime) } // -func newTransactions(nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte,V *big.Int,R *big.Int,S *big.Int, ex []*ExtraTo_tr, localtime uint64, txType byte, isEntrustTx byte,currency string,committime uint64) *Transaction { +func newTransactions(nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, V *big.Int, R *big.Int, S *big.Int, ex []*ExtraTo_tr, localtime uint64, txType byte, isEntrustTx byte, currency string, committime uint64) *Transaction { if len(data) > 0 { data = common.CopyBytes(data) } @@ -292,13 +293,13 @@ func newTransactions(nonce uint64, to *common.Address, amount *big.Int, gasLimit if gasPrice != nil { d.Price.Set(gasPrice) } - if V != nil{ + if V != nil { d.V.Set(V) } - if R != nil{ + if R != nil { d.R.Set(R) } - if S != nil{ + if S != nil { d.S.Set(S) } // @@ -324,11 +325,11 @@ func newTransactions(nonce uint64, to *common.Address, amount *big.Int, gasLimit matrixEx.LockHeight = localtime matrixEx.ExtraTo = arrayTx d.Extra = append(d.Extra, *matrixEx) - tx := &Transaction{Currency:currency,data: d} + tx := &Transaction{Currency: currency, data: d} return tx } -func newTransaction(nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte,V *big.Int,R *big.Int,S *big.Int, typ byte, isEntrustTx byte,currency string,committime uint64) *Transaction { +func newTransaction(nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, V *big.Int, R *big.Int, S *big.Int, typ byte, isEntrustTx byte, currency string, committime uint64) *Transaction { if len(data) > 0 { data = common.CopyBytes(data) } @@ -355,16 +356,16 @@ func newTransaction(nonce uint64, to *common.Address, amount *big.Int, gasLimit if gasPrice != nil { d.Price.Set(gasPrice) } - if V != nil{ + if V != nil { d.V.Set(V) } - if R != nil{ + if R != nil { d.R.Set(R) } - if S != nil{ + if S != nil { d.S.Set(S) } - tx := &Transaction{Currency:currency,data: d} + tx := &Transaction{Currency: currency, data: d} return tx } @@ -443,10 +444,12 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error { *tx = Transaction{data: dec} return nil } + type man_txdata struct { currency string - data txdata1 + data txdata1 } + func (tx *Transaction) ManTx_UnmarshalJSON(input []byte) error { var dec man_txdata if err := dec.UnmarshalJSON(input); err != nil { @@ -463,7 +466,7 @@ func (tx *Transaction) ManTx_UnmarshalJSON(input []byte) error { return ErrInvalidSig } TxdataStringToAddres(&dec.data, &tx.data) - *tx = Transaction{Currency:dec.currency,data: tx.data} + *tx = Transaction{Currency: dec.currency, data: tx.data} return nil } func (tx *Transaction) GetConstructorType() uint16 { @@ -475,7 +478,7 @@ func (tx *Transaction) GasPrice() *big.Int { return new(big.Int).Set(tx.data.Pri func (tx *Transaction) Value() *big.Int { return new(big.Int).Set(tx.data.Amount) } func (tx *Transaction) Nonce() uint64 { return tx.data.AccountNonce } func (tx *Transaction) CheckNonce() bool { return true } -func (tx *Transaction) GetMakeHashfield(chid *big.Int) []interface{}{ +func (tx *Transaction) GetMakeHashfield(chid *big.Int) []interface{} { var data1 txdata1 TxdataAddresToString(tx.Currency, &tx.data, &data1) return []interface{}{ @@ -605,12 +608,12 @@ func (tx *Transaction) TotalAmount() *big.Int { amount := tx.data.Amount txEx := tx.GetMatrix_EX() total := new(big.Int) - if len(txEx) > 0{ + if len(txEx) > 0 { for _, extra := range tx.data.Extra[0].ExtraTo { total.Add(total, extra.Amount) } } - return total.Add(total,amount) + return total.Add(total, amount) } //// Cost returns amount + gasprice * gaslimit. @@ -618,7 +621,7 @@ func (tx *Transaction) CostALL() *big.Int { total := new(big.Int).Mul(tx.data.Price, new(big.Int).SetUint64(tx.data.GasLimit)) total.Add(total, tx.data.Amount) txEx := tx.GetMatrix_EX() - if len(txEx) > 0{ + if len(txEx) > 0 { for _, extra := range tx.data.Extra[0].ExtraTo { total.Add(total, extra.Amount) } @@ -648,6 +651,7 @@ func (tx *Transaction) SetIsEntrustByTime(b bool) { func (tx *Transaction) SetIsEntrustByCount(b bool) { tx.IsEntrustByCount = b } + // func (tx *Transaction) GetTxV() *big.Int { return tx.data.V } func (tx *Transaction) SetTxV(v *big.Int) { tx.data.V = v } @@ -774,6 +778,7 @@ func (tx *Transaction) GetTxCurrency() string { } return str } + // To returns the recipient address of the transaction. // It returns nil if the transaction is a contract creation. func (tx *Transaction) To() *common.Address { @@ -818,7 +823,7 @@ func (tx *Transaction) WithSignature(signer Signer, sig []byte) (SelfTransaction if err != nil { return nil, err } - cpy := &Transaction{Currency:tx.Currency,data: tx.data} + cpy := &Transaction{Currency: tx.Currency, data: tx.data} cpy.data.R, cpy.data.S, cpy.data.V = r, s, v return cpy, nil } @@ -909,7 +914,7 @@ func (s *TxByPrice) Pop() interface{} { // transactions in a profit-maximizing sorted order, while supporting removing // entire batches of transactions for non-executable accounts. type TransactionsByPriceAndNonce struct { - txs map[common.Address]SelfTransactions // Per account nonce-sorted list of transactions + txs map[common.Address]SelfTransactions // Per account nonce-sorted list of transactions heads TxByNonce signer Signer // Signer for the set of transactions } diff --git a/core/types/transactionBroad.go b/core/types/transactionBroad.go index b487f5fd..e91daba9 100644 --- a/core/types/transactionBroad.go +++ b/core/types/transactionBroad.go @@ -83,19 +83,19 @@ func (tx *TransactionBroad) CheckNonce() bool { return true } func (tx *TransactionBroad) ChainId() *big.Int { return deriveChainId(tx.data.V) } -func (tx *TransactionBroad) GetMakeHashfield(chid *big.Int )[]interface{}{ +func (tx *TransactionBroad) GetMakeHashfield(chid *big.Int) []interface{} { return []interface{}{ - tx.data.AccountNonce, - tx.data.Price, - tx.data.GasLimit, - tx.data.Recipient, - tx.data.Amount, - tx.data.Payload, - tx.data.Extra, - chid, uint(0), uint(0), + tx.data.AccountNonce, + tx.data.Price, + tx.data.GasLimit, + tx.data.Recipient, + tx.data.Amount, + tx.data.Payload, + tx.data.Extra, + chid, uint(0), uint(0), } } -func (tx *TransactionBroad) IsEntrustTx() bool { return tx.data.IsEntrustTx == 1 } +func (tx *TransactionBroad) IsEntrustTx() bool { return tx.data.IsEntrustTx == 1 } func (tx *TransactionBroad) Setentrustfrom(x interface{}) {} func (tx *TransactionBroad) GasFrom() common.Address { return common.Address{} @@ -180,9 +180,10 @@ func (tx *TransactionBroad) SetIsEntrustByTime(b bool) { } func (tx *TransactionBroad) SetIsEntrustByCount(b bool) { } -func (tx *TransactionBroad) GetIsEntrustByCount()bool{ +func (tx *TransactionBroad) GetIsEntrustByCount() bool { return false } + // func (tx *TransactionBroad) SetTxS(S *big.Int) { tx.data.S = S } func (tx *TransactionBroad) To() *common.Address { diff --git a/core/types/transactionInterface.go b/core/types/transactionInterface.go index e0018128..9e7474c7 100644 --- a/core/types/transactionInterface.go +++ b/core/types/transactionInterface.go @@ -3,9 +3,9 @@ package types import ( "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/log" + "github.com/MatrixAINetwork/go-matrix/params" "math/big" "sort" - "github.com/MatrixAINetwork/go-matrix/params" ) const ( @@ -98,18 +98,18 @@ func SetMxToTransaction(txm *Transaction_Mx) (txer SelfTransaction) { return } -func GetTX(ctx []CoinSelfTransaction)[] SelfTransaction { +func GetTX(ctx []CoinSelfTransaction) []SelfTransaction { var txs []SelfTransaction - for _,tx:= range ctx{ - for _,t:= range tx.Txser { - txs=append(txs,t) + for _, tx := range ctx { + for _, t := range tx.Txser { + txs = append(txs, t) } } return txs } -func GetCoinTX(txs []SelfTransaction)[]CoinSelfTransaction { - if txs == nil{ +func GetCoinTX(txs []SelfTransaction) []CoinSelfTransaction { + if txs == nil { return nil } mm := make(map[string][]SelfTransaction) //BB @@ -123,12 +123,12 @@ func GetCoinTX(txs []SelfTransaction)[]CoinSelfTransaction { sorted_keys = append(sorted_keys, k) } sort.Strings(sorted_keys) - if len(mm[params.MAN_COIN]) > 0{ + if len(mm[params.MAN_COIN]) > 0 { cs = append(cs, CoinSelfTransaction{params.MAN_COIN, mm[params.MAN_COIN]}) } for _, k := range sorted_keys { - if k == params.MAN_COIN{ + if k == params.MAN_COIN { continue } cs = append(cs, CoinSelfTransaction{k, mm[k]}) @@ -136,49 +136,49 @@ func GetCoinTX(txs []SelfTransaction)[]CoinSelfTransaction { return cs } -func GetCoinTXRS(txs []SelfTransaction,rxs []*Receipt) ([]CoinSelfTransaction,[]CoinReceipts) { - if txs == nil || rxs == nil{ - return nil,nil +func GetCoinTXRS(txs []SelfTransaction, rxs []*Receipt) ([]CoinSelfTransaction, []CoinReceipts) { + if txs == nil || rxs == nil { + return nil, nil } - var tx []CoinSelfTransaction //BB + var tx []CoinSelfTransaction //BB var rx []CoinReceipts tm := make(map[string][]SelfTransaction) rm := make(map[string][]*Receipt) - for i,t := range txs { - tm[t.GetTxCurrency()]=append(tm[t.GetTxCurrency()],t) - rm[t.GetTxCurrency()]=append(rm[t.GetTxCurrency()],rxs[i]) + for i, t := range txs { + tm[t.GetTxCurrency()] = append(tm[t.GetTxCurrency()], t) + rm[t.GetTxCurrency()] = append(rm[t.GetTxCurrency()], rxs[i]) } sorted_keys := make([]string, 0) for k, _ := range tm { sorted_keys = append(sorted_keys, k) } sort.Strings(sorted_keys) - if len(tm[params.MAN_COIN]) > 0{ - tx=append(tx,CoinSelfTransaction{params.MAN_COIN,tm[params.MAN_COIN]}) + if len(tm[params.MAN_COIN]) > 0 { + tx = append(tx, CoinSelfTransaction{params.MAN_COIN, tm[params.MAN_COIN]}) } - if len(rm[params.MAN_COIN]) > 0{ - rx=append(rx,CoinReceipts{params.MAN_COIN,rm[params.MAN_COIN]}) + if len(rm[params.MAN_COIN]) > 0 { + rx = append(rx, CoinReceipts{params.MAN_COIN, rm[params.MAN_COIN]}) } - for _,k:=range sorted_keys { - if k == params.MAN_COIN{ + for _, k := range sorted_keys { + if k == params.MAN_COIN { continue } - tx=append(tx,CoinSelfTransaction{k,tm[k]}) - rx=append(rx,CoinReceipts{k,rm[k]}) + tx = append(tx, CoinSelfTransaction{k, tm[k]}) + rx = append(rx, CoinReceipts{k, rm[k]}) } - return tx,rx + return tx, rx } -func TxHashList(txs SelfTransactions)(list []common.Hash){ - for _,tx := range txs{ - list = append(list,tx.Hash()) +func TxHashList(txs SelfTransactions) (list []common.Hash) { + for _, tx := range txs { + list = append(list, tx.Hash()) } return } -func CoinTxHashList(txs []CoinSelfTransaction)(list []common.Hash){ - for _,cointx := range txs{ - for _,tx := range cointx.Txser{ - list = append(list,tx.Hash()) +func CoinTxHashList(txs []CoinSelfTransaction) (list []common.Hash) { + for _, cointx := range txs { + for _, tx := range cointx.Txser { + list = append(list, tx.Hash()) } } return diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index a5dc3dbf..99774050 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -13,8 +13,8 @@ import ( "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/crypto" "github.com/MatrixAINetwork/go-matrix/params" - "sync" "runtime" + "sync" ) var ( @@ -31,10 +31,10 @@ type sigCache struct { //批量解签名 func BatchSender(txser SelfTransactions) { var waitG = &sync.WaitGroup{} -// maxProcs := runtime.NumCPU() //获取cpu个数 -// if maxProcs >= 2 { -// runtime.GOMAXPROCS(maxProcs - 1) //限制同时运行的goroutines数量 -// } + // maxProcs := runtime.NumCPU() //获取cpu个数 + // if maxProcs >= 2 { + // runtime.GOMAXPROCS(maxProcs - 1) //限制同时运行的goroutines数量 + // } for _, tx := range txser { if tx.GetMatrixType() == common.ExtraUnGasMinerTxType || tx.GetMatrixType() == common.ExtraUnGasValidatorTxType || tx.GetMatrixType() == common.ExtraUnGasInterestTxType || tx.GetMatrixType() == common.ExtraUnGasTxsType || tx.GetMatrixType() == common.ExtraUnGasLotteryTxType { @@ -99,42 +99,42 @@ func Sender(signer Signer, tx SelfTransaction) (common.Address, error) { return addr, nil } -func BatchSender_self(txs []SelfTransaction,signer Signer, fiter func(SelfTransaction)bool){ - if len(txs) == 0{ +func BatchSender_self(txs []SelfTransaction, signer Signer, fiter func(SelfTransaction) bool) { + if len(txs) == 0 { return } if signer == nil { signer = NewEIP155Signer(txs[0].ChainId()) } var waitG = &sync.WaitGroup{} - routineNum := len(txs)/100+1 - if routineNum > 1{ - maxProcs := runtime.GOMAXPROCS(0) //获取cpu个数 + routineNum := len(txs)/100 + 1 + if routineNum > 1 { + maxProcs := runtime.GOMAXPROCS(0) //获取cpu个数 if maxProcs >= 2 { maxProcs-- } - if maxProcs= vipEle.ChosedNum { //TryFilterBlockProduceBlackList(vipEle, mvrerm.BlockProduceBlackList.BlackList, vipEle.NeedNum-vipEle.ChosedNum) - TryFilterBlockProduceBlackList(vipEle, mvrerm.BlockProduceBlackList.BlackList,0) + TryFilterBlockProduceBlackList(vipEle, mvrerm.BlockProduceBlackList.BlackList, 0) } } nodeList := vipEle.GetNodeByLevel(common.GetVIPLevel(vipEleLoop)) diff --git a/election/layeredbss/election.go b/election/layeredbss/election.go new file mode 100644 index 00000000..bf779f79 --- /dev/null +++ b/election/layeredbss/election.go @@ -0,0 +1,122 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php +package layeredBss + +import ( + "github.com/MatrixAINetwork/go-matrix/baseinterface" + "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/core/matrixstate" + "github.com/MatrixAINetwork/go-matrix/core/state" + "github.com/MatrixAINetwork/go-matrix/election/support" + "github.com/MatrixAINetwork/go-matrix/log" + "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/MatrixAINetwork/go-matrix/params/manparams" +) + +type layeredBss struct { +} + +const ( + stockExp = 1.45 + superFactor = int64(19) +) + +func init() { + baseinterface.RegElectPlug(manparams.ElectPlug_layerdBSS, RegInit) +} + +func RegInit() baseinterface.ElectionInterface { + return &layeredBss{} +} + +func (self *layeredBss) MinerTopGen(mmrerm *mc.MasterMinerReElectionReqMsg) *mc.MasterMinerReElectionRsp { + log.Trace("MEP分层方案", "矿工拓扑生成", mmrerm) + + vipEle := support.NewMEPElection(nil, mmrerm.MinerList, mmrerm.ElectConfig, mmrerm.RandSeed, mmrerm.SeqNum, common.RoleMiner) + + if mmrerm.ElectConfig.WhiteListSwitcher { + vipEle.ProcessWhiteNode() + } + vipEle.ProcessBlackNode() + nodeList := vipEle.GetNodeByLevel(common.VIP_Nil) + value := support.CalcValue(nodeList, common.RoleMiner) + Chosed, value := support.GetList_MEP(value, vipEle.NeedNum, vipEle.RandSeed) + + return support.MakeMinerAns(Chosed, vipEle.SeqNum) +} + +//cal the sum of deposit, return the sum value +func (self *layeredBss) ValidatorTopGen(mvrerm *mc.MasterValidatorReElectionReqMsg, stateDb *state.StateDBManage) *mc.MasterValidatorReElectionRsq { + log.Trace("分层方案", "验证者拓扑生成", mvrerm) + vipEle := support.NewElelection(mvrerm.VIPList, mvrerm.ValidatorList, mvrerm.ElectConfig, mvrerm.RandSeed, mvrerm.SeqNum, common.RoleValidator) + vipEle.SetBlockBlackList(mvrerm.BlockProduceBlackList) + if mvrerm.ElectConfig.WhiteListSwitcher { + vipEle.ProcessWhiteNode() + } + vipEle.ProcessBlackNode() + + //supernode election + superNodeS, superNodeN:= vipEle.GenSuperNode(superFactor) + vipEle.SetChosed(superNodeS) + + //get randElect List + randPickNodeList := vipEle.GetUsableNode() + //cal randElect node values + randPickValue := support.CalcValueEW(randPickNodeList, stockExp) + superNodeValue := support.CalcValueEW(superNodeN, stockExp) + + //rand Elect + Chosed, superNodeStock := support.RandSampleFilterBlackList(randPickValue, superNodeValue, vipEle.NeedNum-vipEle.ChosedNum, vipEle.RandSeed, vipEle.BlockBlackProc) + vipEle.SetChosed(Chosed) + + //re-calculate superNode stocks + vipEle.SuperNodeStockProc(superNodeStock, stockExp) + + //set all blackslah node Unavailable + vipEle.FilterBlockSlashList() + + Master := []support.Strallyint{} + Backup := []support.Strallyint{} + Candidate := []support.Strallyint{} + + for _, v := range vipEle.HasChosedNode { + for _, vv := range v { + temp := support.Strallyint{Addr: vv.Addr, Value: vv.Value, VIPLevel: common.VIP_Nil} + if len(Master) < int(vipEle.EleCfg.ValidatorNum) { + Master = append(Master, temp) + continue + } + if len(Backup) < int(vipEle.EleCfg.BackValidator) { + Backup = append(Backup, temp) + continue + } + } + } + + lastNode := vipEle.GetLastNode() + for _, v := range lastNode { + if len(Candidate) < int(4*vipEle.EleCfg.ValidatorNum-vipEle.EleCfg.BackValidator) { + Candidate = append(Candidate, support.Strallyint{Addr: v.Address, Value: 1}) + } + } + ans := support.MakeValidatoeTopGenAns(mvrerm.SeqNum, Master, Backup, Candidate) + //ans.UpDateList = &mc.BlockProduceSlashBlackList{vipEle.BlockBlackProc.List} + matrixstate.SetBlockProduceBlackList(stateDb, &mc.BlockProduceSlashBlackList{vipEle.BlockBlackProc.List}) + return ans +} + +func TransVIPNode(vipnode []support.Node) []support.Strallyint { + ans := []support.Strallyint{} + for _, v := range vipnode { + ans = append(ans, support.Strallyint{Value: support.DefaultStock, Addr: v.Address}) + } + return ans +} +func (self *layeredBss) ToPoUpdate(allNative support.AllNative, topoG *mc.TopologyGraph) []mc.Alternative { + return support.ToPoUpdate(allNative, topoG) +} + +func (self *layeredBss) PrimarylistUpdate(Q0, Q1, Q2 []mc.TopologyNodeInfo, online mc.TopologyNodeInfo, flag int) ([]mc.TopologyNodeInfo, []mc.TopologyNodeInfo, []mc.TopologyNodeInfo) { + return support.PrimarylistUpdate(Q0, Q1, Q2, online, flag) +} diff --git a/election/layeredbss/module_test.go b/election/layeredbss/module_test.go new file mode 100644 index 00000000..829f2c4c --- /dev/null +++ b/election/layeredbss/module_test.go @@ -0,0 +1,489 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php + +package layeredBss + +import ( + "encoding/json" + "github.com/MatrixAINetwork/go-matrix/baseinterface" + "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/core/matrixstate" + "github.com/MatrixAINetwork/go-matrix/core/state" + "github.com/MatrixAINetwork/go-matrix/core/vm" + "github.com/MatrixAINetwork/go-matrix/log" + "github.com/MatrixAINetwork/go-matrix/mandb" + "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/MatrixAINetwork/go-matrix/params/manparams" + "github.com/pkg/errors" + "io/ioutil" + "math/big" + "testing" +) + +type VipCfg struct { + Amount string + Number uint64 +} + +type StringAccount struct { + Account string +} +type NodeList struct { + Address string + SignAddress string + Account string +} +type SlashList struct { + Account string + ProhibitNum uint16 +} +type Election struct { + Account string + Position uint64 + Stock uint16 + VipRole uint16 + Amount uint64 +} +type ElectInfo struct { + TopNodeNum uint16 + BackUpNodeNum uint16 + CandidateNodeNum uint64 + VipCfg []VipCfg + Random uint64 + NodeList []NodeList + SlashCfgList []SlashList + SlashUpdateList []SlashList + Election []Election + WhiteList []StringAccount + BlackList []StringAccount + WhiteListSwitcher bool +} + +func init() { + log.InitLog(3) +} + +func genState() *state.StateDBManage { + chaindb := mandb.NewMemDatabase() + roots := make([]common.CoinRoot, 0) + State, _ := state.NewStateDBManage(roots, chaindb, state.NewDatabase(chaindb)) + matrixstate.SetVersionInfo(State, manparams.VersionAlpha) + return State +} + +func readTestCfg(path string, cfg *ElectInfo) error { + data, err := ioutil.ReadFile(path) + if err != nil { + return errors.New("case not open case file") + } + if err := json.Unmarshal([]byte(data), cfg); err != nil { + log.ERROR("", "", err) + return errors.New("unmarshal case file failed") + } + return nil +} +func changeMatlabSlash(s []SlashList) *mc.BlockProduceSlashBlackList { + slashList := &mc.BlockProduceSlashBlackList{make([]mc.UserBlockProduceSlash, 0)} + for i := 0; i < len(s); i++ { + slashNode := mc.UserBlockProduceSlash{common.HexToAddress(s[i].Account), s[i].ProhibitNum} + slashList.BlackList = append(slashList.BlackList, slashNode) + } + return slashList +} +func changeMatlabAccount(list []StringAccount) []common.Address { + var goAddress = make([]common.Address, 0) + for _, v := range list { + goAddress = append(goAddress, common.HexToAddress(v.Account)) + } + return goAddress +} +func changeMatlabDeposit(list []NodeList) []vm.DepositDetail { + goList := make([]vm.DepositDetail, 0) + for _, v := range list { + deposit, _ := new(big.Int).SetString(v.Account, 0) + goList = append(goList, vm.DepositDetail{Address: common.HexToAddress(v.Address), SignAddress: common.HexToAddress(v.SignAddress), Deposit: deposit}) + } + return goList +} +func ValidatorElectProcess(vectorPath string) (bool, error) { + cfg := &ElectInfo{} + if err := readTestCfg(vectorPath, cfg); err != nil { + return false, err + } + + ValidatorList := changeMatlabDeposit(cfg.NodeList) + blackList := changeMatlabAccount(cfg.BlackList) + whiteList := changeMatlabAccount(cfg.WhiteList) + slashList := changeMatlabSlash(cfg.SlashCfgList) + data := &mc.MasterValidatorReElectionReqMsg{ + RandSeed: new(big.Int).SetUint64(cfg.Random), + ValidatorList: ValidatorList, + FoundationValidatorList: []vm.DepositDetail{}, + ElectConfig: mc.ElectConfigInfo_All{ValidatorNum: cfg.TopNodeNum, BackValidator: cfg.BackUpNodeNum, BlackList: blackList, WhiteList: whiteList, WhiteListSwitcher: cfg.WhiteListSwitcher}, + BlockProduceBlackList: *slashList, + } + currstate := genState() + vEleRsp := baseinterface.NewElect("layerd_BSS").ValidatorTopGen(data, currstate) + + if status, err := validatorDataCmp(vEleRsp, cfg.Election); !status { + return status, err + } + status, err := validatorSlashCmp(currstate, cfg) + + return status, err +} + +func validatorSlashCmp(state *state.StateDBManage, config *ElectInfo) (bool, error) { + matlabResult := changeMatlabSlash(config.SlashUpdateList) + if updateSlash, err := matrixstate.GetBlockProduceBlackList(state); err != nil { + return false, errors.New("读取状态树不正确") + } else { + if len(updateSlash.BlackList) != len(matlabResult.BlackList) { + return false, errors.New("惩罚更新长度不一致") + } + for i := 0; i < len(updateSlash.BlackList); i++ { + if !updateSlash.BlackList[i].Address.Equal(matlabResult.BlackList[i].Address) { + return false, errors.New("黑名单地址不一致") + } + if updateSlash.BlackList[i].ProhibitCycleCounter != matlabResult.BlackList[i].ProhibitCycleCounter { + log.Info(updateSlash.BlackList[i].Address.String(), "Go", updateSlash.BlackList[i].ProhibitCycleCounter, "Matlab", matlabResult.BlackList[i].ProhibitCycleCounter) + return false, errors.New("惩罚更新不一致") + } + } + } + return true, nil +} +func validatorDataCmp(goResult *mc.MasterValidatorReElectionRsq, matlabResult []Election) (bool, error) { + var reshape = make([]mc.ElectNodeInfo, 0) + + reshape = append(reshape, goResult.MasterValidator...) + reshape = append(reshape, goResult.BackUpValidator...) + reshape = append(reshape, goResult.CandidateValidator...) + + log.Trace("GO输出") + for _, v := range reshape { + log.Trace("GO Result", "Address", v.Account.String(), "Vip", v.VIPLevel, "Stock", v.Stock, "Type", v.Type) + } + if len(reshape) != len(matlabResult) { + log.ERROR("输出结果长度不一致", "MatLab", len(matlabResult), "Go", len(reshape)) + return false, errors.New("比较长度不一致") + } + + for i := 0; i < len(reshape); i++ { + mdata := matlabResult[i] + gdata := reshape[i] + if !common.HexToAddress(mdata.Account).Equal(gdata.Account) { + log.Info("", "索引", i, "M Addr", common.HexToAddress(mdata.Account).String(), "GO Addr", gdata.Account.String()) + return false, errors.New("地址不一致") + } + if mdata.Stock != gdata.Stock { + log.Info("", "索引", i, "M Addr", common.HexToAddress(mdata.Account).String(), "GO Addr", gdata.Account.String(), "M Stock", mdata.Stock, "GO Stock", gdata.Stock) + return false, errors.New("股权不一致") + } + + /* if mdata.VipRole != uint16(gdata.VIPLevel) { + return false, errors.New("VIP不一致") + }*/ + } + return true, nil +} + +func MinerElectProcess(vectorPath string) (bool, error) { + cfg := new(ElectInfo) + testdata, err := ioutil.ReadFile(vectorPath) + if err != nil { + return false, errors.New("case not open case file") + } + if err := json.Unmarshal([]byte(testdata), cfg); err != nil { + return false, errors.New("unmarshal case file failed") + } + + minerList := make([]vm.DepositDetail, 0) + for _, v := range cfg.NodeList { + deposit, _ := new(big.Int).SetString(v.Account, 0) + minerList = append(minerList, vm.DepositDetail{Address: common.HexToAddress(v.Address), SignAddress: common.HexToAddress(v.SignAddress), Deposit: deposit}) + } + Vip := make([]mc.VIPConfig, 0) + Vip = append(Vip, mc.VIPConfig{MinMoney: 0, ElectUserNum: 0, StockScale: 1000}) + for i := 0; i < len(cfg.VipCfg); i++ { + v := cfg.VipCfg[len(cfg.VipCfg)-i-1] + minmoney, status := new(big.Int).SetString(v.Amount, 10) + if !status { + return false, errors.New("set vip cfg minmoney failed") + } + Vip = append(Vip, mc.VIPConfig{MinMoney: minmoney.Uint64(), ElectUserNum: uint8(v.Number), StockScale: 1000}) + } + var blackList = make([]common.Address, 0) + for _, v := range cfg.BlackList { + blackList = append(blackList, common.HexToAddress(v.Account)) + } + var whiteList = make([]common.Address, 0) + for _, v := range cfg.WhiteList { + whiteList = append(whiteList, common.HexToAddress(v.Account)) + } + data := &mc.MasterMinerReElectionReqMsg{ + SeqNum: 0, + RandSeed: new(big.Int).SetUint64(cfg.Random), + MinerList: minerList, + ElectConfig: mc.ElectConfigInfo_All{MinerNum: cfg.TopNodeNum, BlackList: blackList, WhiteList: whiteList, WhiteListSwitcher: cfg.WhiteListSwitcher}, + } + ans := baseinterface.NewElect("layerd").MinerTopGen(data) + status, err := minerDataCmp(ans, cfg.Election) + return status, err +} + +func minerDataCmp(goResult *mc.MasterMinerReElectionRsp, matlabResult []Election) (bool, error) { + var reshape = make([]mc.ElectNodeInfo, 0) + reshape = append(reshape, goResult.MasterMiner...) + log.INFO("GO输出") + for _, v := range reshape { + log.INFO("GO Result", "Address", v.Account.String(), "Vip", v.VIPLevel, "Stock", v.Stock, "Type", v.Type) + } + if len(reshape) != len(matlabResult) { + return false, errors.New("比较长度不一致") + } + + for i := 0; i < len(reshape); i++ { + mdata := matlabResult[i] + gdata := reshape[i] + if !common.HexToAddress(mdata.Account).Equal(gdata.Account) { + log.INFO("", "索引", i, "M Addr", common.HexToAddress(mdata.Account).String(), "GO Addr", gdata.Account.String()) + return false, errors.New("地址不一致") + } + if mdata.Stock != gdata.Stock { + log.INFO("", "索引", i, "M Addr", common.HexToAddress(mdata.Account).String(), "GO Addr", gdata.Account.String(), "M Stock", mdata.Stock, "GO Stock", gdata.Stock) + return false, errors.New("股权不一致") + } + } + return true, nil +} + +func TestValidatorCase1(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case1.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase2(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case2.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase3(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case3.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase4(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case4.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase5(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case5.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase6(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case6.json"); !status { + t.Error(err) + } +} +func TestValidatorCase7(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case7.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase8(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case8.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase9(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case9.json"); !status { + t.Error(err) + } +} +func TestValidatorCase10(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case10.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase11(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case11.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase12(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case12.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase13(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case13.json"); !status { + t.Error(err) + } +} +func TestValidatorCase14(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case14.json"); !status { + t.Error(err) + } +} +func TestValidatorCase15(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case15.json"); !status { + t.Error(err) + } +} +func TestValidatorCase16(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case16.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase17(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case17.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase18(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case18.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase19(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case19.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase20(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case20.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase21(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case21.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase22(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case22.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase23(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case23.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase24(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case24.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase25(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case25.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase26(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case26.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase27(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case27.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase28(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case28.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase29(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case29.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase30(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case30.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase31(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case31.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase32(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case32.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase33(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case33.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase34(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case34.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase35(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case35.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase36(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case36.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase37(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case37.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase38(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case38.json"); !status { + t.Error(err) + } +} + +func TestValidatorCase39(t *testing.T) { + if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case39.json"); !status { + t.Error(err) + } +} diff --git a/election/layeredmep/election.go b/election/layeredmep/election.go index 8526d6db..a47350a8 100644 --- a/election/layeredmep/election.go +++ b/election/layeredmep/election.go @@ -6,6 +6,7 @@ package layeredmep import ( "github.com/MatrixAINetwork/go-matrix/baseinterface" "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/core/state" "github.com/MatrixAINetwork/go-matrix/election/support" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/mc" @@ -67,7 +68,7 @@ func printVipBlackList(blackList []mc.UserBlockProduceSlash) { } } } -func (self *layeredMep) ValidatorTopGen(mvrerm *mc.MasterValidatorReElectionReqMsg) *mc.MasterValidatorReElectionRsq { +func (self *layeredMep) ValidatorTopGen(mvrerm *mc.MasterValidatorReElectionReqMsg, stateDb *state.StateDBManage) *mc.MasterValidatorReElectionRsq { log.Trace("分层方案", "验证者拓扑生成", mvrerm) vipEle := support.NewElelection(mvrerm.VIPList, mvrerm.ValidatorList, mvrerm.ElectConfig, mvrerm.RandSeed, mvrerm.SeqNum, common.RoleValidator) @@ -75,7 +76,6 @@ func (self *layeredMep) ValidatorTopGen(mvrerm *mc.MasterValidatorReElectionReqM vipEle.ProcessWhiteNode() } vipEle.ProcessBlackNode() - //vipEle.DisPlayNode() for vipEleLoop := len(vipEle.VipLevelCfg) - 1; vipEleLoop >= 0; vipEleLoop-- { if vipEle.VipLevelCfg[vipEleLoop].ElectUserNum <= 0 && vipEleLoop != 0 { //vip0继续处理 diff --git a/election/matlab_test.go b/election/matlab_test.go index e556240d..fbad0974 100644 --- a/election/matlab_test.go +++ b/election/matlab_test.go @@ -1,3 +1,7 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php + package election import ( @@ -18,13 +22,13 @@ type VipCfg struct { Number uint64 } type NodeList struct { - Address string + Address string SignAddress string - Account string + Account string } type BlackList struct { - Account string + Account string } type WhiteList struct { Account string @@ -37,20 +41,21 @@ type Election struct { Amount uint64 } type ElectInfo struct { - TopNodeNum uint16 - BackUpNodeNum uint16 - CandidateNodeNum uint64 - VipCfg []VipCfg - Random uint64 - NodeList []NodeList - BlackList []BlackList - Election []Election + TopNodeNum uint16 + BackUpNodeNum uint16 + CandidateNodeNum uint64 + VipCfg []VipCfg + Random uint64 + NodeList []NodeList + BlackList []BlackList + Election []Election WhiteList []WhiteList WhiteListSwitcher bool } + func init() { log.InitLog(3) - } +} func ValidatorElectProcess(vectorPath string) (bool, error) { cfg := new(ElectInfo) testdata, err := ioutil.ReadFile(vectorPath) @@ -77,9 +82,9 @@ func ValidatorElectProcess(vectorPath string) (bool, error) { Vip = append(Vip, mc.VIPConfig{MinMoney: minmoney.Uint64(), ElectUserNum: uint8(v.Number), StockScale: 1000}) } var blackList = make([]common.Address, 0) - for _, v := range cfg.BlackList{ - blackList = append(blackList,common.HexToAddress(v.Account)) -} + for _, v := range cfg.BlackList { + blackList = append(blackList, common.HexToAddress(v.Account)) + } var whiteList = make([]common.Address, 0) for _, v := range cfg.WhiteList { whiteList = append(whiteList, common.HexToAddress(v.Account)) @@ -90,10 +95,10 @@ func ValidatorElectProcess(vectorPath string) (bool, error) { RandSeed: new(big.Int).SetUint64(cfg.Random), ValidatorList: ValidatorList, FoundationValidatorList: []vm.DepositDetail{}, - ElectConfig: mc.ElectConfigInfo_All{ValidatorNum: cfg.TopNodeNum, BackValidator: cfg.BackUpNodeNum, BlackList: blackList, WhiteList:whiteList, WhiteListSwitcher:cfg.WhiteListSwitcher}, + ElectConfig: mc.ElectConfigInfo_All{ValidatorNum: cfg.TopNodeNum, BackValidator: cfg.BackUpNodeNum, BlackList: blackList, WhiteList: whiteList, WhiteListSwitcher: cfg.WhiteListSwitcher}, VIPList: Vip, } - ans := baseinterface.NewElect("layerd").ValidatorTopGen(data) + ans := baseinterface.NewElect("layerd").ValidatorTopGen(data, nil) status, err := validatorDataCmp(ans, cfg.Election) return status, err } @@ -106,9 +111,9 @@ func validatorDataCmp(goResult *mc.MasterValidatorReElectionRsq, matlabResult [] reshape = append(reshape, goResult.CandidateValidator...) log.INFO("GO输出") - for _, v := range reshape{ + for _, v := range reshape { log.INFO("GO Result", "Address", v.Account.String(), "Vip", v.VIPLevel, "Stock", v.Stock, "Type", v.Type) - } + } if len(reshape) != len(matlabResult) { return false, errors.New("比较长度不一致") } @@ -123,16 +128,15 @@ func validatorDataCmp(goResult *mc.MasterValidatorReElectionRsq, matlabResult [] if mdata.Stock != gdata.Stock { log.INFO("", "索引", i, "M Addr", common.HexToAddress(mdata.Account).String(), "GO Addr", gdata.Account.String(), "M Stock", mdata.Stock, "GO Stock", gdata.Stock) return false, errors.New("股权不一致") - } + } if mdata.VipRole != uint16(gdata.VIPLevel) { return false, errors.New("VIP不一致") + } } -} return true, nil } - func MinerElectProcess(vectorPath string) (bool, error) { cfg := new(ElectInfo) testdata, err := ioutil.ReadFile(vectorPath) @@ -146,7 +150,7 @@ func MinerElectProcess(vectorPath string) (bool, error) { minerList := make([]vm.DepositDetail, 0) for _, v := range cfg.NodeList { deposit, _ := new(big.Int).SetString(v.Account, 0) - minerList = append(minerList, vm.DepositDetail{Address: common.HexToAddress(v.Address), SignAddress:common.HexToAddress(v.SignAddress), Deposit: deposit}) + minerList = append(minerList, vm.DepositDetail{Address: common.HexToAddress(v.Address), SignAddress: common.HexToAddress(v.SignAddress), Deposit: deposit}) } Vip := make([]mc.VIPConfig, 0) Vip = append(Vip, mc.VIPConfig{MinMoney: 0, ElectUserNum: 0, StockScale: 1000}) @@ -159,34 +163,34 @@ func MinerElectProcess(vectorPath string) (bool, error) { Vip = append(Vip, mc.VIPConfig{MinMoney: minmoney.Uint64(), ElectUserNum: uint8(v.Number), StockScale: 1000}) } var blackList = make([]common.Address, 0) - for _, v := range cfg.BlackList{ - blackList = append(blackList,common.HexToAddress(v.Account)) + for _, v := range cfg.BlackList { + blackList = append(blackList, common.HexToAddress(v.Account)) } var whiteList = make([]common.Address, 0) for _, v := range cfg.WhiteList { whiteList = append(whiteList, common.HexToAddress(v.Account)) } data := &mc.MasterMinerReElectionReqMsg{ - SeqNum: 0, - RandSeed: new(big.Int).SetUint64(cfg.Random), - MinerList: minerList, - ElectConfig: mc.ElectConfigInfo_All{MinerNum:cfg.TopNodeNum, BlackList:blackList,WhiteList:whiteList, WhiteListSwitcher:cfg.WhiteListSwitcher}, + SeqNum: 0, + RandSeed: new(big.Int).SetUint64(cfg.Random), + MinerList: minerList, + ElectConfig: mc.ElectConfigInfo_All{MinerNum: cfg.TopNodeNum, BlackList: blackList, WhiteList: whiteList, WhiteListSwitcher: cfg.WhiteListSwitcher}, } ans := baseinterface.NewElect("layerd").MinerTopGen(data) status, err := minerDataCmp(ans, cfg.Election) return status, err - } +} func minerDataCmp(goResult *mc.MasterMinerReElectionRsp, matlabResult []Election) (bool, error) { var reshape = make([]mc.ElectNodeInfo, 0) reshape = append(reshape, goResult.MasterMiner...) log.INFO("GO输出") - for _, v := range reshape{ + for _, v := range reshape { log.INFO("GO Result", "Address", v.Account.String(), "Vip", v.VIPLevel, "Stock", v.Stock, "Type", v.Type) } if len(reshape) != len(matlabResult) { return false, errors.New("比较长度不一致") - } + } for i := 0; i < len(reshape); i++ { mdata := matlabResult[i] @@ -198,7 +202,7 @@ func minerDataCmp(goResult *mc.MasterMinerReElectionRsp, matlabResult []Election if mdata.Stock != gdata.Stock { log.INFO("", "索引", i, "M Addr", common.HexToAddress(mdata.Account).String(), "GO Addr", gdata.Account.String(), "M Stock", mdata.Stock, "GO Stock", gdata.Stock) return false, errors.New("股权不一致") - } + } } return true, nil } @@ -218,7 +222,7 @@ func TestValidatorCase3(t *testing.T) { if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case3.json"); !status { t.Error(err) } - } +} func TestValidatorCase4(t *testing.T) { if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case4.json"); !status { t.Error(err) @@ -242,13 +246,13 @@ func TestValidatorCase7(t *testing.T) { func TestValidatorCase8(t *testing.T) { if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case8.json"); !status { t.Error(err) - } - } + } +} func TestValidatorCase9(t *testing.T) { if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case9.json"); !status { t.Error(err) } - } +} func TestValidatorCase10(t *testing.T) { if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case10.json"); !status { t.Error(err) @@ -257,8 +261,8 @@ func TestValidatorCase10(t *testing.T) { func TestValidatorCase11(t *testing.T) { if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case11.json"); !status { t.Error(err) - } } +} func TestValidatorCase12(t *testing.T) { if status, err := ValidatorElectProcess(".\\testdata\\testvectorV\\case12.json"); !status { t.Error(err) diff --git a/election/nochoice/election.go b/election/nochoice/election.go index 0e2105ce..f674ae10 100644 --- a/election/nochoice/election.go +++ b/election/nochoice/election.go @@ -6,6 +6,7 @@ package nochoice import ( "github.com/MatrixAINetwork/go-matrix/baseinterface" "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/core/state" "github.com/MatrixAINetwork/go-matrix/election/support" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/mc" @@ -49,7 +50,7 @@ func (self *nochoice) MinerTopGen(mmrerm *mc.MasterMinerReElectionReqMsg) *mc.Ma } -func (self *nochoice) ValidatorTopGen(mvrerm *mc.MasterValidatorReElectionReqMsg) *mc.MasterValidatorReElectionRsq { +func (self *nochoice) ValidatorTopGen(mvrerm *mc.MasterValidatorReElectionReqMsg, stateDb *state.StateDBManage) *mc.MasterValidatorReElectionRsq { log.INFO("直接选举方案", "验证者拓扑生成", len(mvrerm.ValidatorList)) nodeElect := support.NewElelection(nil, mvrerm.ValidatorList, mvrerm.ElectConfig, mvrerm.RandSeed, mvrerm.SeqNum, common.RoleValidator) diff --git a/election/stock/election.go b/election/stock/election.go index 62117a66..abe4c91c 100644 --- a/election/stock/election.go +++ b/election/stock/election.go @@ -6,6 +6,7 @@ package stock import ( "github.com/MatrixAINetwork/go-matrix/baseinterface" "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/core/state" "github.com/MatrixAINetwork/go-matrix/election/support" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/mc" @@ -37,7 +38,7 @@ func (self *StockElect) MinerTopGen(mmrerm *mc.MasterMinerReElectionReqMsg) *mc. return support.MakeMinerAns(Master, nodeElect.SeqNum) } -func (self *StockElect) ValidatorTopGen(mvrerm *mc.MasterValidatorReElectionReqMsg) *mc.MasterValidatorReElectionRsq { +func (self *StockElect) ValidatorTopGen(mvrerm *mc.MasterValidatorReElectionReqMsg, stateDb *state.StateDBManage) *mc.MasterValidatorReElectionRsq { log.INFO("选举种子", "验证者拓扑生成", len(mvrerm.ValidatorList)) nodeElect := support.NewElelection(nil, mvrerm.ValidatorList, mvrerm.ElectConfig, mvrerm.RandSeed, mvrerm.SeqNum, common.RoleValidator) diff --git a/election/support/algorithm.go b/election/support/algorithm.go index 12eda01f..8580ec0f 100644 --- a/election/support/algorithm.go +++ b/election/support/algorithm.go @@ -4,8 +4,11 @@ package support import ( + "errors" + "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/common/mt19937" + "github.com/MatrixAINetwork/go-matrix/log" ) func GetList_VIP(probnormalized []Pnormalized, needNum int, rand *mt19937.RandUniform) ([]Strallyint, []Pnormalized) { @@ -26,7 +29,7 @@ func GetList_VIP(probnormalized []Pnormalized, needNum int, rand *mt19937.RandUn tempRand := float64(rand.Uniform(0.0, 1.0)) node, status := Sample1NodesInValNodes_VIP(probnormalized, tempRand) - if !status{ + if !status { continue } _, ok := dict[node] @@ -84,7 +87,7 @@ func Sample1NodesInValNodes_VIP(probnormalized []Pnormalized, rand01 float64) (c } } - return common.Address{},false + return common.Address{}, false } func GetList_Common(probnormalized []Pnormalized, needNum int, rand *mt19937.RandUniform) ([]Strallyint, []Pnormalized) { @@ -105,7 +108,7 @@ func GetList_Common(probnormalized []Pnormalized, needNum int, rand *mt19937.Ran tempRand := float64(rand.Uniform(0.0, 1.0)) node, status := Sample1NodesInValNodes_Common(probnormalized, tempRand) - if !status{ + if !status { continue } _, ok := dict[node] @@ -139,6 +142,127 @@ func GetList_Common(probnormalized []Pnormalized, needNum int, rand *mt19937.Ran return ChoseNode, RemainingProbNormalizedNodes } +func mapCounter(m map[common.Address]int, address common.Address) (error, bool) { + if m == nil { + return errors.New("input map is nil"), false + } + if _, ok := m[address]; ok { + m[address] = m[address] + 1 + return nil, false + } else { + m[address] = 1 + return nil, true + } +} + +func isAllSuperNodeSampled(supeNodeMap map[common.Address]int) bool{ + if len(supeNodeMap) == 0{ + return true + } + status := true + for _, v := range supeNodeMap{ + if v == 0{ + status = false + break + } + } + return status +} + +func RandSampleFilterBlackList(randNodeValue []Pnormalized, superNodeValue []Pnormalized, needNum int, rand *mt19937.RandUniform, blackList *BlockProduceProc) ([]Strallyint, map[common.Address]int) { + probnormalized := append(randNodeValue, superNodeValue...) + probnormalized = Normalize_Common(probnormalized) + ChoseNode := make([]Strallyint, 0) + + //init vip stock 0 + superNodeStcok := make(map[common.Address]int) + for _, v := range(superNodeValue){ + superNodeStcok[v.Addr] = 0 + } + + if len(randNodeValue) == 0 { + return ChoseNode, superNodeStcok + } + + if needNum > len(randNodeValue) { + needNum = len(randNodeValue) + } + + nonBlackListDict := make(map[common.Address]int) + orderAddress := []common.Address{} + blackListDict := make(map[common.Address]int) + + for i := 0; i < PowerWeightMaxSmple; i++ { + tempRand := float64(rand.Uniform(0.0, 1.0)) + node, status := Sample1NodesInValNodes_Common(probnormalized, tempRand) + if !status { + continue + } + //if select superNode, superNode stock add 1. It's not a rand node + if val, ok := superNodeStcok[node]; ok{ + superNodeStcok[node] = val + 1 + continue + } + + if _, ok := blackList.IsBlackList(node); ok { + if err, _ := mapCounter(blackListDict, node); err != nil { + log.ERROR("Election Module", "blackListDict", "uninitialized") + } + } else { + if err, status := mapCounter(nonBlackListDict, node); err != nil { + log.ERROR("Election Module", "blackListDict", "uninitialized") + } else if status { + orderAddress = append(orderAddress, node) + } + } + + if len(nonBlackListDict) >= (needNum) && isAllSuperNodeSampled(superNodeStcok){ + break + } + } + + //super node stock protect + for key, val := range superNodeStcok{ + if val == 0{ + superNodeStcok[key] = 1 + } + } + + for k, v := range blackListDict { + log.Trace("Layered_BSS", "RandNode", k.String(), "Elect Slash", true, "Rand PickNum", v) + } + + for _, v := range orderAddress { + ChoseNode = append(ChoseNode, Strallyint{Addr: v, Value: nonBlackListDict[v]}) + } + + for _, item := range probnormalized { + + if _, ok := superNodeStcok[item.Addr]; ok == true{ + continue + } + + if _, ok := nonBlackListDict[item.Addr]; ok == true { + continue + } + + if _, ok := blackList.IsBlackList(item.Addr); ok { + continue + } + + if len(ChoseNode) < needNum { + ChoseNode = append(ChoseNode, Strallyint{Addr: item.Addr, Value: 1}) + } + } + + //modify block produce slash counter + for address, _ := range blackListDict { + blackList.DecrementCount(address) + } + + return ChoseNode, superNodeStcok +} + func GetList_MEP(probnormalized []Pnormalized, needNum int, rand *mt19937.RandUniform) ([]Strallyint, []Pnormalized) { probnormalized = Normalize_Common(probnormalized) if len(probnormalized) == 0 { @@ -154,7 +278,7 @@ func GetList_MEP(probnormalized []Pnormalized, needNum int, rand *mt19937.RandUn for i := 0; i < MaxSample; i++ { tempRand := float64(rand.Uniform(0.0, 1.0)) node, status := Sample1NodesInValNodes_Common(probnormalized, tempRand) - if !status{ + if !status { continue } _, ok := dict[node] diff --git a/election/support/baseclass.go b/election/support/baseclass.go index adfababd..c8ec2ddf 100644 --- a/election/support/baseclass.go +++ b/election/support/baseclass.go @@ -8,7 +8,9 @@ import ( "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/common/mt19937" "github.com/MatrixAINetwork/go-matrix/core/vm" + "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/mc" + "math" "math/big" "math/rand" ) @@ -16,6 +18,7 @@ import ( const ( DefaultMinerStock = 1 ) + type RatioList struct { MinNum uint64 Ratio float64 @@ -42,15 +45,15 @@ type Strallyint struct { } type Node struct { - Address common.Address + Address common.Address SignAddress common.Address - Deposit *big.Int - WithdrawH *big.Int - OnlineTime *big.Int - Ratio uint16 - vipLevel common.VIPRoleType - index int - Usable bool + Deposit *big.Int + WithdrawH *big.Int + OnlineTime *big.Int + Ratio uint16 + vipLevel common.VIPRoleType + index int + Usable bool } type Electoion struct { @@ -65,7 +68,8 @@ type Electoion struct { NeedNum int HasChosedNode [][]Strallyint MapMoney map[common.Address]uint64 - BlockProduceSlashBlackList []common.Address + BlockProduceSlashBlackList mc.BlockProduceSlashBlackList + BlockBlackProc *BlockProduceProc } func (node *Node) SetUsable(status bool) { @@ -217,6 +221,60 @@ func (vip *Electoion) ProcessBlackNode() { } } +func (vip *Electoion) GetMinSuperNodeAmount() (bool, uint64) { + L := len(vip.HasChosedNode[0]) + + if L == 0 { + return false, 1 + } + + minv, _ := vip.MapMoney[vip.HasChosedNode[0][0].Addr] + for i := 1; i < L; i++ { + amount, _ := vip.MapMoney[vip.HasChosedNode[0][i].Addr] + if amount < minv { + minv = amount + } + } + return true, minv +} + +func stockProtect(stock int) int { + if stock == 0 { + stock = 1 + } + if stock > 0xFFFF { + stock = 0xFFFF + } + return stock +} +func (vip *Electoion) SuperNodeStockProc(randSuperNodeStock map[common.Address]int, stockExp float64) { + //no supernode , ignore + if len(vip.HasChosedNode[0]) == 0 { + return + } + + //no rand sample case : All mortgages are the same. fix stock 1000; + if len(vip.HasChosedNode[1]) == 0 { + _, minSuperNodeAmount := vip.GetMinSuperNodeAmount() + for i := 0; i < len(vip.HasChosedNode[0]); i++ { + factor := math.Pow(float64(vip.MapMoney[vip.HasChosedNode[0][i].Addr])/float64(minSuperNodeAmount), stockExp) + stock := int(factor*100 + 0.5) + stock = stockProtect(stock) + vip.HasChosedNode[0][i].Value = stock + } + } else { + for i := 0; i < len(vip.HasChosedNode[0]); i++ { + address := vip.HasChosedNode[0][i].Addr + stock := 1 + if value, ok := randSuperNodeStock[address]; ok{ + stock = value + } + stock = stockProtect(stock) + vip.HasChosedNode[0][i].Value = stock + } + } +} + func (vip *Electoion) GetVipStock(addr common.Address) int { stockSum := int(0) stockDespoit := uint64(0) @@ -245,12 +303,41 @@ func (vip *Electoion) GetVipStock(addr common.Address) int { return ratio } + +type BlockProduceProc struct { + addressMap map[common.Address]int + List []mc.UserBlockProduceSlash +} + +func NewBlockProduceProc(blackList mc.BlockProduceSlashBlackList) *BlockProduceProc { + s := &BlockProduceProc{make(map[common.Address]int), make([]mc.UserBlockProduceSlash, 0, 0)} + if blackList.BlackList != nil { + for k, v := range blackList.BlackList { + s.addressMap[v.Address] = k + s.List = append(s.List, v) + } + } + return s +} +func (s *BlockProduceProc) IsBlackList(address common.Address) (int, bool) { + k, ok := s.addressMap[address] + return k, ok +} + +func (s *BlockProduceProc) DecrementCount(address common.Address) { + if k, ok := s.addressMap[address]; ok { + if s.List[k].ProhibitCycleCounter > 0 { + s.List[k].ProhibitCycleCounter = s.List[k].ProhibitCycleCounter - 1 + } + } +} + func (vip *Electoion) ProcessWhiteNode() { - for k, v := range vip.NodeList { - if !FindAddress(v.Address, vip.EleCfg.WhiteList) { - vip.NodeList[k].SetUsable(false) - } + for k, v := range vip.NodeList { + if !FindAddress(v.Address, vip.EleCfg.WhiteList) { + vip.NodeList[k].SetUsable(false) } + } } func (vip *Electoion) GetNodeByAccount(address common.Address) (int, bool) { for k, v := range vip.NodeList { @@ -272,6 +359,81 @@ func (vip *Electoion) GetNodeByLevel(level common.VIPRoleType) []Node { } return specialNode } +func (vip *Electoion) FilterBlockSlashList() { + for i := 0; i < len(vip.NodeList); i++ { + if _, ok := vip.BlockBlackProc.IsBlackList(vip.NodeList[i].Address); ok { + vip.NodeList[i].Usable = false + } + } +} +func (vip *Electoion) GetUsableNode() []Node { + usableNodeList := make([]Node, 0) + for i := 0; i < len(vip.NodeList); i++ { + if vip.NodeList[i].Usable == false { + continue + } + usableNodeList = append(usableNodeList, vip.NodeList[i]) + } + return usableNodeList +} +func superNodePrePorc(nodeList []Node, superThreshold int64) []Node { + superNode := make([]Node, 0) + + if nodeList == nil { + return superNode + } + acc := big.NewInt(0) + for _, v := range nodeList { + if v.Usable { + acc.Add(acc, v.Deposit) + } + } + + fac := big.NewInt(superThreshold) + for _, v := range nodeList { + if v.Usable == false { + continue + } + + if big.NewInt(0).Mul(v.Deposit, fac).Cmp(acc) >= 0 { + superNode = append(superNode, v) + } + } + return superNode +} +func (vip *Electoion) GenSuperNode(superThreshold int64) ([]Strallyint, []Node) { + vipNodeMap := make(map[common.Address]int) + + for k, v := range vip.NodeList { + vipNodeMap[v.Address] = k + } + //pre get super node + preSuperNode := superNodePrePorc(vip.NodeList, superThreshold) + + //set all nodes usable + for _, v := range preSuperNode { + if index, ok := vipNodeMap[v.Address]; ok { + vip.NodeList[index].SetUsable(false) + } else { + log.ERROR("Election Module", "Pre SuperNode Invalid", v.Address.String()) + } + } + + //Exclude BlockSlashBlackList From pre-superNode + superNodeS := make([]Strallyint, 0, len(preSuperNode)) + superNodeN := make([]Node, 0, len(preSuperNode)) + for _, v := range preSuperNode { + if _, ok := vip.BlockBlackProc.IsBlackList(v.Address); ok { + vip.BlockBlackProc.DecrementCount(v.Address) + log.Trace("Layered_BSS", "SuperNode", v.Address.String(), "Elect Slash", true) + } else { + log.Trace("Layered_BSS", "SuperNode", v.Address.String(), "Elect Slash", false) + superNodeS = append(superNodeS, Strallyint{Value: 1, Addr: v.Address, VIPLevel: common.VIP_1}) + superNodeN = append(superNodeN, v) + } + } + return superNodeS, superNodeN +} func (vip *Electoion) GetNodeIndexByLevel(level common.VIPRoleType) []int { specialNode := make([]int, 0) @@ -319,6 +481,10 @@ func (vip *Electoion) GetIndex(addr common.Address) (int, bool) { return 0, false } +func (vip *Electoion) SetBlockBlackList(list mc.BlockProduceSlashBlackList) { + vip.BlockBlackProc = NewBlockProduceProc(list) +} + type SortNodeList []Node func (self SortNodeList) Len() int { diff --git a/election/support/config.go b/election/support/config.go index 3c3a7d8e..c1865ff5 100644 --- a/election/support/config.go +++ b/election/support/config.go @@ -1,10 +1,11 @@ package support const ( - ModuleLogName = "选举基础模块" - MaxSample = 1000 //配置参数,采样最多发生1000次,是一个离P+M较远的值 - J = 0 //基金会验证节点个数tps_weight - DefaultStock = 1 + ModuleLogName = "选举基础模块" + MaxSample = 1000 //配置参数,采样最多发生1000次,是一个离P+M较远的值 + PowerWeightMaxSmple = 1000 + J = 0 //基金会验证节点个数tps_weight + DefaultStock = 1 ) const ( diff --git a/election/support/quant.go b/election/support/quant.go index 74ebaf12..e6c50ece 100644 --- a/election/support/quant.go +++ b/election/support/quant.go @@ -3,6 +3,7 @@ package support import ( "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/log" + "math" "math/big" ) @@ -68,10 +69,24 @@ func CalcValue(nodes []Node, role common.RoleType) []Pnormalized { value += DefaultQuantificationRatio.Add_Online * self.OnlineTimeStake() value += DefaultQuantificationRatio.Add_Deposit * self.DepositStake(role) value *= (float64(item.Ratio) / float64(DefaultRatioDenominator)) - //保护价值函数值 - if 0 == value{ - value = 1 + //保护价值函数值 + if 0 == value { + value = 1 + } + CapitalMap = append(CapitalMap, Pnormalized{Addr: self.Address, Value: float64(value)}) } + return CapitalMap +} + +func CalcValueEW(nodes []Node, stockExp float64) []Pnormalized { + var CapitalMap []Pnormalized + for _, item := range nodes { + self := SelfNodeInfo{Address: item.Address, Stk: item.Deposit, Uptime: item.OnlineTime.Uint64(), Tps: DefaultTps} + val := big.NewInt(0).Div(item.Deposit, big.NewInt(1e18)).Int64() + if val <= 0 { + val = 1 + } + value := math.Pow(float64(val), stockExp) CapitalMap = append(CapitalMap, Pnormalized{Addr: self.Address, Value: float64(value)}) } return CapitalMap diff --git a/internal/debug/flags.go b/internal/debug/flags.go index 246f275a..9301ca95 100644 --- a/internal/debug/flags.go +++ b/internal/debug/flags.go @@ -12,11 +12,11 @@ import ( "os" "runtime" - "github.com/fjl/memsize/memsizeui" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/log/term" "github.com/MatrixAINetwork/go-matrix/metrics" "github.com/MatrixAINetwork/go-matrix/metrics/exp" + "github.com/fjl/memsize/memsizeui" colorable "github.com/mattn/go-colorable" "gopkg.in/urfave/cli.v1" ) @@ -39,6 +39,16 @@ var ( Usage: "Logging output dir:eg:linux /var/log/MatrixLog, window C:\\MatrixLog, otherwise null means current path /MatrixLog/", Value: "", } + verNetlogFlag = cli.StringFlag{ + Name: "netlog", + Usage: "netlog addr,egg: 192.168.1.12:514 ", + Value: "", + } + verNetlogModeFlag = cli.StringFlag{ + Name: "netlogmode", + Usage: "netlog mode,egg: tcp,udp ", + Value: "udp", + } vmoduleFlag = cli.StringFlag{ Name: "vmodule", Usage: "Per-module verbosity: comma-separated list of = (e.g. man/*=5,p2p=4)", @@ -88,7 +98,7 @@ var ( // Flags holds all command-line flags required for debugging. var Flags = []cli.Flag{ - verbosityFlag, verOutPutFlag, verOutPutDirFlag, vmoduleFlag, backtraceAtFlag, debugFlag, + verbosityFlag, verOutPutFlag, verOutPutDirFlag,verNetlogFlag, verNetlogModeFlag, vmoduleFlag, backtraceAtFlag, debugFlag, pprofFlag, pprofAddrFlag, pprofPortFlag, memprofilerateFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag, } @@ -119,7 +129,22 @@ func Setup(ctx *cli.Context, logdir string) error { if logPath == "" { logPath = "MatrixLog" } - + flgnet := ctx.GlobalString(verNetlogFlag.Name) + var netHandler log.Handler = nil + var err error + if len(flgnet) > 0{ + //netHandler,err = log.SetNetLogHandler("udp", "192.168.122.7:514","gman_netlog",log.TerminalFormat(false)) + mode := ctx.GlobalString(verNetlogModeFlag.Name) + if len(mode)== 0 { + mode = "udp" + } + netHandler,err = log.SetNetLogHandler(mode, flgnet,"gman_netlog",log.TerminalFormat(false)) + if err != nil { + netHandler = nil + } + } + //neth,err:= log.SetNetLogHandler("udp", "192.168.122.7:514","gman_netlog",log.TerminalFormat(false)) + flg := ctx.GlobalInt(verOutPutFlag.Name) if flg > 0 { if logPath != "" { @@ -132,10 +157,18 @@ func Setup(ctx *cli.Context, logdir string) error { if err != nil { return err } - if flg == 1 { - glogger.SetHandler(log.MultiHandler(rfh)) + if (netHandler == nil){ + if flg == 1 { + glogger.SetHandler(log.MultiHandler(rfh)) + } else { + glogger.SetHandler(log.MultiHandler(ostream, rfh)) + } } else { - glogger.SetHandler(log.MultiHandler(ostream, rfh)) + if flg == 1 { + glogger.SetHandler(log.MultiHandler(rfh,netHandler)) + } else { + glogger.SetHandler(log.MultiHandler(ostream, rfh,netHandler)) + } } } } diff --git a/internal/jsre/deps/bindata.go b/internal/jsre/deps/bindata.go index dbcc2635..93dbc6ab 100644 --- a/internal/jsre/deps/bindata.go +++ b/internal/jsre/deps/bindata.go @@ -162,7 +162,7 @@ func AssetNames() []string { // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ "bignumber.js": bignumberJs, - "web3.js": web3Js, + "web3.js": web3Js, } // AssetDir returns the file names below a certain @@ -204,9 +204,10 @@ type bintree struct { Func func() (*asset, error) Children map[string]*bintree } + var _bintree = &bintree{nil, map[string]*bintree{ "bignumber.js": &bintree{bignumberJs, map[string]*bintree{}}, - "web3.js": &bintree{web3Js, map[string]*bintree{}}, + "web3.js": &bintree{web3Js, map[string]*bintree{}}, }} // RestoreAsset restores an asset under the given directory @@ -255,4 +256,3 @@ func _filePath(dir, name string) string { cannonicalName := strings.Replace(name, "\\", "/", -1) return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) } - diff --git a/internal/manapi/api.go b/internal/manapi/api.go index c5d79fed..13ca1825 100644 --- a/internal/manapi/api.go +++ b/internal/manapi/api.go @@ -701,12 +701,12 @@ func (s *PublicBlockChainAPI) GetDestroyBalance(ctx context.Context, blockNr rpc coinlist = append(coinlist, coin) } - value,_ := new(big.Int).SetString(params.DestroyBalance,0) - for i := 0; i< len(coinlist)/params.CoinDampingNum; i++{ + value, _ := new(big.Int).SetString(params.DestroyBalance, 0) + for i := 0; i < len(coinlist)/params.CoinDampingNum; i++ { tmpa := big.NewInt(95) tmpb := big.NewInt(100) - value.Mul(value,tmpa) - value.Quo(value,tmpb) + value.Mul(value, tmpa) + value.Quo(value, tmpb) } return value, nil } @@ -844,12 +844,12 @@ func (s *PublicBlockChainAPI) GetEntrustList(strAuthFrom string) []common.Entrus if s.b.CurrentBlock().NumberU64() <= entrustData.EndHeight { validEntrustList = append(validEntrustList, entrustData) } - } else if entrustData.EnstrustSetType == params.EntrustByTime{ + } else if entrustData.EnstrustSetType == params.EntrustByTime { if s.b.CurrentBlock().Time().Uint64() <= entrustData.EndTime { validEntrustList = append(validEntrustList, entrustData) } - }else if entrustData.EnstrustSetType == params.EntrustByCount{ - if entrustData.EntrustCount > 0{ + } else if entrustData.EnstrustSetType == params.EntrustByCount { + if entrustData.EntrustCount > 0 { validEntrustList = append(validEntrustList, entrustData) } } @@ -1145,7 +1145,7 @@ type CallArgs struct { GasPrice hexutil.Big `json:"gasPrice"` Value hexutil.Big `json:"value"` Data hexutil.Bytes `json:"data"` - ExtraTo []*ExtraTo_Mx `json:"extra_to"` // + ExtraTo []*ExtraTo_Mx `json:"extra_to"` // } type ManCallArgs struct { From string `json:"from"` @@ -1155,7 +1155,7 @@ type ManCallArgs struct { GasPrice hexutil.Big `json:"gasPrice"` Value hexutil.Big `json:"value"` Data hexutil.Bytes `json:"data"` - ExtraTo []*ExtraTo_Mx1 `json:"extra_to"` // + ExtraTo []*ExtraTo_Mx1 `json:"extra_to"` // } func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr rpc.BlockNumber, vmCfg vm.Config, timeout time.Duration) ([]byte, uint64, bool, error) { @@ -1187,16 +1187,16 @@ func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr //msg := new(types.Transaction) //types.NewMessage(addr, args.To, 0, args.Value.ToInt(), gas, gasPrice, args.Data, false) //msg := &types.TransactionCall{types.NewTransaction(params.NonceAddOne, *args.To, args.Value.ToInt(), gas, gasPrice, args.Data, nil, nil, nil, 0, 0, "MAN", 0)} extra := make([]*types.ExtraTo_tr, 0) - if len(args.ExtraTo) > 0{ + if len(args.ExtraTo) > 0 { var tmpExtra types.ExtraTo_tr for _, ar := range args.ExtraTo { tmpExtra.To_tr = ar.To2 tmpExtra.Input_tr = ar.Input2 tmpExtra.Value_tr = ar.Value2 - extra = append(extra,&tmpExtra) + extra = append(extra, &tmpExtra) } } - msg := &types.TransactionCall{types.NewTransactions(params.NonceAddOne, *args.To, args.Value.ToInt(), gas, gasPrice, args.Data, nil, nil, nil, extra,0, 0,0,"MAN", 0)} + msg := &types.TransactionCall{types.NewTransactions(params.NonceAddOne, *args.To, args.Value.ToInt(), gas, gasPrice, args.Data, nil, nil, nil, extra, 0, 0, 0, "MAN", 0)} msg.SetFromLoad(addr) // Setup context so it may be cancelled the call has completed // or, in case of unmetered gas, setup a context with a timeout. diff --git a/internal/manapi/api_test.go b/internal/manapi/api_test.go index e32b059a..2c31e20e 100644 --- a/internal/manapi/api_test.go +++ b/internal/manapi/api_test.go @@ -1,27 +1,31 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php + package manapi import ( - "testing" - "math/big" - "github.com/MatrixAINetwork/go-matrix/common/hexutil" "encoding/json" + "github.com/MatrixAINetwork/go-matrix/common/hexutil" + "math/big" "strings" + "testing" ) -func TestSendArgsMarshal(t *testing.T){ - aaa := SendTxArgs1{From:"mmamamamam",To:new(string)} +func TestSendArgsMarshal(t *testing.T) { + aaa := SendTxArgs1{From: "mmamamamam", To: new(string)} *aaa.To = "bbbb" aaa.GasPrice = (*hexutil.Big)(big.NewInt(1000000000000)) - buff,err := json.Marshal(aaa) - if err!=nil { + buff, err := json.Marshal(aaa) + if err != nil { t.Error(err) } str := string(buff) - str1 := strings.Replace(str,"0xe8d4a51000","0x00e8d4a51000",-1) + str1 := strings.Replace(str, "0xe8d4a51000", "0x00e8d4a51000", -1) t.Log(str1) bbb := SendTxArgs1{} - err = json.Unmarshal(buff,&bbb) - if err != nil{ + err = json.Unmarshal(buff, &bbb) + if err != nil { t.Error(err) } t.Log(bbb) diff --git a/leaderelect/cdc.go b/leaderelect/cdc.go index 1ab3f294..53488b44 100644 --- a/leaderelect/cdc.go +++ b/leaderelect/cdc.go @@ -80,12 +80,14 @@ func (dc *cdc) AnalysisState(parentHeader *types.Header, parentState StateReader } if err := dc.leaderCal.SetValidatorsAndSpecials(parentHeader, validators, specials, bcInterval); err != nil { + log.Warn(dc.logInfo, "SetValidatorsAndSpecials err", err) return err } consensusIndex := dc.curConsensusTurn.TotalTurns() consensusLeader, err := dc.GetLeader(consensusIndex, bcInterval) if err != nil { + log.Warn(dc.logInfo, "dc.GetLeader() err", err) return err } if dc.curReelectTurn != 0 { diff --git a/leaderelect/ctrlHandle.go b/leaderelect/ctrlHandle.go index 20380898..c5255bd3 100644 --- a/leaderelect/ctrlHandle.go +++ b/leaderelect/ctrlHandle.go @@ -10,6 +10,7 @@ import ( "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/MatrixAINetwork/go-matrix/params/manparams" ) func (self *controller) handleMsg(data interface{}) { @@ -69,6 +70,11 @@ func (self *controller) handleStartMsg(msg *startControllerMsg) { return } + if manparams.VersionCmp(string(msg.parentHeader.Version), manparams.VersionGamma) >= 0 { + log.Trace(self.logInfo, "开始消息处理", "版本号不匹配, 不处理消息", "header version", string(msg.parentHeader.Version)) + return + } + a0Address := ca.GetDepositAddress() nodeAddress := ca.GetSignAddress() self.SetSelfAddress(a0Address, nodeAddress) diff --git a/leaderelect/leaderCal.go b/leaderelect/leaderCal.go index 03618027..11d75871 100644 --- a/leaderelect/leaderCal.go +++ b/leaderelect/leaderCal.go @@ -10,6 +10,7 @@ import ( "github.com/MatrixAINetwork/go-matrix/core/types" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/MatrixAINetwork/go-matrix/params/manparams" "github.com/pkg/errors" ) @@ -69,8 +70,8 @@ func (self *leaderCalculator) SetValidatorsAndSpecials(preHeader *types.Header, log.Error(self.logInfo, "计算leader列表", "获取真实的preLeader失败", "err", err) return err } - log.Trace(self.logInfo, "计算leader列表", "开始", "preLeader", realPreLeader.Hex(), "前区块中出现超级区块", preAppearSuper, "高度", self.number) - leaderList, err := calLeaderList(realPreLeader, self.number, preAppearSuper, validators, bcInterval) + log.Trace(self.logInfo, "计算leader列表", "开始", "preLeader", realPreLeader.Hex(), "前区块中出现超级区块", preAppearSuper, "高度", self.number, "validators size", len(validators)) + leaderList, err := calLeaderList(string(preHeader.Version), realPreLeader, self.number, preAppearSuper, validators, bcInterval, self.logInfo) if err != nil { return err } @@ -128,17 +129,23 @@ func (self *leaderCalculator) GetLeader(turn uint32, bcInterval *mc.BCIntervalIn return leaders, nil } -func calLeaderList(preLeader common.Address, curNumber uint64, preIsSupper bool, validators []mc.TopologyNodeInfo, bcInterval *mc.BCIntervalInfo) (map[uint32]common.Address, error) { +func calLeaderList(version string, preLeader common.Address, curNumber uint64, preIsSupper bool, validators []mc.TopologyNodeInfo, bcInterval *mc.BCIntervalInfo, logInfo string) (map[uint32]common.Address, error) { ValidatorNum := len(validators) var startPos = 0 if preIsSupper || bcInterval.IsReElectionNumber(curNumber-1) || bcInterval.IsReElectionNumber(curNumber) { startPos = 0 } else { - preIndex, err := findLeaderIndex(preLeader, validators) - if err != nil { - return nil, err + if preIndex, err := findLeaderIndex(preLeader, validators); err != nil { + if manparams.VersionCmp(version, manparams.VersionGamma) >= 0 { + log.Info(logInfo, "未在验证者列表中未找到preLeader", preLeader.Hex(), "validators", validators, "版本", version) + startPos = 0 + } else { + log.Info(logInfo, "未在验证者列表中未找到preLeader", preLeader.Hex(), "validators", validators, "版本", version) + return nil, err + } + } else { + startPos = preIndex + 1 } - startPos = preIndex + 1 } leaderList := make(map[uint32]common.Address) for i := 0; i < ValidatorNum; i++ { diff --git a/leaderelect/leaderReElection.go b/leaderelect/leaderReElection.go index 426b5f9e..1197166c 100644 --- a/leaderelect/leaderReElection.go +++ b/leaderelect/leaderReElection.go @@ -9,6 +9,7 @@ import ( "github.com/MatrixAINetwork/go-matrix/event" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/MatrixAINetwork/go-matrix/params/manparams" "github.com/pkg/errors" ) @@ -197,6 +198,11 @@ func (self *LeaderIdentity) blockPOSFinishedMsgHandle(msg *mc.BlockPOSFinishedNo return } + if manparams.VersionCmp(string(msg.Header.Version), manparams.VersionGamma) >= 0 { + log.Trace(self.extraInfo, "区块POS完成消息处理", "版本号不匹配, 不处理消息", "header version", string(msg.Header.Version), "number", msg.Header.Number) + return + } + log.Debug(self.extraInfo, "区块POS完成消息处理", "开始", "高度", msg.Number) err := self.ctrlManager.ReceiveMsg(msg.Number, msg) if err != nil { diff --git a/leaderelect2.0/cdc.go b/leaderelect2.0/cdc.go new file mode 100644 index 00000000..c39b891a --- /dev/null +++ b/leaderelect2.0/cdc.go @@ -0,0 +1,425 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php +package leaderelect2 + +import ( + "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/core" + "github.com/MatrixAINetwork/go-matrix/core/matrixstate" + "github.com/MatrixAINetwork/go-matrix/core/types" + "github.com/MatrixAINetwork/go-matrix/depoistInfo" + "github.com/MatrixAINetwork/go-matrix/log" + "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/MatrixAINetwork/go-matrix/params" + "github.com/pkg/errors" +) + +type cdc struct { + state stateDef + number uint64 + selfAddr common.Address // 自己的抵押账户A0 + selfNodeAddr common.Address // 自己的实际node账户 + role common.RoleType + curConsensusTurn mc.ConsensusTurnInfo + consensusLeader common.Address + curReelectTurn uint32 + reelectMaster common.Address + isMaster bool + leaderCal *leaderCalculator + bcInterval *mc.BCIntervalInfo + parentState StateReader + turnTime *turnTimes + chain *core.BlockChain + logInfo string +} + +func newCDC(number uint64, chain *core.BlockChain, logInfo string) *cdc { + dc := &cdc{ + state: stIdle, + number: number, + selfAddr: common.Address{}, + selfNodeAddr: common.Address{}, + role: common.RoleNil, + curConsensusTurn: mc.ConsensusTurnInfo{}, + consensusLeader: common.Address{}, + curReelectTurn: 0, + reelectMaster: common.Address{}, + isMaster: false, + bcInterval: nil, + parentState: nil, + turnTime: newTurnTimes(), + chain: chain, + logInfo: logInfo, + } + + dc.leaderCal = newLeaderCalculator(chain, dc.number, dc.logInfo) + return dc +} + +func (dc *cdc) AnalysisState(parentHeader *types.Header, parentState StateReader) error { + if parentState == nil || parentHeader == nil { + return errors.New("parent state or parentHeader is nil") + } + + validators, role, err := dc.readValidatorsAndRoleFromState(parentState) + if err != nil { + return err + } + specials, err := dc.readSpecialAccountsFromState(parentState) + if err != nil { + return err + } + config, err := dc.readLeaderConfigFromState(parentState) + if err != nil { + return err + } + bcInterval, err := dc.readBroadCastIntervalFromState(parentState) + if err != nil { + return err + } + + if err := dc.leaderCal.SetValidatorsAndSpecials(parentHeader, validators, specials, bcInterval); err != nil { + log.Warn(dc.logInfo, "SetValidatorsAndSpecials err", err) + return err + } + + consensusIndex := dc.curConsensusTurn.TotalTurns() + consensusLeader, err := dc.GetLeader(consensusIndex, bcInterval) + if err != nil { + log.Warn(dc.logInfo, "dc.GetLeader() err", err) + return err + } + if dc.curReelectTurn != 0 { + reelectLeader, err := dc.GetLeader(consensusIndex+dc.curReelectTurn, bcInterval) + if err != nil { + return err + } + dc.reelectMaster.Set(reelectLeader) + } else { + dc.reelectMaster.Set(common.Address{}) + } + if err := dc.turnTime.SetTimeConfig(config); err != nil { + log.Error(dc.logInfo, "turnTime设置时间配置参数失败", err) + return err + } + dc.bcInterval = bcInterval + dc.consensusLeader.Set(consensusLeader) + dc.parentState = parentState + dc.role = role + + return nil +} + +func (dc *cdc) SetConsensusTurn(consensusTurn mc.ConsensusTurnInfo) error { + consensusLeader, err := dc.GetLeader(consensusTurn.TotalTurns(), dc.bcInterval) + if err != nil { + return errors.Errorf("获取共识leader错误(%v), 共识轮次: %s", err, consensusTurn.String()) + } + + dc.consensusLeader.Set(consensusLeader) + dc.curConsensusTurn = consensusTurn + dc.reelectMaster.Set(common.Address{}) + dc.curReelectTurn = 0 + return nil +} + +func (dc *cdc) SetReelectTurn(reelectTurn uint32) error { + if dc.curReelectTurn == reelectTurn { + return nil + } + if reelectTurn == 0 { + dc.reelectMaster.Set(common.Address{}) + dc.curReelectTurn = 0 + return nil + } + master, err := dc.GetLeader(dc.curConsensusTurn.TotalTurns()+reelectTurn, dc.bcInterval) + if err != nil { + return errors.Errorf("获取master错误(%v), 重选轮次(%d), 共识轮次(%d)", err, reelectTurn, dc.curConsensusTurn.String()) + } + dc.reelectMaster.Set(master) + dc.curReelectTurn = reelectTurn + return nil +} + +func (dc *cdc) GetLeader(turn uint32, bcInterval *mc.BCIntervalInfo) (common.Address, error) { + leaders, err := dc.leaderCal.GetLeader(turn, bcInterval) + if err != nil { + return common.Address{}, err + } + return leaders.leader, nil +} + +func (dc *cdc) GetConsensusLeader() common.Address { + return dc.consensusLeader +} + +func (dc *cdc) GetReelectMaster() common.Address { + return dc.reelectMaster +} + +func (dc *cdc) PrepareLeaderMsg() (*mc.LeaderChangeNotify, error) { + leaders, err := dc.leaderCal.GetLeader(dc.curConsensusTurn.TotalTurns()+dc.curReelectTurn, dc.bcInterval) + if err != nil { + return nil, err + } + + beginTime, endTime := dc.turnTime.CalTurnTime(dc.curConsensusTurn.TotalTurns(), dc.curReelectTurn) + return &mc.LeaderChangeNotify{ + PreLeader: dc.leaderCal.preLeader, + Leader: leaders.leader, + NextLeader: leaders.nextLeader, + ConsensusTurn: dc.curConsensusTurn, + ReelectTurn: dc.curReelectTurn, + Number: dc.number, + ConsensusState: dc.state != stReelect, + TurnBeginTime: beginTime, + TurnEndTime: endTime, + }, nil +} + +func (dc *cdc) readValidatorsAndRoleFromState(state StateReader) ([]mc.TopologyNodeInfo, common.RoleType, error) { + topology, err := matrixstate.GetTopologyGraph(state) + if err != nil { + return nil, common.RoleNil, err + } + if topology == nil { + return nil, common.RoleNil, errors.New("topology data is nil") + } + + role := dc.getRoleFromTopology(topology) + + validators := make([]mc.TopologyNodeInfo, 0) + for _, node := range topology.NodeList { + if node.Type == common.RoleValidator { + validators = append(validators, node) + } + } + return validators, role, nil +} + +func (dc *cdc) getRoleFromTopology(TopologyGraph *mc.TopologyGraph) common.RoleType { + for _, v := range TopologyGraph.NodeList { + if v.Account == dc.selfAddr { + return v.Type + } + } + return common.RoleNil +} + +func (dc *cdc) readSpecialAccountsFromState(state StateReader) (*specialAccounts, error) { + broadcasts, err := matrixstate.GetBroadcastAccounts(state) + if err != nil { + return nil, err + } + + versionSupers, err := matrixstate.GetVersionSuperAccounts(state) + if err != nil { + return nil, err + } + + blockSupers, err := matrixstate.GetBlockSuperAccounts(state) + if err != nil { + return nil, err + } + + return &specialAccounts{ + broadcasts: broadcasts, + versionSupers: versionSupers, + blockSupers: blockSupers, + }, nil +} + +func (dc *cdc) readLeaderConfigFromState(state StateReader) (*mc.LeaderConfig, error) { + config, err := matrixstate.GetLeaderConfig(state) + if err != nil { + return nil, err + } + if config == nil { + return nil, errors.New("LeaderConfig == nil") + } + return config, nil +} + +func (dc *cdc) readBroadCastIntervalFromState(state StateReader) (*mc.BCIntervalInfo, error) { + interval, err := matrixstate.GetBroadcastInterval(state) + if err != nil { + return nil, err + } + if interval == nil { + return nil, errors.New("broadcast interval is nil") + } + return interval, nil +} + +////////////////////////////////////////////////////////////////////////////////////////// +//提供共识引擎调用,获取数据的接口 +func (dc *cdc) GetCurrentHash() common.Hash { + return dc.leaderCal.preHash +} + +func (dc *cdc) GetGraphByHash(hash common.Hash) (*mc.TopologyGraph, *mc.ElectGraph, error) { + if (hash == common.Hash{}) { + return nil, nil, errors.New("输入hash为空") + } + if hash == dc.leaderCal.preHash { + return dc.chain.GetGraphByState(dc.parentState) + } + return dc.chain.GetGraphByHash(hash) +} + +func (dc *cdc) GetBroadcastAccounts(blockHash common.Hash) ([]common.Address, error) { + if (blockHash == common.Hash{}) { + return nil, errors.New("输入hash为空") + } + if blockHash == dc.leaderCal.preHash { + return dc.leaderCal.specialAccounts.broadcasts, nil + } + return dc.chain.GetBroadcastAccounts(blockHash) +} + +func (dc *cdc) GetVersionSuperAccounts(blockHash common.Hash) ([]common.Address, error) { + if (blockHash == common.Hash{}) { + return nil, errors.New("输入hash为空") + } + if blockHash == dc.leaderCal.preHash { + return dc.leaderCal.specialAccounts.versionSupers, nil + } + return dc.chain.GetVersionSuperAccounts(blockHash) +} + +func (dc *cdc) GetBlockSuperAccounts(blockHash common.Hash) ([]common.Address, error) { + if (blockHash == common.Hash{}) { + return nil, errors.New("输入hash为空") + } + if blockHash == dc.leaderCal.preHash { + return dc.leaderCal.specialAccounts.blockSupers, nil + } + return dc.chain.GetBlockSuperAccounts(blockHash) +} + +func (dc *cdc) GetBroadcastIntervalByHash(blockHash common.Hash) (*mc.BCIntervalInfo, error) { + if (blockHash == common.Hash{}) { + return nil, errors.New("输入hash为空") + } + if blockHash == dc.leaderCal.preHash { + if dc.bcInterval == nil { + return nil, errors.New("缓存中不存在广播周期信息") + } + return dc.bcInterval, nil + } + return dc.chain.GetBroadcastIntervalByHash(blockHash) +} + +func (dc *cdc) GetSignAccountPassword(signAccounts []common.Address) (common.Address, string, error) { + return dc.chain.GetSignAccountPassword(signAccounts) +} + +func (dc *cdc) GetA2AccountsFromA0Account(a0Account common.Address, blockHash common.Hash) ([]common.Address, error) { + if blockHash.Equal(common.Hash{}) { + log.Error(common.SignLog, "cdc获取A2账户", "输入数据区块hash为空") + return nil, errors.New("cdc:输入hash为空") + } + + if blockHash != dc.leaderCal.preHash { + log.Info(common.SignLog, "cdc获取A2账户", "调blockchain接口") + return dc.chain.GetA2AccountsFromA0Account(a0Account, blockHash) + } + + return dc.getA2Accounts(a0Account, blockHash, dc.number-1) +} + +func (dc *cdc) GetA0AccountFromAnyAccount(account common.Address, blockHash common.Hash) (common.Address, common.Address, error) { + if blockHash == (common.Hash{}) { + log.ERROR(common.SignLog, "CDC获取A0账户", "输入的hash为空") + return common.Address{}, common.Address{}, errors.New("cdc: 输入hash为空") + } + if blockHash != dc.leaderCal.preHash { + log.Warn(common.SignLog, "CDC获取A0账户", "采用blockchain的接口") + return dc.chain.GetA0AccountFromAnyAccount(account, blockHash) + } + + return dc.getA0Account(account, blockHash, dc.number-1) +} + +func (dc *cdc) GetA2AccountsFromA0AccountAtSignHeight(a0Account common.Address, blockHash common.Hash, signHeight uint64) ([]common.Address, error) { + if blockHash.Equal(common.Hash{}) { + log.Error(common.SignLog, "cdc获取A2账户", "输入数据区块hash为空") + return nil, errors.New("cdc:输入hash为空") + } + + if blockHash != dc.leaderCal.preHash { + log.Info(common.SignLog, "cdc获取A2账户", "调blockchain接口") + return dc.chain.GetA2AccountsFromA0AccountAtSignHeight(a0Account, blockHash, signHeight) + } + + return dc.getA2Accounts(a0Account, blockHash, signHeight) +} + +func (dc *cdc) GetA0AccountFromAnyAccountAtSignHeight(account common.Address, blockHash common.Hash, signHeight uint64) (common.Address, common.Address, error) { + if blockHash == (common.Hash{}) { + log.ERROR(common.SignLog, "CDC获取A0账户", "输入的hash为空") + return common.Address{}, common.Address{}, errors.New("cdc: 输入hash为空") + } + if blockHash != dc.leaderCal.preHash { + log.Warn(common.SignLog, "CDC获取A0账户", "采用blockchain的接口") + return dc.chain.GetA0AccountFromAnyAccountAtSignHeight(account, blockHash, signHeight) + } + return dc.getA0Account(account, blockHash, signHeight) +} + +func (dc *cdc) getA2Accounts(a0Account common.Address, blockHash common.Hash, signHeight uint64) ([]common.Address, error) { + if nil == dc.parentState { + log.Info(common.SignLog, "cdc获取A2账户", "dc.parentState是空") + return nil, errors.New("cdc: parent stateDB is nil, can't reader data") + } + + a1Account := depoistInfo.GetAuthAccount(dc.parentState, a0Account) + if a1Account == (common.Address{}) { + log.Error(common.SignLog, "cdc获取A2账户", " 不存在A1账户", " a0Account", a0Account.Hex()) + return nil, errors.New("不存在A1账户") + } + + a2Accounts := dc.parentState.GetEntrustFrom(params.MAN_COIN, a1Account, signHeight) + if len(a2Accounts) == 0 { + log.INFO(common.SignLog, "cdc获得A2账户", "失败", "无委托交易,使用A1账户", a1Account.String(), "签名高度", signHeight) + } else { + log.Info(common.SignLog, "cdc获得A2账户", "成功", "账户数量", len(a2Accounts), "签名高度", signHeight) + for i, account := range a2Accounts { + log.Info(common.SignLog, "A2账户", i, "account", account.Hex(), "签名高度", signHeight) + } + } + a2Accounts = append(a2Accounts, a1Account) + return a2Accounts, nil +} + +func (dc *cdc) getA0Account(account common.Address, blockHash common.Hash, signHeight uint64) (common.Address, common.Address, error) { + if nil == dc.parentState { + log.ERROR(common.SignLog, "CDC获取A0账户", "dc.parentState is nil") + return common.Address{}, common.Address{}, errors.New("cdc: parent stateDB is nil, can't reader data") + } + + //假设传入的account为A1账户, 获取A1账户 + a0Account := depoistInfo.GetDepositAccount(dc.parentState, account) + if a0Account != (common.Address{}) { + log.Debug(common.SignLog, "CDC获取A0账户", "成功", "输入A1", account.Hex(), "输出A0", a0Account.Hex()) + return a0Account, account, nil + } + + //账户为A2账户,获取A1 + a1Account := dc.parentState.GetAuthFrom(params.MAN_COIN, account, signHeight) + if a1Account == (common.Address{}) { + log.Error(common.SignLog, "CDC获取A0账户", "账户不是A1也不是A2账户", "Account", account.Hex()) + return common.Address{}, common.Address{}, errors.New("账户不是A1也不是A2账户") + } + + // 根据A1获取A0 + a0Account = depoistInfo.GetDepositAccount(dc.parentState, a1Account) + if a0Account != (common.Address{}) { + log.Debug(common.SignLog, "CDC获取A0账户", "成功", "输入A1", a1Account.Hex(), "输出A0", a0Account.Hex()) + return a0Account, a1Account, nil + } else { + log.Error(common.SignLog, "CDC获取A0账户", "A1账户获取A0账户失败", "A1Account", a1Account.Hex()) + return common.Address{}, common.Address{}, errors.New("获取A0账户失败") + } +} diff --git a/leaderelect2.0/cdc_test.go b/leaderelect2.0/cdc_test.go new file mode 100644 index 00000000..2eb437cf --- /dev/null +++ b/leaderelect2.0/cdc_test.go @@ -0,0 +1,590 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php +package leaderelect2 + +import ( + "reflect" + "testing" + + "encoding/json" + "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/common/hexutil" + "github.com/MatrixAINetwork/go-matrix/core" + "github.com/MatrixAINetwork/go-matrix/core/matrixstate" + "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/MatrixAINetwork/go-matrix/p2p/discover" + "github.com/MatrixAINetwork/go-matrix/params/manparams" +) + +func getTestValidatorGraph() *mc.TopologyGraph { + return &mc.TopologyGraph{ + CurNodeNumber: 0, + NodeList: []mc.TopologyNodeInfo{ + { + Account: common.HexToAddress("0x0EAd6cDB8D214389909a535d4Ccc21A393dDdBA9"), + Position: 0, + Type: common.RoleValidator, + NodeNumber: 0, + }, + { + Account: common.HexToAddress("0x6a3217d128A76e4777403E092bde8362d4117773"), + Position: 1, + Type: common.RoleValidator, + NodeNumber: 1, + }, + { + Account: common.HexToAddress("0xf9E18AcC86179925353713a4A5D0E9BF381fBc17"), + Position: 2, + Type: common.RoleValidator, + NodeNumber: 2, + }, + { + Account: common.HexToAddress("0xa121E6670439ba37E7244d4EB18E42bd6724Ef0F"), + Position: 3, + Type: common.RoleValidator, + NodeNumber: 3, + }, + }, + } +} + +type testState struct { + graphData []byte + accountsData []byte + leaderConfigData []byte + bcIntervalData []byte +} + +func (self *testState) GetMatrixData(hash common.Hash) (val []byte) { + if hash == matrixstate.GetKeyHash(mc.MSKeyTopologyGraph) { + return self.graphData + } + if hash == matrixstate.GetKeyHash(mc.MSKeyMatrixAccount) { + return self.accountsData + } + if hash == matrixstate.GetKeyHash(mc.MSKeyLeaderConfig) { + return self.leaderConfigData + } + if hash == matrixstate.GetKeyHash(mc.MSKeyBroadcastInterval) { + return self.bcIntervalData + } + return nil +} + +func (self *testState) SetMatrixData(hash common.Hash, val []byte) { + return +} + +func (self *testState) GetAuthFrom(entrustFrom common.Address, height uint64) common.Address { + return common.Address{} +} + +func (self *testState) GetEntrustFrom(authFrom common.Address, height uint64) []common.Address { + return nil +} + +func newTestState() *testState { + ts := &testState{} + ts.graphData, _ = json.Marshal(getTestValidatorGraph()) + + return ts +} + +func Test_cdc_AnalysisState(t *testing.T) { + type fields struct { + number uint64 + logInfo string + } + type args struct { + preHash common.Hash + preLeader common.Address + validators []mc.TopologyNodeInfo + } + tests := []struct { + name string + fields fields + args args + wantErr bool + }{ + { + name: "validators为nil", + fields: fields{ + number: 88, + logInfo: "test cdc", + }, + args: args{ + preHash: common.HexToHash("0x16663ee46380133bfb49410bac53a7d83b204d7c360ba23ad764fcaa36d58419"), + preLeader: common.HexToAddress("0x0EAd6cDB8D214389909a535d4Ccc21A393dDdBA9"), + validators: nil, + }, + wantErr: true, + }, + { + name: "leader不在validators中", + fields: fields{ + number: 88, + logInfo: "test cdc", + }, + args: args{ + preHash: common.HexToHash("0x16663ee46380133bfb49410bac53a7d83b204d7c360ba23ad764fcaa36d58419"), + preLeader: common.HexToAddress("0x011111DB8D214389909a535d4Ccc21A393dDdBA9"), + validators: getTestValidatorList(), + }, + wantErr: true, + }, + { + name: "正确入参", + fields: fields{ + number: 88, + logInfo: "test cdc", + }, + args: args{ + preHash: common.HexToHash("0x16663ee46380133bfb49410bac53a7d83b204d7c360ba23ad764fcaa36d58419"), + preLeader: common.HexToAddress("0x0EAd6cDB8D214389909a535d4Ccc21A393dDdBA9"), + validators: []mc.TopologyNodeInfo{ + { + Account: common.HexToAddress("0x0EAd6cDB8D214389909a535d4Ccc21A393dDdBA9"), + Position: 0, + Type: common.RoleValidator, + NodeNumber: 0, + }, + { + Account: common.HexToAddress("0x6a3217d128A76e4777403E092bde8362d4117773"), + Position: 1, + Type: common.RoleValidator, + NodeNumber: 1, + }, + }, + }, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + dc := newCDC(tt.fields.number, nil, tt.fields.logInfo) + if err := dc.SetValidators(tt.args.preHash, tt.args.preLeader, tt.args.validators); (err != nil) != tt.wantErr { + t.Errorf("cdc.SetValidators() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +func Test_cdc_SetConsensusTurn(t *testing.T) { + type fields struct { + number uint64 + logInfo string + preHash common.Hash + preLeader common.Address + validators []mc.TopologyNodeInfo + } + type args struct { + consensusTurn uint32 + } + tests := []struct { + name string + fields fields + args args + wantErr bool + }{ + { + name: "验证者列表未输入", + fields: fields{ + number: 88, + logInfo: "test cdc", + preHash: common.Hash{}, + preLeader: common.Address{}, + validators: nil, + }, + args: args{ + consensusTurn: 1, + }, + wantErr: true, + }, + { + name: "正确情况", + fields: fields{ + number: 88, + logInfo: "test cdc", + preHash: common.HexToHash("0x16663ee46380133bfb49410bac53a7d83b204d7c360ba23ad764fcaa36d58419"), + preLeader: common.HexToAddress("0x0EAd6cDB8D214389909a535d4Ccc21A393dDdBA9"), + validators: getTestValidatorList(), + }, + args: args{ + consensusTurn: 1, + }, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + dc := newCDC(tt.fields.number, nil, tt.fields.logInfo) + dc.SetValidators(tt.fields.preHash, tt.fields.preLeader, tt.fields.validators) + if err := dc.SetConsensusTurn(tt.args.consensusTurn); (err != nil) != tt.wantErr { + t.Errorf("cdc.SetConsensusTurn() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +func Test_cdc_GetLeader(t *testing.T) { + manparams.BroadCastNodes = []manparams.NodeInfo{ + { + NodeID: discover.NodeID{}, + Address: common.HexToAddress("0xa9a2d445dd686d0bbfbffe3b5826a216e49d18a5"), + }, + } + type fields struct { + number uint64 + logInfo string + preHash common.Hash + preLeader common.Address + validators []mc.TopologyNodeInfo + } + type args struct { + turn uint32 + } + tests := []struct { + name string + fields fields + args args + want common.Address + wantErr bool + }{ + { + name: "验证者列表未输入", + fields: fields{ + number: 88, + logInfo: "test cdc", + preHash: common.Hash{}, + preLeader: common.Address{}, + validators: nil, + }, + args: args{ + turn: 1, + }, + want: common.Address{}, + wantErr: true, + }, + { + name: "正确输入,第0轮次", + fields: fields{ + number: 88, + logInfo: "test cdc", + preHash: common.HexToHash("0x16663ee46380133bfb49410bac53a7d83b204d7c360ba23ad764fcaa36d58419"), + preLeader: getTestValidatorList()[0].Account, + validators: getTestValidatorList(), + }, + args: args{ + turn: 0, + }, + want: getTestValidatorList()[1].Account, + wantErr: false, + }, + { + name: "正确输入,第1轮次", + fields: fields{ + number: 88, + logInfo: "test cdc", + preHash: common.HexToHash("0x16663ee46380133bfb49410bac53a7d83b204d7c360ba23ad764fcaa36d58419"), + preLeader: getTestValidatorList()[0].Account, + validators: getTestValidatorList(), + }, + args: args{ + turn: 1, + }, + want: getTestValidatorList()[2].Account, + wantErr: false, + }, + { + name: "正确输入,第14轮次", + fields: fields{ + number: 88, + logInfo: "test cdc", + preHash: common.HexToHash("0x16663ee46380133bfb49410bac53a7d83b204d7c360ba23ad764fcaa36d58419"), + preLeader: getTestValidatorList()[0].Account, + validators: getTestValidatorList(), + }, + args: args{ + turn: 14, + }, + want: getTestValidatorList()[15%4].Account, + wantErr: false, + }, + { + name: "广播区块高度,第0轮次", + fields: fields{ + number: 100, + logInfo: "test cdc", + preHash: common.HexToHash("0x16663ee46380133bfb49410bac53a7d83b204d7c360ba23ad764fcaa36d58419"), + preLeader: getTestValidatorList()[0].Account, + validators: getTestValidatorList(), + }, + args: args{ + turn: 0, + }, + want: common.HexToAddress("0xa9a2d445dd686d0bbfbffe3b5826a216e49d18a5"), + wantErr: false, + }, + { + name: "广播区块高度,第3轮次", + fields: fields{ + number: 100, + logInfo: "test cdc", + preHash: common.HexToHash("0x16663ee46380133bfb49410bac53a7d83b204d7c360ba23ad764fcaa36d58419"), + preLeader: getTestValidatorList()[0].Account, + validators: getTestValidatorList(), + }, + args: args{ + turn: 3, + }, + want: common.HexToAddress("0xa9a2d445dd686d0bbfbffe3b5826a216e49d18a5"), + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + dc := newCDC(tt.fields.number, nil, tt.fields.logInfo) + dc.SetValidators(tt.fields.preHash, tt.fields.preLeader, tt.fields.validators) + got, err := dc.GetLeader(tt.args.turn) + if (err != nil) != tt.wantErr { + t.Errorf("cdc.GetLeader() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("cdc.GetLeader() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_cdc_GetConsensusLeader(t *testing.T) { + type fields struct { + state state + number uint64 + curConsensusTurn uint32 + consensusLeader common.Address + curReelectTurn uint32 + reelectMaster common.Address + isMaster bool + leaderCal *leaderCalculator + turnTime *turnTimes + chain *core.BlockChain + logInfo string + } + tests := []struct { + name string + fields fields + want common.Address + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + dc := &cdc{ + state: tt.fields.state, + number: tt.fields.number, + curConsensusTurn: tt.fields.curConsensusTurn, + consensusLeader: tt.fields.consensusLeader, + curReelectTurn: tt.fields.curReelectTurn, + reelectMaster: tt.fields.reelectMaster, + isMaster: tt.fields.isMaster, + leaderCal: tt.fields.leaderCal, + turnTime: tt.fields.turnTime, + chain: tt.fields.chain, + logInfo: tt.fields.logInfo, + } + if got := dc.GetConsensusLeader(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("cdc.GetConsensusLeader() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_cdc_GetReelectMaster(t *testing.T) { + type fields struct { + state state + number uint64 + curConsensusTurn uint32 + consensusLeader common.Address + curReelectTurn uint32 + reelectMaster common.Address + isMaster bool + leaderCal *leaderCalculator + turnTime *turnTimes + chain *core.BlockChain + logInfo string + } + tests := []struct { + name string + fields fields + want common.Address + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + dc := &cdc{ + state: tt.fields.state, + number: tt.fields.number, + curConsensusTurn: tt.fields.curConsensusTurn, + consensusLeader: tt.fields.consensusLeader, + curReelectTurn: tt.fields.curReelectTurn, + reelectMaster: tt.fields.reelectMaster, + isMaster: tt.fields.isMaster, + leaderCal: tt.fields.leaderCal, + turnTime: tt.fields.turnTime, + chain: tt.fields.chain, + logInfo: tt.fields.logInfo, + } + if got := dc.GetReelectMaster(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("cdc.GetReelectMaster() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_cdc_PrepareLeaderMsg(t *testing.T) { + type fields struct { + state state + number uint64 + curConsensusTurn uint32 + consensusLeader common.Address + curReelectTurn uint32 + reelectMaster common.Address + isMaster bool + leaderCal *leaderCalculator + turnTime *turnTimes + chain *core.BlockChain + logInfo string + } + tests := []struct { + name string + fields fields + want *mc.LeaderChangeNotify + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + dc := &cdc{ + state: tt.fields.state, + number: tt.fields.number, + curConsensusTurn: tt.fields.curConsensusTurn, + consensusLeader: tt.fields.consensusLeader, + curReelectTurn: tt.fields.curReelectTurn, + reelectMaster: tt.fields.reelectMaster, + isMaster: tt.fields.isMaster, + leaderCal: tt.fields.leaderCal, + turnTime: tt.fields.turnTime, + chain: tt.fields.chain, + logInfo: tt.fields.logInfo, + } + got, err := dc.PrepareLeaderMsg() + if (err != nil) != tt.wantErr { + t.Errorf("cdc.PrepareLeaderMsg() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("cdc.PrepareLeaderMsg() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_cdc_GetCurrentHash(t *testing.T) { + type fields struct { + state state + number uint64 + curConsensusTurn uint32 + consensusLeader common.Address + curReelectTurn uint32 + reelectMaster common.Address + isMaster bool + leaderCal *leaderCalculator + turnTime *turnTimes + chain *core.BlockChain + logInfo string + } + tests := []struct { + name string + fields fields + want common.Hash + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + dc := &cdc{ + state: tt.fields.state, + number: tt.fields.number, + curConsensusTurn: tt.fields.curConsensusTurn, + consensusLeader: tt.fields.consensusLeader, + curReelectTurn: tt.fields.curReelectTurn, + reelectMaster: tt.fields.reelectMaster, + isMaster: tt.fields.isMaster, + leaderCal: tt.fields.leaderCal, + turnTime: tt.fields.turnTime, + chain: tt.fields.chain, + logInfo: tt.fields.logInfo, + } + if got := dc.GetCurrentHash(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("cdc.GetCurrentHash() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_cdc_GetValidatorByHash(t *testing.T) { + type fields struct { + state state + number uint64 + curConsensusTurn uint32 + consensusLeader common.Address + curReelectTurn uint32 + reelectMaster common.Address + isMaster bool + leaderCal *leaderCalculator + turnTime *turnTimes + chain *core.BlockChain + logInfo string + } + type args struct { + hash common.Hash + } + tests := []struct { + name string + fields fields + args args + want *mc.TopologyGraph + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + dc := &cdc{ + state: tt.fields.state, + number: tt.fields.number, + curConsensusTurn: tt.fields.curConsensusTurn, + consensusLeader: tt.fields.consensusLeader, + curReelectTurn: tt.fields.curReelectTurn, + reelectMaster: tt.fields.reelectMaster, + isMaster: tt.fields.isMaster, + leaderCal: tt.fields.leaderCal, + turnTime: tt.fields.turnTime, + chain: tt.fields.chain, + logInfo: tt.fields.logInfo, + } + got, err := dc.GetValidatorByHash(tt.args.hash) + if (err != nil) != tt.wantErr { + t.Errorf("cdc.GetValidatorByHash() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("cdc.GetValidatorByHash() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/leaderelect2.0/commdef.go b/leaderelect2.0/commdef.go new file mode 100644 index 00000000..b636ef94 --- /dev/null +++ b/leaderelect2.0/commdef.go @@ -0,0 +1,115 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php +package leaderelect2 + +import ( + "github.com/MatrixAINetwork/go-matrix/accounts/signhelper" + "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/consensus" + "github.com/MatrixAINetwork/go-matrix/core" + "github.com/MatrixAINetwork/go-matrix/core/state" + "github.com/MatrixAINetwork/go-matrix/core/types" + "github.com/MatrixAINetwork/go-matrix/core/vm" + "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/MatrixAINetwork/go-matrix/msgsend" + "github.com/pkg/errors" +) + +var ( + ErrMsgAccountIsNull = errors.New("不合法的账户:空账户") + ErrValidatorsIsNil = errors.New("验证者列表为空") + ErrValidatorNotFound = errors.New("验证者未找到") + ErrMsgExistInCache = errors.New("缓存中已存在消息") + ErrNoMsgInCache = errors.New("缓存中没有目标消息") + ErrParamsIsNil = errors.New("参数为nil") + ErrSelfReqIsNil = errors.New("缓存中没有self请求") + ErrPOSResultIsNil = errors.New("POS结果为nil/header为nil") + ErrLeaderResultIsNil = errors.New("leader共识结果为nil") + ErrCDCOrSignHelperisNil = errors.New("cdc or signHelper is nil") +) + +type Matrix interface { + BlockChain() *core.BlockChain + SignHelper() *signhelper.SignHelper + DPOSEngine() consensus.DPOSEngine + Engine() consensus.Engine + HD() *msgsend.HD + FetcherNotify(hash common.Hash, number uint64, addr common.Address) +} + +type StateReader interface { + vm.StateDBManager +} + +const defaultBeginTime = int64(0) + +const mangerCacheMax = 2 + +type stateDef uint8 + +const ( + stIdle stateDef = iota + stPos + stReelect + stMining + stWaiting +) + +func (s stateDef) String() string { + switch s { + case stIdle: + return "未运行阶段" + case stPos: + return "POS阶段" + case stReelect: + return "重选阶段" + case stMining: + return "挖矿结果等待阶段" + case stWaiting: + return "等待阶段" // 广播区块时 + default: + return "未知状态" + } +} + +type leaderData struct { + leader common.Address + nextLeader common.Address +} + +func (self *leaderData) copyData() *leaderData { + newData := &leaderData{ + leader: common.Address{}, + nextLeader: common.Address{}, + } + + newData.leader.Set(self.leader) + newData.nextLeader.Set(self.nextLeader) + return newData +} + +type startControllerMsg struct { + parentHeader *types.Header + parentStateDB *state.StateDBManage +} + +func isFirstConsensusTurn(turnInfo *mc.ConsensusTurnInfo) bool { + if turnInfo == nil { + return false + } + return turnInfo.PreConsensusTurn == 0 && turnInfo.UsedReelectTurn == 0 +} + +func calcNextConsensusTurn(curConsensusTurn mc.ConsensusTurnInfo, curReelectTurn uint32) mc.ConsensusTurnInfo { + return mc.ConsensusTurnInfo{ + PreConsensusTurn: curConsensusTurn.TotalTurns(), + UsedReelectTurn: curReelectTurn, + } +} + +type specialAccounts struct { + broadcasts []common.Address + versionSupers []common.Address + blockSupers []common.Address +} diff --git a/leaderelect2.0/controller.go b/leaderelect2.0/controller.go new file mode 100644 index 00000000..30d78b21 --- /dev/null +++ b/leaderelect2.0/controller.go @@ -0,0 +1,124 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php +package leaderelect2 + +import ( + "time" + + "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/log" + "github.com/MatrixAINetwork/go-matrix/mc" + "strconv" +) + +type controller struct { + timer *time.Timer + reelectTimer *time.Timer + matrix Matrix + dc *cdc + mp *msgPool + selfCache *masterCache + msgCh chan interface{} + quitCh chan struct{} + logInfo string +} + +func newController(matrix Matrix, logInfo string, number uint64) *controller { + if number < 1 { + log.Crit(logInfo, "创建controller失败", "number < 1", "number", number) + } + ctrller := &controller{ + timer: time.NewTimer(time.Minute), + reelectTimer: time.NewTimer(time.Minute), + matrix: matrix, + dc: newCDC(number, matrix.BlockChain(), logInfo), + mp: newMsgPool(), + selfCache: newMasterCache(number), + msgCh: make(chan interface{}, 10), + quitCh: make(chan struct{}), + logInfo: logInfo, + } + + go ctrller.run() + return ctrller +} + +func (self *controller) Close() { + close(self.quitCh) +} + +func (self *controller) ReceiveMsg(msg interface{}) { + self.msgCh <- msg +} + +func (self *controller) Number() uint64 { + return self.dc.number +} + +func (self *controller) State() stateDef { + return self.dc.state +} + +func (self *controller) ConsensusTurn() *mc.ConsensusTurnInfo { + return &self.dc.curConsensusTurn +} + +func (self *controller) ParentHash() common.Hash { + return self.dc.leaderCal.preHash +} + +func (self *controller) run() { + self.setTimer(0, self.timer) + self.setTimer(0, self.reelectTimer) + for { + select { + case msg := <-self.msgCh: + self.handleMsg(msg) + + case <-self.timer.C: + self.timeOutHandle() + + case <-self.reelectTimer.C: + self.reelectTimeOutHandle() + + case <-self.quitCh: + return + } + } +} + +func (self *controller) publishLeaderMsg() { + msg, err := self.dc.PrepareLeaderMsg() + if err != nil { + log.ERROR(self.logInfo, "公布leader身份消息", "准备消息失败", "err", err) + return + } + log.Debug(self.logInfo, "公布leader身份消息, leader", msg.Leader.Hex(), "高度", msg.Number, + "共识状态", msg.ConsensusState, "共识轮次", msg.ConsensusTurn.String(), "重选轮次", msg.ReelectTurn, + "pre Leader", msg.PreLeader.Hex(), "Next Leader", msg.NextLeader.Hex()) + mc.PublishEvent(mc.Leader_LeaderChangeNotify, msg) +} + +func (self *controller) setTimer(outTime int64, timer *time.Timer) { + var OK bool + if outTime <= 0 { + OK = timer.Stop() + } else { + OK = timer.Reset(time.Duration(outTime) * time.Second) + } + if !OK { + for { + select { + case <-timer.C: + log.Trace(self.logInfo, "超时器处理", "释放无用超时") + default: + return + } + } + } +} + +func (self *controller) curTurnInfo() string { + return "共识轮次(" + self.dc.curConsensusTurn.String() + ")&重选轮次(" + strconv.Itoa(int(self.dc.curReelectTurn)) + ")" +} diff --git a/leaderelect2.0/ctrlHandle.go b/leaderelect2.0/ctrlHandle.go new file mode 100644 index 00000000..cb06293b --- /dev/null +++ b/leaderelect2.0/ctrlHandle.go @@ -0,0 +1,177 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php +package leaderelect2 + +import ( + "time" + + "github.com/MatrixAINetwork/go-matrix/ca" + "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/log" + "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/MatrixAINetwork/go-matrix/params/manparams" +) + +func (self *controller) handleMsg(data interface{}) { + if nil == data { + log.WARN(self.logInfo, "消息处理", "收到nil消息") + return + } + + switch data.(type) { + case *startControllerMsg: + msg, _ := data.(*startControllerMsg) + self.handleStartMsg(msg) + + case *mc.BlockPOSFinishedNotify: + msg, _ := data.(*mc.BlockPOSFinishedNotify) + self.handleBlockPOSFinishedNotify(msg) + + case *mc.HD_V2_ReelectInquiryReqMsg: + msg, _ := data.(*mc.HD_V2_ReelectInquiryReqMsg) + self.handleInquiryReq(msg) + + case *mc.HD_V2_ReelectInquiryRspMsg: + msg, _ := data.(*mc.HD_V2_ReelectInquiryRspMsg) + self.handleInquiryRsp(msg) + + case *mc.HD_V2_ReelectLeaderReqMsg: + msg, _ := data.(*mc.HD_V2_ReelectLeaderReqMsg) + self.handleRLReq(msg) + + case *mc.HD_V2_ConsensusVote: + msg, _ := data.(*mc.HD_V2_ConsensusVote) + self.handleRLVote(msg) + + case *mc.HD_V2_ReelectBroadcastMsg: + msg, _ := data.(*mc.HD_V2_ReelectBroadcastMsg) + self.handleBroadcastMsg(msg) + + case *mc.HD_V2_ReelectBroadcastRspMsg: + msg, _ := data.(*mc.HD_V2_ReelectBroadcastRspMsg) + self.handleBroadcastRsp(msg) + + default: + log.WARN(self.logInfo, "消息处理", "未知消息类型") + } +} + +func (self *controller) SetSelfAddress(addr common.Address, nodeAddr common.Address) { + self.dc.selfAddr = addr + self.dc.selfNodeAddr = nodeAddr + self.selfCache.selfAddr = addr + self.selfCache.selfNodeAddr = nodeAddr +} + +func (self *controller) handleStartMsg(msg *startControllerMsg) { + if nil == msg || nil == msg.parentHeader { + log.WARN(self.logInfo, "开始消息处理", ErrParamsIsNil) + return + } + + if manparams.VersionCmp(string(msg.parentHeader.Version), manparams.VersionGamma) < 0 { + log.Trace(self.logInfo, "开始消息处理", "版本号不匹配, 不处理消息", "header version", string(msg.parentHeader.Version)) + return + } + + if self.mp.parentHeader != nil && self.mp.parentHeader.Time.Cmp(msg.parentHeader.Time) == 1 { + log.Warn(self.logInfo, "开始消息处理", "parentHeader时间戳比现有时间戳小", "msg time", msg.parentHeader.Time, "cache time", self.mp.parentHeader.Time) + return + } + + a0Address := ca.GetDepositAddress() + nodeAddress := ca.GetSignAddress() + self.SetSelfAddress(a0Address, nodeAddress) + + log.Debug(self.logInfo, "开始消息处理", "start", "高度", self.dc.number, "preLeader", msg.parentHeader.Leader.Hex(), "header time", msg.parentHeader.Time.Int64()) + if err := self.dc.AnalysisState(msg.parentHeader, msg.parentStateDB); err != nil { + log.Error(self.logInfo, "开始消息处理", "分析状态树信息错误", "err", err) + return + } + + if self.dc.role != common.RoleValidator { + log.Debug(self.logInfo, "开始消息处理", "身份错误, 不是验证者", "高度", self.dc.number) + self.mp.SaveParentHeader(msg.parentHeader) + return + } + + if self.dc.bcInterval.IsBroadcastNumber(self.dc.number) { + log.Debug(self.logInfo, "开始消息处理", "区块为广播区块,不开启定时器") + self.dc.state = stIdle + self.publishLeaderMsg() + self.mp.SaveParentHeader(msg.parentHeader) + self.dc.state = stWaiting + return + } + + if self.dc.turnTime.SetBeginTime(msg.parentHeader.Time.Int64()) { + self.mp.SaveParentHeader(msg.parentHeader) + if isFirstConsensusTurn(self.ConsensusTurn()) { + curTime := time.Now().Unix() + st, remainTime, reelectTurn := self.dc.turnTime.CalState(0, curTime) + log.Debug(self.logInfo, "开始消息处理", "完成", "状态计算结果", st.String(), "剩余时间", remainTime, "重选轮次", reelectTurn) + self.dc.state = st + self.dc.curReelectTurn = 0 + self.setTimer(remainTime, self.timer) + if st == stPos { + self.processPOSState() + } else if st == stReelect { + self.startReelect(reelectTurn) + } + } + } + + //公布leader身份 + self.publishLeaderMsg() +} + +func (self *controller) handleBlockPOSFinishedNotify(msg *mc.BlockPOSFinishedNotify) { + if nil == msg || nil == msg.Header { + log.WARN(self.logInfo, "POS完成通知消息处理", ErrParamsIsNil) + return + } + if err := self.mp.SavePOSNotifyMsg(msg); err == nil { + log.Debug(self.logInfo, "POS完成通知消息处理", "缓存成功", "高度", msg.Number, "leader", msg.Header.Leader, "leader轮次", msg.ConsensusTurn.String()) + } + self.processPOSState() +} + +func (self *controller) timeOutHandle() { + curTime := time.Now().Unix() + st, remainTime, reelectTurn := self.dc.turnTime.CalState(self.dc.curConsensusTurn.TotalTurns(), curTime) + switch self.State() { + case stPos: + log.Warn(self.logInfo, "超时事件", "POS未完成", "轮次", self.curTurnInfo(), "高度", self.Number(), + "状态计算结果", st.String(), "下次超时时间", remainTime, "计算的重选轮次", reelectTurn, + "轮次开始时间", self.dc.turnTime.GetBeginTime(self.ConsensusTurn().TotalTurns()), "leader", self.dc.GetConsensusLeader().Hex()) + case stReelect: + log.Warn(self.logInfo, "超时事件", "重选未完成", "轮次", self.curTurnInfo(), "高度", self.Number(), + "状态计算结果", st.String(), "下次超时时间", remainTime, "计算的重选轮次", reelectTurn, + "轮次开始时间", self.dc.turnTime.GetBeginTime(self.ConsensusTurn().TotalTurns()), "master", self.dc.GetReelectMaster().Hex()) + default: + log.Error(self.logInfo, "超时事件", "当前状态错误", "state", self.State().String(), "轮次", self.curTurnInfo(), "高度", self.Number(), + "轮次开始时间", self.dc.turnTime.GetBeginTime(self.ConsensusTurn().TotalTurns()), "当前时间", curTime) + return + } + + self.setTimer(remainTime, self.timer) + self.dc.state = st + self.startReelect(reelectTurn) +} + +func (self *controller) processPOSState() { + if self.State() != stPos { + log.Debug(self.logInfo, "执行检查POS状态", "状态不正常,不执行", "当前状态", self.State().String()) + return + } + + if _, err := self.mp.GetPOSNotifyMsg(self.dc.GetConsensusLeader(), self.dc.curConsensusTurn); err != nil { + log.Debug(self.logInfo, "执行检查POS状态", "获取POS完成消息失败", "err", err) + return + } + + log.Debug(self.logInfo, "POS完成", "状态切换为<挖矿结果等待阶段>") + self.setTimer(0, self.timer) + self.dc.state = stMining +} diff --git a/leaderelect2.0/ctrlManager.go b/leaderelect2.0/ctrlManager.go new file mode 100644 index 00000000..dbe0567e --- /dev/null +++ b/leaderelect2.0/ctrlManager.go @@ -0,0 +1,120 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php +package leaderelect2 + +import ( + "github.com/MatrixAINetwork/go-matrix/log" + "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/pkg/errors" + "sync" +) + +type ControllerManager struct { + mu sync.Mutex + curChainState mc.ChainState + ctrlMap map[uint64]*controller + matrix Matrix + logInfo string +} + +func NewControllerManager(matrix Matrix, logInfo string) *ControllerManager { + return &ControllerManager{ + curChainState: mc.ChainState{}, + ctrlMap: make(map[uint64]*controller), + matrix: matrix, + logInfo: logInfo, + } +} + +func (cm *ControllerManager) StartController(number uint64, superBlkSeq uint64, msg *startControllerMsg) { + cm.mu.Lock() + defer cm.mu.Unlock() + + switch cm.curChainState.Cmp(superBlkSeq, number) { + case 1: //cur > input + log.Debug(cm.logInfo, "处理start controller消息", "超级序号或高度低于当前值,不处理", + "curNumber", cm.curChainState.CurNumber(), "number", number, + "curSuperSeq", cm.curChainState.SuperSeq(), "superSeq", superBlkSeq) + return + case -1: // cur < input + if cm.curChainState.SuperSeq() < superBlkSeq { + log.Debug(cm.logInfo, "处理start controller消息", "超级区块序号变更,清空之前状态", + "curSuperSeq", cm.curChainState.SuperSeq(), "superSeq", superBlkSeq) + cm.clearCtrlMap() + } + cm.curChainState.Reset(superBlkSeq, number) + cm.fixCtrlMap() + } + + cm.getController(number).ReceiveMsg(msg) +} + +func (cm *ControllerManager) ReceiveMsgByCur(msg interface{}) { + cm.mu.Lock() + defer cm.mu.Unlock() + if cm.curChainState.CurNumber() <= 0 { + return + } + ctrl := cm.getController(cm.curChainState.CurNumber()) + ctrl.ReceiveMsg(msg) +} + +func (cm *ControllerManager) ReceiveMsg(number uint64, msg interface{}) error { + if number <= 0 { + return errors.New("number(0) is illegal") + } + cm.mu.Lock() + defer cm.mu.Unlock() + if err := cm.isLegalNumber(number); err != nil { + return err + } + ctrl := cm.getController(number) + ctrl.ReceiveMsg(msg) + return nil +} + +func (cm *ControllerManager) fixCtrlMap() { + if len(cm.ctrlMap) == 0 { + return + } + delKeys := make([]uint64, 0) + for key, ctrl := range cm.ctrlMap { + if err := cm.isLegalNumber(key); err != nil { + ctrl.Close() + delKeys = append(delKeys, key) + } + } + for _, delKey := range delKeys { + delete(cm.ctrlMap, delKey) + } +} + +func (cm *ControllerManager) clearCtrlMap() { + if len(cm.ctrlMap) == 0 { + return + } + for _, ctrl := range cm.ctrlMap { + ctrl.Close() + } + cm.ctrlMap = make(map[uint64]*controller) +} + +func (cm *ControllerManager) isLegalNumber(number uint64) error { + if number < cm.curChainState.CurNumber() { + return errors.Errorf("number(%d) is less than current number(%d)", number, cm.curChainState.CurNumber()) + } + if number > cm.curChainState.CurNumber()+mangerCacheMax { + return errors.Errorf("number(%d) is too big than current number(%d)", number, cm.curChainState.CurNumber()) + } + return nil +} + +func (cm *ControllerManager) getController(number uint64) *controller { + ctrl, OK := cm.ctrlMap[number] + if OK == false { + ctrl = newController(cm.matrix, cm.logInfo, number) + cm.ctrlMap[number] = ctrl + } + return ctrl +} diff --git a/leaderelect2.0/ctrlReelection.go b/leaderelect2.0/ctrlReelection.go new file mode 100644 index 00000000..45f2795d --- /dev/null +++ b/leaderelect2.0/ctrlReelection.go @@ -0,0 +1,686 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php + +package leaderelect2 + +import ( + "time" + + "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/core/types" + "github.com/MatrixAINetwork/go-matrix/log" + "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/pkg/errors" +) + +func (self *controller) startReelect(reelectTurn uint32) { + log.Info(self.logInfo, "重选流程", "开启处理", "重选轮次", reelectTurn, "共识轮次", self.dc.curConsensusTurn.String(), "高度", self.dc.number) + if self.State() != stReelect { + log.Trace(self.logInfo, "开启重选流程", "当前状态不是重选状态,不处理", "状态", self.State().String(), "重选轮次", reelectTurn, "共识轮次", self.dc.curConsensusTurn.String(), "高度", self.dc.number) + return + } + if self.dc.curReelectTurn == reelectTurn { + log.Trace(self.logInfo, "开启重选流程", "重选已启动,不处理", "重选轮次", reelectTurn, "共识轮次", self.dc.curConsensusTurn.String(), "高度", self.dc.number) + return + } + + if err := self.dc.SetReelectTurn(reelectTurn); err != nil { + log.Error(self.logInfo, "开启重选流程", "设置重选轮次失败", "err", err, "高度", self.dc.number) + return + } + beginTime, endTime := self.dc.turnTime.CalTurnTime(self.dc.curConsensusTurn.TotalTurns(), self.dc.curReelectTurn) + master := self.dc.GetReelectMaster() + if master == self.dc.selfAddr { + log.Debug(self.logInfo, "(master)开启重选流程", master.Hex(), "轮次", self.curTurnInfo(), "高度", self.dc.number, + "轮次开始时间", time.Unix(beginTime, 0).String(), "轮次结束时间", time.Unix(endTime, 0).String(), "self", self.dc.selfAddr.Hex()) + self.dc.isMaster = true + self.setTimer(self.dc.turnTime.reelectHandleInterval, self.reelectTimer) + self.sendInquiryReq() + } else { + log.Debug(self.logInfo, "(follower)开启重选流程", master.Hex(), "轮次", self.curTurnInfo(), "高度", self.dc.number, + "轮次开始时间", time.Unix(beginTime, 0).String(), "轮次结束时间", time.Unix(endTime, 0).String(), "self", self.dc.selfAddr.Hex()) + self.dc.isMaster = false + self.setTimer(0, self.reelectTimer) + } + + self.publishLeaderMsg() +} + +func (self *controller) finishReelectWithPOS(posResult *mc.HD_BlkConsensusReqMsg, from common.Address) { + log.INFO(self.logInfo, "完成leader重选", "POS结果重置,恢复并开始挖矿等待", "共识轮次", self.ConsensusTurn().String(), "高度", self.Number()) + mc.PublishEvent(mc.Leader_RecoveryState, &mc.RecoveryStateMsg{Type: mc.RecoveryTypePOS, Header: posResult.Header, From: from}) + self.setTimer(0, self.timer) + self.setTimer(0, self.reelectTimer) + self.dc.state = stMining + self.dc.SetReelectTurn(0) + self.dc.isMaster = false + self.selfCache.ClearSelfInquiryMsg() + self.publishLeaderMsg() +} + +func (self *controller) finishReelectWithRLConsensus(rlResult *mc.HD_V2_ReelectLeaderConsensus) { + consensusTurn := calcNextConsensusTurn(rlResult.Req.InquiryReq.ConsensusTurn, rlResult.Req.InquiryReq.ReelectTurn) + if err := self.dc.SetConsensusTurn(consensusTurn); err != nil { + log.Error(self.logInfo, "完成leader重选", "leader重置, 设置共识轮次失败", "err", err) + return + } + + //缓存共识结果消息 + self.mp.SaveRLConsensusMsg(rlResult) + + self.setTimer(0, self.reelectTimer) + self.selfCache.ClearSelfInquiryMsg() + self.dc.isMaster = false + curTime := time.Now().Unix() + st, remainTime, reelectTurn := self.dc.turnTime.CalState(consensusTurn.TotalTurns(), curTime) + log.INFO(self.logInfo, "完成leader重选", "leader重置", "重选轮次", reelectTurn, "旧共识轮次", self.ConsensusTurn().String(), "新共识轮次", consensusTurn.String(), "高度", self.Number(), + "状态计算结果", st.String(), "下次超时时间", remainTime, "计算的重选轮次", reelectTurn, "轮次开始时间", self.dc.turnTime.GetBeginTime(self.ConsensusTurn().TotalTurns())) + self.dc.state = st + self.dc.curReelectTurn = 0 + self.setTimer(remainTime, self.timer) + if st == stPos { + self.processPOSState() + } else if st == stReelect { + self.startReelect(reelectTurn) + } + + self.publishLeaderMsg() +} + +func (self *controller) reelectTimeOutHandle() { + if self.State() != stReelect { + log.Info(self.logInfo, "重选处理定时器超时", "状态错误,当前状态不是重选阶段", "当前状态", self.State().String()) + return + } + switch self.selfCache.GetInquiryResult() { + case mc.ReelectRSPTypeNone: + self.sendInquiryReq() + case mc.ReelectRSPTypeAgree: + self.sendRLReq() + case mc.ReelectRSPTypePOS, mc.ReelectRSPTypeAlreadyRL: + self.sendResultBroadcastMsg() + default: + log.Warn(self.logInfo, "重选处理定时器超时", "当前询问结果错误", "inquiryResult", self.selfCache.GetInquiryResult()) + } + self.setTimer(self.dc.turnTime.reelectHandleInterval, self.reelectTimer) +} + +func (self *controller) handleInquiryReq(req *mc.HD_V2_ReelectInquiryReqMsg) { + if nil == req { + log.INFO(self.logInfo, "询问请求处理", "消息为nil") + return + } + if self.State() == stIdle { + log.INFO(self.logInfo, "询问请求处理", "当前状态为idle,忽略消息", "from", req.From.Hex(), "高度", self.dc.number) + return + } + + fromMaster, _, err := self.dc.GetA0AccountFromAnyAccount(req.From, self.dc.leaderCal.preHash) + if err != nil { + log.Info(self.logInfo, "询问请求处理", "根据from获取master的A0账户失败!", "from", req.From.Hex(), "err", err) + return + } + + if req.Master != fromMaster { + log.INFO(self.logInfo, "询问请求处理", "消息master与from不匹配", "master", req.Master.Hex(), "from", fromMaster.Hex(), "高度", self.dc.number) + return + } + log.Debug(self.logInfo, "询问消息处理", "开始", "高度", req.Number, "共识轮次", req.ConsensusTurn.String(), "重选轮次", req.ReelectTurn, "本地轮次信息", self.curTurnInfo(), "from", req.From.Hex()) + + // 对比请求高度 + if req.Number < self.Number() { + // 消息高度<本地高度: 请求方高度落后 + reqHash := types.RlpHash(req) + log.Trace(self.logInfo, "询问请求处理", "请求高度<本地高度, 发送响应(新区块已准备完毕)", "请求高度", req.Number, "本地高度", self.Number(), "reqHash", reqHash.TerminalString()) + self.sendInquiryRspWithNewBlockReady(reqHash, req.From, req.Number) + return + } else if req.Number > self.Number() { + // 消息高度>本地高度: 本地高度落后 + if self.State() == stReelect && self.dc.isMaster { + log.Trace(self.logInfo, "询问请求处理", "高度落后,但当前是master,不另外发送询问", "请求高度", req.Number, "本地高度", self.Number(), "目标", req.From.Hex()) + return + } else { + log.Trace(self.logInfo, "询问请求处理", "请求高度>本地高度, 主动询问对方状态", "请求高度", req.Number, "本地高度", self.Number(), "目标", req.From.Hex()) + self.sendInquiryReqToSingle(req.From) + return + } + } + + // 高度相同,对比header时间戳 + curHeaderTime := self.mp.parentHeader.Time.Uint64() + if req.HeaderTime < curHeaderTime { + // 消息HeaderTime<本地HeaderTime: 请求方HeaderTime落后 + reqHash := types.RlpHash(req) + log.Trace(self.logInfo, "询问请求处理", "请求HeaderTime<本地HeaderTime, 发送响应(新区块已准备完毕)", + "请求HeaderTime", req.HeaderTime, "本地HeaderTime", curHeaderTime, "reqHash", reqHash.TerminalString()) + self.sendInquiryRspWithNewBlockReady(reqHash, req.From, req.Number) + return + } else if req.HeaderTime > curHeaderTime { + // 消息HeaderTime>本地HeaderTime: 本地HeaderTime落后 + if self.State() == stReelect && self.dc.isMaster { + log.Trace(self.logInfo, "询问请求处理", "HeaderTime落后,但当前是master,不另外发送询问", + "请求HeaderTime", req.HeaderTime, "本地HeaderTime", curHeaderTime, "req from", req.From.Hex()) + return + } else { + log.Trace(self.logInfo, "询问请求处理", "请求HeaderTime>本地HeaderTime, 主动询问对方状态", + "请求HeaderTime", req.HeaderTime, "本地HeaderTime", curHeaderTime, "高度", req.Number, "目标", req.From.Hex()) + self.sendInquiryReqToSingle(req.From) + return + } + } + + // 高度、headerTime相同,对比共识轮次 + if req.ConsensusTurn.Cmp(self.dc.curConsensusTurn) < 0 { + // 消息轮次<本地轮次: 请求方共识轮次落后 + log.Trace(self.logInfo, "询问请求处理", "请求共识轮次<本地共识轮次, 发送响应(重选共识结果)", "消息共识轮次", req.ConsensusTurn.String(), "本地共识轮次", self.dc.curConsensusTurn.String(), "高度", self.dc.number) + self.sendInquiryRspWithRLConsensus(types.RlpHash(req), req.From) + return + } else if req.ConsensusTurn.Cmp(self.dc.curConsensusTurn) > 0 { + // 消息轮次>本地轮次: 本地共识轮次落后 + log.Trace(self.logInfo, "询问请求处理", "请求共识轮次>本地共识轮次, 主动询问对方状态", "消息共识轮次", req.ConsensusTurn.String(), "本地共识轮次", self.dc.curConsensusTurn.String(), "高度", self.dc.number) + if self.State() == stReelect && self.dc.isMaster { + log.Trace(self.logInfo, "询问请求处理", "共识轮次落后,但当前是master,不另外发送询问", "消息共识轮次", req.ConsensusTurn.String(), "本地共识轮次", self.dc.curConsensusTurn.String(), "高度", self.dc.number) + return + } else { + self.sendInquiryReqToSingle(req.From) + return + } + } else { + master, err := self.dc.GetLeader(req.ConsensusTurn.TotalTurns()+req.ReelectTurn, self.dc.bcInterval) + if err != nil { + log.Info(self.logInfo, "询问请求处理", "验证消息合法性", "本地计算master失败", err) + return + } + + if master != req.Master { + log.Info(self.logInfo, "询问请求处理", "验证消息合法性失败,master不匹配", "master", req.Master.Hex(), "local master", master.Hex()) + return + } + switch self.State() { + case stMining: + reqHash := types.RlpHash(req) + log.Debug(self.logInfo, "询问消息处理", "本地状态为mining, 发送POS完成响应", "高度", req.Number, "from", req.From.Hex(), "req hash", reqHash.TerminalString()) + self.sendInquiryRspWithPOS(reqHash, req.From, req.Number) + return + + case stReelect: + if req.ReelectTurn != self.dc.curReelectTurn { + log.Debug(self.logInfo, "询问请求处理", "重选轮次不匹配,忽略消息", "消息重选轮次", req.ReelectTurn, "本地重选轮次", self.dc.curReelectTurn, "高度", self.dc.number) + return + } + if err := self.dc.turnTime.CheckTimeLegal(self.dc.curConsensusTurn.TotalTurns(), self.dc.curReelectTurn, int64(req.TimeStamp)); err != nil { + log.Debug(self.logInfo, "询问请求处理", "请求时间搓检查", "异常", err, "轮次", self.curTurnInfo(), "高度", self.dc.number) + return + } + self.sendInquiryRspWithAgree(types.RlpHash(req), req.From, req.Number) + + default: + log.INFO(self.logInfo, "询问请求处理", "本地状态异常,不响应请求", "本地状态", self.State().String()) + return + } + } +} + +func (self *controller) handleInquiryRsp(rsp *mc.HD_V2_ReelectInquiryRspMsg) { + log.Trace(self.logInfo, "询问响应处理", "开始", "req hash", rsp.ReqHash.TerminalString(), "类型", rsp.Type, "from", rsp.From.Hex()) + if self.selfCache.GetInquiryResult() != mc.ReelectRSPTypeNone { + log.Trace(self.logInfo, "询问响应处理", "本地已有询问结果,忽略消息", "当前询问结果", self.selfCache.GetInquiryResult()) + return + } + + if err := self.selfCache.IsMatchedInquiryRsp(rsp); err != nil { + log.Info(self.logInfo, "询问响应处理", "响应匹配检查", "err", err, "高度", self.dc.number) + return + } + switch rsp.Type { + case mc.ReelectRSPTypeNewBlockReady: + self.processNewBlockReadyRsp(rsp.NewBlock, rsp.From) + return + + case mc.ReelectRSPTypeAlreadyRL: + if err := self.checkRLResult(rsp.RLResult); err != nil { + log.Info(self.logInfo, "询问响应处理(leader重选已完成)", "消息检查", "err", err) + return + } + if err := self.selfCache.GenBroadcastMsgWithInquiryResult(rsp.Type, rsp); err != nil { + log.Warn(self.logInfo, "询问响应处理(leader重选已完成)", "生成广播消息失败", "结果类型", rsp.Type, "err", err) + return + } + self.sendResultBroadcastMsg() + self.finishReelectWithRLConsensus(rsp.RLResult) + + case mc.ReelectRSPTypePOS: + if err := self.checkPOSResult(rsp.POSResult); err != nil { + log.Info(self.logInfo, "询问响应处理(POS完成响应)", "消息检查", "err", err) + return + } + if err := self.selfCache.GenBroadcastMsgWithInquiryResult(rsp.Type, rsp); err != nil { + log.Warn(self.logInfo, "询问响应处理(POS完成响应)", "生存广播消息失败", "结果类型", rsp.Type, "err", err) + return + } + log.Trace(self.logInfo, "询问响应处理(POS完成响应)", "开始广播结果") + self.sendResultBroadcastMsg() + + case mc.ReelectRSPTypeAgree: + if err := self.selfCache.SaveInquiryVote(rsp.ReqHash, rsp.AgreeSign, rsp.From, self.dc, self.matrix.SignHelper()); err != nil { + log.Info(self.logInfo, "询问响应处理(同意更换leader响应)", "保存同意签名失败", "err", err) + return + } + + signs := self.selfCache.GetInquiryVotes() + log.Trace(self.logInfo, "询问响应处理(同意更换leader响应)", "保存签名成功", "签名总数", len(signs)) + rightSigns, err := self.matrix.DPOSEngine().VerifyHashWithVerifiedSignsAndBlock(self.dc, signs, self.ParentHash()) + if err != nil { + log.Trace(self.logInfo, "询问响应处理(同意更换leader响应)", "同意的签名没有通过POS共识", "err", err) + return + } + + if err := self.selfCache.GenRLReqMsg(rightSigns); err != nil { + log.Error(self.logInfo, "询问响应处理(同意更换leader响应)", "生存更换leader请求消息失败", "err", err) + return + } + log.Trace(self.logInfo, "询问响应处理(同意更换leader响应)", "POS共识通过, 发送更换leader请求") + self.sendRLReq() + } +} + +func (self *controller) handleRLReq(req *mc.HD_V2_ReelectLeaderReqMsg) { + if self.State() != stReelect { + log.Info(self.logInfo, "leader重选请求处理", "本地状态错误", "本地状态", self.State().String()) + return + } + if err := self.checkRLReqMsg(req); err != nil { + log.Info(self.logInfo, "leader重选请求处理", "消息异常", "err", err) + return + } + + hash := types.RlpHash(req) + sign, err := self.matrix.SignHelper().SignHashWithValidateByReader(self.dc, hash.Bytes(), true, self.ParentHash()) + if err != nil { + log.Error(self.logInfo, "leader重选请求处理", "签名失败", "err", err) + return + } + rsp := &mc.HD_ConsensusVote{ + Number: self.dc.number, + SignHash: hash, + Sign: sign, + } + log.Trace(self.logInfo, "leader重选请求处理", "发送投票", "高度", self.dc.number, "req hash", rsp.SignHash.TerminalString(), "target", req.InquiryReq.From.Hex()) + self.matrix.HD().SendNodeMsg(mc.HD_V2_LeaderReelectVote, rsp, common.RoleNil, []common.Address{req.InquiryReq.From}) +} + +func (self *controller) handleRLVote(msg *mc.HD_V2_ConsensusVote) { + if nil == msg { + log.Info(self.logInfo, "处理leader重选响应", "消息为nil") + return + } + if err := self.selfCache.SaveRLVote(msg.SignHash, msg.Sign, msg.From, self.dc, self.matrix.SignHelper()); err != nil { + log.Info(self.logInfo, "处理leader重选响应", "保存签名错误", "err", err) + return + } + signs := self.selfCache.GetRLVotes() + rightSigns, err := self.matrix.DPOSEngine().VerifyHashWithVerifiedSignsAndBlock(self.dc, signs, self.ParentHash()) + if err != nil { + log.Debug(self.logInfo, "处理leader重选响应", "签名没有通过POS共识", "总票数", len(signs), "err", err) + return + } + + log.Trace(self.logInfo, "处理leader重选响应", "POS共识通过, 准备发送重选结果广播") + if err := self.selfCache.GenBroadcastMsgWithRLSuccess(rightSigns); err != nil { + log.Warn(self.logInfo, "处理leader重选响应", "生成广播(leader重选成功)消息失败", "err", err) + return + } + self.sendResultBroadcastMsg() +} + +func (self *controller) handleBroadcastMsg(msg *mc.HD_V2_ReelectBroadcastMsg) { + if nil == msg { + log.Info(self.logInfo, "处理重选结果广播", "消息为nil") + return + } + if err := self.processResultBroadcastMsg(msg); err != nil { + log.Info(self.logInfo, "处理重选结果广播失败", err) + return + } + self.sendResultBroadcastRsp(msg) +} + +func (self *controller) handleBroadcastRsp(rsp *mc.HD_V2_ReelectBroadcastRspMsg) { + if nil == rsp { + log.Error(self.logInfo, "处理重选结果广播响应", "响应消息为nil") + return + } + + if err := self.selfCache.SaveBroadcastVote(rsp.ResultHash, rsp.Sign, rsp.From, self.dc, self.matrix.SignHelper()); err != nil { + log.Error(self.logInfo, "处理重选结果广播响应", "保存响应失败", "err", err) + return + } + signs := self.selfCache.GetBroadcastVotes() + _, err := self.matrix.DPOSEngine().VerifyHashWithVerifiedSignsAndBlock(self.dc, signs, self.ParentHash()) + if err != nil { + log.INFO(self.logInfo, "处理重选结果广播响应", "响应没有通过POS共识", "票总数", len(signs), "err", err) + return + } + log.Trace(self.logInfo, "处理重选结果广播响应", "POS共识通过, 准备处理广播结果") + resultMsg, err := self.selfCache.GetLocalBroadcastMsg() + if err != nil { + log.Error(self.logInfo, "处理本地重选结果广播", "获取本地重选结果广播错误", "err", err) + return + } + if err := self.processResultBroadcastMsg(resultMsg); err != nil { + log.Error(self.logInfo, "处理本地重选结果广播失败", err) + return + } +} + +func (self *controller) processResultBroadcastMsg(msg *mc.HD_V2_ReelectBroadcastMsg) error { + if msg == nil { + return ErrParamsIsNil + } + switch msg.Type { + case mc.ReelectRSPTypePOS: + posResult := msg.POSResult + if nil == posResult || nil == posResult.Header { + return ErrPOSResultIsNil + } + if posResult.Header.Leader != self.dc.GetConsensusLeader() { + return errors.Errorf("消息中headerLeader(%s) != 本地共识leader(%s)", posResult.Header.Leader.Hex(), self.dc.GetConsensusLeader().Hex()) + } + if err := self.matrix.DPOSEngine().VerifyBlock(self.dc, posResult.Header); err != nil { + return errors.Errorf("POS完成结果中的POS结果验证错误(%v)", err) + } + self.finishReelectWithPOS(posResult, msg.From) + + case mc.ReelectRSPTypeAgree, mc.ReelectRSPTypeAlreadyRL: + if err := self.checkRLResult(msg.RLResult); err != nil { + return err + } + self.finishReelectWithRLConsensus(msg.RLResult) + default: + return errors.Errorf("结果类型(%v)错误", msg.Type) + } + return nil +} + +func (self *controller) sendInquiryReq() { + req := &mc.HD_V2_ReelectInquiryReqMsg{ + Number: self.Number(), + HeaderTime: self.mp.parentHeader.Time.Uint64(), + ConsensusTurn: self.dc.curConsensusTurn, + ReelectTurn: self.dc.curReelectTurn, + TimeStamp: uint64(time.Now().Unix()), + Master: self.dc.selfAddr, + From: self.dc.selfNodeAddr, + } + reqHash := self.selfCache.SaveInquiryReq(req) + selfSign, err := self.matrix.SignHelper().SignHashWithValidateByReader(self.dc, reqHash.Bytes(), true, self.ParentHash()) + if err != nil { + log.Error(self.logInfo, "send<重选询问请求>", "自己的同意签名失败", "err", err, "高度", self.Number(), "轮次", self.curTurnInfo()) + return + } + if err := self.selfCache.SaveInquiryVote(reqHash, selfSign, self.dc.selfNodeAddr, self.dc, self.matrix.SignHelper()); err != nil { + log.Error(self.logInfo, "send<重选询问请求>", "保存自己的同意签名错误", "err", err) + return + } + + log.Trace(self.logInfo, "send<重选询问请求>", "成功", "轮次", self.curTurnInfo(), "高度", self.Number(), "reqHash", reqHash.TerminalString()) + self.matrix.HD().SendNodeMsg(mc.HD_V2_LeaderReelectInquiryReq, req, common.RoleValidator, nil) + return +} + +func (self *controller) sendInquiryReqToSingle(target common.Address) { + curTime := time.Now().Unix() + if false == self.selfCache.CanSendSingleInquiryReq(curTime, self.dc.turnTime.reelectHandleInterval) { + log.Trace(self.logInfo, "send<重选询问请求>single", "尚未达到发送间隔,不发送请求") + return + } + req := &mc.HD_V2_ReelectInquiryReqMsg{ + Number: self.Number(), + HeaderTime: self.mp.parentHeader.Time.Uint64(), + ConsensusTurn: self.dc.curConsensusTurn, + ReelectTurn: self.dc.curReelectTurn, + TimeStamp: uint64(curTime), + Master: self.dc.selfAddr, + From: self.dc.selfNodeAddr, + } + reqHash := self.selfCache.SaveInquiryReq(req) + log.Trace(self.logInfo, "send<重选询问请求>single", "成功", "轮次", self.curTurnInfo(), "高度", self.Number(), "reqHash", reqHash.TerminalString()) + self.matrix.HD().SendNodeMsg(mc.HD_V2_LeaderReelectInquiryReq, req, common.RoleNil, []common.Address{target}) + self.selfCache.SetLastSingleInquiryReqTime(curTime) + return +} + +func (self *controller) sendInquiryRspWithPOS(reqHash common.Hash, target common.Address, number uint64) { + POSMsg, err := self.mp.GetPOSNotifyMsg(self.dc.GetConsensusLeader(), self.dc.curConsensusTurn) + if err != nil { + log.Warn(self.logInfo, "send<询问响应(POS完成响应)>", "获取POS通知消息错误", "err", err, "高度", number, + "共识轮次", self.dc.curConsensusTurn, "共识leader", self.dc.GetConsensusLeader()) + return + } + rsp := &mc.HD_V2_ReelectInquiryRspMsg{ + Number: number, + ReqHash: reqHash, + Type: mc.ReelectRSPTypePOS, + AgreeSign: common.Signature{}, + POSResult: &mc.HD_BlkConsensusReqMsg{Header: POSMsg.Header, TxsCode: POSMsg.TxsCode, ConsensusTurn: self.dc.curConsensusTurn}, + RLResult: nil, + NewBlock: nil, + } + self.matrix.HD().SendNodeMsg(mc.HD_V2_LeaderReelectInquiryRsp, rsp, common.RoleNil, []common.Address{target}) +} + +func (self *controller) sendInquiryRspWithAgree(reqHash common.Hash, target common.Address, number uint64) { + sign, err := self.matrix.SignHelper().SignHashWithValidateByReader(self.dc, reqHash.Bytes(), true, self.ParentHash()) + if err != nil { + log.Error(self.logInfo, "send<询问响应(同意更换leader响应)>", "签名失败", "err", err, "高度", number, + "共识轮次", self.dc.curConsensusTurn.String(), "重选轮次", self.dc.curReelectTurn) + return + } + rsp := &mc.HD_V2_ReelectInquiryRspMsg{ + Number: number, + ReqHash: reqHash, + Type: mc.ReelectRSPTypeAgree, + AgreeSign: sign, + POSResult: nil, + RLResult: nil, + NewBlock: nil, + } + log.Trace(self.logInfo, "send<询问响应(同意更换leader响应)>", "成功", "reqHash", reqHash.TerminalString(), "高度", number, + "轮次信息", self.curTurnInfo(), "目标", target.Hex()) + self.matrix.HD().SendNodeMsg(mc.HD_V2_LeaderReelectInquiryRsp, rsp, common.RoleNil, []common.Address{target}) +} + +func (self *controller) sendInquiryRspWithRLConsensus(reqHash common.Hash, target common.Address) { + consensusMsg, err := self.mp.GetRLConsensusMsg(self.dc.curConsensusTurn) + if err != nil { + log.Error(self.logInfo, "send<询问响应(leader重选已完成)>", "获取leader重选共识消息错误", "err", err, "高度", self.Number(), + "轮次信息", self.curTurnInfo(), "目标", target.Hex()) + return + } + rsp := &mc.HD_V2_ReelectInquiryRspMsg{ + Number: self.Number(), + ReqHash: reqHash, + Type: mc.ReelectRSPTypeAlreadyRL, + AgreeSign: common.Signature{}, + POSResult: nil, + RLResult: consensusMsg, + NewBlock: nil, + } + log.Trace(self.logInfo, "send<询问响应(leader重选已完成)>", "成功", "轮次", consensusMsg.Req.InquiryReq.ConsensusTurn, "高度", self.Number(), + "轮次信息", self.curTurnInfo(), "目标", target.Hex()) + self.matrix.HD().SendNodeMsg(mc.HD_V2_LeaderReelectInquiryRsp, rsp, common.RoleNil, []common.Address{target}) +} + +func (self *controller) sendInquiryRspWithNewBlockReady(reqHash common.Hash, target common.Address, number uint64) { + parentHeader := self.mp.GetParentHeader() + if parentHeader == nil { + log.Warn(self.logInfo, "send<询问响应(新区块已准备完毕响应)>", "获取区块失败") + return + } + + rsp := &mc.HD_V2_ReelectInquiryRspMsg{ + Number: number, + ReqHash: reqHash, + Type: mc.ReelectRSPTypeNewBlockReady, + AgreeSign: common.Signature{}, + POSResult: nil, + RLResult: nil, + NewBlock: parentHeader, + } + log.Trace(self.logInfo, "send<询问响应(新区块已准备完毕响应)>", "成功", "block hash", parentHeader.Hash().TerminalString(), "req hash", reqHash.TerminalString(), "to", target.Hex()) + self.matrix.HD().SendNodeMsg(mc.HD_V2_LeaderReelectInquiryRsp, rsp, common.RoleNil, []common.Address{target}) +} + +func (self *controller) sendRLReq() { + req, reqHash, err := self.selfCache.GetRLReqMsg() + if err != nil { + log.Warn(self.logInfo, "send", "获取请求消息失败", "err", err) + return + } + + selfSign, err := self.matrix.SignHelper().SignHashWithValidateByReader(self.dc, reqHash.Bytes(), true, self.ParentHash()) + if err != nil { + log.Error(self.logInfo, "send", "自己的签名失败", "err", err, "高度", self.Number(), "轮次", self.curTurnInfo()) + return + } + if err := self.selfCache.SaveRLVote(reqHash, selfSign, self.dc.selfNodeAddr, self.dc, self.matrix.SignHelper()); err != nil { + log.Error(self.logInfo, "send", "保存自己签名错误", "err", err) + return + } + + log.Trace(self.logInfo, "send, hash", reqHash.TerminalString(), "轮次", self.curTurnInfo(), "高度", self.Number()) + self.matrix.HD().SendNodeMsg(mc.HD_V2_LeaderReelectReq, req, common.RoleValidator, nil) +} + +func (self *controller) sendResultBroadcastMsg() { + msg, msgHash, err := self.selfCache.GetBroadcastMsg() + if err != nil { + log.Warn(self.logInfo, "send<重选结果广播>", "获取广播消息失败", "err", err) + return + } + selfSign, err := self.matrix.SignHelper().SignHashWithValidateByReader(self.dc, msgHash.Bytes(), true, self.ParentHash()) + if err != nil { + log.Error(self.logInfo, "send<重选结果广播>", "自己的响应签名失败", "err", err, "高度", self.Number(), "轮次", self.curTurnInfo()) + return + } + if err := self.selfCache.SaveBroadcastVote(msgHash, selfSign, self.dc.selfNodeAddr, self.dc, self.matrix.SignHelper()); err != nil { + log.Error(self.logInfo, "send<重选结果广播>", "保存自己的响应失败", "err", err) + return + } + log.Trace(self.logInfo, "send<重选结果广播>, hash", msgHash.TerminalString(), "轮次", self.curTurnInfo(), "高度", self.Number(), "类型", msg.Type) + self.matrix.HD().SendNodeMsg(mc.HD_V2_LeaderReelectBroadcast, msg, common.RoleValidator, nil) +} + +func (self *controller) sendResultBroadcastRsp(req *mc.HD_V2_ReelectBroadcastMsg) { + resultHash := types.RlpHash(req) + sign, err := self.matrix.SignHelper().SignHashWithValidateByReader(self.dc, resultHash.Bytes(), true, self.ParentHash()) + if err != nil { + log.Error(self.logInfo, "响应结果广播消息", "签名失败", "err", err) + return + } + rsp := mc.HD_V2_ReelectBroadcastRspMsg{ + Number: self.Number(), + ResultHash: resultHash, + Sign: sign, + } + self.matrix.HD().SendNodeMsg(mc.HD_V2_LeaderReelectBroadcastRsp, rsp, common.RoleNil, []common.Address{req.From}) +} + +func (self *controller) checkRLReqMsg(req *mc.HD_V2_ReelectLeaderReqMsg) error { + if nil == req || nil == req.InquiryReq { + return ErrParamsIsNil + } + if req.InquiryReq.ConsensusTurn != self.dc.curConsensusTurn { + return errors.Errorf("共识轮次不匹配, 消息(%d) != 本地(%d)", req.InquiryReq.ConsensusTurn, self.dc.curConsensusTurn) + } + if req.InquiryReq.ReelectTurn != self.dc.curReelectTurn { + return errors.Errorf("重选轮次不匹配, 消息(%d) != 本地(%d)", req.InquiryReq.ReelectTurn, self.dc.curReelectTurn) + } + if req.InquiryReq.Master != self.dc.GetReelectMaster() { + return errors.Errorf("master不匹配, master(%s) != 本地master(%s)", req.InquiryReq.Master.Hex(), self.dc.GetReelectMaster().Hex()) + } + if int64(req.TimeStamp) < int64(req.InquiryReq.TimeStamp) { + return errors.Errorf("请求时间戳(%d) < 询问时间戳(%d)", int64(req.TimeStamp), int64(req.InquiryReq.TimeStamp)) + } + if err := self.dc.turnTime.CheckTimeLegal(self.dc.curConsensusTurn.TotalTurns(), self.dc.curReelectTurn, int64(req.TimeStamp)); err != nil { + return err + } + if _, err := self.matrix.DPOSEngine().VerifyHashWithBlock(self.dc, types.RlpHash(req.InquiryReq), req.AgreeSigns, self.ParentHash()); err != nil { + return errors.Errorf("请求中的询问同意签名POS未通过(%v)", err) + } + + return nil +} + +func (self *controller) checkRLResult(result *mc.HD_V2_ReelectLeaderConsensus) error { + if nil == result { + return ErrLeaderResultIsNil + } + turn := calcNextConsensusTurn(result.Req.InquiryReq.ConsensusTurn, result.Req.InquiryReq.ReelectTurn) + if turn.Cmp(self.dc.curConsensusTurn) < 0 { + return errors.Errorf("消息目标共识轮次(%d) < 本地共识轮次(%d)", turn.String(), self.dc.curConsensusTurn.String()) + } + if _, err := self.matrix.DPOSEngine().VerifyHashWithBlock(self.dc, types.RlpHash(result.Req), result.Votes, self.ParentHash()); err != nil { + return errors.Errorf("leader重选完成结果的POS验证失败(%v)", err) + } + return nil +} + +func (self *controller) checkPOSResult(posResult *mc.HD_BlkConsensusReqMsg) error { + if nil == posResult { + return errors.New("POS结果为nil") + } + if posResult.Header.Number.Uint64() != self.Number() { + return errors.Errorf("高度不匹配, pos number[%d] != local number[%d]", posResult.Header.Number.Uint64(), self.Number()) + } + if posResult.ConsensusTurn != self.dc.curConsensusTurn || posResult.Header.Leader != self.dc.consensusLeader { + return errors.Errorf("pos结果轮次不匹配, pos轮次[%s] leader[%s], local轮次[%s], leader[%s]", + posResult.ConsensusTurn.String(), posResult.Header.Leader.Hex(), self.ConsensusTurn().String(), self.dc.GetConsensusLeader().Hex()) + } + if err := self.matrix.DPOSEngine().VerifyBlock(self.dc, posResult.Header); err != nil { + return errors.Errorf("POS验证失败(%v)", err) + } + return nil +} + +func (self *controller) processNewBlockReadyRsp(header *types.Header, from common.Address) { + if nil == header { + log.Info(self.logInfo, "处理新区块响应", "区块header为nil") + return + } + + number := header.Number.Uint64() + parentHeader := self.matrix.BlockChain().GetHeader(header.ParentHash, number-1) + if parentHeader == nil { + log.Warn(self.logInfo, "处理新区块响应", "没有父区块,进行fetch", "parent number", number-1, "parent hash", header.ParentHash.TerminalString(), "source", from.Hex()) + self.matrix.FetcherNotify(header.ParentHash, number-1, from) + return + } + + //POW验证 + bcInterval, err := self.matrix.BlockChain().GetBroadcastIntervalByHash(header.ParentHash) + if err != nil { + log.Warn(self.logInfo, "处理新区块响应", "获取广播周期信息失败", "err", err) + return + } + + isBroadcast := bcInterval.IsBroadcastNumber(number) + seal := !isBroadcast + err = self.matrix.Engine().VerifyHeader(self.matrix.BlockChain(), header, seal) + if err != nil { + log.Warn(self.logInfo, "处理新区块响应", "POW验证失败", "高度", number, "verify seal", seal, "block hash", header.Hash().TerminalString(), "err", err) + return + } + + //POS验证 + err = self.matrix.DPOSEngine().VerifyBlock(self.dc, header) + if err != nil { + log.Warn(self.logInfo, "处理新区块响应", "POS验证失败", "高度", number, "block hash", header.Hash().TerminalString(), "err", err) + return + } + + //发送恢复状态消息 + log.Debug(self.logInfo, "处理新区块响应", "发送恢复状态消息", "高度", number, "block hash", header.Hash().TerminalString()) + mc.PublishEvent(mc.Leader_RecoveryState, &mc.RecoveryStateMsg{Type: mc.RecoveryTypeFullHeader, Header: header, From: from, IsBroadcast: isBroadcast}) +} diff --git a/leaderelect2.0/leaderCal.go b/leaderelect2.0/leaderCal.go new file mode 100644 index 00000000..102c97ae --- /dev/null +++ b/leaderelect2.0/leaderCal.go @@ -0,0 +1,167 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php + +package leaderelect2 + +import ( + "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/core" + "github.com/MatrixAINetwork/go-matrix/core/types" + "github.com/MatrixAINetwork/go-matrix/log" + "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/pkg/errors" +) + +type leaderCalculator struct { + number uint64 + preLeader common.Address + preHash common.Hash + leaderList map[uint32]common.Address + validators []mc.TopologyNodeInfo + specialAccounts specialAccounts + chain *core.BlockChain + logInfo string +} + +func newLeaderCalculator(chain *core.BlockChain, number uint64, logInfo string) *leaderCalculator { + return &leaderCalculator{ + number: number, + preLeader: common.Address{}, + preHash: common.Hash{}, + leaderList: make(map[uint32]common.Address), + validators: nil, + specialAccounts: specialAccounts{}, + chain: chain, + logInfo: logInfo, + } +} + +func (self *leaderCalculator) getRealPreLeader(preHeader *types.Header, bcInterval *mc.BCIntervalInfo) (common.Address, bool, error) { + header := preHeader + number := preHeader.Number.Uint64() + preAppearSuper := header.IsSuperHeader() + + for header.IsSuperHeader() || bcInterval.IsBroadcastNumber(number) { + if header.IsSuperHeader() { + preAppearSuper = true + } + + if number == 0 { + return header.Leader, preAppearSuper, nil + } + header = self.chain.GetHeader(header.ParentHash, number-1) + if header == nil { + return common.Address{}, preAppearSuper, errors.Errorf("获取父区块(%d, %s)失败, header is nil! ", number-1, header.ParentHash.TerminalString()) + } + number = header.Number.Uint64() + } + return header.Leader, preAppearSuper, nil +} + +func (self *leaderCalculator) SetValidatorsAndSpecials(preHeader *types.Header, validators []mc.TopologyNodeInfo, specials *specialAccounts, bcInterval *mc.BCIntervalInfo) error { + if preHeader == nil || validators == nil || specials == nil || bcInterval == nil { + return ErrValidatorsIsNil + } + + realPreLeader, preAppearSuper, err := self.getRealPreLeader(preHeader, bcInterval) + if err != nil { + log.Error(self.logInfo, "计算leader列表", "获取真实的preLeader失败", "err", err) + return err + } + log.Trace(self.logInfo, "计算leader列表", "开始", "preLeader", realPreLeader.Hex(), "前区块中出现超级区块", preAppearSuper, "高度", self.number, "validators size", len(validators)) + leaderList, err := calLeaderList(realPreLeader, self.number, preAppearSuper, validators, bcInterval, self.logInfo) + if err != nil { + return err + } + self.leaderList = leaderList + self.preLeader.Set(preHeader.Leader) + self.preHash.Set(preHeader.Hash()) + self.validators = validators + self.specialAccounts.broadcasts = specials.broadcasts + self.specialAccounts.versionSupers = specials.versionSupers + self.specialAccounts.blockSupers = specials.blockSupers + + return nil +} + +func (self *leaderCalculator) GetValidators() (*mc.TopologyGraph, error) { + if len(self.validators) == 0 { + return nil, errors.New("验证者列表为空") + } + rlt := &mc.TopologyGraph{} + for i := 0; i < len(self.validators); i++ { + rlt.NodeList = append(rlt.NodeList, self.validators[i]) + } + return rlt, nil +} + +func (self *leaderCalculator) GetLeader(turn uint32, bcInterval *mc.BCIntervalInfo) (*leaderData, error) { + if bcInterval == nil { + return nil, errors.New("leader calculator: param bcInterval is nil") + } + leaderCount := uint32(len(self.leaderList)) + if leaderCount == 0 { + return nil, ErrValidatorsIsNil + } + + leaders := &leaderData{} + number := self.number + if bcInterval.IsReElectionNumber(number) { + leaders.leader = common.Address{} + leaders.nextLeader.Set(self.leaderList[turn%leaderCount]) + return leaders, nil + } + + if bcInterval.IsBroadcastNumber(number) { + leaders.leader = common.Address{} + leaders.nextLeader.Set(self.leaderList[(turn)%leaderCount]) + return leaders, nil + } + + leaders.leader.Set(self.leaderList[turn%leaderCount]) + if bcInterval.IsBroadcastNumber(number + 1) { + leaders.nextLeader = common.Address{} + } else { + leaders.nextLeader.Set(self.leaderList[(turn+1)%leaderCount]) + } + return leaders, nil +} + +func calLeaderList(preLeader common.Address, curNumber uint64, preIsSupper bool, validators []mc.TopologyNodeInfo, bcInterval *mc.BCIntervalInfo, logInfo string) (map[uint32]common.Address, error) { + ValidatorNum := len(validators) + var startPos = 0 + if preIsSupper || bcInterval.IsReElectionNumber(curNumber-1) || bcInterval.IsReElectionNumber(curNumber) { + startPos = 0 + } else { + if preIndex, err := findLeaderIndex(preLeader, validators); err != nil { + log.Info(logInfo, "未在验证者列表中未找到preLeader", preLeader.Hex(), "validators", validators) + startPos = 0 + } else { + startPos = preIndex + 1 + } + } + leaderList := make(map[uint32]common.Address) + for i := 0; i < ValidatorNum; i++ { + leaderList[uint32(i)] = validators[(startPos+int(i))%ValidatorNum].Account + } + return leaderList, nil +} + +func findLeaderIndex(preLeader common.Address, validators []mc.TopologyNodeInfo) (int, error) { + for index, v := range validators { + if v.Account == preLeader { + return index, nil + } + } + return 0, ErrValidatorNotFound +} + +func (self *leaderCalculator) dumpAllValidators(logInfo string) { + size := len(self.validators) + log.Debug(logInfo, "dump info", "验证者列表", "总数", size, "高度", self.number, "parentHash", self.preHash.TerminalString(), "parentLeader", self.preLeader.Hex()) + for i := 0; i < size; i++ { + item := self.validators[i] + log.Debug(logInfo, "dump info", "验证者列表", "index", i, "node", item.Account.Hex(), "pos", item.Position) + } +} diff --git a/leaderelect2.0/leaderReElection.go b/leaderelect2.0/leaderReElection.go new file mode 100644 index 00000000..f9c233d4 --- /dev/null +++ b/leaderelect2.0/leaderReElection.go @@ -0,0 +1,274 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php +package leaderelect2 + +import ( + "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/core/matrixstate" + "github.com/MatrixAINetwork/go-matrix/event" + "github.com/MatrixAINetwork/go-matrix/log" + "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/MatrixAINetwork/go-matrix/params/manparams" + "github.com/pkg/errors" +) + +type LeaderIdentity struct { + ctrlManager *ControllerManager + matrix Matrix + extraInfo string + newBlockReadyCh chan *mc.NewBlockReadyMsg + newBlockReadySub event.Subscription + roleUpdateCh chan *mc.RoleUpdatedMsg + roleUpdateSub event.Subscription + blkPOSNotifyCh chan *mc.BlockPOSFinishedNotify + blkPOSNotifySub event.Subscription + rlInquiryReqCh chan *mc.HD_V2_ReelectInquiryReqMsg + rlInquiryReqSub event.Subscription + rlInquiryRspCh chan *mc.HD_V2_ReelectInquiryRspMsg + rlInquiryRspSub event.Subscription + rlReqCh chan *mc.HD_V2_ReelectLeaderReqMsg + rlReqSub event.Subscription + rlVoteCh chan *mc.HD_V2_ConsensusVote + rlVoteSub event.Subscription + rlBroadcastCh chan *mc.HD_V2_ReelectBroadcastMsg + rlBroadcastSub event.Subscription + rlBroadcastRspCh chan *mc.HD_V2_ReelectBroadcastRspMsg + rlBroadcastRspSub event.Subscription +} + +func NewLeaderIdentityService(matrix Matrix, extraInfo string) (*LeaderIdentity, error) { + var server = &LeaderIdentity{ + ctrlManager: NewControllerManager(matrix, extraInfo), + matrix: matrix, + extraInfo: extraInfo, + newBlockReadyCh: make(chan *mc.NewBlockReadyMsg, 1), + roleUpdateCh: make(chan *mc.RoleUpdatedMsg, 1), + blkPOSNotifyCh: make(chan *mc.BlockPOSFinishedNotify, 1), + rlInquiryReqCh: make(chan *mc.HD_V2_ReelectInquiryReqMsg, 1), + rlInquiryRspCh: make(chan *mc.HD_V2_ReelectInquiryRspMsg, 1), + rlReqCh: make(chan *mc.HD_V2_ReelectLeaderReqMsg, 1), + rlVoteCh: make(chan *mc.HD_V2_ConsensusVote, 1), + rlBroadcastCh: make(chan *mc.HD_V2_ReelectBroadcastMsg, 1), + rlBroadcastRspCh: make(chan *mc.HD_V2_ReelectBroadcastRspMsg, 1), + } + + if err := server.subEvents(); err != nil { + log.ERROR(server.extraInfo, "服务创建失败", err) + return nil, err + } + + go server.run() + + log.INFO(server.extraInfo, "服务创建", "成功") + return server, nil +} + +func (self *LeaderIdentity) subEvents() error { + //订阅身份变更消息 + var err error + if self.newBlockReadySub, err = mc.SubscribeEvent(mc.BlockGenor_NewBlockReady, self.newBlockReadyCh); err != nil { + return errors.Errorf("订阅事件错误(%v)", err) + } + if self.roleUpdateSub, err = mc.SubscribeEvent(mc.CA_RoleUpdated, self.roleUpdateCh); err != nil { + return errors.Errorf("订阅事件错误(%v)", err) + } + if self.blkPOSNotifySub, err = mc.SubscribeEvent(mc.BlkVerify_POSFinishedNotify, self.blkPOSNotifyCh); err != nil { + return errors.Errorf("订阅事件错误(%v)", err) + } + if self.rlInquiryReqSub, err = mc.SubscribeEvent(mc.HD_V2_LeaderReelectInquiryReq, self.rlInquiryReqCh); err != nil { + return errors.Errorf("订阅<重选询问请求V2>事件错误(%v)", err) + } + if self.rlInquiryRspSub, err = mc.SubscribeEvent(mc.HD_V2_LeaderReelectInquiryRsp, self.rlInquiryRspCh); err != nil { + return errors.Errorf("订阅<重选询问响应V2>事件错误(%v)", err) + } + if self.rlReqSub, err = mc.SubscribeEvent(mc.HD_V2_LeaderReelectReq, self.rlReqCh); err != nil { + return errors.Errorf("订阅事件错误(%v)", err) + } + if self.rlVoteSub, err = mc.SubscribeEvent(mc.HD_V2_LeaderReelectVote, self.rlVoteCh); err != nil { + return errors.Errorf("订阅事件错误(%v)", err) + } + if self.rlBroadcastSub, err = mc.SubscribeEvent(mc.HD_V2_LeaderReelectBroadcast, self.rlBroadcastCh); err != nil { + return errors.Errorf("订阅<重选广播V2>事件错误(%v)", err) + } + if self.rlBroadcastRspSub, err = mc.SubscribeEvent(mc.HD_V2_LeaderReelectBroadcastRsp, self.rlBroadcastRspCh); err != nil { + return errors.Errorf("订阅<重选广播响应V2>事件错误(%v)", err) + } + return nil +} + +func (self *LeaderIdentity) run() { + defer func() { + self.rlBroadcastRspSub.Unsubscribe() + self.rlBroadcastSub.Unsubscribe() + self.rlVoteSub.Unsubscribe() + self.rlReqSub.Unsubscribe() + self.rlInquiryRspSub.Unsubscribe() + self.rlInquiryReqSub.Unsubscribe() + self.blkPOSNotifySub.Unsubscribe() + self.roleUpdateSub.Unsubscribe() + self.newBlockReadySub.Unsubscribe() + }() + + for { + select { + case msg := <-self.newBlockReadyCh: + go self.newBlockReadyBCHandle(msg) + case msg := <-self.roleUpdateCh: + go self.roleUpdateMsgHandle(msg) + case msg := <-self.blkPOSNotifyCh: + go self.blockPOSFinishedMsgHandle(msg) + case msg := <-self.rlInquiryReqCh: + go self.rlInquiryReqHandle(msg) + case msg := <-self.rlInquiryRspCh: + go self.rlInquiryRspHandle(msg) + case msg := <-self.rlReqCh: + go self.rlReqMsgHandle(msg) + case msg := <-self.rlVoteCh: + go self.rlVoteMsgHandle(msg) + case msg := <-self.rlBroadcastCh: + go self.rlBroadcastHandle(msg) + case msg := <-self.rlBroadcastRspCh: + go self.rlBroadcastRspHandle(msg) + } + } +} + +func (self *LeaderIdentity) newBlockReadyBCHandle(msg *mc.NewBlockReadyMsg) { + if msg == nil || msg.Header == nil { + log.ERROR(self.extraInfo, "NewBlockReady处理错误", ErrParamsIsNil) + return + } + + curNumber := msg.Header.Number.Uint64() + log.Debug(self.extraInfo, "NewBlockReady消息处理", "开始", "高度", curNumber) + + // 获取超级区块序号 + supBlkState, err := matrixstate.GetSuperBlockCfg(msg.State) + if err != nil { + log.ERROR(self.extraInfo, "NewBlockReady消息处理", "获取超级区块序号失败", "err", err, "高度", curNumber) + return + } + + startMsg := &startControllerMsg{ + parentHeader: msg.Header, + parentStateDB: msg.State, + } + self.ctrlManager.StartController(curNumber+1, supBlkState.Seq, startMsg) +} + +func (self *LeaderIdentity) roleUpdateMsgHandle(msg *mc.RoleUpdatedMsg) { + if msg == nil { + log.ERROR(self.extraInfo, "CA身份通知消息处理", ErrParamsIsNil) + return + } + if (msg.Leader == common.Address{}) { + log.ERROR(self.extraInfo, "CA身份通知消息处理", ErrMsgAccountIsNull) + return + } + + log.Debug(self.extraInfo, "CA身份通知消息处理", "开始", "高度", msg.BlockNum, "身份", msg.Role, "block hash", msg.BlockHash.TerminalString()) + header := self.matrix.BlockChain().GetHeaderByHash(msg.BlockHash) + if nil == header { + log.ERROR(self.extraInfo, "CA身份通知消息处理", "获取区块header失败", "block hash", msg.BlockHash.TerminalString()) + return + } + + //获取状态树 + parentState, err := self.matrix.BlockChain().StateAt(header.Roots) + if err != nil { + log.ERROR(self.extraInfo, "CA身份通知消息处理", "获取区块状态树失败", "err", err, "高度", msg.BlockNum) + return + } + + startMsg := &startControllerMsg{ + parentHeader: header, + parentStateDB: parentState, + } + self.ctrlManager.StartController(msg.BlockNum+1, msg.SuperSeq, startMsg) +} + +func (self *LeaderIdentity) blockPOSFinishedMsgHandle(msg *mc.BlockPOSFinishedNotify) { + if msg == nil { + log.Error(self.extraInfo, "区块POS完成消息处理", "错误", "消息不合法", ErrParamsIsNil) + return + } + if (msg.Header.Leader == common.Address{}) { + log.Error(self.extraInfo, "区块POS完成消息处理", "错误", "消息不合法", ErrMsgAccountIsNull) + return + } + + if manparams.VersionCmp(string(msg.Header.Version), manparams.VersionGamma) < 0 { + log.Trace(self.extraInfo, "区块POS完成消息处理", "版本号不匹配, 不处理消息", "header version", string(msg.Header.Version), "number", msg.Header.Number) + return + } + + log.Debug(self.extraInfo, "区块POS完成消息处理", "开始", "高度", msg.Number) + err := self.ctrlManager.ReceiveMsg(msg.Number, msg) + if err != nil { + log.Error(self.extraInfo, "区块POS完成消息处理", "controller接受消息失败", "err", err) + } +} + +func (self *LeaderIdentity) rlInquiryReqHandle(req *mc.HD_V2_ReelectInquiryReqMsg) { + if req == nil { + log.Info(self.extraInfo, "重选询问消息", "错误", "消息不合法", ErrParamsIsNil) + return + } + self.ctrlManager.ReceiveMsgByCur(req) +} + +func (self *LeaderIdentity) rlInquiryRspHandle(rsp *mc.HD_V2_ReelectInquiryRspMsg) { + if rsp == nil { + log.Info(self.extraInfo, "重选询问响应消息", "错误", "消息不合法", ErrParamsIsNil) + return + } + err := self.ctrlManager.ReceiveMsg(rsp.Number, rsp) + if err != nil { + log.Info(self.extraInfo, "重选询问响应消息", "controller接受消息失败", "err", err) + } +} + +func (self *LeaderIdentity) rlReqMsgHandle(req *mc.HD_V2_ReelectLeaderReqMsg) { + if req == nil { + log.Info(self.extraInfo, "leader重选请求消息", "错误", "消息不合法", ErrParamsIsNil) + return + } + err := self.ctrlManager.ReceiveMsg(req.InquiryReq.Number, req) + if err != nil { + log.Info(self.extraInfo, "leader重选请求消息", "controller接受消息失败", "err", err) + } +} + +func (self *LeaderIdentity) rlVoteMsgHandle(req *mc.HD_V2_ConsensusVote) { + if req == nil { + log.Info(self.extraInfo, "leader重选投票消息", "错误", "消息不合法", ErrParamsIsNil) + return + } + err := self.ctrlManager.ReceiveMsg(req.Number, req) + if err != nil { + log.Info(self.extraInfo, "leader重选投票消息", "controller接受消息失败", "err", err) + } +} + +func (self *LeaderIdentity) rlBroadcastHandle(msg *mc.HD_V2_ReelectBroadcastMsg) { + if msg == nil { + log.Info(self.extraInfo, "重选广播消息", "错误", "消息不合法", ErrParamsIsNil) + return + } + err := self.ctrlManager.ReceiveMsg(msg.Number, msg) + if err != nil { + log.Info(self.extraInfo, "重选广播消息", "controller接受消息失败", "err", err) + } +} + +func (self *LeaderIdentity) rlBroadcastRspHandle(rsp *mc.HD_V2_ReelectBroadcastRspMsg) { + if rsp == nil { + log.Info(self.extraInfo, "重选广播响应消息", "错误", "消息不合法", ErrParamsIsNil) + return + } + err := self.ctrlManager.ReceiveMsg(rsp.Number, rsp) + if err != nil { + log.Info(self.extraInfo, "重选广播响应消息", "controller接受消息失败", "err", err) + } +} diff --git a/leaderelect2.0/leaderReElection_test.go b/leaderelect2.0/leaderReElection_test.go new file mode 100644 index 00000000..ddaecb62 --- /dev/null +++ b/leaderelect2.0/leaderReElection_test.go @@ -0,0 +1,113 @@ +package leaderelect2 + +import ( + "encoding/json" + "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/core/matrixstate" + "github.com/MatrixAINetwork/go-matrix/mc" +) + +func getTestValidatorGraph() *mc.TopologyGraph { + return &mc.TopologyGraph{ + CurNodeNumber: 0, + NodeList: []mc.TopologyNodeInfo{ + { + Account: common.HexToAddress("0x0EAd6cDB8D214389909a535d4Ccc21A393dDdBA9"), + Position: 0, + Type: common.RoleValidator, + NodeNumber: 0, + }, + { + Account: common.HexToAddress("0x6a3217d128A76e4777403E092bde8362d4117773"), + Position: 1, + Type: common.RoleValidator, + NodeNumber: 1, + }, + { + Account: common.HexToAddress("0xf9E18AcC86179925353713a4A5D0E9BF381fBc17"), + Position: 2, + Type: common.RoleValidator, + NodeNumber: 2, + }, + { + Account: common.HexToAddress("0xa121E6670439ba37E7244d4EB18E42bd6724Ef0F"), + Position: 3, + Type: common.RoleValidator, + NodeNumber: 3, + }, + }, + } +} + +func getSpecialAccounts() *mc.MatrixSpecialAccounts { + return &mc.MatrixSpecialAccounts{ + BroadcastAccount: mc.NodeInfo{Address: common.HexToAddress("0x4444444444444444444444444444444444444444")}, + InnerMinerAccounts: nil, + FoundationAccount: common.HexToAddress("0x4444444444444444444444444444444444444444"), + VersionSuperAccounts: nil, + BlockSuperAccounts: nil, + } +} + +func getLeaderConfig() *mc.LeaderConfig { + return &mc.LeaderConfig{ + ParentMiningTime: 20, + PosOutTime: 20, + ReelectOutTime: 40, + ReelectHandleInterval: 3, + } +} + +func getbcInterval() *mc.BCIntervalInfo { + return &mc.BCIntervalInfo{ + LastBCNumber: 0, + LastReelectNumber: 0, + BCInterval: 100, + BackupEnableNumber: 0, + BackupBCInterval: 0, + } +} + +type testState struct { + graphData []byte + accountsData []byte + leaderConfigData []byte + bcIntervalData []byte +} + +func newTestState() *testState { + ts := &testState{} + ts.graphData, _ = json.Marshal(getTestValidatorGraph()) + ts.accountsData, _ = json.Marshal(getSpecialAccounts()) + ts.leaderConfigData, _ = json.Marshal(getLeaderConfig()) + ts.bcIntervalData, _ = json.Marshal(getbcInterval()) + return ts +} + +func (self *testState) GetMatrixData(hash common.Hash) (val []byte) { + if hash == matrixstate.GetKeyHash(mc.MSKeyTopologyGraph) { + return self.graphData + } + if hash == matrixstate.GetKeyHash(mc.MSKeyMatrixAccount) { + return self.accountsData + } + if hash == matrixstate.GetKeyHash(mc.MSKeyLeaderConfig) { + return self.leaderConfigData + } + if hash == matrixstate.GetKeyHash(mc.MSKeyBroadcastInterval) { + return self.bcIntervalData + } + return nil +} + +func (self *testState) SetMatrixData(hash common.Hash, val []byte) { + return +} + +func (self *testState) GetAuthFrom(entrustFrom common.Address, height uint64) common.Address { + return common.Address{} +} + +func (self *testState) GetEntrustFrom(authFrom common.Address, height uint64) []common.Address { + return nil +} diff --git a/leaderelect2.0/masterCache.go b/leaderelect2.0/masterCache.go new file mode 100644 index 00000000..67176d25 --- /dev/null +++ b/leaderelect2.0/masterCache.go @@ -0,0 +1,282 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php +package leaderelect2 + +import ( + "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/core/types" + + "time" + + "github.com/MatrixAINetwork/go-matrix/accounts/signhelper" + "github.com/MatrixAINetwork/go-matrix/log" + "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/pkg/errors" +) + +type posPool struct { + reqHash common.Hash + reqMsg interface{} + voteCache map[common.Address]*common.VerifiedSign +} + +func newPosPool() *posPool { + return &posPool{ + reqHash: common.Hash{}, + reqMsg: nil, + voteCache: make(map[common.Address]*common.VerifiedSign), + } +} + +func (pp *posPool) clear() { + pp.reqHash = common.Hash{} + pp.reqMsg = nil + pp.voteCache = make(map[common.Address]*common.VerifiedSign) +} + +func (pp *posPool) saveReqMsg(reqMsg interface{}) { + pp.reqMsg = reqMsg +} + +func (pp *posPool) saveReqMsgAndHash(reqMsg interface{}) common.Hash { + pp.reqMsg = reqMsg + pp.reqHash = types.RlpHash(reqMsg) + pp.voteCache = make(map[common.Address]*common.VerifiedSign) + return pp.reqHash +} + +func (pp *posPool) getReqMsg() interface{} { + return pp.reqMsg +} + +func (pp *posPool) saveVoteMsg(reqHash common.Hash, sign common.Signature, from common.Address, cdc *cdc, signHelper *signhelper.SignHelper) error { + if (pp.reqHash == common.Hash{} || pp.reqMsg == nil) { + return ErrSelfReqIsNil + } + if cdc == nil || cdc.leaderCal == nil || signHelper == nil { + return ErrCDCOrSignHelperisNil + } + + if reqHash != pp.reqHash { + return errors.Errorf("reqHash不匹配, reqHash(%s)!=localHash(%s)", reqHash.TerminalString(), pp.reqHash.TerminalString()) + } + if _, exist := pp.voteCache[from]; exist { + return errors.Errorf("响应已存在, from[%v]", from) + } + depositAccount, signAccount, validate, err := signHelper.VerifySignWithValidateByReader(cdc, reqHash.Bytes(), sign.Bytes(), cdc.leaderCal.preHash) + if err != nil { + return errors.Errorf("签名解析错误(%v)", err) + } + if signAccount != from { + return errors.Errorf("签名账户(%s)与发送账户(%s)不匹配", signAccount.Hex(), from.Hex()) + } + if !validate { + return errors.New("签名为不同意签名") + } + pp.voteCache[signAccount] = &common.VerifiedSign{Sign: sign, Account: depositAccount, Validate: validate, Stock: 0} + return nil +} + +func (pp *posPool) getVotes() []*common.VerifiedSign { + signs := make([]*common.VerifiedSign, 0) + for _, v := range pp.voteCache { + sign := v + signs = append(signs, sign) + } + return signs +} + +type masterCache struct { + number uint64 + selfAddr common.Address + selfNodeAddr common.Address + lastSignalInquiryTime int64 + inquiryResult mc.ReelectRSPType + inquiryPool *posPool + rlReqPool *posPool + broadcastPool *posPool +} + +func newMasterCache(number uint64) *masterCache { + return &masterCache{ + number: number, + selfAddr: common.Address{}, + selfNodeAddr: common.Address{}, + lastSignalInquiryTime: 0, + inquiryResult: mc.ReelectRSPTypeNone, + inquiryPool: newPosPool(), + rlReqPool: newPosPool(), + broadcastPool: newPosPool(), + } +} + +func (self *masterCache) ClearSelfInquiryMsg() { + self.lastSignalInquiryTime = 0 + self.inquiryResult = mc.ReelectRSPTypeNone + self.inquiryPool.clear() + self.rlReqPool.clear() + self.broadcastPool.clear() +} + +func (self *masterCache) CanSendSingleInquiryReq(time int64, interval int64) bool { + if time-self.lastSignalInquiryTime <= interval { + return false + } + return true +} + +func (self *masterCache) SetLastSingleInquiryReqTime(time int64) { + self.lastSignalInquiryTime = time +} + +func (self *masterCache) GetInquiryResult() mc.ReelectRSPType { + return self.inquiryResult +} + +func (self *masterCache) SaveInquiryReq(req *mc.HD_V2_ReelectInquiryReqMsg) common.Hash { + if nil == req { + log.Debug("leader masterCache", "SaveInquiryReq()", "param is nil") + return common.Hash{} + } + + self.ClearSelfInquiryMsg() + self.inquiryResult = mc.ReelectRSPTypeNone + return self.inquiryPool.saveReqMsgAndHash(req) +} + +func (self *masterCache) IsMatchedInquiryRsp(rsp *mc.HD_V2_ReelectInquiryRspMsg) error { + if nil == rsp { + return ErrParamsIsNil + } + if (self.inquiryPool.reqHash == common.Hash{}) { + return ErrSelfReqIsNil + } + if rsp.ReqHash != self.inquiryPool.reqHash { + return errors.Errorf("reqHash不匹配, reqHash(%s)!=localHash(%s)", rsp.ReqHash.TerminalString(), self.inquiryPool.reqHash.TerminalString()) + } + return nil +} + +func (self *masterCache) SaveInquiryVote(reqHash common.Hash, sign common.Signature, from common.Address, cdc *cdc, signHelper *signhelper.SignHelper) error { + return self.inquiryPool.saveVoteMsg(reqHash, sign, from, cdc, signHelper) +} + +func (self *masterCache) GetInquiryVotes() []*common.VerifiedSign { + return self.inquiryPool.getVotes() +} + +func (self *masterCache) GenRLReqMsg(inquiryAgreeVotes []common.Signature) error { + if self.inquiryResult != mc.ReelectRSPTypeNone { + return errors.Errorf("已存在询问结果(%v),无法生存重选请求", self.inquiryResult) + } + self.inquiryResult = mc.ReelectRSPTypeAgree + + inquiryMsg, OK := self.inquiryPool.getReqMsg().(*mc.HD_V2_ReelectInquiryReqMsg) + if OK == false || inquiryMsg == nil { + return errors.New("获取询问消息失败") + } + + reqMsg := &mc.HD_V2_ReelectLeaderReqMsg{ + InquiryReq: inquiryMsg, + AgreeSigns: inquiryAgreeVotes, + TimeStamp: 0, + } + self.rlReqPool.saveReqMsg(reqMsg) + self.inquiryPool.clear() + return nil +} + +func (self *masterCache) GenBroadcastMsgWithInquiryResult(result mc.ReelectRSPType, rsp *mc.HD_V2_ReelectInquiryRspMsg) error { + if result != mc.ReelectRSPTypePOS && result != mc.ReelectRSPTypeAlreadyRL { + return errors.Errorf("设置目标结果类型错误! target result = %v", result) + } + if self.inquiryResult != mc.ReelectRSPTypeNone { + return errors.Errorf("已存在询问结果(%v)", self.inquiryResult) + } + self.inquiryResult = result + self.inquiryPool.clear() + + broadcastMsg := &mc.HD_V2_ReelectBroadcastMsg{ + Number: self.number, + Type: result, + POSResult: rsp.POSResult, + RLResult: rsp.RLResult, + From: self.selfNodeAddr, + } + self.broadcastPool.saveReqMsg(broadcastMsg) + return nil +} + +func (self *masterCache) GenBroadcastMsgWithRLSuccess(rlAgreeVotes []common.Signature) error { + if self.inquiryResult != mc.ReelectRSPTypeAgree { + return errors.Errorf("当前询问结果(%v) != ReelectRSPTypeAgree", self.inquiryResult) + } + + rlReq, OK := self.rlReqPool.getReqMsg().(*mc.HD_V2_ReelectLeaderReqMsg) + if OK == false || rlReq == nil { + return errors.New("缓存中获取重选leader请求消息失败!") + } + + self.inquiryResult = mc.ReelectRSPTypeAlreadyRL + + rlResult := &mc.HD_V2_ReelectLeaderConsensus{ + Req: rlReq, + Votes: rlAgreeVotes, + } + broadcastMsg := &mc.HD_V2_ReelectBroadcastMsg{ + Number: self.number, + Type: mc.ReelectRSPTypeAgree, + POSResult: nil, + RLResult: rlResult, + From: self.selfNodeAddr, + } + self.broadcastPool.saveReqMsg(broadcastMsg) + self.rlReqPool.clear() + return nil +} + +func (self *masterCache) GetRLReqMsg() (*mc.HD_V2_ReelectLeaderReqMsg, common.Hash, error) { + if self.inquiryResult != mc.ReelectRSPTypeAgree { + return nil, common.Hash{}, errors.Errorf("当前询问结果(%v) != ReelectRSPTypeAgree", self.inquiryResult) + } + + reqMsg, OK := self.rlReqPool.getReqMsg().(*mc.HD_V2_ReelectLeaderReqMsg) + if OK == false || reqMsg == nil { + return nil, common.Hash{}, errors.New("缓存中不存在请求消息") + } + reqMsg.TimeStamp = uint64(time.Now().Unix()) + return reqMsg, self.rlReqPool.saveReqMsgAndHash(reqMsg), nil +} + +func (self *masterCache) SaveRLVote(signHash common.Hash, sign common.Signature, from common.Address, cdc *cdc, signHelper *signhelper.SignHelper) error { + return self.rlReqPool.saveVoteMsg(signHash, sign, from, cdc, signHelper) +} + +func (self *masterCache) GetRLVotes() []*common.VerifiedSign { + return self.rlReqPool.getVotes() +} + +func (self *masterCache) GetBroadcastMsg() (*mc.HD_V2_ReelectBroadcastMsg, common.Hash, error) { + broadcastMsg, OK := self.broadcastPool.getReqMsg().(*mc.HD_V2_ReelectBroadcastMsg) + if OK == false || broadcastMsg == nil { + return nil, common.Hash{}, errors.Errorf("缓存中没有重选结果广播消息") + } + return broadcastMsg, self.broadcastPool.saveReqMsgAndHash(broadcastMsg), nil +} + +func (self *masterCache) GetLocalBroadcastMsg() (*mc.HD_V2_ReelectBroadcastMsg, error) { + broadcastMsg, OK := self.broadcastPool.getReqMsg().(*mc.HD_V2_ReelectBroadcastMsg) + if OK == false || broadcastMsg == nil { + return nil, errors.Errorf("缓存中没有重选结果广播消息") + } + return broadcastMsg, nil +} + +func (self *masterCache) SaveBroadcastVote(broadcastHash common.Hash, sign common.Signature, from common.Address, cdc *cdc, signHelper *signhelper.SignHelper) error { + return self.broadcastPool.saveVoteMsg(broadcastHash, sign, from, cdc, signHelper) +} + +func (self *masterCache) GetBroadcastVotes() []*common.VerifiedSign { + return self.broadcastPool.getVotes() +} diff --git a/leaderelect2.0/msgPool.go b/leaderelect2.0/msgPool.go new file mode 100644 index 00000000..565b0794 --- /dev/null +++ b/leaderelect2.0/msgPool.go @@ -0,0 +1,76 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php +package leaderelect2 + +import ( + "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/core/types" + "github.com/MatrixAINetwork/go-matrix/mc" +) + +type msgPool struct { + parentHeader *types.Header + posNotifyCache []*mc.BlockPOSFinishedNotify + rlConsensusCache map[mc.ConsensusTurnInfo]*mc.HD_V2_ReelectLeaderConsensus +} + +func newMsgPool() *msgPool { + return &msgPool{ + parentHeader: nil, + posNotifyCache: make([]*mc.BlockPOSFinishedNotify, 0), + rlConsensusCache: make(map[mc.ConsensusTurnInfo]*mc.HD_V2_ReelectLeaderConsensus), + } +} + +func (mp *msgPool) SavePOSNotifyMsg(msg *mc.BlockPOSFinishedNotify) error { + if nil == msg || nil == msg.Header || (msg.Header.Leader == common.Address{}) { + return ErrParamsIsNil + } + + //存在检查 + for _, oldMsg := range mp.posNotifyCache { + if oldMsg.ConsensusTurn == msg.ConsensusTurn && oldMsg.Header.Leader == msg.Header.Leader { + return ErrMsgExistInCache + } + } + + mp.posNotifyCache = append(mp.posNotifyCache, msg) + return nil +} + +func (mp *msgPool) GetPOSNotifyMsg(leader common.Address, consensusTurn mc.ConsensusTurnInfo) (*mc.BlockPOSFinishedNotify, error) { + for _, msg := range mp.posNotifyCache { + if msg.ConsensusTurn == consensusTurn && msg.Header.Leader == leader { + return msg, nil + } + } + return nil, ErrNoMsgInCache +} + +func (mp *msgPool) SaveRLConsensusMsg(msg *mc.HD_V2_ReelectLeaderConsensus) { + if nil == msg || nil == msg.Req || nil == msg.Req.InquiryReq || (msg.Req.InquiryReq.Master == common.Address{}) { + return + } + consensusTurn := calcNextConsensusTurn(msg.Req.InquiryReq.ConsensusTurn, msg.Req.InquiryReq.ReelectTurn) + mp.rlConsensusCache[consensusTurn] = msg +} + +func (mp *msgPool) GetRLConsensusMsg(consensusTurn mc.ConsensusTurnInfo) (*mc.HD_V2_ReelectLeaderConsensus, error) { + msg, OK := mp.rlConsensusCache[consensusTurn] + if !OK { + return nil, ErrNoMsgInCache + } + return msg, nil +} + +func (mp *msgPool) SaveParentHeader(header *types.Header) { + if nil == header { + return + } + mp.parentHeader = header +} + +func (mp *msgPool) GetParentHeader() *types.Header { + return mp.parentHeader +} diff --git a/leaderelect2.0/time_test.go b/leaderelect2.0/time_test.go new file mode 100644 index 00000000..a2b258dd --- /dev/null +++ b/leaderelect2.0/time_test.go @@ -0,0 +1,54 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php +package leaderelect2 + +import ( + "github.com/MatrixAINetwork/go-matrix/log" + "math/big" + "sort" + "testing" + "time" +) + +func TestSliceSort(t *testing.T) { + log.InitLog(3) + testSlice := make([]*big.Int, 0) + testSlice = append(testSlice, big.NewInt(10), big.NewInt(-1), big.NewInt(22), big.NewInt(6)) + log.INFO("before sort", "slice", testSlice) + sort.Slice(testSlice, func(i, j int) bool { + return testSlice[i].Cmp(testSlice[j]) > 0 + }) + log.INFO("after sort", "slice", testSlice) +} + +func TestTimer(t *testing.T) { + log.InitLog(3) + recvCh := make(chan struct{}) + go TimerRunning(t, recvCh) + + //time.Sleep(7 * time.Second) + recvCh <- struct{}{} + time.Sleep(11111 * time.Second) +} + +func TimerRunning(t *testing.T, recv chan struct{}) { + timer := time.NewTimer(10 * time.Second) + log.Info("开始定时器") + for { + select { + case <-recv: + log.Info("收到停止消息") + time.Sleep(12 * time.Second) + log.Info("停止定时器") + result := timer.Reset(10 * time.Second) + log.Info("重置定时器", "结果", result) + if result == false { + <-timer.C + } + + case <-timer.C: + log.Info("超时了!!!") + } + } +} diff --git a/leaderelect2.0/turnTimes.go b/leaderelect2.0/turnTimes.go new file mode 100644 index 00000000..7242deba --- /dev/null +++ b/leaderelect2.0/turnTimes.go @@ -0,0 +1,102 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php +package leaderelect2 + +import ( + "time" + + "github.com/MatrixAINetwork/go-matrix/log" + "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/pkg/errors" +) + +type turnTimes struct { + beginTime int64 // 轮次开始时间, 即区块头时间 + parentMiningTime int64 // 预留父区块挖矿时间 + turnOutTime int64 // 轮次超时时间 + reelectHandleInterval int64 // 重选处理间隔时间 +} + +func newTurnTimes() *turnTimes { + tt := &turnTimes{ + beginTime: 0, + parentMiningTime: 0, + turnOutTime: 0, + reelectHandleInterval: 0, + } + + return tt +} + +func (tt *turnTimes) SetTimeConfig(config *mc.LeaderConfig) error { + if config == nil { + return ErrParamsIsNil + } + + tt.parentMiningTime = int64(config.ParentMiningTime) + tt.turnOutTime = int64(config.PosOutTime) + tt.reelectHandleInterval = int64(config.ReelectHandleInterval) + return nil +} + +func (tt *turnTimes) SetBeginTime(time int64) bool { + if time <= tt.beginTime { + return false + } + tt.beginTime = time + return true +} + +func (tt *turnTimes) GetBeginTime(consensusTurn uint32) int64 { + beginTime, _ := tt.CalTurnTime(consensusTurn, 0) + return beginTime +} + +func (tt *turnTimes) GetPosEndTime(consensusTurn uint32) int64 { + _, endTime := tt.CalTurnTime(consensusTurn, 0) + return endTime +} + +func (tt *turnTimes) CalState(consensusTurn uint32, time int64) (st stateDef, remainTime int64, reelectTurn uint32) { + if tt.turnOutTime == 0 { + log.Error("critical", "turnTimes", "turnOutTime == 0") + return stReelect, 0, 0 + } + posTime := tt.turnOutTime + if consensusTurn == 0 { + posTime += tt.parentMiningTime + } + + passTime := time - tt.GetBeginTime(consensusTurn) + if passTime < posTime { + return stPos, posTime - passTime, 0 + } + + st = stReelect + reelectTurn = uint32((passTime-posTime)/tt.turnOutTime) + 1 + _, endTime := tt.CalTurnTime(consensusTurn, reelectTurn) + remainTime = endTime - time + return +} + +func (tt *turnTimes) CalTurnTime(consensusTurn uint32, reelectTurn uint32) (beginTime int64, endTime int64) { + totalTurn := consensusTurn + reelectTurn + if totalTurn == 0 { + beginTime = tt.beginTime + endTime = beginTime + tt.parentMiningTime + tt.turnOutTime + } else { + beginTime = tt.beginTime + tt.parentMiningTime + tt.turnOutTime*int64(totalTurn) + endTime = beginTime + tt.turnOutTime + } + return +} + +func (tt *turnTimes) CheckTimeLegal(consensusTurn uint32, reelectTurn uint32, checkTime int64) error { + beginTime, endTime := tt.CalTurnTime(consensusTurn, reelectTurn) + if checkTime <= beginTime || checkTime >= endTime { + return errors.Errorf("时间(%s)非法,轮次起止时间(%s - %s)", + time.Unix(checkTime, 0).String(), time.Unix(beginTime, 0).String(), time.Unix(endTime, 0).String()) + } + return nil +} diff --git a/leaderelect2.0/turnTimes_test.go b/leaderelect2.0/turnTimes_test.go new file mode 100644 index 00000000..5c1c1b5f --- /dev/null +++ b/leaderelect2.0/turnTimes_test.go @@ -0,0 +1,143 @@ +// Copyright (c) 2018 The MATRIX Authors + +// Distributed under the MIT software license, see the accompanying + +// file COPYING or or http://www.opensource.org/licenses/mit-license.php + +package leaderelect2 + +import ( + "github.com/MatrixAINetwork/go-matrix/mc" + "testing" +) + +func Test_turnTimes_SetBeginTime(t *testing.T) { + type args struct { + consensusTurn uint32 + time int64 + } + tests := []struct { + name string + args []args + want []bool + }{ + { + name: "各种情况下的时间设置", + args: []args{ + { + consensusTurn: 0, + time: 100, + }, + { + consensusTurn: 0, + time: 98, + }, + { + consensusTurn: 1, + time: 98, + }, + { + consensusTurn: 0, + time: 100, + }, + { + consensusTurn: 0, + time: 101, + }, + }, + want: []bool{true, false, true, false, true}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tts := newTurnTimes() + for i, ttarg := range tt.args { + if got := tts.SetBeginTime(ttarg.time); got != tt.want[i] { + t.Errorf("index(%d), turnTimes.SetBeginTime() = %v, want %v", i, got, tt.want[i]) + } + } + }) + } +} + +func Test_turnTimes_GetBeginTime(t *testing.T) { + tt := newTurnTimes() + tt.SetBeginTime(100) + + if got := tt.GetBeginTime(0); got != 100 { + t.Errorf("turnTimes.GetBeginTime() = %v, want %v", got, 100) + } + + if got := tt.GetBeginTime(3); got != 0 { + t.Errorf("turnTimes.GetBeginTime() = %v, want %v", got, 0) + } + + if got := tt.GetBeginTime(5); got != 500 { + t.Errorf("turnTimes.GetBeginTime() = %v, want %v", got, 500) + } +} + +func Test_turnTimes_GetPosEndTime(t *testing.T) { + type fields struct { + beginTimes int64 + parentMiningTime int64 // 预留父区块挖矿时间 + turnOutTime int64 // 轮次超时时间 + } + type args struct { + consensusTurn uint32 + } + tests := []struct { + name string + fields fields + args args + want int64 + }{ + { + name: "无开始时间时,0轮次的POS结束时间", + fields: fields{0, 20, 40}, + args: args{0}, + want: 60, + }, + { + name: "有开始时间时,0轮次的POS结束时间", + fields: fields{0, 20, 40}, + args: args{0}, + want: 360, + }, + { + name: "无开始时间时,2轮次的POS结束时间", + fields: fields{0, 20, 40}, + args: args{2}, + want: 140, + }, + { + name: "有开始时间时,3轮次的POS结束时间", + fields: fields{400, 20, 40}, + args: args{3}, + want: 400 + 180, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tts := &turnTimes{ + beginTime: tt.fields.beginTimes, + } + if got := tts.GetPosEndTime(tt.args.consensusTurn); got != tt.want { + t.Errorf("turnTimes.GetPosEndTime() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_turnTimes_CalState(t *testing.T) { + tts := newTurnTimes() + tts.SetBeginTime(5) + + tts.SetTimeConfig(&mc.LeaderConfig{ + ParentMiningTime: 5, + PosOutTime: 5, + ReelectOutTime: 30, + ReelectHandleInterval: 5, + }) + +} diff --git a/log/syslog.go b/log/syslog.go index 3f1cd426..016d1ddd 100644 --- a/log/syslog.go +++ b/log/syslog.go @@ -19,6 +19,10 @@ func SyslogHandler(priority syslog.Priority, tag string, fmtr Format) (Handler, // SyslogNetHandler opens a connection to a log daemon over the network and writes // all log records to it. +func SetNetLogHandler(net,addr,tag string,fmtr Format)(Handler, error){ + wr, err := syslog.Dial(net, addr, syslog.LOG_INFO, tag) + return sharedSyslog(fmtr, wr, err) +} func SyslogNetHandler(net, addr string, priority syslog.Priority, tag string, fmtr Format) (Handler, error) { wr, err := syslog.Dial(net, addr, priority, tag) return sharedSyslog(fmtr, wr, err) diff --git a/log/syslog_windows.go b/log/syslog_windows.go new file mode 100644 index 00000000..fac14fdd --- /dev/null +++ b/log/syslog_windows.go @@ -0,0 +1,12 @@ +// +build !linux + +package log +import ( + "errors" +) + + +func SetNetLogHandler(net,addr,tag string,fmtr Format)(Handler, error){ + return nil,errors.New("window not support") + +} \ No newline at end of file diff --git a/man/api.go b/man/api.go index 968c4d69..cdc9d918 100644 --- a/man/api.go +++ b/man/api.go @@ -26,13 +26,13 @@ import ( "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/MatrixAINetwork/go-matrix/base58" "github.com/MatrixAINetwork/go-matrix/man/wizard" "github.com/MatrixAINetwork/go-matrix/miner" "github.com/MatrixAINetwork/go-matrix/params" "github.com/MatrixAINetwork/go-matrix/rlp" "github.com/MatrixAINetwork/go-matrix/rpc" "github.com/MatrixAINetwork/go-matrix/trie" - "github.com/MatrixAINetwork/go-matrix/base58" ) // PublicMatrixAPI provides an API to access Matrix full node-related @@ -440,15 +440,15 @@ func NewPublicDebugAPI(man *Matrix) *PublicDebugAPI { } // DumpBlock retrieves the entire state of the database at a given block. -func (api *PublicDebugAPI) DumpBlock(blockNr rpc.BlockNumber,cointyp string, addr string) ([]state.CoinDump, error) { - if cointyp != ""{ +func (api *PublicDebugAPI) DumpBlock(blockNr rpc.BlockNumber, cointyp string, addr string) ([]state.CoinDump, error) { + if cointyp != "" { cointyp = strings.ToUpper(cointyp) } var address common.Address - if addr != ""{ - tmpaddress,err := base58.Base58DecodeToAddress(addr) - if err != nil{ - return nil,err + if addr != "" { + tmpaddress, err := base58.Base58DecodeToAddress(addr) + if err != nil { + return nil, err } address = tmpaddress } diff --git a/man/api_backend.go b/man/api_backend.go index 2f9eebd8..daa719bc 100644 --- a/man/api_backend.go +++ b/man/api_backend.go @@ -250,7 +250,7 @@ func (b *ManAPIBackend) GetPoolTransactions() (types.SelfTransactions, error) { return nil, err } var txs types.SelfTransactions - for _,txsmap := range pending{ + for _, txsmap := range pending { for _, batch := range txsmap { txs = append(txs, batch...) } diff --git a/man/api_backend_test.go b/man/api_backend_test.go index 23d28c94..b19beede 100644 --- a/man/api_backend_test.go +++ b/man/api_backend_test.go @@ -20813,11 +20813,11 @@ func TestManAPIBackend_GetFutureRewards(t *testing.T) { BackupRewardRate: BackupRate, } brc := &mc.BlkRewardCfg{ - MinerMount: 2000, + MinerMount: 2000, MinerAttenuationNum: halfNumber, - ValidatorMount: 2000, + ValidatorMount: 2000, ValidatorAttenuationNum: halfNumber, - RewardRate: rrc, + RewardRate: rrc, } matrixstate.SetBlkRewardCfg(state, brc) matrixstate.SetInterestCalc(state, "1") @@ -20984,11 +20984,11 @@ func TestManAPIBackend_GetFutureRewards2(t *testing.T) { BackupRewardRate: BackupRate, } brc := &mc.BlkRewardCfg{ - MinerMount: 2, + MinerMount: 2, MinerAttenuationNum: halfNumber, - ValidatorMount: 2, + ValidatorMount: 2, ValidatorAttenuationNum: halfNumber, - RewardRate: rrc, + RewardRate: rrc, } matrixstate.SetBlkRewardCfg(state, brc) matrixstate.SetInterestCalc(state, "1") diff --git a/man/api_test.go b/man/api_test.go index fdeecf11..bbcc50e1 100644 --- a/man/api_test.go +++ b/man/api_test.go @@ -8,10 +8,10 @@ import ( "reflect" "testing" - "github.com/davecgh/go-spew/spew" "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/core/state" "github.com/MatrixAINetwork/go-matrix/mandb" + "github.com/davecgh/go-spew/spew" ) var dumper = spew.ConfigState{Indent: " "} diff --git a/man/api_tracer.go b/man/api_tracer.go index 05804fd4..2bc60fd8 100644 --- a/man/api_tracer.go +++ b/man/api_tracer.go @@ -183,8 +183,8 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl // Trace all the transactions contained within var txs []types.SelfTransaction for _, currencie := range task.block.Currencies() { - for _,tx:=range currencie.Transactions.Transactions{ - txs=append(txs,tx) + for _, tx := range currencie.Transactions.Transactions { + txs = append(txs, tx) } } for i, tx := range txs { @@ -261,8 +261,8 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl // Send the block over to the concurrent tracers (if not in the fast-forward phase) var txs []types.SelfTransaction for _, currencie := range block.Currencies() { - for _,tx:=range currencie.Transactions.Transactions{ - txs=append(txs,tx) + for _, tx := range currencie.Transactions.Transactions { + txs = append(txs, tx) } } if number > origin { @@ -275,7 +275,7 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl traced += uint64(len(txs)) } // Generate the next state snapshot fast without tracing - _, _, err := api.man.blockchain.Processor(block.Header().Version).ProcessTxs(block, statedb, vm.Config{}, nil) + _, _, err := api.man.blockchain.Processor(block.Header().Version).ProcessTxs(block, statedb, vm.Config{}, nil) if err != nil { failed = err break @@ -408,8 +408,8 @@ func (api *PrivateDebugAPI) traceBlock(ctx context.Context, block *types.Block, // Execute all the transaction contained within the block concurrently var txs []types.SelfTransaction for _, currencie := range block.Currencies() { - for _,tx:=range currencie.Transactions.Transactions{ - txs=append(txs,tx) + for _, tx := range currencie.Transactions.Transactions { + txs = append(txs, tx) } } var ( @@ -518,7 +518,7 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (* if block = api.man.blockchain.GetBlockByNumber(block.NumberU64() + 1); block == nil { return nil, fmt.Errorf("block #%d not found", block.NumberU64()+1) } - _, _, err := api.man.blockchain.Processor(block.Header().Version).ProcessTxs(block, statedb, vm.Config{}, nil) + _, _, err := api.man.blockchain.Processor(block.Header().Version).ProcessTxs(block, statedb, vm.Config{}, nil) if err != nil { return nil, err } @@ -639,8 +639,8 @@ func (api *PrivateDebugAPI) computeTxEnv(blockHash common.Hash, txIndex int, ree //signer := types.MakeSigner(api.config, block.Number()) var txs []types.SelfTransaction for _, currencie := range block.Currencies() { - for _,tx:=range currencie.Transactions.Transactions{ - txs=append(txs,tx) + for _, tx := range currencie.Transactions.Transactions { + txs = append(txs, tx) } } diff --git a/man/backend.go b/man/backend.go index 4309899f..4881203a 100644 --- a/man/backend.go +++ b/man/backend.go @@ -57,6 +57,7 @@ import ( "time" "github.com/MatrixAINetwork/go-matrix/leaderelect" + "github.com/MatrixAINetwork/go-matrix/leaderelect2.0" "github.com/MatrixAINetwork/go-matrix/lessdisk" "github.com/MatrixAINetwork/go-matrix/olconsensus" "github.com/MatrixAINetwork/go-matrix/p2p/discover" @@ -113,14 +114,15 @@ type Matrix struct { hd *msgsend.HD //node传进来的 signHelper *signhelper.SignHelper - reelection *reelection.ReElection //换届服务 - random *baseinterface.Random - olConsensus *olconsensus.TopNodeService - blockGen *blkgenor.BlockGenor - manBlkManage *blkmanage.ManBlkManage - blockVerify *blkverify.BlockVerify - leaderServer *leaderelect.LeaderIdentity - lessDiskSvr *lessdisk.Server + reelection *reelection.ReElection //换届服务 + random *baseinterface.Random + olConsensus *olconsensus.TopNodeService + blockGen *blkgenor.BlockGenor + manBlkManage *blkmanage.ManBlkManage + blockVerify *blkverify.BlockVerify + leaderServer *leaderelect.LeaderIdentity + leaderServerV2 *leaderelect2.LeaderIdentity + lessDiskSvr *lessdisk.Server lock sync.RWMutex // Protects the variadic fields (e.g. gas price and manbase) } @@ -257,6 +259,10 @@ func New(ctx *pod.ServiceContext, config *Config) (*Matrix, error) { if err != nil { return nil, err } + man.leaderServerV2, err = leaderelect2.NewLeaderIdentityService(man, "leader服务V2") + if err != nil { + return nil, err + } man.manBlkManage, err = blkmanage.New(man) if err != nil { return nil, err @@ -273,7 +279,6 @@ func New(ctx *pod.ServiceContext, config *Config) (*Matrix, error) { man.lessDiskSvr.FuncSwitch(ctx.GetConfig().LessDisk) return man, nil - } func makeExtraData(extra []byte) []byte { @@ -295,7 +300,7 @@ func makeExtraData(extra []byte) []byte { // CreateDB creates the chain database. func CreateDB(ctx *pod.ServiceContext, config *Config, name string) (mandb.Database, error) { - db, err := ctx.OpenDatabase(name, config.DatabaseCache, config.DatabaseHandles) + db, err := ctx.OpenDatabase(name, config.DatabaseCache, config.DatabaseHandles,config.DatabaseTableSize) if err != nil { return nil, err } diff --git a/man/config.go b/man/config.go index fe4d69c7..81fb2640 100644 --- a/man/config.go +++ b/man/config.go @@ -31,12 +31,13 @@ var DefaultConfig = Config{ DatasetsInMem: 1, DatasetsOnDisk: 2, }, - NetworkId: 1, - LightPeers: 100, - DatabaseCache: 768, - TrieCache: 256, - TrieTimeout: 5 * time.Minute, - GasPrice: big.NewInt(18 * params.Shannon), + NetworkId: 1, + LightPeers: 100, + DatabaseCache: 768, + DatabaseTableSize: 2, + TrieCache: 256, + TrieTimeout: 5 * time.Minute, + GasPrice: big.NewInt(18 * params.Shannon), TxPool: core.DefaultTxPoolConfig, GPO: gasprice.Config{ @@ -80,6 +81,7 @@ type Config struct { DatabaseHandles int `toml:"-"` DatabaseCache int TrieCache int + DatabaseTableSize int TrieTimeout time.Duration // Mining-related options diff --git a/man/downloader/api.go b/man/downloader/api.go index cc4bc2aa..88eaf7f5 100644 --- a/man/downloader/api.go +++ b/man/downloader/api.go @@ -28,8 +28,8 @@ type PublicDownloaderAPI struct { // installSyncSubscription channel. func NewPublicDownloaderAPI(d *Downloader, m *event.TypeMux) *PublicDownloaderAPI { api := &PublicDownloaderAPI{ - d: d, - mux: m, + d: d, + mux: m, installSyncSubscription: make(chan chan interface{}), uninstallSyncSubscription: make(chan *uninstallSyncSubscriptionRequest), } diff --git a/man/downloader/fakepeer.go b/man/downloader/fakepeer.go index 13b5e4a4..63cce88d 100644 --- a/man/downloader/fakepeer.go +++ b/man/downloader/fakepeer.go @@ -31,9 +31,9 @@ func NewFakePeer(id string, db mandb.Database, hc *core.HeaderChain, dl *Downloa // Head implements downloader.Peer, returning the current head hash and number // of the best known header. -func (p *FakePeer) Head() (common.Hash, *big.Int, uint64, uint64) { +func (p *FakePeer) Head() (common.Hash, *big.Int, uint64, uint64, uint64, uint64) { header := p.hc.CurrentHeader() - return header.Hash(), header.Number, header.SuperBlockSeq(), 0 + return header.Hash(), header.Number, header.SuperBlockSeq(), 0, 0, 0 } // RequestHeadersByHash implements downloader.Peer, returning a batch of headers @@ -116,7 +116,7 @@ func (p *FakePeer) RequestBodies(hashes []common.Hash) error { ) for _, hash := range hashes { block := rawdb.ReadBlock(p.db, hash, *p.hc.GetBlockNumber(hash)) - txs = append(txs,block.Currencies()) + txs = append(txs, block.Currencies()) uncles = append(uncles, block.Uncles()) } p.dl.DeliverBodies(p.id, txs, uncles) diff --git a/man/downloader/peer.go b/man/downloader/peer.go index 5acabaaf..0bf4dd54 100644 --- a/man/downloader/peer.go +++ b/man/downloader/peer.go @@ -65,7 +65,7 @@ type peerConnection struct { // LightPeer encapsulates the methods required to synchronise with a remote light peer. type LightPeer interface { - Head() (common.Hash, *big.Int, uint64, uint64) + Head() (hash common.Hash, td *big.Int, sbs uint64, sbHash uint64, bt uint64, bn uint64) RequestHeadersByHash(common.Hash, int, int, bool) error RequestHeadersByNumber(uint64, int, int, bool) error } @@ -83,7 +83,9 @@ type lightPeerWrapper struct { peer LightPeer } -func (w *lightPeerWrapper) Head() (common.Hash, *big.Int, uint64, uint64) { return w.peer.Head() } +func (w *lightPeerWrapper) Head() (hash common.Hash, td *big.Int, sbs uint64, sbHash uint64, bt uint64, bn uint64) { + return w.peer.Head() +} func (w *lightPeerWrapper) RequestHeadersByHash(h common.Hash, amount int, skip int, reverse bool) error { return w.peer.RequestHeadersByHash(h, amount, skip, reverse) } diff --git a/man/filters/filter.go b/man/filters/filter.go index d12944da..82d5b91b 100644 --- a/man/filters/filter.go +++ b/man/filters/filter.go @@ -175,14 +175,14 @@ func (f *Filter) unindexedLogs(ctx context.Context, end uint64) ([]types.CoinLog if header == nil || err != nil { return logs, err } - for _,cr:=range header.Roots{ - if bloomFilter(cr.Bloom, f.addresses, f.topics) { - found, err := f.checkMatches(ctx, header) - if err != nil { - return logs, err + for _, cr := range header.Roots { + if bloomFilter(cr.Bloom, f.addresses, f.topics) { + found, err := f.checkMatches(ctx, header) + if err != nil { + return logs, err + } + logs = append(logs, found...) } - logs = append(logs, found...) - } } } @@ -202,26 +202,26 @@ func (f *Filter) checkMatches(ctx context.Context, header *types.Header) (logs [ unfiltered = append(unfiltered, logs) } logs = filterLogs(unfiltered, nil, nil, f.addresses, f.topics) - for _,ls:= range logs{ - if len(ls.Logs) > 0 { - // We have matching logs, check if we need to resolve full logs via the light client - if ls.Logs[0].TxHash == (common.Hash{}) { - receipts, err := f.backend.GetReceipts(ctx, header.Hash()) - if err != nil { - return nil, err - } - unfiltered = unfiltered[:0] - for _, receipt := range receipts { - if receipt.CoinType==ls.CoinType { - for _,r:=range receipt.Receiptlist{ - unfiltered = append(unfiltered,types.CoinLogs{ls.CoinType, r.Logs}) + for _, ls := range logs { + if len(ls.Logs) > 0 { + // We have matching logs, check if we need to resolve full logs via the light client + if ls.Logs[0].TxHash == (common.Hash{}) { + receipts, err := f.backend.GetReceipts(ctx, header.Hash()) + if err != nil { + return nil, err + } + unfiltered = unfiltered[:0] + for _, receipt := range receipts { + if receipt.CoinType == ls.CoinType { + for _, r := range receipt.Receiptlist { + unfiltered = append(unfiltered, types.CoinLogs{ls.CoinType, r.Logs}) + } } } } - } + } } -} logs = filterLogs(unfiltered, nil, nil, f.addresses, f.topics) return logs, nil } @@ -240,40 +240,40 @@ func includes(addresses []common.Address, a common.Address) bool { func filterLogs(logs []types.CoinLogs, fromBlock, toBlock *big.Int, addresses []common.Address, topics [][]common.Hash) (ret []types.CoinLogs) { for _, l := range logs { var r []*types.Log -Logs: - for _, log := range l.Logs { - if fromBlock != nil && fromBlock.Int64() >= 0 && fromBlock.Uint64() > log.BlockNumber { - continue + Logs: + for _, log := range l.Logs { + if fromBlock != nil && fromBlock.Int64() >= 0 && fromBlock.Uint64() > log.BlockNumber { + continue - } - if toBlock != nil && toBlock.Int64() >= 0 && toBlock.Uint64() < log.BlockNumber { - continue - } + } + if toBlock != nil && toBlock.Int64() >= 0 && toBlock.Uint64() < log.BlockNumber { + continue + } - if len(addresses) > 0 && !includes(addresses, log.Address) { - continue - } - // If the to filtered topics is greater than the amount of topics in logs, skip. - if len(topics) > len(log.Topics) { - continue Logs - } - for i, topics := range topics { - match := len(topics) == 0 // empty rule set == wildcard - for _, topic := range topics { - if log.Topics[i] == topic { - match = true - break - } + if len(addresses) > 0 && !includes(addresses, log.Address) { + continue } - if !match { + // If the to filtered topics is greater than the amount of topics in logs, skip. + if len(topics) > len(log.Topics) { continue Logs } - } - r=append(r,log) + for i, topics := range topics { + match := len(topics) == 0 // empty rule set == wildcard + for _, topic := range topics { + if log.Topics[i] == topic { + match = true + break + } + } + if !match { + continue Logs + } + } + r = append(r, log) + } + ret = append(ret, types.CoinLogs{l.CoinType, r}) } - ret = append(ret, types.CoinLogs{l.CoinType,r}) -} return } diff --git a/man/filters/filter_system.go b/man/filters/filter_system.go index 5cc5c562..b72d7466 100644 --- a/man/filters/filter_system.go +++ b/man/filters/filter_system.go @@ -93,7 +93,7 @@ type EventSystem struct { install chan *subscription // install filter for event notification uninstall chan *subscription // remove filter for event notification txsCh chan core.NewTxsEvent // Channel to receive new transactions event - logsCh chan []types.CoinLogs // Channel to receive new log event + logsCh chan []types.CoinLogs // Channel to receive new log event rmLogsCh chan core.RemovedLogsEvent // Channel to receive removed log event chainCh chan core.ChainEvent // Channel to receive new chain event } @@ -396,50 +396,50 @@ func (es *EventSystem) lightFilterNewHead(newHeader *types.Header, callBack func // filter logs of a single header in light client mode func (es *EventSystem) lightFilterLogs(header *types.Header, addresses []common.Address, topics [][]common.Hash, remove bool) []types.CoinLogs { var ls []types.CoinLogs -for _,cr:= range header.Roots{ - if bloomFilter(cr.Bloom, addresses, topics) { - // Get the logs of the block - ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - defer cancel() - logsList, err := es.backend.GetLogs(ctx, header.Hash()) - if err != nil { - return nil - } - var unfiltered []types.CoinLogs - for _, logs := range logsList { - //for _, log := range logs.Logs { + for _, cr := range header.Roots { + if bloomFilter(cr.Bloom, addresses, topics) { + // Get the logs of the block + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + defer cancel() + logsList, err := es.backend.GetLogs(ctx, header.Hash()) + if err != nil { + return nil + } + var unfiltered []types.CoinLogs + for _, logs := range logsList { + //for _, log := range logs.Logs { //logcopy := *log //logcopy.Removed = remove - logcopy:=logs - logcopy.CoinType=logs.CoinType + logcopy := logs + logcopy.CoinType = logs.CoinType unfiltered = append(unfiltered, logcopy) - //} - } - logs := filterLogs(unfiltered, nil, nil, addresses, topics) - for _,l:=range logs{ - if len(l.Logs) > 0 && l.Logs[0].TxHash == (common.Hash{}) { - // We have matching but non-derived logs - receipts, err := es.backend.GetReceipts(ctx, header.Hash()) - if err != nil { - return nil + //} } - unfiltered = unfiltered[:0] - for _, receipt := range receipts { - //receipt.CoinType - for _, log := range receipt.Receiptlist { - logcopy:=types.CoinLogs{receipt.CoinType,log.Logs} - //logcopy := *log - //logcopy.Removed = remove - unfiltered = append(unfiltered, logcopy) + logs := filterLogs(unfiltered, nil, nil, addresses, topics) + for _, l := range logs { + if len(l.Logs) > 0 && l.Logs[0].TxHash == (common.Hash{}) { + // We have matching but non-derived logs + receipts, err := es.backend.GetReceipts(ctx, header.Hash()) + if err != nil { + return nil + } + unfiltered = unfiltered[:0] + for _, receipt := range receipts { + //receipt.CoinType + for _, log := range receipt.Receiptlist { + logcopy := types.CoinLogs{receipt.CoinType, log.Logs} + //logcopy := *log + //logcopy.Removed = remove + unfiltered = append(unfiltered, logcopy) + } + } + logs = filterLogs(unfiltered, nil, nil, addresses, topics) } - } - logs = filterLogs(unfiltered, nil, nil, addresses, topics) - } + } + ls = append(ls, logs...) } - ls=append(ls,logs...) } -} return ls } diff --git a/man/gasprice/gasprice.go b/man/gasprice/gasprice.go index 1d2961e2..7704ba8a 100644 --- a/man/gasprice/gasprice.go +++ b/man/gasprice/gasprice.go @@ -156,7 +156,7 @@ func (gpo *Oracle) getBlockPrices(ctx context.Context, signer types.Signer, bloc } //blockTxs := block.Transactions() - for _,curr := range block.Currencies(){ + for _, curr := range block.Currencies() { txs := make([]types.SelfTransaction, len(curr.Transactions.GetTransactions())) copy(txs, curr.Transactions.GetTransactions()) sort.Sort(transactionsByGasPrice(txs)) diff --git a/man/handler.go b/man/handler.go index 18d03aec..173d5f5d 100644 --- a/man/handler.go +++ b/man/handler.go @@ -14,6 +14,8 @@ import ( "sync/atomic" "time" + "github.com/MatrixAINetwork/go-matrix/params/manparams" + "github.com/MatrixAINetwork/go-matrix/ca" "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/consensus" @@ -306,13 +308,23 @@ func (pm *ProtocolManager) handle(p *peer) error { hash = head.Hash() number = head.Number.Uint64() td = pm.blockchain.GetTd(hash, number) + bt = pm.blockchain.CurrentHeader().Time.Uint64() sbs = sbi.Seq sbHash = sbi.Num ) - if err := p.Handshake(pm.networkId, td, hash, sbs, genesis.Hash(), sbHash); err != nil { - p.Log().Debug("Matrix handshake failed", "err", err) - return err + + if manparams.CanSwitchGammaCanonicalChain(time.Now().Unix()) { + if err := p.NewHandshake(pm.networkId, bt, hash, sbs, genesis.Hash(), sbHash, number); err != nil { + p.Log().Debug("Matrix handshake failed", "err", err) + return err + } + } else { + if err := p.Handshake(pm.networkId, td, hash, sbs, genesis.Hash(), sbHash); err != nil { + p.Log().Debug("Matrix handshake failed", "err", err) + return err + } } + // if rw, ok := p.rw.(*meteredMsgReadWriter); ok { if rw, ok := p.rw.(*meteredMsgReadWriter); ok { rw.Init(p.version) @@ -474,37 +486,6 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { p.Log().Trace("download handleMsg BlockHeadersMsg", "len", len(headers)) - // If no headers were received, but we're expending a DAO fork check, maybe it's that - if len(headers) == 0 && p.forkDrop != nil { - // Possibly an empty reply to the fork header checks, sanity check TDs - verifyDAO := true - p.Log().Trace("download BlockHeadersMsg forkDrop") - // If we already have a DAO header, we can check the peer's TD against it. If - // the peer's ahead of this, it too must have a reply to the DAO check - if daoHeader := pm.blockchain.GetHeaderByNumber(pm.chainconfig.DAOForkBlock.Uint64()); daoHeader != nil { - _, td, sbs, _ := p.Head() - sbs, err := pm.blockchain.GetSuperBlockSeq() - if nil != err { - p.Log().Error("get super seq error") - return nil - } - if sbs > sbs { - verifyDAO = false - } else if sbs == sbs { - if td.Cmp(pm.blockchain.GetTd(daoHeader.Hash(), daoHeader.Number.Uint64())) >= 0 { - verifyDAO = false - } - } - - } - // If we're seemingly on the same chain, disable the drop timer - if verifyDAO { - p.Log().Debug("Seems to be on the same side of the DAO fork") - p.forkDrop.Stop() - p.forkDrop = nil - return nil - } - } // Filter out any explicitly requested headers, deliver the rest to the downloader filter := len(headers) == 1 if filter { @@ -721,41 +702,74 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { // Assuming the block is importable by the peer, but possibly not yet done so, // calculate the head hash and TD that the peer truly must have. + + // Update the peers total difficulty if better than the previous var ( trueHead = request.Block.ParentHash() trueTD = new(big.Int).Sub(request.TD, request.Block.Difficulty()) trueSBS = request.SBS ) - // Update the peers total difficulty if better than the previous - _, td, sbs, _ := p.Head() - p.Log().Trace("handleMsg receive NewBlockMsg", "超级区块序号", trueSBS, "缓存序号", sbs, "trueTD", trueTD) - if trueSBS < sbs { - //todo:日志 - break - } + _, td, sbs, _, bt, bn := p.Head() + if manparams.CanSwitchGammaCanonicalChain(time.Now().Unix()) { + + p.Log().Trace("handleMsg receive NewBlockMsg", "超级区块序号", trueSBS, "缓存序号", sbs, "高度", request.Block.NumberU64(), "时间", request.Block.Time()) + if common.IsGreaterLink(common.LinkInfo{Sbs: trueSBS, Bn: request.Block.NumberU64(), Bt: request.Block.Time().Uint64()}, common.LinkInfo{Sbs: sbs, Bn: bn, Bt: bt}) { + p.SetHead(trueHead, trueTD, trueSBS, request.SBH, request.Block.Time().Uint64(), request.Block.NumberU64()) + + // Schedule a sync if above ours. Note, this will not fire a sync for a gap of + // a singe block (as the true TD is below the propagated block), however this + // scenario should easily be covered by the fetcher. + currentBlock := pm.blockchain.CurrentBlock() + td := pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64()) + if td == nil { + log.Error("td is nil", "peer", p.id) + break + } + sbs, err := pm.blockchain.GetSuperBlockSeq() + if nil != err { + log.Error("get super seq error") + break + } - if trueSBS > sbs || trueTD.Cmp(td) > 0 { - p.SetHead(trueHead, trueTD, trueSBS, request.SBH) + if common.IsGreaterLink(common.LinkInfo{Sbs: trueSBS, Bn: request.Block.NumberU64(), Bt: request.Block.Time().Uint64()}, common.LinkInfo{Sbs: sbs, Bn: currentBlock.NumberU64(), Bt: currentBlock.Time().Uint64()}) { - // Schedule a sync if above ours. Note, this will not fire a sync for a gap of - // a singe block (as the true TD is below the propagated block), however this - // scenario should easily be covered by the fetcher. - currentBlock := pm.blockchain.CurrentBlock() - td := pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64()) - if td == nil { - log.Error("td is nil", "peer", p.id) - break + log.Trace("handleMsg receive NewBlockMsg", "超级区块序号", trueSBS, "本地序号", sbs, + "远程高度", request.Block.NumberU64(), "本地高度", currentBlock.NumberU64(), "远程时间", request.Block.Time(), "本地时间", currentBlock.Time()) + go pm.synchronise(p) + } } - sbs, err := pm.blockchain.GetSuperBlockSeq() - if nil != err { - log.Error("get super seq error") + } else { + + p.Log().Trace("handleMsg receive NewBlockMsg", "超级区块序号", trueSBS, "缓存序号", sbs, "trueTD", trueTD) + if trueSBS < sbs { + //todo:日志 break } if trueSBS > sbs || trueTD.Cmp(td) > 0 { - log.Trace("handleMsg receive NewBlockMsg", "超级区块序号", trueSBS, "本地序号", sbs, "远程td", trueTD, "本地td", td) - go pm.synchronise(p) + p.SetHead(trueHead, trueTD, trueSBS, request.SBH, request.Block.Time().Uint64(), request.Block.NumberU64()) + + // Schedule a sync if above ours. Note, this will not fire a sync for a gap of + // a singe block (as the true TD is below the propagated block), however this + // scenario should easily be covered by the fetcher. + currentBlock := pm.blockchain.CurrentBlock() + td := pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64()) + if td == nil { + log.Error("td is nil", "peer", p.id) + break + } + sbs, err := pm.blockchain.GetSuperBlockSeq() + if nil != err { + log.Error("get super seq error") + break + } + + if trueSBS > sbs || trueTD.Cmp(td) > 0 { + log.Trace("handleMsg receive NewBlockMsg", "超级区块序号", trueSBS, "本地序号", sbs, "远程td", trueTD, "本地td", td) + go pm.synchronise(p) + } } + } case msg.Code == TxMsg: diff --git a/man/peer.go b/man/peer.go index 6265c0d8..ad8db8fd 100644 --- a/man/peer.go +++ b/man/peer.go @@ -11,6 +11,8 @@ import ( "sync" "time" + "github.com/MatrixAINetwork/go-matrix/params/manparams" + "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/core/types" "github.com/MatrixAINetwork/go-matrix/log" @@ -57,6 +59,8 @@ type PeerInfo struct { Head string `json:"head"` // SHA3 hash of the peer's best owned block SuperBlockNum uint64 `json:"superBlockNum"` // SuperBlockHash SuperBlockSeq uint64 `json:"superBlockSeq"` // SuperBlockHash + BlockTime uint64 `json:"blockTime"` // blockTime + BlockHeight uint64 `json:"blockHeight"` // blockHeight } // propEvent is a block propagation, waiting for its turn in the broadcast queue. @@ -78,8 +82,10 @@ type peer struct { forkDrop *time.Timer // Timed connection dropper if forks aren't validated in time head common.Hash + bn uint64 sbn uint64 td *big.Int + bt uint64 sbs uint64 lock sync.RWMutex @@ -145,7 +151,7 @@ func (p *peer) close() { // Info gathers and returns a collection of metadata known about a peer. func (p *peer) Info() *PeerInfo { - hash, td, sbs, sbHash := p.Head() + hash, td, sbs, sbHash, bt, bn := p.Head() return &PeerInfo{ Version: p.version, @@ -153,21 +159,23 @@ func (p *peer) Info() *PeerInfo { Head: hash.Hex(), SuperBlockNum: sbHash, SuperBlockSeq: sbs, + BlockTime: bt, + BlockHeight: bn, } } // Head retrieves a copy of the current head hash and total difficulty of the // peer. -func (p *peer) Head() (hash common.Hash, td *big.Int, sbs uint64, sbHash uint64) { +func (p *peer) Head() (hash common.Hash, td *big.Int, sbs uint64, sbHash uint64, uint64, bn uint64) { p.lock.RLock() defer p.lock.RUnlock() copy(hash[:], p.head[:]) - return hash, new(big.Int).Set(p.td), p.sbs, p.sbn + return hash, new(big.Int).Set(p.td), p.sbs, p.sbn, p.bt, p.bn } // SetHead updates the head hash and total difficulty of the peer. -func (p *peer) SetHead(hash common.Hash, td *big.Int, sbs uint64, sbn uint64) { +func (p *peer) SetHead(hash common.Hash, td *big.Int, sbs uint64, sbn uint64, bt uint64, bn uint64) { p.lock.Lock() defer p.lock.Unlock() @@ -175,6 +183,8 @@ func (p *peer) SetHead(hash common.Hash, td *big.Int, sbs uint64, sbn uint64) { p.td.Set(td) p.sbs = sbs p.sbn = sbn + p.bn = bn + p.bt = bt } // MarkBlock marks a block as known for the peer, ensuring that the block will @@ -417,7 +427,45 @@ func (p *peer) Handshake(network uint64, td *big.Int, head common.Hash, sbs uint return p2p.DiscReadTimeout } } - p.td, p.head, p.sbs, p.sbn = status.TD, status.CurrentBlock, status.SBS, status.SBH + p.td, p.head, p.sbs, p.sbn, p.bt, p.bn = status.TD, status.CurrentBlock, status.SBS, status.SBH, 0, 0 + return nil +} + +// Handshake executes the eth protocol handshake, negotiating version number, +// network IDs, difficulties, head and genesis blocks. +func (p *peer) NewHandshake(network uint64, blockTime uint64, head common.Hash, sbs uint64, genesis common.Hash, sbh uint64, bn uint64) error { + // Send out own handshake in a new thread + errc := make(chan error, 2) + var status statusNewData // safe to read after two values have been received from errc + + go func() { + errc <- p2p.Send(p.rw, StatusMsg, &statusNewData{ + ProtocolVersion: uint32(p.version), + NetworkId: network, + SBS: sbs, + SBH: sbh, + BN: bn, + BlockTime: blockTime, + CurrentBlock: head, + GenesisBlock: genesis, + }) + }() + go func() { + errc <- p.readNewStatus(network, &status, genesis) + }() + timeout := time.NewTimer(handshakeTimeout) + defer timeout.Stop() + for i := 0; i < 2; i++ { + select { + case err := <-errc: + if err != nil { + return err + } + case <-timeout.C: + return p2p.DiscReadTimeout + } + } + p.bt, p.head, p.sbs, p.sbn, p.bn, p.td = status.BlockTime, status.CurrentBlock, status.SBS, status.SBH, status.BN, new(big.Int).SetUint64(0) return nil } @@ -448,6 +496,33 @@ func (p *peer) readStatus(network uint64, status *statusData, genesis common.Has return nil } +func (p *peer) readNewStatus(network uint64, status *statusNewData, genesis common.Hash) (err error) { + msg, err := p.rw.ReadMsg() + if err != nil { + return err + } + if msg.Code != StatusMsg { + return errResp(ErrNoStatusMsg, "first msg has code %x (!= %x)", msg.Code, StatusMsg) + } + if msg.Size > ProtocolMaxMsgSize { + return errResp(ErrMsgTooLarge, "%v > %v", msg.Size, ProtocolMaxMsgSize) + } + // Decode the handshake and make sure everything matches + if err := msg.Decode(&status); err != nil { + return errResp(ErrDecode, "msg %v: %v", msg, err) + } + if status.GenesisBlock != genesis { + return errResp(ErrGenesisBlockMismatch, "%x (!= %x)", status.GenesisBlock[:8], genesis[:8]) + } + if status.NetworkId != network { + return errResp(ErrNetworkIdMismatch, "%d (!= %d)", status.NetworkId, network) + } + if int(status.ProtocolVersion) != p.version { + return errResp(ErrProtocolVersionMismatch, "%d (!= %d)", status.ProtocolVersion, p.version) + } + return nil +} + // String implements fmt.Stringer. func (p *peer) String() string { return fmt.Sprintf("Peer %s [%s]", p.id, @@ -551,10 +626,7 @@ func (ps *peerSet) PeersWithoutTx(hash common.Hash) []*peer { return list } -// BestPeer retrieves the known peer with the currently highest total difficulty. -func (ps *peerSet) BestPeer() *peer { - ps.lock.RLock() - defer ps.lock.RUnlock() +func (ps *peerSet) bestPeerA() *peer { var ( bestPeer *peer @@ -562,7 +634,7 @@ func (ps *peerSet) BestPeer() *peer { bestBs uint64 ) for _, p := range ps.peers { - _, td, sb, _ := p.Head() + _, td, sb, _, _, _ := p.Head() if sb < bestBs { continue } @@ -574,6 +646,37 @@ func (ps *peerSet) BestPeer() *peer { return bestPeer } +func (ps *peerSet) bestPeerB() *peer { + + var ( + bestPeer *peer + bestTime uint64 + bestBs uint64 + bestBn uint64 + ) + for _, p := range ps.peers { + _, _, sb, _, bt, bn := p.Head() + + //todo:bestTd + if bestPeer == nil || common.IsGreaterLink(common.LinkInfo{Sbs: sb, Bn: bn, Bt: bt}, common.LinkInfo{Sbs: bestBs, Bn: bestBn, Bt: bestTime}) { + bestPeer, bestBs, bestTime, bestBn = p, sb, bt, bn + } + + } + return bestPeer +} + +// BestPeer retrieves the known peer with the currently highest total difficulty. +func (ps *peerSet) BestPeer() *peer { + ps.lock.RLock() + defer ps.lock.RUnlock() + if manparams.CanSwitchGammaCanonicalChain(time.Now().Unix()) { + return ps.bestPeerB() + } else { + return ps.bestPeerA() + } +} + // Close disconnects all peers. // No new peers can be registered after Close has returned. func (ps *peerSet) Close() { diff --git a/man/protocol.go b/man/protocol.go index a38fca6e..ca323255 100644 --- a/man/protocol.go +++ b/man/protocol.go @@ -110,6 +110,18 @@ type statusData struct { GenesisBlock common.Hash } +// statusData is the network packet for the status message. +type statusNewData struct { + ProtocolVersion uint32 + NetworkId uint64 + BN uint64 + SBS uint64 + SBH uint64 + BlockTime uint64 + CurrentBlock common.Hash + GenesisBlock common.Hash +} + // newBlockHashesData is the network packet for the block announcements. type newBlockHashesData []struct { Hash common.Hash // Hash of one particular block being announced @@ -163,9 +175,9 @@ func (hn *hashOrNumber) DecodeRLP(s *rlp.Stream) error { // newBlockData is the network packet for the block propagation message. type newBlockData struct { Block *types.Block - TD *big.Int - SBH uint64 //超级区块高度 - SBS uint64 //超级区块序号 + TD *big.Int // + SBH uint64 //超级区块高度 + SBS uint64 //超级区块序号 } // blockBody represents the data content of a single block. diff --git a/man/sync.go b/man/sync.go index 952c252d..997ef96e 100644 --- a/man/sync.go +++ b/man/sync.go @@ -13,6 +13,8 @@ import ( "sync/atomic" "time" + "github.com/MatrixAINetwork/go-matrix/params/manparams" + "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/core/types" "github.com/MatrixAINetwork/go-matrix/log" @@ -235,23 +237,22 @@ func (pm *ProtocolManager) syncer() { // synchronise tries to sync up our local block chain with a remote peer. func (pm *ProtocolManager) synchronise(peer *peer) { // Short circuit if no peers are available - log.Trace("download sync.go enter Synchronise peer", "peer", peer) if peer == nil { return } // Make sure the peer's TD is higher than our own currentBlock := pm.blockchain.CurrentBlock() td := pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64()) - sbi, err := pm.blockchain.GetSuperBlockInfo() if nil != err { log.Error("get super seq error") return } + log.Trace("download sync.go enter Synchronise peer", "peer", peer) sbs := sbi.Seq sbh := sbi.Num - pHead, pTd, pSbs, pSbh := peer.Head() + pHead, pTd, pSbs, pSbh, bt, bn := peer.Head() log.Trace("download sync.go enter Synchronise td", "td", td, "pTd", pTd, "Sbs", sbs, "pSbs", pSbs) if pSbs < sbs { go peer.SendBlockHeaders([]*types.Header{currentBlock.Header()}) @@ -260,10 +261,23 @@ func (pm *ProtocolManager) synchronise(peer *peer) { return } if pSbs == sbs { - if nil == td || pTd.Cmp(td) <= 0 { - log.Trace("对端peer超级td小于本地的td", "本地td", td, "peertd", pTd, "peer hex", peer.id) - return + if manparams.CanSwitchGammaCanonicalChain(time.Now().Unix()) { + if bn < currentBlock.NumberU64() { + log.Trace("对端peer高度小于本地的高度", "本地高度", currentBlock.NumberU64(), "对端高度", bn, "peer hex", peer.id) + return + } else if bn == currentBlock.NumberU64() { + if bt < currentBlock.Time().Uint64() { + log.Trace("对端peer高度小于本地的高度", "本地时间", currentBlock.Time(), "对端时间", bt, "peer hex", peer.id) + return + } + } + } else { + if nil == td || pTd.Cmp(td) <= 0 { + log.Trace("对端peer超级td小于本地的td", "本地td", td, "peertd", pTd, "peer hex", peer.id) + return + } } + } log.Warn("download sync.go enter Synchronise", "currentBlock", currentBlock.NumberU64()) @@ -285,19 +299,6 @@ func (pm *ProtocolManager) synchronise(peer *peer) { log.Trace("download sync.go enter Synchronise set fastSync", "currentBlock", currentBlock.NumberU64()) }*/ - if mode == downloader.FastSync { - log.Trace("download sync.go enter Synchronise fastSync hash", "currentBlock", currentBlock.NumberU64()) - // Make sure the peer's total difficulty we are synchronizing is higher. - if sbs > pSbs { - return - } - if sbs == pSbs { - //todo:fast模式 - if pm.blockchain.GetTdByHash(pm.blockchain.CurrentFastBlock().Hash()).Cmp(pTd) >= 0 { - return - } - } - } //log.Trace("download sync.go enter Synchronise downloader", "currentBlock", currentBlock.NumberU64()) // Run the sync cycle, and disable fast sync if we've went past the pivot block if err := pm.downloader.Synchronise(peer.id, pHead, pTd, pSbs, pSbh, mode); err != nil { diff --git a/man/wizard/wizard_super.go b/man/wizard/wizard_super.go index 4dd88f78..5f3f88c5 100644 --- a/man/wizard/wizard_super.go +++ b/man/wizard/wizard_super.go @@ -106,7 +106,7 @@ func (w *wizard) MakeSuperGenesis(bc *core.BlockChain, db mandb.Database, num ui } curElect := make([]core.GenesisElect, 0) for _, v := range elect.ElectList { - curElect = append(curElect, core.GenesisElect{Account: core.GenesisAddress(v.Account), Stock: v.Stock, Type: common.ElectRoleType(v.Type), VIP: v.VIPLevel}) + curElect = append(curElect, core.GenesisElect{Account: core.GenesisAddress(v.Account), Stock: v.Stock, Type: v.Type.Transfer2ElectRole(), VIP: v.VIPLevel}) } genesis.MState.CurElect = &curElect genesis.NextElect = elect.TransferNextElect2CommonElect() @@ -139,7 +139,7 @@ func (w *wizard) MakeSuperGenesis(bc *core.BlockChain, db mandb.Database, num ui } curElect := make([]core.GenesisElect, 0) for _, v := range elect.ElectList { - curElect = append(curElect, core.GenesisElect{Account: core.GenesisAddress(v.Account), Stock: v.Stock, Type: common.ElectRoleType(v.Type), VIP: v.VIPLevel}) + curElect = append(curElect, core.GenesisElect{Account: core.GenesisAddress(v.Account), Stock: v.Stock, Type: v.Type.Transfer2ElectRole(), VIP: v.VIPLevel}) } genesis.MState.CurElect = &curElect genesis.NextElect = elect.TransferNextElect2CommonElect() diff --git a/manclient/manclient.go b/manclient/manclient.go index 957b000a..e06d1b43 100644 --- a/manclient/manclient.go +++ b/manclient/manclient.go @@ -135,7 +135,7 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface txs[i] = tx.tx } - mm :=make( map[string][]types.SelfTransaction) //BB + mm := make(map[string][]types.SelfTransaction) //BB for _, tx := range txs { cointype := tx.GetTxCurrency() mm[cointype] = append(mm[cointype], tx) diff --git a/mandb/database.go b/mandb/database.go index 9802e54f..844ea1fd 100644 --- a/mandb/database.go +++ b/mandb/database.go @@ -48,7 +48,7 @@ type LDBDatabase struct { } // NewLDBDatabase returns a LevelDB wrapped object. -func NewLDBDatabase(file string, cache int, handles int) (*LDBDatabase, error) { +func NewLDBDatabase(file string, cache int, handles int,dbSize int) (*LDBDatabase, error) { logger := log.New("database", file) // Ensure we have some minimal caching and file guarantees @@ -58,7 +58,7 @@ func NewLDBDatabase(file string, cache int, handles int) (*LDBDatabase, error) { if handles < 16 { handles = 16 } - logger.Info("Allocated cache and file handles", "cache", cache, "handles", handles) + logger.Info("Allocated cache and file handles", "cache", cache, "handles", handles,"dbSize",dbSize) // Open the db and recover any potential corruptions db, err := leveldb.OpenFile(file, &opt.Options{ @@ -66,6 +66,7 @@ func NewLDBDatabase(file string, cache int, handles int) (*LDBDatabase, error) { BlockCacheCapacity: cache / 2 * opt.MiB, WriteBuffer: cache / 4 * opt.MiB, // Two of these are used internally Filter: filter.NewBloomFilter(10), + CompactionTableSize: dbSize * opt.MiB, }) if _, corrupted := err.(*errors.ErrCorrupted); corrupted { db, err = leveldb.RecoverFile(file, nil) diff --git a/manstats/manstats.go b/manstats/manstats.go index 58c6e440..2da95159 100644 --- a/manstats/manstats.go +++ b/manstats/manstats.go @@ -471,7 +471,7 @@ type blockStats struct { // txStats is the information to report about individual transactions. type txStats struct { Currency string - Hashes []common.Hash `json:"hash"` + Hashes []common.Hash `json:"hash"` } // uncleStats is a custom wrapper around an uncle array to force serializing @@ -521,12 +521,12 @@ func (s *Service) assembleBlockStats(block *types.Block) *blockStats { header = block.Header() td = s.man.BlockChain().GetTd(header.Hash(), header.Number.Uint64()) txs = make([]txStats, 0) - for _,curr := range block.Currencies(){ - hashs := make([]common.Hash,0) + for _, curr := range block.Currencies() { + hashs := make([]common.Hash, 0) for _, tx := range curr.Transactions.GetTransactions() { - hashs = append(hashs,tx.Hash()) + hashs = append(hashs, tx.Hash()) } - txs = append(txs,txStats{Currency:curr.CurrencyName,Hashes:hashs}) + txs = append(txs, txStats{Currency: curr.CurrencyName, Hashes: hashs}) } uncles = block.Uncles() @@ -535,16 +535,16 @@ func (s *Service) assembleBlockStats(block *types.Block) *blockStats { author, _ := s.engine.Author(header) return &blockStats{ - Number: header.Number, - Hash: header.Hash(), - ParentHash: header.ParentHash, - Timestamp: header.Time, - Miner: author, - GasUsed: header.GasUsed, - GasLimit: header.GasLimit, - Diff: header.Difficulty.String(), - TotalDiff: td.String(), - Txs: txs, + Number: header.Number, + Hash: header.Hash(), + ParentHash: header.ParentHash, + Timestamp: header.Time, + Miner: author, + GasUsed: header.GasUsed, + GasLimit: header.GasLimit, + Diff: header.Difficulty.String(), + TotalDiff: td.String(), + Txs: txs, //TxHash: header.TxHash, Root: header.Roots, Uncles: uncles, diff --git a/matrixwork/work.go b/matrixwork/work.go index fc58a187..91e5bd26 100644 --- a/matrixwork/work.go +++ b/matrixwork/work.go @@ -77,9 +77,9 @@ type Work struct { transer []types.SelfTransaction recpts []*types.Receipt - createdAt time.Time - packNum int //MAN以外的其他币种打包数量限制(不能超过MAN的1/100) - coinType string + createdAt time.Time + packNum int //MAN以外的其他币种打包数量限制(不能超过MAN的1/100) + coinType string mapcoingasUse coingasUse } type coingasUse struct { @@ -88,7 +88,6 @@ type coingasUse struct { mu sync.RWMutex } - func (cu *coingasUse) setCoinGasUse(txer types.SelfTransaction, gasuse uint64) { cu.mu.Lock() defer cu.mu.Unlock() @@ -154,17 +153,17 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txser map[common.Address env.gasPool = new(core.GasPool).AddGas(env.header.GasLimit) } - coalescedLogs := make([]types.CoinLogs,0,1024) - retTxs = make([]types.SelfTransaction,0,1024) + coalescedLogs := make([]types.CoinLogs, 0, 1024) + retTxs = make([]types.SelfTransaction, 0, 1024) tmpRetmap := make(map[byte][]uint32) isExceed := false for _, txers := range txser { - if isExceed{ + if isExceed { break } //txs := types.GetCoinTX(txers) for _, txer := range txers { - if uint64(env.packNum) >= params.OtherCoinPackNum && env.coinType != params.MAN_COIN{ + if uint64(env.packNum) >= params.OtherCoinPackNum && env.coinType != params.MAN_COIN { isExceed = true break } @@ -203,16 +202,16 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txser map[common.Address // Everything ok, collect the logs and shift in the next transaction from the same account if txer.GetTxNLen() != 0 { n := txer.GetTxN(0) - tmpRetmap[txer.TxType()] = append(tmpRetmap[txer.TxType()],n) + tmpRetmap[txer.TxType()] = append(tmpRetmap[txer.TxType()], n) /* - if listN, ok := tmpRetmap[txer.TxType()]; ok { - listN = append(listN, n) - tmpRetmap[txer.TxType()] = listN - } else { - listN := make([]uint32, 1) - listN[0] = n - tmpRetmap[txer.TxType()] = listN - } + if listN, ok := tmpRetmap[txer.TxType()]; ok { + listN = append(listN, n) + tmpRetmap[txer.TxType()] = listN + } else { + listN := make([]uint32, 1) + listN[0] = n + tmpRetmap[txer.TxType()] = listN + } */ retTxs = append(retTxs, txer) @@ -231,7 +230,7 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txser map[common.Address } } //env.State.Finalise("MAN",true) - listret = make([]*common.RetCallTxN,0,len(tmpRetmap)) + listret = make([]*common.RetCallTxN, 0, len(tmpRetmap)) for t, n := range tmpRetmap { ts := common.RetCallTxN{t, n} listret = append(listret, &ts) @@ -258,8 +257,8 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txser map[common.Address } func isInBlackList(from common.Address) bool { isOk := false - for _,blackaccount := range common.BlackList{ - if from.Equal(blackaccount){ + for _, blackaccount := range common.BlackList { + if from.Equal(blackaccount) { isOk = true break } @@ -269,14 +268,14 @@ func isInBlackList(from common.Address) bool { func (env *Work) commitTransaction(tx types.SelfTransaction, bc ChainReader, coinbase common.Address, gp *core.GasPool) (error, []*types.Log) { //leader和follower过滤黑名单交易 - if isInBlackList(tx.From()){ - log.Error("commitTransaction","tx.from is in blacklist",tx.From().String()) - return core.ErrBlackListTx,nil + if isInBlackList(tx.From()) { + log.Error("commitTransaction", "tx.from is in blacklist", tx.From().String()) + return core.ErrBlackListTx, nil } - snap := env.State.Snapshot(tx.GetTxCurrency()) + snap := env.State.Snapshot(tx.GetTxCurrency()) var snap1 []int - if tx.GetTxCurrency()!=params.MAN_COIN { + if tx.GetTxCurrency() != params.MAN_COIN { snap1 = env.State.Snapshot(params.MAN_COIN) } receipt, _, _, err := core.ApplyTransaction(env.config, bc, &coinbase, gp, env.State, env.header, tx, &env.header.GasUsed, vm.Config{}) @@ -293,14 +292,14 @@ func (env *Work) commitTransaction(tx types.SelfTransaction, bc ChainReader, coi env.mapcoingasUse.setCoinGasUse(tx, receipt.GasUsed) return nil, receipt.Logs } -func (env *Work) s_commitTransaction(tx types.SelfTransaction, coinbase common.Address, gp *core.GasPool) (error, []*types.Log,*types.Receipt) { +func (env *Work) s_commitTransaction(tx types.SelfTransaction, coinbase common.Address, gp *core.GasPool) (error, []*types.Log, *types.Receipt) { env.State.Prepare(tx.Hash(), common.Hash{}, env.tcount) snap := env.State.Snapshot(tx.GetTxCurrency()) receipt, _, _, err := core.ApplyTransaction(env.config, env.bc, &coinbase, gp, env.State, env.header, tx, &env.header.GasUsed, vm.Config{}) if err != nil { log.Error("s_commitTransaction commit err. ", "err", err) env.State.RevertToSnapshot(tx.GetTxCurrency(), snap) - return err, nil,nil + return err, nil, nil } //tmps := make([]types.SelfTransaction, 0) //tmps = append(tmps, tx) @@ -312,7 +311,7 @@ func (env *Work) s_commitTransaction(tx types.SelfTransaction, coinbase common.A //tmpr = append(tmpr, env.recpts...) //env.recpts = tmpr env.tcount++ - return nil, receipt.Logs,receipt + return nil, receipt.Logs, receipt } //Leader @@ -322,17 +321,18 @@ type retStruct struct { no []uint32 txs []*types.Transaction } + func myCoinsort(coins []string) []string { - coinsnoman := make([]string,0,len(coins)) - retCoins := make([]string,0,len(coins)) - for _,coinname := range coins{ - if coinname == params.MAN_COIN{ + coinsnoman := make([]string, 0, len(coins)) + retCoins := make([]string, 0, len(coins)) + for _, coinname := range coins { + if coinname == params.MAN_COIN { continue } - coinsnoman = append(coinsnoman,coinname) + coinsnoman = append(coinsnoman, coinname) } - retCoins = append(retCoins,params.MAN_COIN) - retCoins = append(retCoins,coinsnoman...) + retCoins = append(retCoins, params.MAN_COIN) + retCoins = append(retCoins, coinsnoman...) return retCoins } @@ -348,51 +348,51 @@ func (env *Work) ProcessTransactions(mux *event.TypeMux, tp txPoolReader, upTime env.State.UpdateTxForBtreeBytime(uint32(tim)) log.Info("work", "关键时间点", "开始执行交易", "time", time.Now(), "块高", env.header.Number) - coins := make([]string,0) - coinsnoman := make([]string,0) - for coinname,_ := range pending{ - if coinname == params.MAN_COIN{ + coins := make([]string, 0) + coinsnoman := make([]string, 0) + for coinname, _ := range pending { + if coinname == params.MAN_COIN { continue } - coinsnoman = append(coinsnoman,coinname) //leader + coinsnoman = append(coinsnoman, coinname) //leader } sort.Strings(coinsnoman) - coins = append(coins,params.MAN_COIN) - coins = append(coins,coinsnoman...) + coins = append(coins, params.MAN_COIN) + coins = append(coins, coinsnoman...) //先跑MAN交易,后跑其他币种交易 - for _,coinname := range coins{ + for _, coinname := range coins { env.packNum = 0 env.coinType = coinname tmplistret, tmporiginalTxs := env.commitTransactions(mux, pending[coinname], common.Address{}) - originalTxs = append(originalTxs,tmporiginalTxs...) - listret = append(listret,tmplistret...) + originalTxs = append(originalTxs, tmporiginalTxs...) + listret = append(listret, tmplistret...) } //finalCoinTxs -按币种存放的所有交易;finalCoinRecpets -按币种存放的所有收据 - tCoinTxs,tCoinRecpets := types.GetCoinTXRS(env.transer,env.recpts) // env.transer就是originalTxs - finalCoinTxs := make([]types.CoinSelfTransaction,0,len(coins)) - finalCoinRecpets := make([]types.CoinReceipts,0,len(coins)) + tCoinTxs, tCoinRecpets := types.GetCoinTXRS(env.transer, env.recpts) // env.transer就是originalTxs + finalCoinTxs := make([]types.CoinSelfTransaction, 0, len(coins)) + finalCoinRecpets := make([]types.CoinReceipts, 0, len(coins)) //查看是否有MAN分区(MAN币),如果有直接append到finalCoinTxs,没有就创建MAN分区用于后面存奖励交易 isHaveManCoin := false - for _,tcoin := range tCoinTxs{ - if tcoin.CoinType == params.MAN_COIN{ + for _, tcoin := range tCoinTxs { + if tcoin.CoinType == params.MAN_COIN { isHaveManCoin = true break } } - if !isHaveManCoin{ + if !isHaveManCoin { var MANCoinReceipt types.CoinReceipts var MANtmCointxs types.CoinSelfTransaction MANtmCointxs.CoinType = params.MAN_COIN //MAN分区必须有,用于存放矿工和验证者奖励费 MANCoinReceipt.CoinType = params.MAN_COIN - finalCoinTxs = append(finalCoinTxs,MANtmCointxs) - finalCoinRecpets = append(finalCoinRecpets,MANCoinReceipt) + finalCoinTxs = append(finalCoinTxs, MANtmCointxs) + finalCoinRecpets = append(finalCoinRecpets, MANCoinReceipt) } - finalCoinTxs = append(finalCoinTxs,tCoinTxs...) - finalCoinRecpets = append(finalCoinRecpets,tCoinRecpets...) + finalCoinTxs = append(finalCoinTxs, tCoinTxs...) + finalCoinRecpets = append(finalCoinRecpets, tCoinRecpets...) CoinsMap := make(map[string]bool) //存放所有币种 - for _,cointxs := range finalCoinTxs{ + for _, cointxs := range finalCoinTxs { CoinsMap[cointxs.CoinType] = true } @@ -404,57 +404,57 @@ func (env *Work) ProcessTransactions(mux *event.TypeMux, tp txPoolReader, upTime log.Info("work", "关键时间点", "执行交易完成,开始执行奖励", "time", time.Now(), "块高", env.header.Number, "tx num ", len(originalTxs)) rewart := env.bc.Processor(env.header.Version).ProcessReward(env.State, env.header, upTime, from, env.mapcoingasUse.mapcoin) rewardTxmap := env.makeTransaction(rewart) - allfinalTxs := make([]types.CoinSelfTransaction,0,len(coins)) //按币种存放的所有交易切片(先放分区币种的奖励交易,然后存该币种的普通交易) - allfinalRecpets := make([]types.CoinReceipts,0,len(coins)) //按币种存放的所有收据切片(先放分区币种的奖励收据,然后存该币种的普通收据) + allfinalTxs := make([]types.CoinSelfTransaction, 0, len(coins)) //按币种存放的所有交易切片(先放分区币种的奖励交易,然后存该币种的普通交易) + allfinalRecpets := make([]types.CoinReceipts, 0, len(coins)) //按币种存放的所有收据切片(先放分区币种的奖励收据,然后存该币种的普通收据) //防止多币种交易下一个区块的没有该币种的交易,但有该币种奖励 - tmpcoins := make([]string,0) - for rewardCoinname,_ := range rewardTxmap{ + tmpcoins := make([]string, 0) + for rewardCoinname, _ := range rewardTxmap { //tmpcoins = append(tmpcoins,rewardCoinname) CoinsMap[rewardCoinname] = true } - for coinname,_ := range CoinsMap{ - tmpcoins = append(tmpcoins,coinname) + for coinname, _ := range CoinsMap { + tmpcoins = append(tmpcoins, coinname) } coins = myCoinsort(tmpcoins) //先跑MAN奖励交易,后跑其他币种奖励交易 - for _,coinname := range coins{ + for _, coinname := range coins { var tCoinReceipt types.CoinReceipts var tCointxs types.CoinSelfTransaction - tmpTxs := make([]types.SelfTransaction,0) - tmpRecepts := make(types.Receipts,0) + tmpTxs := make([]types.SelfTransaction, 0) + tmpRecepts := make(types.Receipts, 0) //tmpcoinRecpets := make([]types.CoinReceipts,0,len(coins)) for _, tx := range rewardTxmap[coinname] { - err, _ ,recpts:= env.s_commitTransaction(tx, common.Address{}, new(core.GasPool).AddGas(0)) + err, _, recpts := env.s_commitTransaction(tx, common.Address{}, new(core.GasPool).AddGas(0)) if err != nil { log.Error("work.go", "ProcessTransactions:::reward Tx call Error", err) continue } - tmpTxs = append(tmpTxs,tx) //奖励放对应分区币种的前面 - tmpRecepts = append(tmpRecepts,recpts) //奖励放对应分区币种的前面 + tmpTxs = append(tmpTxs, tx) //奖励放对应分区币种的前面 + tmpRecepts = append(tmpRecepts, recpts) //奖励放对应分区币种的前面 } //tmpTxs = append(tmpTxs,tRewartTx...) //奖励交易放对应分区币种的前面 - for _,cointxs := range finalCoinTxs{ - if coinname == cointxs.CoinType{ - tmpTxs = append(tmpTxs,cointxs.Txser...) //普通交易放后面 + for _, cointxs := range finalCoinTxs { + if coinname == cointxs.CoinType { + tmpTxs = append(tmpTxs, cointxs.Txser...) //普通交易放后面 } } tCointxs.CoinType = coinname tCointxs.Txser = tmpTxs - allfinalTxs = append(allfinalTxs,tCointxs) + allfinalTxs = append(allfinalTxs, tCointxs) - for _,coinrecpts := range finalCoinRecpets{ - if coinname == coinrecpts.CoinType{ - tmpRecepts = append(tmpRecepts,coinrecpts.Receiptlist...) + for _, coinrecpts := range finalCoinRecpets { + if coinname == coinrecpts.CoinType { + tmpRecepts = append(tmpRecepts, coinrecpts.Receiptlist...) } } tCoinReceipt.CoinType = coinname tCoinReceipt.Receiptlist = tmpRecepts - allfinalRecpets = append(allfinalRecpets,tCoinReceipt) + allfinalRecpets = append(allfinalRecpets, tCoinReceipt) } - env.State.Finalise("",true) + env.State.Finalise("", true) env.txs = allfinalTxs env.Receipts = allfinalRecpets log.Info("work", "关键时间点", "奖励执行完成", "time", time.Now(), "块高", env.header.Number) @@ -526,7 +526,7 @@ func (env *Work) makeTransaction(rewarts []common.RewarTx) (coinTxs map[string]t //txers = append(txers, tx) rewartTxs := coinTxs[rewart.CoinRange] - rewartTxs = append(rewartTxs,tx) + rewartTxs = append(rewartTxs, tx) coinTxs[rewart.CoinRange] = rewartTxs } return @@ -555,117 +555,117 @@ func (env *Work) ProcessBroadcastTransactions(mux *event.TypeMux, txs []types.Co tim := env.header.Time.Uint64() env.State.UpdateTxForBtree(uint32(tim)) env.State.UpdateTxForBtreeBytime(uint32(tim)) - coins := make([]string,0,len(txs)+1) - if len(txs)>1{ + coins := make([]string, 0, len(txs)+1) + if len(txs) > 1 { txs = mysort(txs) } env.mapcoingasUse.clearmap() for _, tx := range txs { env.packNum = 0 env.coinType = tx.CoinType - coins = append(coins,tx.CoinType) + coins = append(coins, tx.CoinType) for _, t := range tx.Txser { - if uint64(env.packNum) >= params.OtherCoinPackNum && env.coinType != params.MAN_COIN{ + if uint64(env.packNum) >= params.OtherCoinPackNum && env.coinType != params.MAN_COIN { break } env.commitTransaction(t, env.bc, common.Address{}, nil) env.packNum++ } } - coinsnoman := make([]string,0,len(txs)+1) - for _,coinname := range coins{ - if coinname == params.MAN_COIN{ + coinsnoman := make([]string, 0, len(txs)+1) + for _, coinname := range coins { + if coinname == params.MAN_COIN { continue } - coinsnoman = append(coinsnoman,coinname) + coinsnoman = append(coinsnoman, coinname) } sort.Strings(coinsnoman) - tcoins := make([]string,0,len(txs)+1) - tcoins = append(tcoins,params.MAN_COIN) - tcoins = append(tcoins,coinsnoman...) + tcoins := make([]string, 0, len(txs)+1) + tcoins = append(tcoins, params.MAN_COIN) + tcoins = append(tcoins, coinsnoman...) coins = tcoins //前面是man币,后面是排序过的币种 //finalCoinTxs -按币种存放的所有交易;finalCoinRecpets -按币种存放的所有收据 - tCoinTxs,tCoinRecpets := types.GetCoinTXRS(env.transer,env.recpts) // env.transer就是originalTxs - finalCoinTxs := make([]types.CoinSelfTransaction,0) - finalCoinRecpets := make([]types.CoinReceipts,0) + tCoinTxs, tCoinRecpets := types.GetCoinTXRS(env.transer, env.recpts) // env.transer就是originalTxs + finalCoinTxs := make([]types.CoinSelfTransaction, 0) + finalCoinRecpets := make([]types.CoinReceipts, 0) //env.State.Finalise("MAN",true) //查看是否有MAN分区(MAN币),如果有直接append到finalCoinTxs,没有就创建MAN分区用于后面存奖励交易 isHaveManCoin := false - for _,tcoin := range tCoinTxs{ - if tcoin.CoinType == params.MAN_COIN{ + for _, tcoin := range tCoinTxs { + if tcoin.CoinType == params.MAN_COIN { isHaveManCoin = true break } } - if !isHaveManCoin{ + if !isHaveManCoin { var MANCoinReceipt types.CoinReceipts var MANtmCointxs types.CoinSelfTransaction MANtmCointxs.CoinType = params.MAN_COIN //MAN分区必须有,用于存放矿工和验证者奖励费 MANCoinReceipt.CoinType = params.MAN_COIN - finalCoinTxs = append(finalCoinTxs,MANtmCointxs) - finalCoinRecpets = append(finalCoinRecpets,MANCoinReceipt) + finalCoinTxs = append(finalCoinTxs, MANtmCointxs) + finalCoinRecpets = append(finalCoinRecpets, MANCoinReceipt) } - finalCoinTxs = append(finalCoinTxs,tCoinTxs...) - finalCoinRecpets = append(finalCoinRecpets,tCoinRecpets...) + finalCoinTxs = append(finalCoinTxs, tCoinTxs...) + finalCoinRecpets = append(finalCoinRecpets, tCoinRecpets...) CoinsMap := make(map[string]bool) //存放所有币种 - for _,cointxs := range finalCoinTxs{ + for _, cointxs := range finalCoinTxs { CoinsMap[cointxs.CoinType] = true } rewart := env.bc.Processor(env.header.Version).ProcessReward(env.State, env.header, nil, nil, nil) rewardTxmap := env.makeTransaction(rewart) - allfinalTxs := make([]types.CoinSelfTransaction,0,len(coins)) //按币种存放的所有交易切片(先放分区币种的奖励交易,然后存该币种的普通交易) - allfinalRecpets := make([]types.CoinReceipts,0,len(coins)) //按币种存放的所有收据切片(先放分区币种的奖励收据,然后存该币种的普通收据) + allfinalTxs := make([]types.CoinSelfTransaction, 0, len(coins)) //按币种存放的所有交易切片(先放分区币种的奖励交易,然后存该币种的普通交易) + allfinalRecpets := make([]types.CoinReceipts, 0, len(coins)) //按币种存放的所有收据切片(先放分区币种的奖励收据,然后存该币种的普通收据) //防止多币种交易下一个区块的没有该币种的交易,但有该币种奖励 - tmpcoins := make([]string,0) - for rewardCoinname,_ := range rewardTxmap{ + tmpcoins := make([]string, 0) + for rewardCoinname, _ := range rewardTxmap { CoinsMap[rewardCoinname] = true } - for coinname,_ := range CoinsMap{ - tmpcoins = append(tmpcoins,coinname) + for coinname, _ := range CoinsMap { + tmpcoins = append(tmpcoins, coinname) } coins = myCoinsort(tmpcoins) //先跑MAN奖励交易,后跑其他币种奖励交易 - for _,coinname := range coins{ + for _, coinname := range coins { var tCoinReceipt types.CoinReceipts var tCointxs types.CoinSelfTransaction - tmpTxs := make([]types.SelfTransaction,0) - tmpRecepts := make(types.Receipts,0) + tmpTxs := make([]types.SelfTransaction, 0) + tmpRecepts := make(types.Receipts, 0) //tmpcoinRecpets := make([]types.CoinReceipts,0,len(coins)) for _, tx := range rewardTxmap[coinname] { - err, _ ,recpts:= env.s_commitTransaction(tx, common.Address{}, new(core.GasPool).AddGas(0)) + err, _, recpts := env.s_commitTransaction(tx, common.Address{}, new(core.GasPool).AddGas(0)) if err != nil { log.Error("work.go", "ProcessTransactions:::reward Tx call Error", err) continue } - tmpTxs = append(tmpTxs,tx) //奖励放对应分区币种的前面 - tmpRecepts = append(tmpRecepts,recpts) //奖励放对应分区币种的前面 + tmpTxs = append(tmpTxs, tx) //奖励放对应分区币种的前面 + tmpRecepts = append(tmpRecepts, recpts) //奖励放对应分区币种的前面 } //tmpTxs = append(tmpTxs,tRewartTx...) //奖励交易放对应分区币种的前面 - for _,cointxs := range finalCoinTxs{ - if coinname == cointxs.CoinType{ - tmpTxs = append(tmpTxs,cointxs.Txser...) + for _, cointxs := range finalCoinTxs { + if coinname == cointxs.CoinType { + tmpTxs = append(tmpTxs, cointxs.Txser...) } } tCointxs.CoinType = coinname tCointxs.Txser = tmpTxs - allfinalTxs = append(allfinalTxs,tCointxs) + allfinalTxs = append(allfinalTxs, tCointxs) - for _,coinrecpts := range finalCoinRecpets{ - if coinname == coinrecpts.CoinType{ - tmpRecepts = append(tmpRecepts,coinrecpts.Receiptlist...) + for _, coinrecpts := range finalCoinRecpets { + if coinname == coinrecpts.CoinType { + tmpRecepts = append(tmpRecepts, coinrecpts.Receiptlist...) } } tCoinReceipt.CoinType = coinname tCoinReceipt.Receiptlist = tmpRecepts - allfinalRecpets = append(allfinalRecpets,tCoinReceipt) + allfinalRecpets = append(allfinalRecpets, tCoinReceipt) } - env.State.Finalise("",true) + env.State.Finalise("", true) env.txs = allfinalTxs env.Receipts = allfinalRecpets return @@ -673,33 +673,33 @@ func (env *Work) ProcessBroadcastTransactions(mux *event.TypeMux, txs []types.Co func mysort(s []types.CoinSelfTransaction) (sortCointxs []types.CoinSelfTransaction) { tmap := make(map[string][]types.SelfTransaction) - keys := make([]string,0) - coinsnoman := make([]string,0) - coins := make([]string,0) - for _,k := range s{ + keys := make([]string, 0) + coinsnoman := make([]string, 0) + coins := make([]string, 0) + for _, k := range s { txs := tmap[k.CoinType] - txs = append(txs,k.Txser...) + txs = append(txs, k.Txser...) tmap[k.CoinType] = txs - keys = append(keys,k.CoinType) + keys = append(keys, k.CoinType) } sort.Strings(keys) isHaveMan := false - for _,key := range keys{ - if key == params.MAN_COIN{ + for _, key := range keys { + if key == params.MAN_COIN { isHaveMan = true continue } - coinsnoman = append(coinsnoman,key) + coinsnoman = append(coinsnoman, key) } - if isHaveMan{ - coins = append(coins,params.MAN_COIN) + if isHaveMan { + coins = append(coins, params.MAN_COIN) } - coins = append(coins,coinsnoman...) - for _,coinname := range coins{ + coins = append(coins, coinsnoman...) + for _, coinname := range coins { var cointx types.CoinSelfTransaction cointx.CoinType = coinname - cointx.Txser = append(cointx.Txser,tmap[coinname]...) - sortCointxs = append(sortCointxs,cointx) + cointx.Txser = append(cointx.Txser, tmap[coinname]...) + sortCointxs = append(sortCointxs, cointx) } return sortCointxs } @@ -714,16 +714,16 @@ func (env *Work) ConsensusTransactions(mux *event.TypeMux, txs []types.CoinSelfT env.State.UpdateTxForBtree(uint32(tim)) env.State.UpdateTxForBtreeBytime(uint32(tim)) from := make(map[string][]common.Address) - coins := make([]string,0,len(txs)+1) + coins := make([]string, 0, len(txs)+1) log.Info("work", "关键时间点", "开始执行交易", "time", time.Now(), "块高", env.header.Number) - if len(txs)>1{ + if len(txs) > 1 { txs = mysort(txs) } for _, tx := range txs { env.packNum = 0 env.coinType = tx.CoinType - coins = append(coins,tx.CoinType) + coins = append(coins, tx.CoinType) // If we don't have enough gas for any further transactions then we're done if env.gasPool.Gas() < params.TxGas { log.Trace("Not enough gas for further transactions", "have", env.gasPool, "want", params.TxGas) @@ -731,7 +731,7 @@ func (env *Work) ConsensusTransactions(mux *event.TypeMux, txs []types.CoinSelfT } // Start executing the transaction for _, t := range tx.Txser { - if uint64(env.packNum) >= params.OtherCoinPackNum && env.coinType != params.MAN_COIN{ + if uint64(env.packNum) >= params.OtherCoinPackNum && env.coinType != params.MAN_COIN { break } env.State.Prepare(t.Hash(), common.Hash{}, env.tcount) @@ -747,44 +747,44 @@ func (env *Work) ConsensusTransactions(mux *event.TypeMux, txs []types.CoinSelfT } } - coinsnoman := make([]string,0,len(txs)+1) - for _,coinname := range coins{ - if coinname == params.MAN_COIN{ + coinsnoman := make([]string, 0, len(txs)+1) + for _, coinname := range coins { + if coinname == params.MAN_COIN { continue } - coinsnoman = append(coinsnoman,coinname) //fllow + coinsnoman = append(coinsnoman, coinname) //fllow } sort.Strings(coinsnoman) - tcoins := make([]string,0,len(txs)+1) - tcoins = append(tcoins,params.MAN_COIN) - tcoins = append(tcoins,coinsnoman...) + tcoins := make([]string, 0, len(txs)+1) + tcoins = append(tcoins, params.MAN_COIN) + tcoins = append(tcoins, coinsnoman...) coins = tcoins //前面是man币,后面是排序过的币种 //finalCoinTxs -按币种存放的所有交易;finalCoinRecpets -按币种存放的所有收据 - tCoinTxs,tCoinRecpets := types.GetCoinTXRS(env.transer,env.recpts) // env.transer就是originalTxs - finalCoinTxs := make([]types.CoinSelfTransaction,0,len(coins)) - finalCoinRecpets := make([]types.CoinReceipts,0,len(coins)) + tCoinTxs, tCoinRecpets := types.GetCoinTXRS(env.transer, env.recpts) // env.transer就是originalTxs + finalCoinTxs := make([]types.CoinSelfTransaction, 0, len(coins)) + finalCoinRecpets := make([]types.CoinReceipts, 0, len(coins)) //查看是否有MAN分区(MAN币),如果有直接append到finalCoinTxs,没有就创建MAN分区用于后面存奖励交易 isHaveManCoin := false - for _,tcoin := range tCoinTxs{ - if tcoin.CoinType == params.MAN_COIN{ + for _, tcoin := range tCoinTxs { + if tcoin.CoinType == params.MAN_COIN { isHaveManCoin = true break } } - if !isHaveManCoin{ + if !isHaveManCoin { var MANCoinReceipt types.CoinReceipts var MANtmCointxs types.CoinSelfTransaction MANtmCointxs.CoinType = params.MAN_COIN //MAN分区必须有,用于存放矿工和验证者奖励费 MANCoinReceipt.CoinType = params.MAN_COIN - finalCoinTxs = append(finalCoinTxs,MANtmCointxs) - finalCoinRecpets = append(finalCoinRecpets,MANCoinReceipt) + finalCoinTxs = append(finalCoinTxs, MANtmCointxs) + finalCoinRecpets = append(finalCoinRecpets, MANCoinReceipt) } - finalCoinTxs = append(finalCoinTxs,tCoinTxs...) - finalCoinRecpets = append(finalCoinRecpets,tCoinRecpets...) + finalCoinTxs = append(finalCoinTxs, tCoinTxs...) + finalCoinRecpets = append(finalCoinRecpets, tCoinRecpets...) //env.State.Finalise("MAN",true) CoinsMap := make(map[string]bool) //存放所有币种 - for _,cointxs := range finalCoinTxs{ + for _, cointxs := range finalCoinTxs { CoinsMap[cointxs.CoinType] = true } @@ -792,56 +792,56 @@ func (env *Work) ConsensusTransactions(mux *event.TypeMux, txs []types.CoinSelfT rewart := env.bc.Processor(env.header.Version).ProcessReward(env.State, env.header, upTime, from, env.mapcoingasUse.mapcoin) rewardTxmap := env.makeTransaction(rewart) - allfinalTxs := make([]types.CoinSelfTransaction,0,len(coins)) //按币种存放的所有交易切片(先放分区币种的奖励交易,然后存该币种的普通交易) - allfinalRecpets := make([]types.CoinReceipts,0,len(coins)) //按币种存放的所有收据切片(先放分区币种的奖励收据,然后存该币种的普通收据) + allfinalTxs := make([]types.CoinSelfTransaction, 0, len(coins)) //按币种存放的所有交易切片(先放分区币种的奖励交易,然后存该币种的普通交易) + allfinalRecpets := make([]types.CoinReceipts, 0, len(coins)) //按币种存放的所有收据切片(先放分区币种的奖励收据,然后存该币种的普通收据) //防止多币种交易下一个区块的没有该币种的交易,但有该币种奖励 - tmpcoins := make([]string,0) - for rewardCoinname,_ := range rewardTxmap{ + tmpcoins := make([]string, 0) + for rewardCoinname, _ := range rewardTxmap { CoinsMap[rewardCoinname] = true } - for coinname,_ := range CoinsMap{ - tmpcoins = append(tmpcoins,coinname) + for coinname, _ := range CoinsMap { + tmpcoins = append(tmpcoins, coinname) } coins = myCoinsort(tmpcoins) //先跑MAN奖励交易,后跑其他币种奖励交易 - for _,coinname := range coins{ + for _, coinname := range coins { var tCoinReceipt types.CoinReceipts var tCointxs types.CoinSelfTransaction - tmpTxs := make([]types.SelfTransaction,0) - tmpRecepts := make(types.Receipts,0) + tmpTxs := make([]types.SelfTransaction, 0) + tmpRecepts := make(types.Receipts, 0) //tmpcoinRecpets := make([]types.CoinReceipts,0,len(coins)) for _, tx := range rewardTxmap[coinname] { - err, _ ,recpts:= env.s_commitTransaction(tx, common.Address{}, new(core.GasPool).AddGas(0)) + err, _, recpts := env.s_commitTransaction(tx, common.Address{}, new(core.GasPool).AddGas(0)) if err != nil { log.Error("work.go", "ProcessTransactions:::reward Tx call Error", err) continue } - tmpTxs = append(tmpTxs,tx) //奖励放对应分区币种的前面 - tmpRecepts = append(tmpRecepts,recpts) //奖励放对应分区币种的前面 + tmpTxs = append(tmpTxs, tx) //奖励放对应分区币种的前面 + tmpRecepts = append(tmpRecepts, recpts) //奖励放对应分区币种的前面 } //tmpTxs = append(tmpTxs,tRewartTx...) //奖励交易放对应分区币种的前面 - for _,cointxs := range finalCoinTxs{ - if coinname == cointxs.CoinType{ - tmpTxs = append(tmpTxs,cointxs.Txser...) + for _, cointxs := range finalCoinTxs { + if coinname == cointxs.CoinType { + tmpTxs = append(tmpTxs, cointxs.Txser...) } } tCointxs.CoinType = coinname tCointxs.Txser = tmpTxs - allfinalTxs = append(allfinalTxs,tCointxs) - for _,coinrecpts := range finalCoinRecpets{ - if coinname == coinrecpts.CoinType{ - tmpRecepts = append(tmpRecepts,coinrecpts.Receiptlist...) + allfinalTxs = append(allfinalTxs, tCointxs) + for _, coinrecpts := range finalCoinRecpets { + if coinname == coinrecpts.CoinType { + tmpRecepts = append(tmpRecepts, coinrecpts.Receiptlist...) } } tCoinReceipt.CoinType = coinname tCoinReceipt.Receiptlist = tmpRecepts - allfinalRecpets = append(allfinalRecpets,tCoinReceipt) + allfinalRecpets = append(allfinalRecpets, tCoinReceipt) } env.txs = allfinalTxs env.Receipts = allfinalRecpets - env.State.Finalise("",true) + env.State.Finalise("", true) if len(coalescedLogs) > 0 || env.tcount > 0 { go func(logs []types.CoinLogs, tcount int) { diff --git a/mc/events.go b/mc/events.go index 979ccd39..668bae91 100644 --- a/mc/events.go +++ b/mc/events.go @@ -74,5 +74,13 @@ const ( BlockInserted + //leaderV2 + HD_V2_LeaderReelectInquiryReq + HD_V2_LeaderReelectInquiryRsp + HD_V2_LeaderReelectReq + HD_V2_LeaderReelectVote + HD_V2_LeaderReelectBroadcast + HD_V2_LeaderReelectBroadcastRsp + LastEventCode ) diff --git a/mc/msgdef2.0.go b/mc/msgdef2.0.go new file mode 100644 index 00000000..3effce94 --- /dev/null +++ b/mc/msgdef2.0.go @@ -0,0 +1,65 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php +package mc + +import ( + "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/core/types" +) + +type HD_V2_ReelectInquiryReqMsg struct { + Number uint64 + HeaderTime uint64 + ConsensusTurn ConsensusTurnInfo + ReelectTurn uint32 + TimeStamp uint64 + Master common.Address + From common.Address +} + +type HD_V2_ReelectInquiryRspMsg struct { + Number uint64 + ReqHash common.Hash + Type ReelectRSPType + AgreeSign common.Signature + POSResult *HD_BlkConsensusReqMsg + RLResult *HD_V2_ReelectLeaderConsensus + NewBlock *types.Header + From common.Address +} + +type HD_V2_ReelectLeaderReqMsg struct { + InquiryReq *HD_V2_ReelectInquiryReqMsg + AgreeSigns []common.Signature + TimeStamp uint64 +} + +//共识投票消息 +type HD_V2_ConsensusVote struct { + SignHash common.Hash + Number uint64 + Sign common.Signature + From common.Address +} + +type HD_V2_ReelectLeaderConsensus struct { + Req *HD_V2_ReelectLeaderReqMsg + Votes []common.Signature +} + +type HD_V2_ReelectBroadcastMsg struct { + Number uint64 + Type ReelectRSPType + POSResult *HD_BlkConsensusReqMsg + RLResult *HD_V2_ReelectLeaderConsensus + TimeStamp uint64 + From common.Address +} + +type HD_V2_ReelectBroadcastRspMsg struct { + Number uint64 + ResultHash common.Hash + Sign common.Signature + From common.Address +} diff --git a/metrics/influxdb/influxdb.go b/metrics/influxdb/influxdb.go index 3cef8530..a2bf7137 100644 --- a/metrics/influxdb/influxdb.go +++ b/metrics/influxdb/influxdb.go @@ -9,8 +9,8 @@ import ( uurl "net/url" "time" - "github.com/influxdata/influxdb/client" "github.com/MatrixAINetwork/go-matrix/metrics" + "github.com/influxdata/influxdb/client" ) type reporter struct { diff --git a/msgsend/dispatcher.go b/msgsend/dispatcher.go index 68a13e20..362baedc 100644 --- a/msgsend/dispatcher.go +++ b/msgsend/dispatcher.go @@ -81,7 +81,7 @@ func (self *HD) receive() { select { case data := <-self.dataChan: subCode := mc.EventCode(data.Data.SubCode) - log.Trace("HD", "SubCode", subCode) + log.Trace("HD", "SubCode", subCode, "from", data.Account.Hex()) codec, err := self.findCodec(subCode) if err != nil { log.ERROR("HD", "receive findCodec err", err) diff --git a/msgsend/msgCodec.go b/msgsend/msgCodec.go index b344c2bc..7a99d979 100644 --- a/msgsend/msgCodec.go +++ b/msgsend/msgCodec.go @@ -29,6 +29,13 @@ func (self *HD) initCodec() { self.registerCodec(mc.HD_LeaderReelectBroadcastRsp, new(lrResultBCRspCodec)) self.registerCodec(mc.HD_FullBlockReq, new(fullBlockReqCodec)) self.registerCodec(mc.HD_FullBlockRsp, new(fullBlockRspCodec)) + + self.registerCodec(mc.HD_V2_LeaderReelectInquiryReq, new(lrInquiryReqCodecV2)) + self.registerCodec(mc.HD_V2_LeaderReelectInquiryRsp, new(lrInquiryRspCodecV2)) + self.registerCodec(mc.HD_V2_LeaderReelectReq, new(lrReqCodecV2)) + self.registerCodec(mc.HD_V2_LeaderReelectVote, new(lrVoteCodecV2)) + self.registerCodec(mc.HD_V2_LeaderReelectBroadcast, new(lrResultBCCodecV2)) + self.registerCodec(mc.HD_V2_LeaderReelectBroadcastRsp, new(lrResultBCRspCodecV2)) } //每个模块需要自己实现这两个接口 diff --git a/msgsend/msgCodec2.0.go b/msgsend/msgCodec2.0.go new file mode 100644 index 00000000..0e48fa52 --- /dev/null +++ b/msgsend/msgCodec2.0.go @@ -0,0 +1,153 @@ +// Copyright (c) 2018 The MATRIX Authors +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php + +package msgsend + +import ( + "encoding/json" + "github.com/MatrixAINetwork/go-matrix/common" + "github.com/MatrixAINetwork/go-matrix/mc" + "github.com/pkg/errors" +) + +//////////////////////////////////////////////////////////////////////// +// 重选询问请求消息 +type lrInquiryReqCodecV2 struct { +} + +func (*lrInquiryReqCodecV2) EncodeFn(msg interface{}) ([]byte, error) { + data, err := json.Marshal(msg) + if err != nil { + return nil, errors.Errorf("json.Marshal failed: %s", err) + } + return data, nil +} + +func (*lrInquiryReqCodecV2) DecodeFn(data []byte, from common.Address) (interface{}, error) { + msg := new(mc.HD_V2_ReelectInquiryReqMsg) + err := json.Unmarshal([]byte(data), msg) + if err != nil { + return nil, errors.Errorf("json.Unmarshal failed: %s", err) + } + msg.From.Set(from) + return msg, nil +} + +//////////////////////////////////////////////////////////////////////// +// 重选询问响应消息 +type lrInquiryRspCodecV2 struct { +} + +func (*lrInquiryRspCodecV2) EncodeFn(msg interface{}) ([]byte, error) { + data, err := json.Marshal(msg) + if err != nil { + return nil, errors.Errorf("json.Marshal failed: %s", err) + } + return data, nil +} + +func (*lrInquiryRspCodecV2) DecodeFn(data []byte, from common.Address) (interface{}, error) { + msg := new(mc.HD_V2_ReelectInquiryRspMsg) + err := json.Unmarshal([]byte(data), msg) + if err != nil { + return nil, errors.Errorf("json.Unmarshal failed: %s", err) + } + msg.From.Set(from) + return msg, nil +} + +//////////////////////////////////////////////////////////////////////// +// leader重选请求消息 +type lrReqCodecV2 struct { +} + +func (*lrReqCodecV2) EncodeFn(msg interface{}) ([]byte, error) { + data, err := json.Marshal(msg) + if err != nil { + return nil, errors.Errorf("json.Marshal failed: %s", err) + } + return data, nil +} + +func (*lrReqCodecV2) DecodeFn(data []byte, from common.Address) (interface{}, error) { + msg := new(mc.HD_V2_ReelectLeaderReqMsg) + err := json.Unmarshal([]byte(data), msg) + if err != nil { + return nil, errors.Errorf("json.Unmarshal failed: %s", err) + } + if msg.InquiryReq == nil { + return nil, errors.Errorf("'InquiryReq' of the msg is nil") + } + msg.InquiryReq.From.Set(from) + return msg, nil +} + +//////////////////////////////////////////////////////////////////////// +// leader重选投票消息 +type lrVoteCodecV2 struct { +} + +func (*lrVoteCodecV2) EncodeFn(msg interface{}) ([]byte, error) { + data, err := json.Marshal(msg) + if err != nil { + return nil, errors.Errorf("json.Marshal failed: %s", err) + } + return data, nil +} + +func (*lrVoteCodecV2) DecodeFn(data []byte, from common.Address) (interface{}, error) { + msg := new(mc.HD_V2_ConsensusVote) + err := json.Unmarshal([]byte(data), msg) + if err != nil { + return nil, errors.Errorf("json.Unmarshal failed: %s", err) + } + msg.From.Set(from) + return msg, nil +} + +//////////////////////////////////////////////////////////////////////// +// leader重选结果广播消息 +type lrResultBCCodecV2 struct { +} + +func (*lrResultBCCodecV2) EncodeFn(msg interface{}) ([]byte, error) { + data, err := json.Marshal(msg) + if err != nil { + return nil, errors.Errorf("json.Marshal failed: %s", err) + } + return data, nil +} + +func (*lrResultBCCodecV2) DecodeFn(data []byte, from common.Address) (interface{}, error) { + msg := new(mc.HD_V2_ReelectBroadcastMsg) + err := json.Unmarshal([]byte(data), msg) + if err != nil { + return nil, errors.Errorf("json.Unmarshal failed: %s", err) + } + msg.From.Set(from) + return msg, nil +} + +//////////////////////////////////////////////////////////////////////// +// leader重选结果广播响应消息 +type lrResultBCRspCodecV2 struct { +} + +func (*lrResultBCRspCodecV2) EncodeFn(msg interface{}) ([]byte, error) { + data, err := json.Marshal(msg) + if err != nil { + return nil, errors.Errorf("json.Marshal failed: %s", err) + } + return data, nil +} + +func (*lrResultBCRspCodecV2) DecodeFn(data []byte, from common.Address) (interface{}, error) { + msg := new(mc.HD_V2_ReelectBroadcastRspMsg) + err := json.Unmarshal([]byte(data), msg) + if err != nil { + return nil, errors.Errorf("json.Unmarshal failed: %s", err) + } + msg.From.Set(from) + return msg, nil +} diff --git a/p2p/discover/udp.go b/p2p/discover/udp.go index f34f3b10..abdcb537 100644 --- a/p2p/discover/udp.go +++ b/p2p/discover/udp.go @@ -21,7 +21,7 @@ import ( "github.com/MatrixAINetwork/go-matrix/rlp" ) -const Version = 4 +const Version = 5 // Errors var ( diff --git a/p2p/discover/udp_test.go b/p2p/discover/udp_test.go index 6284b3bb..5f011078 100644 --- a/p2p/discover/udp_test.go +++ b/p2p/discover/udp_test.go @@ -21,10 +21,10 @@ import ( "testing" "time" - "github.com/davecgh/go-spew/spew" "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/crypto" "github.com/MatrixAINetwork/go-matrix/rlp" + "github.com/davecgh/go-spew/spew" ) func init() { diff --git a/p2p/nat/nat.go b/p2p/nat/nat.go index e3a32040..28c98cda 100644 --- a/p2p/nat/nat.go +++ b/p2p/nat/nat.go @@ -13,8 +13,8 @@ import ( "sync" "time" - "github.com/jackpal/go-nat-pmp" "github.com/MatrixAINetwork/go-matrix/log" + "github.com/jackpal/go-nat-pmp" ) // An implementation of nat.Interface can map local ports to ports diff --git a/p2p/rlpx.go b/p2p/rlpx.go index 2f7c444d..88302d60 100644 --- a/p2p/rlpx.go +++ b/p2p/rlpx.go @@ -23,13 +23,13 @@ import ( "sync" "time" - "github.com/golang/snappy" "github.com/MatrixAINetwork/go-matrix/crypto" "github.com/MatrixAINetwork/go-matrix/crypto/ecies" "github.com/MatrixAINetwork/go-matrix/crypto/secp256k1" "github.com/MatrixAINetwork/go-matrix/crypto/sha3" "github.com/MatrixAINetwork/go-matrix/p2p/discover" "github.com/MatrixAINetwork/go-matrix/rlp" + "github.com/golang/snappy" ) const ( diff --git a/p2p/simulations/adapters/docker.go b/p2p/simulations/adapters/docker.go index 38f239e6..ebec7b6c 100644 --- a/p2p/simulations/adapters/docker.go +++ b/p2p/simulations/adapters/docker.go @@ -15,10 +15,10 @@ import ( "runtime" "strings" - "github.com/docker/docker/pkg/reexec" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/p2p/discover" "github.com/MatrixAINetwork/go-matrix/pod" + "github.com/docker/docker/pkg/reexec" ) // DockerAdapter is a NodeAdapter which runs simulation nodes inside Docker diff --git a/p2p/simulations/adapters/exec.go b/p2p/simulations/adapters/exec.go index b6b14f32..202d1b97 100644 --- a/p2p/simulations/adapters/exec.go +++ b/p2p/simulations/adapters/exec.go @@ -21,12 +21,12 @@ import ( "syscall" "time" - "github.com/docker/docker/pkg/reexec" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/p2p" "github.com/MatrixAINetwork/go-matrix/p2p/discover" "github.com/MatrixAINetwork/go-matrix/pod" "github.com/MatrixAINetwork/go-matrix/rpc" + "github.com/docker/docker/pkg/reexec" "golang.org/x/net/websocket" ) diff --git a/p2p/simulations/adapters/types.go b/p2p/simulations/adapters/types.go index 3fb6fa84..256c0f1b 100644 --- a/p2p/simulations/adapters/types.go +++ b/p2p/simulations/adapters/types.go @@ -12,12 +12,12 @@ import ( "net" "os" - "github.com/docker/docker/pkg/reexec" "github.com/MatrixAINetwork/go-matrix/crypto" "github.com/MatrixAINetwork/go-matrix/p2p" "github.com/MatrixAINetwork/go-matrix/p2p/discover" "github.com/MatrixAINetwork/go-matrix/pod" "github.com/MatrixAINetwork/go-matrix/rpc" + "github.com/docker/docker/pkg/reexec" ) // Node represents a node in a simulation network which is created by a diff --git a/p2p/simulations/http.go b/p2p/simulations/http.go index 8cd07806..d6c89c92 100644 --- a/p2p/simulations/http.go +++ b/p2p/simulations/http.go @@ -17,12 +17,12 @@ import ( "strings" "sync" - "github.com/julienschmidt/httprouter" "github.com/MatrixAINetwork/go-matrix/event" "github.com/MatrixAINetwork/go-matrix/p2p" "github.com/MatrixAINetwork/go-matrix/p2p/discover" "github.com/MatrixAINetwork/go-matrix/p2p/simulations/adapters" "github.com/MatrixAINetwork/go-matrix/rpc" + "github.com/julienschmidt/httprouter" "golang.org/x/net/websocket" ) diff --git a/params/config.go b/params/config.go index b470dd81..4a8003fb 100644 --- a/params/config.go +++ b/params/config.go @@ -320,9 +320,11 @@ type Rules struct { IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool IsByzantium bool } + var grules Rules + func (c *ChainConfig) Rules(num *big.Int) *Rules { - if grules.ChainId == nil{ + if grules.ChainId == nil { chainId := c.ChainId if chainId == nil { chainId = new(big.Int) diff --git a/params/manparams/matrixconfig.go b/params/manparams/matrixconfig.go index 5946f409..567c09ec 100644 --- a/params/manparams/matrixconfig.go +++ b/params/manparams/matrixconfig.go @@ -5,15 +5,15 @@ package manparams import ( + "bufio" "encoding/json" "fmt" + "github.com/MatrixAINetwork/go-matrix/base58" + "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/params" "io/ioutil" "os" - "github.com/MatrixAINetwork/go-matrix/common" - "github.com/MatrixAINetwork/go-matrix/base58" - "bufio" ) const ( @@ -41,10 +41,11 @@ const ( EveryBroadcastSeed = "everybroadcastseed" EveryBroadcastSeed_Plug_MaxNonce = "MaxNonce" - ElectPlug_layerd = "layerd" - ElectPlug_stock = "stock" - ELectPlug_direct = "direct" + ElectPlug_layerd = "layerd" + ElectPlug_stock = "stock" + ELectPlug_direct = "direct" ElectPlug_layerdMEP = "layerd_MEP" + ElectPlug_layerdBSS = "layerd_BSS" ) var ( @@ -77,13 +78,13 @@ func Config_Init(Config_PATH string) { fmt.Println("无bootnode节点") os.Exit(-1) } - if len(v.ConsensusAccount) > 0{ - for _,consensusmanaddr := range v.ConsensusAccount{ - tmpaccount,err := base58.Base58DecodeToAddress(consensusmanaddr) - if err == nil{ - common.ConsensusAccounts = append(common.ConsensusAccounts,tmpaccount) //协商的用于发送黑名单账户列表 - }else{ - log.Error("协商账户格式错误","err",err) + if len(v.ConsensusAccount) > 0 { + for _, consensusmanaddr := range v.ConsensusAccount { + tmpaccount, err := base58.Base58DecodeToAddress(consensusmanaddr) + if err == nil { + common.ConsensusAccounts = append(common.ConsensusAccounts, tmpaccount) //协商的用于发送黑名单账户列表 + } else { + log.Error("协商账户格式错误", "err", err) } } } @@ -91,29 +92,28 @@ func Config_Init(Config_PATH string) { } func ReadBlacklist(path string) { - file,err := os.Open(path) - if err == nil{ + file, err := os.Open(path) + if err == nil { reader := bufio.NewReader(file) - for{ - buf,_,err := reader.ReadLine() - if err != nil{ + for { + buf, _, err := reader.ReadLine() + if err != nil { break } - addr,err := base58.Base58DecodeToAddress(string(buf)) - if err != nil{ - log.Error("ReadBlacklist","black format error",string(buf)) + addr, err := base58.Base58DecodeToAddress(string(buf)) + if err != nil { + log.Error("ReadBlacklist", "black format error", string(buf)) continue } - common.BlackListString = append(common.BlackListString,string(buf)) - common.BlackList = append(common.BlackList,addr) + common.BlackListString = append(common.BlackListString, string(buf)) + common.BlackList = append(common.BlackList, addr) } } file.Close() } - type Config struct { - BootNode []string + BootNode []string ConsensusAccount []string } diff --git a/params/manparams/version.go b/params/manparams/version.go index d3d003f7..7da63ff5 100644 --- a/params/manparams/version.go +++ b/params/manparams/version.go @@ -10,18 +10,35 @@ import ( const ( VersionAlpha = "1.0.0.0" //增加版本号示例 - VersionBeta = "1.0.0.1" - //VersionSignatureBeta = "0xc3a8b3c887e2a896cca7a3d86997ac458d4f2e1ac0472fbc37290ee131eb82400cde214d72427dcf83ad22eb5b98a269311c1589fab14d0eeeee632617714cc000" - //VersionNumBeta = uint64(32) + VersionBeta = "1.0.0.1" + VersionGamma = "1.0.0.2" + //todo:上线后需要修改 + VersionSignatureGamma = "0x69bd3f6dbbca1012d7f68b5263900c9561da66b675088bc613460701c59b056e7b2695e1c3f84de28afd8f6797f1244bef1652a96d6cb58de151969cdc0956f700" //jerry + VersionNumGamma = uint64(330003) + newP2PVersionTimeStamp = 1558346400 ) var VersionList [][]byte var VersionSignatureMap map[string][]common.Signature func init() { - VersionList = [][]byte{[]byte(VersionAlpha) /*[]byte(VersionBeta)*/} + VersionList = [][]byte{[]byte(VersionAlpha), []byte(VersionBeta), []byte(VersionGamma)} VersionSignatureMap = make(map[string][]common.Signature) - //VersionSignatureMap[VersionBeta] = []common.Signature{common.BytesToSignature(common.FromHex(VersionSignatureBeta))} + VersionSignatureMap[VersionGamma] = []common.Signature{common.BytesToSignature(common.FromHex(VersionSignatureGamma))} +} + +// version1 > version2 return 1 +// version1 = version2 return 0 +// version1 < version2 return -1 +func VersionCmp(version1 string, version2 string) int { + if version1 == version2 { + return 0 + } + if version1 > version2 { + return 1 + } else { + return -1 + } } func IsCorrectVersion(version []byte) bool { @@ -48,3 +65,6 @@ func GetVersionSignature(parentBlock *types.Block, version []byte) []common.Sign return nil } +func CanSwitchGammaCanonicalChain(currentTime int64) bool { + return currentTime > newP2PVersionTimeStamp +} diff --git a/params/protocol_params.go b/params/protocol_params.go index c8f308c9..06d66076 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -14,22 +14,22 @@ var ( ) const ( - GasLimitBoundDivisor uint64 = 1024 // The bound divisor of the gas limit, used in update calculations. - MinGasLimit uint64 = 1050000000 // Minimum the gas limit may ever be. - GenesisGasLimit uint64 = 1050000000 // Gas limit of the Genesis block. - OtherCoinPackNum uint64 = GenesisGasLimit / 21000 / 100 //其他币种打包限制为MAN的1/100 - MaximumExtraDataSize uint64 = 32 // Maximum size extra data may be after Genesis. - ExpByteGas uint64 = 10 // Times ceil(log256(exponent)) for the EXP instruction. - SloadGas uint64 = 50 // Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. - CallValueTransferGas uint64 = 9000 // Paid for CALL when the value transfer is non-zero. - CallNewAccountGas uint64 = 25000 // Paid for CALL when the destination address didn't exist prior. - TxGas uint64 = 21000 // Per transaction not creating a contract. NOTE: Not payable on data of calls between transactions. - TxGasContractCreation uint64 = 53000 // Per transaction that creates a contract. NOTE: Not payable on data of calls between transactions. - TxDataZeroGas uint64 = 4 // Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. - QuadCoeffDiv uint64 = 512 // Divisor for the quadratic particle of the memory cost equation. - SstoreSetGas uint64 = 20000 // Once per SLOAD operation. - LogDataGas uint64 = 8 // Per byte in a LOG* operation's data. - CallStipend uint64 = 2300 // Free gas given at beginning of call. + GasLimitBoundDivisor uint64 = 1024 // The bound divisor of the gas limit, used in update calculations. + MinGasLimit uint64 = 1050000000 // Minimum the gas limit may ever be. + GenesisGasLimit uint64 = 1050000000 // Gas limit of the Genesis block. + OtherCoinPackNum uint64 = GenesisGasLimit / 21000 / 100 //其他币种打包限制为MAN的1/100 + MaximumExtraDataSize uint64 = 32 // Maximum size extra data may be after Genesis. + ExpByteGas uint64 = 10 // Times ceil(log256(exponent)) for the EXP instruction. + SloadGas uint64 = 50 // Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. + CallValueTransferGas uint64 = 9000 // Paid for CALL when the value transfer is non-zero. + CallNewAccountGas uint64 = 25000 // Paid for CALL when the destination address didn't exist prior. + TxGas uint64 = 21000 // Per transaction not creating a contract. NOTE: Not payable on data of calls between transactions. + TxGasContractCreation uint64 = 53000 // Per transaction that creates a contract. NOTE: Not payable on data of calls between transactions. + TxDataZeroGas uint64 = 4 // Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. + QuadCoeffDiv uint64 = 512 // Divisor for the quadratic particle of the memory cost equation. + SstoreSetGas uint64 = 20000 // Once per SLOAD operation. + LogDataGas uint64 = 8 // Per byte in a LOG* operation's data. + CallStipend uint64 = 2300 // Free gas given at beginning of call. Sha3Gas uint64 = 30 // Once per SHA3 operation. Sha3WordGas uint64 = 6 // Once per word of the SHA3 operation's data. @@ -70,21 +70,21 @@ const ( Bn256PairingPerPointGas uint64 = 80000 // Per-point price for an elliptic curve pairing check // - TxCount uint64 = 1000 //一对多交易最多可以支持1000笔(包括扩展之外的那一个交易) - ErrTxConsensus uint64 = 6 //错误交易需要共识的个数(超过6个节点认为该笔交易错误就可以确认删除这笔交易) - SubBlockNum uint64 = 200 //超过SubBlockNum区块高度就删除某些东西(超过20个区块就删除未打包的交易) - NonceAddOne uint64 = 0x0010000000000000 //Nonce最高位加1 - NonceSubOne uint64 = 0x0001FFFFFFFFFFFF //Nonce最高位减1 - MaxTxN uint32 = 0x1FFFF //交易编号最大值 - FloodMaxTransactions int = 200 //洪泛交易数量阈值 - TxSize uint64 = 32 * 1024 //交易的大小 - TxGasPrice uint64 = 18000000000 //交易费 - EntrustByHeight byte = 0 //按块高委托 - EntrustByTime byte = 1 //按时间委托 - EntrustByCount byte = 2 //按次数委托 - CallTxPachNum uint64 = 9999 //币种打包交易数量限制 - CoinTypeUnit uint64 = 1000000000000000000//*big.Int = new(big.Int).SetString("0xDE0B6B3A7640000",0)//new(big.Int).SetString("0xDE0B6B3A7640000",0) - CoinDampingNum int = 100 //每100个币种衰减百分之五 + TxCount uint64 = 1000 //一对多交易最多可以支持1000笔(包括扩展之外的那一个交易) + ErrTxConsensus uint64 = 6 //错误交易需要共识的个数(超过6个节点认为该笔交易错误就可以确认删除这笔交易) + SubBlockNum uint64 = 200 //超过SubBlockNum区块高度就删除某些东西(超过20个区块就删除未打包的交易) + NonceAddOne uint64 = 0x0010000000000000 //Nonce最高位加1 + NonceSubOne uint64 = 0x0001FFFFFFFFFFFF //Nonce最高位减1 + MaxTxN uint32 = 0x1FFFF //交易编号最大值 + FloodMaxTransactions int = 200 //洪泛交易数量阈值 + TxSize uint64 = 32 * 1024 //交易的大小 + TxGasPrice uint64 = 18000000000 //交易费 + EntrustByHeight byte = 0 //按块高委托 + EntrustByTime byte = 1 //按时间委托 + EntrustByCount byte = 2 //按次数委托 + CallTxPachNum uint64 = 9999 //币种打包交易数量限制 + CoinTypeUnit uint64 = 1000000000000000000 //*big.Int = new(big.Int).SetString("0xDE0B6B3A7640000",0)//new(big.Int).SetString("0xDE0B6B3A7640000",0) + CoinDampingNum int = 100 //每100个币种衰减百分之五 // Udp buffer MaxUdpBuf uint32 = 1024 * 64 @@ -98,9 +98,10 @@ const ( ) var ( - DifficultyBoundDivisor = big.NewInt(10) // The bound divisor of the difficulty, used in the update calculations. - GenesisDifficulty = big.NewInt(10) // Difficulty of the Genesis block. - MinimumDifficulty = big.NewInt(10) // The minimum that the difficulty may ever be. - DurationLimit = big.NewInt(6) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. - FloodTime = 1 * time.Second //洪泛时间阈值 + DifficultyBoundDivisor = big.NewInt(10) // The bound divisor of the difficulty, used in the update calculations. + GenesisDifficulty = big.NewInt(10) // Difficulty of the Genesis block. + MinimumDifficulty = big.NewInt(10) // The minimum that the difficulty may ever be. + DurationLimit = big.NewInt(6) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. + VersionGammaDurationLimit = big.NewInt(9) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. + FloodTime = 1 * time.Second //洪泛时间阈值 ) diff --git a/pod/node.go b/pod/node.go index 5524afa5..5c1e7d06 100644 --- a/pod/node.go +++ b/pod/node.go @@ -710,7 +710,7 @@ func (n *Node) OpenDatabase(name string, cache, handles int) (mandb.Database, er if n.config.DataDir == "" { return mandb.NewMemDatabase(), nil } - return mandb.NewLDBDatabase(n.config.resolvePath(name), cache, handles) + return mandb.NewLDBDatabase(n.config.resolvePath(name), cache, handles,2) } // ResolvePath returns the absolute path of a resource in the instance directory. diff --git a/pod/service.go b/pod/service.go index 9d17a20f..2e3e22cb 100644 --- a/pod/service.go +++ b/pod/service.go @@ -41,11 +41,11 @@ func (ctx *ServiceContext) GetConfig() *Config { // OpenDatabase opens an existing database with the given name (or creates one // if no previous can be found) from within the node's data directory. If the // node is an ephemeral one, a memory database is returned. -func (ctx *ServiceContext) OpenDatabase(name string, cache int, handles int) (mandb.Database, error) { +func (ctx *ServiceContext) OpenDatabase(name string, cache int, handles int,dbsize int) (mandb.Database, error) { if ctx.config.DataDir == "" { return mandb.NewMemDatabase(), nil } - db, err := mandb.NewLDBDatabase(ctx.config.resolvePath(name), cache, handles) + db, err := mandb.NewLDBDatabase(ctx.config.resolvePath(name), cache, handles,dbsize) if err != nil { return nil, err } diff --git a/reelection/cal.go b/reelection/cal.go index dcbd8e6f..6af05f71 100644 --- a/reelection/cal.go +++ b/reelection/cal.go @@ -54,7 +54,7 @@ func (self *ReElection) GetElectConfig(hash common.Hash) (*mc.ElectConfigInfo_Al } innerMiners, err := matrixstate.GetInnerMinerAccounts(st) - if err != nil{ + if err != nil { log.Error("MSKeyInnerList", "MSKeyAccountInnerMiners", "反射失败", "hash", hash) return nil, err } diff --git a/reelection/gen_election_topology.go b/reelection/gen_election_topology.go index 24199e01..580f5d1b 100644 --- a/reelection/gen_election_topology.go +++ b/reelection/gen_election_topology.go @@ -4,6 +4,7 @@ package reelection import ( + "github.com/MatrixAINetwork/go-matrix/ca" "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/core/matrixstate" "github.com/MatrixAINetwork/go-matrix/core/state" @@ -22,12 +23,12 @@ func (p *ReElection) GenElection(state *state.StateDBManage, preBlockHash common return p.TransferToElectionStu(info) } -func (p *ReElection) GetNetTopology(num uint64, parentHash common.Hash, bcInterval *mc.BCIntervalInfo) (*common.NetTopology, []*mc.HD_OnlineConsensusVoteResultMsg) { +func (p *ReElection) GetNetTopology(num uint64, version string, parentHash common.Hash, bcInterval *mc.BCIntervalInfo) (*common.NetTopology, []*mc.HD_OnlineConsensusVoteResultMsg) { if bcInterval.IsReElectionNumber(num + 1) { return p.genAllNetTopology(parentHash) } - return p.genChgNetTopology(num, parentHash) + return p.genChgNetTopology(num, version, parentHash) } func (p *ReElection) genAllNetTopology(parentHash common.Hash) (*common.NetTopology, []*mc.HD_OnlineConsensusVoteResultMsg) { @@ -40,7 +41,7 @@ func (p *ReElection) genAllNetTopology(parentHash common.Hash) (*common.NetTopol return p.TransferToNetTopologyAllStu(info), nil } -func (p *ReElection) genChgNetTopology(num uint64, parentHash common.Hash) (*common.NetTopology, []*mc.HD_OnlineConsensusVoteResultMsg) { +func (p *ReElection) genChgNetTopology(num uint64, version string, parentHash common.Hash) (*common.NetTopology, []*mc.HD_OnlineConsensusVoteResultMsg) { state, err := p.bc.StateAtBlockHash(parentHash) if err != nil { log.Warn(Module, "生成拓扑变化", "获取父状态树失败", "err", err) @@ -65,7 +66,7 @@ func (p *ReElection) genChgNetTopology(num uint64, parentHash common.Hash) (*com return nil, nil } - offlineNodes, onlineNods, consensusList := p.getOnlineStatus(onlineResults, topology, electState, num) + offlineNodes, onlineNods, consensusList := p.getOnlineStatus(version, onlineResults, topology, electState, num) // generate topology alter info alterInfo, err := p.GetTopoChange(parentHash, offlineNodes, onlineNods) @@ -82,7 +83,7 @@ func (p *ReElection) genChgNetTopology(num uint64, parentHash common.Hash) (*com return ans, consensusList } -func (p *ReElection) getOnlineStatus(onlineResults []*mc.HD_OnlineConsensusVoteResultMsg, topology *mc.TopologyGraph, electState *mc.ElectOnlineStatus, num uint64) ([]common.Address, []common.Address, []*mc.HD_OnlineConsensusVoteResultMsg) { +func (p *ReElection) getOnlineStatus(version string, onlineResults []*mc.HD_OnlineConsensusVoteResultMsg, topology *mc.TopologyGraph, electState *mc.ElectOnlineStatus, num uint64) ([]common.Address, []common.Address, []*mc.HD_OnlineConsensusVoteResultMsg) { offlineNodes := make([]common.Address, 0) onlineNods := make([]common.Address, 0) consensusList := make([]*mc.HD_OnlineConsensusVoteResultMsg, 0) @@ -103,6 +104,12 @@ func (p *ReElection) getOnlineStatus(onlineResults []*mc.HD_OnlineConsensusVoteR // 节点为当前拓扑图节点 if topology.AccountIsInGraph(node) { if state == mc.OffLine { + if manparams.VersionCmp(version, manparams.VersionGamma) >= 0 { + if node == ca.GetDepositAddress() { + log.Trace(Module, "生成拓扑变化信息", "不将自己的下线共识放入出块共识中", "状态", state, "node", node.Hex()) + continue + } + } offlineNodes = append(offlineNodes, node) consensusList = append(consensusList, result) } else { diff --git a/reelection/process_tate.go b/reelection/process_tate.go index 93071e63..be6995f6 100644 --- a/reelection/process_tate.go +++ b/reelection/process_tate.go @@ -2,14 +2,16 @@ package reelection import ( "errors" + "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/core" + "github.com/MatrixAINetwork/go-matrix/core/state" "github.com/MatrixAINetwork/go-matrix/core/types" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/mc" ) -func (self *ReElection) ProduceElectGraphData(block *types.Block, readFn core.PreStateReadFn) (interface{}, error) { +func (self *ReElection) ProduceElectGraphData(block *types.Block, stateDb *state.StateDBManage, readFn core.PreStateReadFn) (interface{}, error) { log.INFO(Module, "ProduceElectGraphData", "start", "height", block.Header().Number.Uint64()) defer log.INFO(Module, "ProduceElectGraphData", "end", "height", block.Header().Number.Uint64()) if err := CheckBlock(block); err != nil { @@ -29,7 +31,7 @@ func (self *ReElection) ProduceElectGraphData(block *types.Block, readFn core.Pr electStates.Number = block.Header().Number.Uint64() currentHash := block.ParentHash() - topState, err := self.HandleTopGen(currentHash) + topState, err := self.HandleTopGen(currentHash, stateDb) if self.IsMinerTopGenTiming(currentHash) { electStates.NextMinerElect = []mc.ElectNodeInfo{} electStates.NextMinerElect = append(electStates.NextMinerElect, topState.MastM...) @@ -76,7 +78,7 @@ func (self *ReElection) ProduceElectGraphData(block *types.Block, readFn core.Pr return electStates, nil } -func (self *ReElection) ProduceElectOnlineStateData(block *types.Block, readFn core.PreStateReadFn) (interface{}, error) { +func (self *ReElection) ProduceElectOnlineStateData(block *types.Block, stateDb *state.StateDBManage, readFn core.PreStateReadFn) (interface{}, error) { if err := CheckBlock(block); err != nil { log.ERROR(Module, "ProduceElectGraphData CheckBlock err ", err) return nil, err @@ -167,7 +169,7 @@ func (self *ReElection) ProduceElectOnlineStateData(block *types.Block, readFn c return electStates, nil } -func (self *ReElection) ProducePreBroadcastStateData(block *types.Block, readFn core.PreStateReadFn) (interface{}, error) { +func (self *ReElection) ProducePreBroadcastStateData(block *types.Block, stateDb *state.StateDBManage, readFn core.PreStateReadFn) (interface{}, error) { if err := CheckBlock(block); err != nil { log.ERROR(Module, "ProducePreBroadcastStateData CheckBlock err ", err) return []byte{}, err @@ -217,7 +219,7 @@ func (self *ReElection) ProducePreBroadcastStateData(block *types.Block, readFn return preBroadcast, nil } -func (self *ReElection) ProduceMinHashData(block *types.Block, readFn core.PreStateReadFn) (interface{}, error) { +func (self *ReElection) ProduceMinHashData(block *types.Block, stateDb *state.StateDBManage, readFn core.PreStateReadFn) (interface{}, error) { if err := CheckBlock(block); err != nil { log.ERROR(Module, "ProduceMinHashData CheckBlock err ", err) return []byte{}, err diff --git a/reelection/topGen.go b/reelection/topGen.go index 7e674a95..6e18efba 100644 --- a/reelection/topGen.go +++ b/reelection/topGen.go @@ -10,6 +10,7 @@ import ( "github.com/MatrixAINetwork/go-matrix/ca" "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/core/matrixstate" + "github.com/MatrixAINetwork/go-matrix/core/state" "github.com/MatrixAINetwork/go-matrix/core/vm" "github.com/MatrixAINetwork/go-matrix/log" "github.com/MatrixAINetwork/go-matrix/mc" @@ -26,7 +27,7 @@ type TopGenStatus struct { CandM []mc.ElectNodeInfo } -func (self *ReElection) HandleTopGen(hash common.Hash) (TopGenStatus, error) { +func (self *ReElection) HandleTopGen(hash common.Hash, stateDb *state.StateDBManage) (TopGenStatus, error) { topGenStatus := TopGenStatus{} if self.IsMinerTopGenTiming(hash) { //矿工生成时间 240 @@ -43,7 +44,7 @@ func (self *ReElection) HandleTopGen(hash common.Hash) (TopGenStatus, error) { if self.IsValidatorTopGenTiming(hash) { //验证者生成时间 260 log.INFO(Module, "计算验证者拓扑计算 ", hash) - MastV, BackV, CandV, err := self.ToGenValidatorTop(hash) + MastV, BackV, CandV, err := self.ToGenValidatorTop(hash, stateDb) if err != nil { log.ERROR(Module, "验证者拓扑生成错误 err", err) return topGenStatus, err @@ -203,7 +204,7 @@ func (self *ReElection) addBlockProduceBlackList(hash common.Hash) (*mc.BlockPro return produceBlackList, nil } -func (self *ReElection) ToGenValidatorTop(hash common.Hash) ([]mc.ElectNodeInfo, []mc.ElectNodeInfo, []mc.ElectNodeInfo, error) { +func (self *ReElection) ToGenValidatorTop(hash common.Hash, stateDb *state.StateDBManage) ([]mc.ElectNodeInfo, []mc.ElectNodeInfo, []mc.ElectNodeInfo, error) { //log.INFO(Module, "准备生成验证者拓扑图", "start", "hash", hash.String()) //defer log.INFO(Module, "生成验证者拓扑图结束", "end", "hash", hash.String()) height, err := self.GetNumberByHash(hash) @@ -265,7 +266,7 @@ func (self *ReElection) ToGenValidatorTop(hash common.Hash) ([]mc.ElectNodeInfo, return []mc.ElectNodeInfo{}, []mc.ElectNodeInfo{}, []mc.ElectNodeInfo{}, err } - TopRsp := elect.ValidatorTopGen(&mc.MasterValidatorReElectionReqMsg{SeqNum: height, RandSeed: seed, ValidatorList: validatoeDeposit, FoundationValidatorList: foundDeposit, ElectConfig: *electConf, VIPList: vipList, BlockProduceBlackList: *produceBlackList}) + TopRsp := elect.ValidatorTopGen(&mc.MasterValidatorReElectionReqMsg{SeqNum: height, RandSeed: seed, ValidatorList: validatoeDeposit, FoundationValidatorList: foundDeposit, ElectConfig: *electConf, VIPList: vipList, BlockProduceBlackList: *produceBlackList}, stateDb) return TopRsp.MasterValidator, TopRsp.BackUpValidator, TopRsp.CandidateValidator, nil diff --git a/reelection/verify_election_topology.go b/reelection/verify_election_topology.go index d261f649..53cc7320 100644 --- a/reelection/verify_election_topology.go +++ b/reelection/verify_election_topology.go @@ -47,12 +47,12 @@ func (p *ReElection) VerifyElection(header *types.Header, state *state.StateDBMa return nil } -func (p *ReElection) VerifyNetTopology(header *types.Header, onlineConsensusResults []*mc.HD_OnlineConsensusVoteResultMsg) error { +func (p *ReElection) VerifyNetTopology(version string, header *types.Header, onlineConsensusResults []*mc.HD_OnlineConsensusVoteResultMsg) error { if header.NetTopology.Type == common.NetTopoTypeAll { return p.verifyAllNetTopology(header) } - return p.verifyChgNetTopology(header, onlineConsensusResults) + return p.verifyChgNetTopology(version, header, onlineConsensusResults) } func (p *ReElection) VerifyVrf(header *types.Header) error { @@ -105,11 +105,18 @@ func (p *ReElection) verifyAllNetTopology(header *types.Header) error { return nil } -func (p *ReElection) verifyChgNetTopology(header *types.Header, onlineConsensusResults []*mc.HD_OnlineConsensusVoteResultMsg) error { +func (p *ReElection) verifyChgNetTopology(version string, header *types.Header, onlineConsensusResults []*mc.HD_OnlineConsensusVoteResultMsg) error { if len(header.NetTopology.NetTopologyData) == 0 { return nil } - + if manparams.VersionCmp(version, manparams.VersionGamma) >= 0 { + for _, item := range onlineConsensusResults { + if item.Req.Node == header.Leader { + log.Warn(Module, "verifyChgNetTopology", "leader出块共识中存在自己的下线共识", "leader", header.Leader.Hex()) + return errors.New("节点下线共识中出现出块leader自己") + } + } + } // get online and offline info from header and prev topology offlineNodes, onlineNods := p.parseOnlineState(header) //log.INFO(Module, "header.NetTop", header.NetTopology, "高度", header.Number.Uint64()) diff --git a/reward/blkreward/blkreward.go b/reward/blkreward/blkreward.go index 356a7084..dce88657 100644 --- a/reward/blkreward/blkreward.go +++ b/reward/blkreward/blkreward.go @@ -57,7 +57,7 @@ func New(chain util.ChainReader, st util.StateDB, preSt util.StateDB, ppreSt uti log.Error("固定区块奖励", "获取前一个矿工奖励错误", err) return nil } - rewardCfg := cfg.New(RC, nil, preMiner, innerMinerAccounts, util.BlkReward) + rewardCfg := cfg.New(RC, nil, preMiner, innerMinerAccounts, util.BlkReward, data) return rewardexec.New(chain, rewardCfg, st, interval, foundationAccount, currentTop, originElectNodes) } diff --git a/reward/cfg/defaultcfg.go b/reward/cfg/defaultcfg.go index ee41469e..a6ad4e40 100644 --- a/reward/cfg/defaultcfg.go +++ b/reward/cfg/defaultcfg.go @@ -54,6 +54,7 @@ type RewardStateCfg struct { } type RewardCfg struct { + Calc string MinersRate uint64 //矿工网络奖励 ValidatorsRate uint64 //验证者网络奖励 RewardMount *mc.BlkRewardCfg @@ -115,7 +116,7 @@ func (str *DefaultSetRewards) SetMinerOutRewards(reward *big.Int, state util.Sta return str.miner.SetMinerOutRewards(reward, state, num, parentHash, chain, coinType) } -func New(RewardMount *mc.BlkRewardCfg, SetReward SetRewardsExec, preMiner []mc.MultiCoinMinerOutReward, innerMiners []common.Address, rewardType uint8) *RewardCfg { +func New(RewardMount *mc.BlkRewardCfg, SetReward SetRewardsExec, preMiner []mc.MultiCoinMinerOutReward, innerMiners []common.Address, rewardType uint8, calc string) *RewardCfg { //默认配置 if nil == SetReward { @@ -123,6 +124,7 @@ func New(RewardMount *mc.BlkRewardCfg, SetReward SetRewardsExec, preMiner []mc.M } return &RewardCfg{ + Calc: calc, RewardMount: RewardMount, SetReward: SetReward, } diff --git a/reward/interest/interest.go b/reward/interest/interest.go index 3b762293..e642b6ae 100644 --- a/reward/interest/interest.go +++ b/reward/interest/interest.go @@ -1,6 +1,7 @@ package interest import ( + "math" "math/big" "github.com/MatrixAINetwork/go-matrix/common" @@ -19,11 +20,13 @@ import ( const ( PackageName = "利息奖励" Denominator = 1000000000 + POWER = float64(1) ) type interest struct { VIPConfig []mc.VIPConfig InterestConfig *mc.InterestCfg + Calc string } type DepositInterestRate struct { @@ -39,13 +42,13 @@ func (p DepositInterestRateList) Less(i, j int) bool { return p[i].Deposit.Cmp(p func New(st util.StateDB, preSt util.StateDB) *interest { - data, err := matrixstate.GetInterestCalc(preSt) + calc, err := matrixstate.GetInterestCalc(preSt) if nil != err { log.ERROR(PackageName, "获取状态树配置错误") return nil } - if data == util.Stop { + if calc == util.Stop { log.ERROR(PackageName, "停止发放区块奖励", "") return nil } @@ -80,7 +83,7 @@ func New(st util.StateDB, preSt util.StateDB) *interest { return nil } - return &interest{VipCfg, IC} + return &interest{VIPConfig: VipCfg, InterestConfig: IC, Calc: calc} } func (ic *interest) calcNodeInterest(deposit *big.Int, depositInterestRate []*DepositInterestRate, denominator uint64) *big.Int { @@ -107,6 +110,18 @@ func (ic *interest) calcNodeInterest(deposit *big.Int, depositInterestRate []*De return finalResult } +func (ic *interest) calcNodeInterestB(deposit *big.Int) *big.Int { + + if deposit.Cmp(big.NewInt(0)) <= 0 { + log.ERROR(PackageName, "抵押获取错误", deposit) + return big.NewInt(0) + } + + depositMan := new(big.Int).Div(deposit, util.ManPrice).Uint64() + originResult := math.Pow(float64(depositMan), POWER) + return new(big.Int).SetUint64(uint64(originResult)) +} + func (ic *interest) PayInterest(state vm.StateDBManager, num uint64) map[common.Address]*big.Int { if !ic.canPayInterst(state, num, ic.InterestConfig.PayInterval) { return nil @@ -172,13 +187,13 @@ func (ic *interest) getLastInterestNumber(number uint64, InterestInterval uint64 return ans } func (ic *interest) GetReward(state vm.StateDBManager, num uint64, parentHash common.Hash) map[common.Address]*big.Int { - RewardMan := new(big.Int).Mul(new(big.Int).SetUint64(ic.InterestConfig.RewardMount), util.ManPrice) + RewardMan := new(big.Int).Mul(new(big.Int).SetUint64(ic.InterestConfig.RewardMount), util.GetPrice(ic.Calc)) blockReward := util.CalcRewardMountByNumber(state, RewardMan, num-1, ic.InterestConfig.AttenuationPeriod, common.InterestRewardAddress, ic.InterestConfig.AttenuationRate) if blockReward.Uint64() == 0 { log.Error(PackageName, "账户余额为0,不发放利息奖励", "") return nil } - InterestMap := ic.GetInterest(state, num, parentHash) + InterestMap := ic.GetInterest(num, parentHash) RewardMap := util.CalcInterestReward(blockReward, InterestMap) return RewardMap } @@ -195,7 +210,7 @@ func (ic *interest) SetReward(InterestMap map[common.Address]*big.Int, state vm. } } -func (ic *interest) GetInterest(state vm.StateDBManager, num uint64, parentHash common.Hash) map[common.Address]*big.Int { +func (ic *interest) GetInterest(num uint64, parentHash common.Hash) map[common.Address]*big.Int { depositInterestRateList := make(DepositInterestRateList, 0) for _, v := range ic.VIPConfig { if v.MinMoney < 0 { @@ -218,16 +233,30 @@ func (ic *interest) GetInterest(state vm.StateDBManager, num uint64, parentHash log.Debug(PackageName, "计算利息,高度", num) InterestMap := make(map[common.Address]*big.Int) - for _, dv := range depositNodes { + if ic.Calc >= util.CalcGamma { + for _, dv := range depositNodes { - result := ic.calcNodeInterest(dv.Deposit, depositInterestRateList, Denominator) - if result.Cmp(big.NewInt(0)) <= 0 { - log.ERROR(PackageName, "计算的利息非法", result) - continue + result := ic.calcNodeInterestB(dv.Deposit) + if result.Cmp(big.NewInt(0)) <= 0 { + log.ERROR(PackageName, "计算的利息非法", result) + continue + } + InterestMap[dv.Address] = result + //log.Debug(PackageName, "账户", dv.Address.String(), "deposit", dv.Deposit.String(), "利息", result.String()) + } + } else { + for _, dv := range depositNodes { + + result := ic.calcNodeInterest(dv.Deposit, depositInterestRateList, Denominator) + if result.Cmp(big.NewInt(0)) <= 0 { + log.ERROR(PackageName, "计算的利息非法", result) + continue + } + InterestMap[dv.Address] = result + //log.Debug(PackageName, "账户", dv.Address.String(), "deposit", dv.Deposit.String(), "利息", result.String()) } - InterestMap[dv.Address] = result - //log.Debug(PackageName, "账户", dv.Address.String(), "deposit", dv.Deposit.String(), "利息", result.String()) } + return InterestMap } diff --git a/reward/interest/interest_test.go b/reward/interest/interest_test.go deleted file mode 100644 index f7831f54..00000000 --- a/reward/interest/interest_test.go +++ /dev/null @@ -1,14612 +0,0 @@ -package interest - -import ( - "encoding/json" - "fmt" - "math/big" - "strconv" - "testing" - - "github.com/MatrixAINetwork/go-matrix/core/matrixstate" - "github.com/MatrixAINetwork/go-matrix/mc" - - "github.com/MatrixAINetwork/go-matrix/ca" - "github.com/MatrixAINetwork/go-matrix/reward/util" - - "bou.ke/monkey" - "github.com/MatrixAINetwork/go-matrix/core/types" - "github.com/MatrixAINetwork/go-matrix/core/vm" - "github.com/MatrixAINetwork/go-matrix/log" - - "github.com/MatrixAINetwork/go-matrix/common" - . "github.com/smartystreets/goconvey/convey" -) - -var ( - testData1 = `{ - "vipcfg":[ - { - "MinMoney":"0", - "InterestRate":250000, - "ElectUserNum":0, - "StockScale":100 - }, - { - "MinMoney":"1000000", - "InterestRate":500000, - "ElectUserNum":0, - "StockScale":100 - }, - { - "MinMoney":"10000000", - "InterestRate":1000000, - "ElectUserNum":0, - "StockScale":100 - } - ], - "node":[ - { - "Reward":3333416193728519, - "Stock":2, - "Deposit":"814723686393178936357242054", - "Interest":814723686393178936357242, - "Address":"1" - }, - { - "Reward":3706019060969665, - "Stock":1, - "Deposit":"905791937075619224559898552", - "Interest":905791937075619224559898, - "Address":"2" - }, - { - "Reward":519562542359325, - "Stock":2, - "Deposit":"126986816293506055154541621", - "Interest":126986816293506055154541, - "Address":"3" - }, - { - "Reward":3737048425943429, - "Stock":1, - "Deposit":"913375856139019393085364978", - "Interest":913375856139019393085364, - "Address":"4" - }, - { - "Reward":2587277854843755, - "Stock":2, - "Deposit":"632359246225409510350979583", - "Interest":632359246225409510350979, - "Address":"5" - }, - { - "Reward":399083481919241, - "Stock":2, - "Deposit":"97540404999409524578888080", - "Interest":97540404999409524578888, - "Address":"6" - }, - { - "Reward":1139466653787643, - "Stock":1, - "Deposit":"278498218867048397132120406", - "Interest":278498218867048397132120, - "Address":"7" - }, - { - "Reward":2237548438341328, - "Stock":1, - "Deposit":"546881519204983845844260650", - "Interest":546881519204983845844260, - "Address":"8" - }, - { - "Reward":3917608931897574, - "Stock":1, - "Deposit":"957506835434297598484550727", - "Interest":957506835434297598484550, - "Address":"9" - }, - { - "Reward":3947810923007905, - "Stock":1, - "Deposit":"964888535199276531360771633", - "Interest":964888535199276531360771, - "Address":"10" - }, - { - "Reward":644868938490449, - "Stock":1, - "Deposit":"157613081677548283467314316", - "Interest":157613081677548283467314, - "Address":"11" - }, - { - "Reward":3971149667392234, - "Stock":2, - "Deposit":"970592781760615697105015255", - "Interest":970592781760615697105015, - "Address":"12" - }, - { - "Reward":3916218294204555, - "Stock":1, - "Deposit":"957166948242945569989685561", - "Interest":957166948242945569989685, - "Address":"13" - }, - { - "Reward":1985899114651971, - "Stock":2, - "Deposit":"485375648722841224196731234", - "Interest":485375648722841224196731, - "Address":"14" - }, - { - "Reward":3274322226138377, - "Stock":2, - "Deposit":"800280468888800111678884927", - "Interest":800280468888800111678884, - "Address":"15" - }, - { - "Reward":580523466726065, - "Stock":2, - "Deposit":"141886338627215335962713352", - "Interest":141886338627215335962713, - "Address":"16" - }, - { - "Reward":1725622947846464, - "Stock":1, - "Deposit":"421761282626274991440546448", - "Interest":421761282626274991440546, - "Address":"17" - }, - { - "Reward":3746702937226992, - "Stock":2, - "Deposit":"915735525189067089977524727", - "Interest":915735525189067089977524, - "Address":"18" - }, - { - "Reward":3241291231920606, - "Stock":1, - "Deposit":"792207329559554418460109144", - "Interest":792207329559554418460109, - "Address":"19" - }, - { - "Reward":3925732914501834, - "Stock":2, - "Deposit":"959492426392902997288197505", - "Interest":959492426392902997288197, - "Address":"20" - }, - { - "Reward":2682942329972411, - "Stock":1, - "Deposit":"655740699156586837055172997", - "Interest":655740699156586837055172, - "Address":"21" - }, - { - "Reward":146113203350494, - "Stock":1, - "Deposit":"35711678574189553714647722", - "Interest":35711678574189553714647, - "Address":"22" - }, - { - "Reward":3474185697586877, - "Stock":1, - "Deposit":"849129305868777106711277589", - "Interest":849129305868777106711277, - "Address":"23" - }, - { - "Reward":3821403831636750, - "Stock":2, - "Deposit":"933993247757550548735944390", - "Interest":933993247757550548735944, - "Address":"24" - }, - { - "Reward":2777023418175017, - "Stock":1, - "Deposit":"678735154857773470567070615", - "Interest":678735154857773470567070, - "Address":"25" - }, - { - "Reward":3100269777462710, - "Stock":1, - "Deposit":"757740130578333448426530171", - "Interest":757740130578333448426530, - "Address":"26" - }, - { - "Reward":3040502988564857, - "Stock":2, - "Deposit":"743132468124916178993863527", - "Interest":743132468124916178993863, - "Address":"27" - }, - { - "Reward":1604784444553513, - "Stock":1, - "Deposit":"392227019534168164231513172", - "Interest":392227019534168164231513, - "Address":"28" - }, - { - "Reward":2681867055347176, - "Stock":2, - "Deposit":"655477890177556643542698702", - "Interest":655477890177556643542698, - "Address":"29" - }, - { - "Reward":700404918663950, - "Stock":1, - "Deposit":"171186687811561766283153287", - "Interest":171186687811561766283153, - "Address":"30" - }, - { - "Reward":2888765237380657, - "Stock":2, - "Deposit":"706046088019608775184059284", - "Interest":706046088019608775184059, - "Address":"31" - }, - { - "Reward":130243084102206, - "Stock":1, - "Deposit":"31832846377420676020937839", - "Interest":31832846377420676020937, - "Address":"32" - }, - { - "Reward":1133021634084159, - "Stock":2, - "Deposit":"276922984960889961850152389", - "Interest":276922984960889961850152, - "Address":"33" - }, - { - "Reward":188908784398074, - "Stock":2, - "Deposit":"46171390631153941264592238", - "Interest":46171390631153941264592, - "Address":"34" - }, - { - "Reward":397411610715115, - "Stock":2, - "Deposit":"97131781235847536316445735", - "Interest":97131781235847536316445, - "Address":"35" - }, - { - "Reward":3369151659197050, - "Stock":2, - "Deposit":"823457828327292640232982163", - "Interest":823457828327292640232982, - "Address":"36" - }, - { - "Reward":2842869333954678, - "Stock":1, - "Deposit":"694828622975817045144545255", - "Interest":694828622975817045144545, - "Address":"37" - }, - { - "Reward":1297402493030815, - "Stock":2, - "Deposit":"317099480060860527966652577", - "Interest":317099480060860527966652, - "Address":"38" - }, - { - "Reward":3887803457953058, - "Stock":2, - "Deposit":"950222048838354926845796412", - "Interest":950222048838354926845796, - "Address":"39" - }, - { - "Reward":140935048871844, - "Stock":2, - "Deposit":"34446080502908760223934588", - "Interest":34446080502908760223934, - "Address":"40" - }, - { - "Reward":1795108670352182, - "Stock":1, - "Deposit":"438744359656398241757933426", - "Interest":438744359656398241757933, - "Address":"41" - }, - { - "Reward":1561134358764791, - "Stock":1, - "Deposit":"381558457093008396302995197", - "Interest":381558457093008396302995, - "Address":"42" - }, - { - "Reward":3132087725942778, - "Stock":1, - "Deposit":"765516788149002369586614317", - "Interest":765516788149002369586614, - "Address":"43" - }, - { - "Reward":3253535243877005, - "Stock":1, - "Deposit":"795199901137063180919413337", - "Interest":795199901137063180919413, - "Address":"44" - }, - { - "Reward":764583350882440, - "Stock":2, - "Deposit":"186872604554378596299548334", - "Interest":186872604554378596299548, - "Address":"45" - }, - { - "Reward":2003855534456966, - "Stock":2, - "Deposit":"489764395788231055033809506", - "Interest":489764395788231055033809, - "Address":"46" - }, - { - "Reward":1823101846623952, - "Stock":1, - "Deposit":"445586200710899493775418629", - "Interest":445586200710899493775418, - "Address":"47" - }, - { - "Reward":2644369238434788, - "Stock":2, - "Deposit":"646313010111264629748779925", - "Interest":646313010111264629748779, - "Address":"48" - }, - { - "Reward":2902343768734681, - "Stock":1, - "Deposit":"709364830858072559223596832", - "Interest":709364830858072559223596, - "Address":"49" - }, - { - "Reward":3087776689110764, - "Stock":2, - "Deposit":"754686681982360885186702027", - "Interest":754686681982360885186702, - "Address":"50" - }, - { - "Reward":1129347872056572, - "Stock":2, - "Deposit":"276025076998578366985186430", - "Interest":276025076998578366985186, - "Address":"51" - }, - { - "Reward":2780982003819193, - "Stock":1, - "Deposit":"679702676853674803154744283", - "Interest":679702676853674803154744, - "Address":"52" - }, - { - "Reward":2680312762960211, - "Stock":2, - "Deposit":"655098003973840659070910056", - "Interest":655098003973840659070910, - "Address":"53" - }, - { - "Reward":665320771251623, - "Stock":1, - "Deposit":"162611735194630568914168493", - "Interest":162611735194630568914168, - "Address":"54" - }, - { - "Reward":486875250281373, - "Stock":2, - "Deposit":"118997681558376644518427592", - "Interest":118997681558376644518427, - "Address":"55" - }, - { - "Reward":2039040755773153, - "Stock":2, - "Deposit":"498364051982142952650894767", - "Interest":498364051982142952650894, - "Address":"56" - }, - { - "Reward":3926762050228029, - "Stock":2, - "Deposit":"959743958516081074892763914", - "Interest":959743958516081074892763, - "Address":"57" - }, - { - "Reward":1392677434488343, - "Stock":2, - "Deposit":"340385726666133203725043362", - "Interest":340385726666133203725043, - "Address":"58" - }, - { - "Reward":2394604491517818, - "Stock":2, - "Deposit":"585267750979777345860263146", - "Interest":585267750979777345860263, - "Address":"59" - }, - { - "Reward":915719471410460, - "Stock":2, - "Deposit":"223811939491136979720769114", - "Interest":223811939491136979720769, - "Address":"60" - }, - { - "Reward":3073785411089324, - "Stock":1, - "Deposit":"751267059305652851194113669", - "Interest":751267059305652851194113, - "Address":"61" - }, - { - "Reward":1043713596418759, - "Stock":1, - "Deposit":"255095115459269106142121297", - "Interest":255095115459269106142121, - "Address":"62" - }, - { - "Reward":2070107273814794, - "Stock":1, - "Deposit":"505957051665142376611409519", - "Interest":505957051665142376611409, - "Address":"63" - }, - { - "Reward":2860250299434485, - "Stock":1, - "Deposit":"699076722656685967123614407", - "Interest":699076722656685967123614, - "Address":"64" - }, - { - "Reward":3645102479093828, - "Stock":1, - "Deposit":"890903252535798495523897033", - "Interest":890903252535798495523897, - "Address":"65" - }, - { - "Reward":3924910524500875, - "Stock":2, - "Deposit":"959291425205444303623983746", - "Interest":959291425205444303623983, - "Address":"66" - }, - { - "Reward":2238915032796506, - "Stock":2, - "Deposit":"547215529963803071217181559", - "Interest":547215529963803071217181, - "Address":"67" - }, - { - "Reward":567177523237872, - "Stock":1, - "Deposit":"138624442828679139695644004", - "Interest":138624442828679139695644, - "Address":"68" - }, - { - "Reward":610831701678293, - "Stock":1, - "Deposit":"149294005559057474387500447", - "Interest":149294005559057474387500, - "Address":"69" - }, - { - "Reward":1053586876938513, - "Stock":2, - "Deposit":"257508254123736457510759752", - "Interest":257508254123736457510759, - "Address":"70" - }, - { - "Reward":3439768061549276, - "Stock":2, - "Deposit":"840717255983662536963991503", - "Interest":840717255983662536963991, - "Address":"71" - }, - { - "Reward":1040387492491800, - "Stock":2, - "Deposit":"254282178971531047653496331", - "Interest":254282178971531047653496, - "Address":"72" - }, - { - "Reward":3331620610592240, - "Stock":2, - "Deposit":"814284826068816358643296278", - "Interest":814284826068816358643296, - "Address":"73" - }, - { - "Reward":996374707011227, - "Stock":2, - "Deposit":"243524968724989299142737495", - "Interest":243524968724989299142737, - "Address":"74" - }, - { - "Reward":3802052722302043, - "Stock":1, - "Deposit":"929263623187227771902788189", - "Interest":929263623187227771902788, - "Address":"75" - }, - { - "Reward":1431947508781329, - "Stock":2, - "Deposit":"349983765984808736785482498", - "Interest":349983765984808736785482, - "Address":"76" - }, - { - "Reward":804363248966895, - "Stock":1, - "Deposit":"196595250431208179444385829", - "Interest":196595250431208179444385, - "Address":"77" - }, - { - "Reward":1027301663299402, - "Stock":1, - "Deposit":"251083857976031055161691476", - "Interest":251083857976031055161691, - "Address":"78" - }, - { - "Reward":2520527307385083, - "Stock":2, - "Deposit":"616044676146639158537725472", - "Interest":616044676146639158537725, - "Address":"79" - }, - { - "Reward":1936446355485138, - "Stock":2, - "Deposit":"473288848902729264449828169", - "Interest":473288848902729264449828, - "Address":"80" - }, - { - "Reward":1438803750400199, - "Stock":1, - "Deposit":"351659507062996756768985142", - "Interest":351659507062996756768985, - "Address":"81" - }, - { - "Reward":3399309052500292, - "Stock":2, - "Deposit":"830828627896290861096192145", - "Interest":830828627896290861096192, - "Address":"82" - }, - { - "Reward":2394589517451188, - "Stock":2, - "Deposit":"585264091152724263983649804", - "Interest":585264091152724263983649, - "Address":"83" - }, - { - "Reward":2249176755944013, - "Stock":2, - "Deposit":"549723608291139531628551960", - "Interest":549723608291139531628551, - "Address":"84" - }, - { - "Reward":3752668865355671, - "Stock":2, - "Deposit":"917193663829810046382033930", - "Interest":917193663829810046382033, - "Address":"85" - }, - { - "Reward":1169501304612225, - "Stock":2, - "Deposit":"285839018820373547139026904", - "Interest":285839018820373547139026, - "Address":"86" - }, - { - "Reward":3098060787684686, - "Stock":2, - "Deposit":"757200229110721267929766876", - "Interest":757200229110721267929766, - "Address":"87" - }, - { - "Reward":3083858749308238, - "Stock":1, - "Deposit":"753729094278495326272063696", - "Interest":753729094278495326272063, - "Address":"88" - }, - { - "Reward":1556582149659511, - "Stock":2, - "Deposit":"380445846975356660739002407", - "Interest":380445846975356660739002, - "Address":"89" - }, - { - "Reward":2323224283219755, - "Stock":2, - "Deposit":"567821640725221121753907223", - "Interest":567821640725221121753907, - "Address":"90" - }, - { - "Reward":310355426528330, - "Stock":1, - "Deposit":"75854289563063614921437224", - "Interest":75854289563063614921437, - "Address":"91" - }, - { - "Reward":220735204119320, - "Stock":2, - "Deposit":"53950118666607149720532707", - "Interest":53950118666607149720532, - "Address":"92" - }, - { - "Reward":2171741399375123, - "Stock":1, - "Deposit":"530797553008972688997931521", - "Interest":530797553008972688997931, - "Address":"93" - }, - { - "Reward":3187938077439434, - "Stock":2, - "Deposit":"779167230102011165734379045", - "Interest":779167230102011165734379, - "Address":"94" - }, - { - "Reward":3821475172408931, - "Stock":1, - "Deposit":"934010684229182985847567513", - "Interest":934010684229182985847567, - "Address":"95" - }, - { - "Reward":531507143126347, - "Stock":1, - "Deposit":"129906208473730133691380673", - "Interest":129906208473730133691380, - "Address":"96" - }, - { - "Reward":2327324016957882, - "Stock":1, - "Deposit":"568823660872192715670790878", - "Interest":568823660872192715670790, - "Address":"97" - }, - { - "Reward":1920496961386900, - "Stock":1, - "Deposit":"469390641058205826401632673", - "Interest":469390641058205826401632, - "Address":"98" - }, - { - "Reward":48696940910066, - "Stock":1, - "Deposit":"11902069501241396842891161", - "Interest":11902069501241396842891, - "Address":"99" - }, - { - "Reward":1379326636600928, - "Stock":2, - "Deposit":"337122644398881510244862882", - "Interest":337122644398881510244862, - "Address":"100" - }, - { - "Reward":663563784257925, - "Stock":2, - "Deposit":"162182308193242752382645110", - "Interest":162182308193242752382645, - "Address":"101" - }, - { - "Reward":3249790075535137, - "Stock":2, - "Deposit":"794284540683906969967984412", - "Interest":794284540683906969967984, - "Address":"102" - }, - { - "Reward":1273326501008845, - "Stock":1, - "Deposit":"311215042044804879320719286", - "Interest":311215042044804879320719, - "Address":"103" - }, - { - "Reward":2162476606784547, - "Stock":2, - "Deposit":"528533135506212725656945274", - "Interest":528533135506212725656945, - "Address":"104" - }, - { - "Reward":677746537393107, - "Stock":2, - "Deposit":"165648729499780933417930289", - "Interest":165648729499780933417930, - "Address":"105" - }, - { - "Reward":2462990072970521, - "Stock":2, - "Deposit":"601981941401636522221327120", - "Interest":601981941401636522221327, - "Address":"106" - }, - { - "Reward":1075938693095355, - "Stock":1, - "Deposit":"262971284540144290001036397", - "Interest":262971284540144290001036, - "Address":"107" - }, - { - "Reward":2676143943346276, - "Stock":1, - "Deposit":"654079098476782250244239351", - "Interest":654079098476782250244239, - "Address":"108" - }, - { - "Reward":2819899340217208, - "Stock":2, - "Deposit":"689214503140007761501586862", - "Interest":689214503140007761501586, - "Address":"109" - }, - { - "Reward":3061038578518512, - "Stock":2, - "Deposit":"748151592823709465925588757", - "Interest":748151592823709465925588, - "Address":"110" - }, - { - "Reward":1843376699952457, - "Stock":1, - "Deposit":"450541598502497753213685295", - "Interest":450541598502497753213685, - "Address":"111" - }, - { - "Reward":342952516861983, - "Stock":1, - "Deposit":"83821377996932566745995979", - "Interest":83821377996932566745995, - "Address":"112" - }, - { - "Reward":936852025121020, - "Stock":2, - "Deposit":"228976968716818829465765148", - "Interest":228976968716818829465765, - "Address":"113" - }, - { - "Reward":3736890926352271, - "Stock":1, - "Deposit":"913337361501669553485415530", - "Interest":913337361501669553485415, - "Address":"114" - }, - { - "Reward":623449845000765, - "Stock":2, - "Deposit":"152378018969222983615553789", - "Interest":152378018969222983615553, - "Address":"115" - }, - { - "Reward":3378804043376152, - "Stock":1, - "Deposit":"825816977489547410237670994", - "Interest":825816977489547410237670, - "Address":"116" - }, - { - "Reward":2202611046466005, - "Stock":1, - "Deposit":"538342435260057095019852910", - "Interest":538342435260057095019852, - "Address":"117" - }, - { - "Reward":4075653686023765, - "Stock":2, - "Deposit":"996134716626885463607270941", - "Interest":996134716626885463607270, - "Address":"118" - }, - { - "Reward":319852703255509, - "Stock":2, - "Deposit":"78175528753183676223485495", - "Interest":78175528753183676223485, - "Address":"119" - }, - { - "Reward":1811204139177399, - "Stock":2, - "Deposit":"442678269775446331384376183", - "Interest":442678269775446331384376, - "Address":"120" - }, - { - "Reward":436366435840182, - "Stock":1, - "Deposit":"106652770180584388627309287", - "Interest":106652770180584388627309, - "Address":"121" - }, - { - "Reward":3935575573644529, - "Stock":1, - "Deposit":"961898080855053683189855091", - "Interest":961898080855053683189855, - "Address":"122" - }, - { - "Reward":9480390733609, - "Stock":1, - "Deposit":"4634224134067443934316914", - "Interest":2317112067033721967158, - "Address":"123" - }, - { - "Reward":3170521656482725, - "Stock":1, - "Deposit":"774910464711502378073430606", - "Interest":774910464711502378073430, - "Address":"124" - }, - { - "Reward":3343970276565456, - "Stock":1, - "Deposit":"817303220653432971340274303", - "Interest":817303220653432971340274, - "Address":"125" - }, - { - "Reward":3554236910779463, - "Stock":2, - "Deposit":"868694705363509678272901427", - "Interest":868694705363509678272901, - "Address":"126" - }, - { - "Reward":345466591260239, - "Stock":1, - "Deposit":"84435845510910323420139372", - "Interest":84435845510910323420139, - "Address":"127" - }, - { - "Reward":1635698063938239, - "Stock":1, - "Deposit":"399782649098896492038776841", - "Interest":399782649098896492038776, - "Address":"128" - }, - { - "Reward":1063251533741559, - "Stock":2, - "Deposit":"259870402850654214080104580", - "Interest":259870402850654214080104, - "Address":"129" - }, - { - "Reward":3273454881222661, - "Stock":2, - "Deposit":"800068480224307543310580082", - "Interest":800068480224307543310580, - "Address":"130" - }, - { - "Reward":1765116029744806, - "Stock":1, - "Deposit":"431413827463544619082871785", - "Interest":431413827463544619082871, - "Address":"131" - }, - { - "Reward":3725885829452064, - "Stock":1, - "Deposit":"910647594429522921908532021", - "Interest":910647594429522921908532, - "Address":"132" - }, - { - "Reward":744021364604837, - "Stock":1, - "Deposit":"181847028302852486982428810", - "Interest":181847028302852486982428, - "Address":"133" - }, - { - "Reward":1079341289045130, - "Stock":1, - "Deposit":"263802916521990060696871719", - "Interest":263802916521990060696871, - "Address":"134" - }, - { - "Reward":595468134946340, - "Stock":2, - "Deposit":"145538980384717020479034813", - "Interest":145538980384717020479034, - "Address":"135" - }, - { - "Reward":556720204201684, - "Stock":2, - "Deposit":"136068558708663744917482526", - "Interest":136068558708663744917482, - "Address":"136" - }, - { - "Reward":3556681572445502, - "Stock":2, - "Deposit":"869292207640089298345901145", - "Interest":869292207640089298345901, - "Address":"137" - }, - { - "Reward":2371842983549323, - "Stock":1, - "Deposit":"579704587365570178653336600", - "Interest":579704587365570178653336, - "Address":"138" - }, - { - "Reward":2249735624113808, - "Stock":1, - "Deposit":"549860201836331996544325104", - "Interest":549860201836331996544325, - "Address":"139" - }, - { - "Reward":593077972111928, - "Stock":1, - "Deposit":"144954798223726810670113880", - "Interest":144954798223726810670113, - "Address":"140" - }, - { - "Reward":3490149837372282, - "Stock":2, - "Deposit":"853031117721893661362738238", - "Interest":853031117721893661362738, - "Address":"141" - }, - { - "Reward":2545118895295693, - "Stock":1, - "Deposit":"622055131485065970770695902", - "Interest":622055131485065970770695, - "Address":"142" - }, - { - "Reward":1435910566038588, - "Stock":2, - "Deposit":"350952380892270876525838350", - "Interest":350952380892270876525838, - "Address":"143" - }, - { - "Reward":2099944258636532, - "Stock":2, - "Deposit":"513249539867053350411095581", - "Interest":513249539867053350411095, - "Address":"144" - }, - { - "Reward":1643984861184651, - "Stock":1, - "Deposit":"401808033751941739990094446", - "Interest":401808033751941739990094, - "Address":"145" - }, - { - "Reward":310815316278933, - "Stock":2, - "Deposit":"75966691690841914309166459", - "Interest":75966691690841914309166, - "Address":"146" - }, - { - "Reward":981609353882064, - "Stock":1, - "Deposit":"239916153553658029198468794", - "Interest":239916153553658029198468, - "Address":"147" - }, - { - "Reward":504555521385089, - "Stock":1, - "Deposit":"123318934835165539000267654", - "Interest":123318934835165539000267, - "Address":"148" - }, - { - "Reward":752452898880805, - "Stock":2, - "Deposit":"183907788282416717608630542", - "Interest":183907788282416717608630, - "Address":"149" - }, - { - "Reward":981758169224797, - "Stock":2, - "Deposit":"239952525664902771576247196", - "Interest":239952525664902771576247, - "Address":"150" - }, - { - "Reward":1707235015288637, - "Stock":2, - "Deposit":"417267069084369501834336298", - "Interest":417267069084369501834336, - "Address":"151" - }, - { - "Reward":203159531142335, - "Stock":2, - "Deposit":"49654430325742127117435275", - "Interest":49654430325742127117435, - "Address":"152" - }, - { - "Reward":3693434411429437, - "Stock":1, - "Deposit":"902716109915281061946283576", - "Interest":902716109915281061946283, - "Address":"153" - }, - { - "Reward":3865566903777895, - "Stock":2, - "Deposit":"944787189721645992444567865", - "Interest":944787189721645992444567, - "Address":"154" - }, - { - "Reward":2008354908639919, - "Stock":1, - "Deposit":"490864092468079937785960110", - "Interest":490864092468079937785960, - "Address":"155" - }, - { - "Reward":2001761695289629, - "Stock":2, - "Deposit":"489252638400018868841015871", - "Interest":489252638400018868841015, - "Address":"156" - }, - { - "Reward":1381768283451789, - "Stock":2, - "Deposit":"337719409821377158923460195", - "Interest":337719409821377158923460, - "Address":"157" - }, - { - "Reward":3682541844534489, - "Stock":2, - "Deposit":"900053846417661951315846999", - "Interest":900053846417661951315846, - "Address":"158" - }, - { - "Reward":1510761525931940, - "Stock":1, - "Deposit":"369246781120215028519163572", - "Interest":369246781120215028519163, - "Address":"159" - }, - { - "Reward":454982556017956, - "Stock":2, - "Deposit":"111202755293787425295849152", - "Interest":111202755293787425295849, - "Address":"160" - }, - { - "Reward":3192376658700305, - "Stock":2, - "Deposit":"780252068321137914893605590", - "Interest":780252068321137914893605, - "Address":"161" - }, - { - "Reward":1594604124255934, - "Stock":1, - "Deposit":"389738836961253443118011013", - "Interest":389738836961253443118011, - "Address":"162" - }, - { - "Reward":988872251787504, - "Stock":2, - "Deposit":"241691285913832709655507698", - "Interest":241691285913832709655507, - "Address":"163" - }, - { - "Reward":1652593768210745, - "Stock":2, - "Deposit":"403912145588114723797218278", - "Interest":403912145588114723797218, - "Address":"164" - }, - { - "Reward":394640638936250, - "Stock":2, - "Deposit":"96454525168388594026223096", - "Interest":96454525168388594026223, - "Address":"165" - }, - { - "Reward":539964552474453, - "Stock":1, - "Deposit":"131973292606335057543173908", - "Interest":131973292606335057543173, - "Address":"166" - }, - { - "Reward":3854370195746418, - "Stock":2, - "Deposit":"942050590775485141579712261", - "Interest":942050590775485141579712, - "Address":"167" - }, - { - "Reward":3911994229473134, - "Stock":1, - "Deposit":"956134540229802265552510530", - "Interest":956134540229802265552510, - "Address":"168" - }, - { - "Reward":2353447773311775, - "Stock":2, - "Deposit":"575208595078465556588361199", - "Interest":575208595078465556588361, - "Address":"169" - }, - { - "Reward":244586109182509, - "Stock":1, - "Deposit":"59779542947155817068136638", - "Interest":59779542947155817068136, - "Address":"170" - }, - { - "Reward":960594589636212, - "Stock":1, - "Deposit":"234779913372406334739609190", - "Interest":234779913372406334739609, - "Address":"171" - }, - { - "Reward":1444937123992685, - "Stock":2, - "Deposit":"353158571222071060450507109", - "Interest":353158571222071060450507, - "Address":"172" - }, - { - "Reward":3359889441667942, - "Stock":2, - "Deposit":"821194040197959052038034858", - "Interest":821194040197959052038034, - "Address":"173" - }, - { - "Reward":63022677951211, - "Stock":1, - "Deposit":"15403437651555051957229090", - "Interest":15403437651555051957229, - "Address":"174" - }, - { - "Reward":176030523669701, - "Stock":2, - "Deposit":"43023801657807836385391175", - "Interest":43023801657807836385391, - "Address":"175" - }, - { - "Reward":691417360508391, - "Stock":2, - "Deposit":"168990029462704360875858504", - "Interest":168990029462704360875858, - "Address":"176" - }, - { - "Reward":2655835434708839, - "Stock":2, - "Deposit":"649115474956452054306856331", - "Interest":649115474956452054306856, - "Address":"177" - }, - { - "Reward":2993818997047264, - "Stock":1, - "Deposit":"731722385658670315685220176", - "Interest":731722385658670315685220, - "Address":"178" - }, - { - "Reward":2650232120413430, - "Stock":1, - "Deposit":"647745963136306723846124178", - "Interest":647745963136306723846124, - "Address":"179" - }, - { - "Reward":1844940082455888, - "Stock":2, - "Deposit":"450923706430944926109092240", - "Interest":450923706430944926109092, - "Address":"180" - }, - { - "Reward":2238069581274994, - "Stock":1, - "Deposit":"547008892286344972083392422", - "Interest":547008892286344972083392, - "Address":"181" - }, - { - "Reward":1212387203721172, - "Stock":1, - "Deposit":"296320805607773185566718607", - "Interest":296320805607773185566718, - "Address":"182" - }, - { - "Reward":3046887066023226, - "Stock":2, - "Deposit":"744692807074156193366200755", - "Interest":744692807074156193366200, - "Address":"183" - }, - { - "Reward":773103467488647, - "Stock":2, - "Deposit":"188955015032544526578318014", - "Interest":188955015032544526578318, - "Address":"184" - }, - { - "Reward":2809919963380150, - "Stock":2, - "Deposit":"686775433365314991192219134", - "Interest":686775433365314991192219, - "Address":"185" - }, - { - "Reward":750830089367551, - "Stock":2, - "Deposit":"183511155737269726630657653", - "Interest":183511155737269726630657, - "Address":"186" - }, - { - "Reward":1507643071626167, - "Stock":1, - "Deposit":"368484596490336491218315977", - "Interest":368484596490336491218315, - "Address":"187" - }, - { - "Reward":2559698553341260, - "Stock":1, - "Deposit":"625618560729690353922760672", - "Interest":625618560729690353922760, - "Address":"188" - }, - { - "Reward":3192275872865358, - "Stock":1, - "Deposit":"780227435151376824692427877", - "Interest":780227435151376824692427, - "Address":"189" - }, - { - "Reward":331923517362155, - "Stock":1, - "Deposit":"81125768865785263806700363", - "Interest":81125768865785263806700, - "Address":"190" - }, - { - "Reward":3802553304380283, - "Stock":2, - "Deposit":"929385970968729990824690160", - "Interest":929385970968729990824690, - "Address":"191" - }, - { - "Reward":3173803889268418, - "Stock":2, - "Deposit":"775712678608402317345072760", - "Interest":775712678608402317345072, - "Address":"192" - }, - { - "Reward":1991692567093457, - "Stock":1, - "Deposit":"486791632403172358505717123", - "Interest":486791632403172358505717, - "Address":"193" - }, - { - "Reward":1783301629271811, - "Stock":2, - "Deposit":"435858588580919081860634429", - "Interest":435858588580919081860634, - "Address":"194" - }, - { - "Reward":1828001579329718, - "Stock":1, - "Deposit":"446783749429806253954412179", - "Interest":446783749429806253954412, - "Address":"195" - }, - { - "Reward":1253419175132900, - "Stock":2, - "Deposit":"306349472016557378143138843", - "Interest":306349472016557378143138, - "Address":"196" - }, - { - "Reward":2080547079713276, - "Stock":1, - "Deposit":"508508655381126994937197779", - "Interest":508508655381126994937197, - "Address":"197" - }, - { - "Reward":2089805699457335, - "Stock":2, - "Deposit":"510771564172109671103201890", - "Interest":510771564172109671103201, - "Address":"198" - }, - { - "Reward":3345297907599149, - "Stock":1, - "Deposit":"817627708322262058979033027", - "Interest":817627708322262058979033, - "Address":"199" - }, - { - "Reward":3252027602208262, - "Stock":2, - "Deposit":"794831416883453045770960666", - "Interest":794831416883453045770960, - "Address":"200" - }, - { - "Reward":2636207250348716, - "Stock":2, - "Deposit":"644318130193691662739084272", - "Interest":644318130193691662739084, - "Address":"201" - }, - { - "Reward":1549068314000429, - "Stock":1, - "Deposit":"378609382660268445345738340", - "Interest":378609382660268445345738, - "Address":"202" - }, - { - "Reward":3320555775331724, - "Stock":2, - "Deposit":"811580458282477157369365149", - "Interest":811580458282477157369365, - "Address":"203" - }, - { - "Reward":2180039043666506, - "Stock":1, - "Deposit":"532825588799454852312104114", - "Interest":532825588799454852312104, - "Address":"204" - }, - { - "Reward":1434988851028046, - "Stock":1, - "Deposit":"350727103576883303407592263", - "Interest":350727103576883303407592, - "Address":"205" - }, - { - "Reward":3841895190949738, - "Stock":2, - "Deposit":"939001561999886824603722974", - "Interest":939001561999886824603722, - "Address":"206" - }, - { - "Reward":3583892307755600, - "Stock":1, - "Deposit":"875942811492983808294579859", - "Interest":875942811492983808294579, - "Address":"207" - }, - { - "Reward":2250947275902612, - "Stock":2, - "Deposit":"550156342898422190407171598", - "Interest":550156342898422190407171, - "Address":"208" - }, - { - "Reward":2546837125915695, - "Stock":1, - "Deposit":"622475086001227473359700163", - "Interest":622475086001227473359700, - "Address":"209" - }, - { - "Reward":2401874840770533, - "Stock":2, - "Deposit":"587044704531416772225508236", - "Interest":587044704531416772225508, - "Address":"210" - }, - { - "Reward":849971019971520, - "Stock":2, - "Deposit":"207742292733028466324839992", - "Interest":207742292733028466324839, - "Address":"211" - }, - { - "Reward":1232539832124551, - "Stock":2, - "Deposit":"301246330279490659445852356", - "Interest":301246330279490659445852, - "Address":"212" - }, - { - "Reward":1926767985478492, - "Stock":1, - "Deposit":"470923348517590656397133674", - "Interest":470923348517590656397133, - "Address":"213" - }, - { - "Reward":943035017323801, - "Stock":2, - "Deposit":"230488160211558490433419130", - "Interest":230488160211558490433419, - "Address":"214" - }, - { - "Reward":3454462720407472, - "Stock":2, - "Deposit":"844308792695389054303143458", - "Interest":844308792695389054303143, - "Address":"215" - }, - { - "Reward":796871930503220, - "Stock":1, - "Deposit":"194764289567049275755109240", - "Interest":194764289567049275755109, - "Address":"216" - }, - { - "Reward":924351821098209, - "Stock":1, - "Deposit":"225921780972398789091341157", - "Interest":225921780972398789091341, - "Address":"217" - }, - { - "Reward":698446575527483, - "Stock":2, - "Deposit":"170708047147858588134568241", - "Interest":170708047147858588134568, - "Address":"218" - }, - { - "Reward":931481273651461, - "Stock":2, - "Deposit":"227664297816553506950186574", - "Interest":227664297816553506950186, - "Address":"219" - }, - { - "Reward":1782647385161752, - "Stock":1, - "Deposit":"435698684103899114288173040", - "Interest":435698684103899114288173, - "Address":"220" - }, - { - "Reward":1272865165879066, - "Stock":1, - "Deposit":"311102286650412840355084031", - "Interest":311102286650412840355084, - "Address":"221" - }, - { - "Reward":3777978599803193, - "Stock":1, - "Deposit":"923379642103243858395688804", - "Interest":923379642103243858395688, - "Address":"222" - }, - { - "Reward":1760179934461451, - "Stock":1, - "Deposit":"430207391329583965782070186", - "Interest":430207391329583965782070, - "Address":"223" - }, - { - "Reward":756170128174963, - "Stock":1, - "Deposit":"184816320124136068694013166", - "Interest":184816320124136068694013, - "Address":"224" - }, - { - "Reward":3702291862591854, - "Stock":1, - "Deposit":"904880968679892871984352884", - "Interest":904880968679892871984352, - "Address":"225" - }, - { - "Reward":4008609501277381, - "Stock":1, - "Deposit":"979748378356085192218768381", - "Interest":979748378356085192218768, - "Address":"226" - }, - { - "Reward":1795622613890412, - "Stock":1, - "Deposit":"438869973126103207765546482", - "Interest":438869973126103207765546, - "Address":"227" - }, - { - "Reward":454640788082690, - "Stock":1, - "Deposit":"111119223440598768882781025", - "Interest":111119223440598768882781, - "Address":"228" - }, - { - "Reward":1055863540915596, - "Stock":2, - "Deposit":"258064695912066932595243933", - "Interest":258064695912066932595243, - "Address":"229" - }, - { - "Reward":1672264322842223, - "Stock":1, - "Deposit":"408719846112552076537658583", - "Interest":408719846112552076537658, - "Address":"230" - }, - { - "Reward":2433998470653077, - "Stock":2, - "Deposit":"594896074008614328404835430", - "Interest":594896074008614328404835, - "Address":"231" - }, - { - "Reward":1072831072468309, - "Stock":1, - "Deposit":"262211747780845438884744440", - "Interest":262211747780845438884744, - "Address":"232" - }, - { - "Reward":2466513432695000, - "Stock":1, - "Deposit":"602843089382082975020066385", - "Interest":602843089382082975020066, - "Address":"233" - }, - { - "Reward":2909916870379030, - "Stock":1, - "Deposit":"711215780433682942536677682", - "Interest":711215780433682942536677, - "Address":"234" - }, - { - "Reward":907269748535038, - "Stock":2, - "Deposit":"221746734017240099137153232", - "Interest":221746734017240099137153, - "Address":"235" - }, - { - "Reward":480410604637088, - "Stock":2, - "Deposit":"117417650855805910660230777", - "Interest":117417650855805910660230, - "Address":"236" - }, - { - "Reward":1213839951619209, - "Stock":2, - "Deposit":"296675873218326890959539547", - "Interest":296675873218326890959539, - "Address":"237" - }, - { - "Reward":1304271339591572, - "Stock":2, - "Deposit":"318778301925882301407343119", - "Interest":318778301925882301407343, - "Address":"238" - }, - { - "Reward":1735464881266518, - "Stock":2, - "Deposit":"424166759713807239866386787", - "Interest":424166759713807239866386, - "Address":"239" - }, - { - "Reward":2077886108483138, - "Stock":1, - "Deposit":"507858284661118153385317780", - "Interest":507858284661118153385317, - "Address":"240" - }, - { - "Reward":349885178988140, - "Stock":1, - "Deposit":"85515797090043976781148030", - "Interest":85515797090043976781148, - "Address":"241" - }, - { - "Reward":1073937761135893, - "Stock":1, - "Deposit":"262482234698332650427013011", - "Interest":262482234698332650427013, - "Address":"242" - }, - { - "Reward":3277325993521456, - "Stock":1, - "Deposit":"801014622769738782190006004", - "Interest":801014622769738782190006, - "Address":"243" - }, - { - "Reward":119553841428263, - "Stock":2, - "Deposit":"29220277562146290684389436", - "Interest":29220277562146290684389, - "Address":"244" - }, - { - "Reward":3800377332657608, - "Stock":2, - "Deposit":"928854139478044626985607720", - "Interest":928854139478044626985607, - "Address":"245" - }, - { - "Reward":2988125625510808, - "Stock":2, - "Deposit":"730330862855452900291389082", - "Interest":730330862855452900291389, - "Address":"246" - }, - { - "Reward":1999128161951964, - "Stock":2, - "Deposit":"488608973803579149657757659", - "Interest":488608973803579149657757, - "Address":"247" - }, - { - "Reward":2367016988828099, - "Stock":1, - "Deposit":"578525061023438924584734464", - "Interest":578525061023438924584734, - "Address":"248" - }, - { - "Reward":970838261518948, - "Stock":2, - "Deposit":"237283579771521480064206245", - "Interest":237283579771521480064206, - "Address":"249" - }, - { - "Reward":1877365467425721, - "Stock":2, - "Deposit":"458848828179931111930366670", - "Interest":458848828179931111930366, - "Address":"250" - }, - { - "Reward":3940446296665101, - "Stock":1, - "Deposit":"963088539286912959101657504", - "Interest":963088539286912959101657, - "Address":"251" - }, - { - "Reward":2237238303132140, - "Stock":2, - "Deposit":"546805718738967994069134281", - "Interest":546805718738967994069134, - "Address":"252" - }, - { - "Reward":2132210768567104, - "Stock":2, - "Deposit":"521135830804001498611432776", - "Interest":521135830804001498611432, - "Address":"253" - }, - { - "Reward":947561108046952, - "Stock":2, - "Deposit":"231594386708523836129285558", - "Interest":231594386708523836129285, - "Address":"254" - }, - { - "Reward":2000309655750383, - "Stock":2, - "Deposit":"488897743920166938385473903", - "Interest":488897743920166938385473, - "Address":"255" - }, - { - "Reward":2553322112171797, - "Stock":1, - "Deposit":"624060088173689520025373452", - "Interest":624060088173689520025373, - "Address":"256" - }, - { - "Reward":2778661584862710, - "Stock":1, - "Deposit":"679135540865747677770194092", - "Interest":679135540865747677770194, - "Address":"257" - }, - { - "Reward":1618237995034133, - "Stock":2, - "Deposit":"395515215668593045354527812", - "Interest":395515215668593045354527, - "Address":"258" - }, - { - "Reward":1503355425751553, - "Stock":1, - "Deposit":"367436648544476551773503995", - "Interest":367436648544476551773503, - "Address":"259" - }, - { - "Reward":4042297116745396, - "Stock":2, - "Deposit":"987982003161632760256262209", - "Interest":987982003161632760256262, - "Address":"260" - }, - { - "Reward":154407377564775, - "Stock":2, - "Deposit":"37738866239552137927070884", - "Interest":37738866239552137927070, - "Address":"261" - }, - { - "Reward":3621636908305865, - "Stock":2, - "Deposit":"885168008202475320453890048", - "Interest":885168008202475320453890, - "Address":"262" - }, - { - "Reward":3736684168652488, - "Stock":1, - "Deposit":"913286827639238962826227879", - "Interest":913286827639238962826227, - "Address":"263" - }, - { - "Reward":3257561136026235, - "Stock":1, - "Deposit":"796183873585212031906049881", - "Interest":796183873585212031906049, - "Address":"264" - }, - { - "Reward":403878165917882, - "Stock":1, - "Deposit":"98712278655574303699458494", - "Interest":98712278655574303699458, - "Address":"265" - }, - { - "Reward":1071437666001816, - "Stock":1, - "Deposit":"261871183870716062183477556", - "Interest":261871183870716062183477, - "Address":"266" - }, - { - "Reward":1372101903601864, - "Stock":2, - "Deposit":"335356839962796526858366187", - "Interest":335356839962796526858366, - "Address":"267" - }, - { - "Reward":2781085413733345, - "Stock":2, - "Deposit":"679727951377337991096935224", - "Interest":679727951377337991096935, - "Address":"268" - }, - { - "Reward":558702842407792, - "Stock":2, - "Deposit":"136553137355369669238257377", - "Interest":136553137355369669238257, - "Address":"269" - }, - { - "Reward":2950879498518055, - "Stock":1, - "Deposit":"721227498581740178458788187", - "Interest":721227498581740178458788, - "Address":"270" - }, - { - "Reward":436812779961863, - "Stock":1, - "Deposit":"106761861607241437256377881", - "Interest":106761861607241437256377, - "Address":"271" - }, - { - "Reward":2674827514182658, - "Stock":2, - "Deposit":"653757348668559612476650953", - "Interest":653757348668559612476650, - "Address":"272" - }, - { - "Reward":2021897031378252, - "Stock":1, - "Deposit":"494173936639270117159802493", - "Interest":494173936639270117159802, - "Address":"273" - }, - { - "Reward":3187465484731220, - "Stock":2, - "Deposit":"779051723231275139455188446", - "Interest":779051723231275139455188, - "Address":"274" - }, - { - "Reward":2925551590146033, - "Stock":2, - "Deposit":"715037078400694081644000950", - "Interest":715037078400694081644000, - "Address":"275" - }, - { - "Reward":3697544089457150, - "Stock":1, - "Deposit":"903720560556316332432450217", - "Interest":903720560556316332432450, - "Address":"276" - }, - { - "Reward":3645181247204112, - "Stock":2, - "Deposit":"890922504330789233337759095", - "Interest":890922504330789233337759, - "Address":"277" - }, - { - "Reward":1367217560928216, - "Stock":2, - "Deposit":"334163052737496246716871970", - "Interest":334163052737496246716871, - "Address":"278" - }, - { - "Reward":2858896472148299, - "Stock":2, - "Deposit":"698745832334794481084703386", - "Interest":698745832334794481084703, - "Address":"279" - }, - { - "Reward":809332649296875, - "Stock":2, - "Deposit":"197809826685929168734490311", - "Interest":197809826685929168734490, - "Address":"280" - }, - { - "Reward":124957315816320, - "Stock":2, - "Deposit":"30540946304636662489734137", - "Interest":30540946304636662489734, - "Address":"281" - }, - { - "Reward":3044356301736995, - "Stock":2, - "Deposit":"744074260367462381190124606", - "Interest":744074260367462381190124, - "Address":"282" - }, - { - "Reward":2045825979851990, - "Stock":2, - "Deposit":"500022435590200875493160690", - "Interest":500022435590200875493160, - "Address":"283" - }, - { - "Reward":1963586260892262, - "Stock":2, - "Deposit":"479922141146060465826471599", - "Interest":479922141146060465826471, - "Address":"284" - }, - { - "Reward":3701642421311227, - "Stock":1, - "Deposit":"904722238067362738443024394", - "Interest":904722238067362738443024, - "Address":"285" - }, - { - "Reward":2495250102358769, - "Stock":1, - "Deposit":"609866648422558443882178011", - "Interest":609866648422558443882178, - "Address":"286" - }, - { - "Reward":2527162496638592, - "Stock":2, - "Deposit":"617666389588454656240433248", - "Interest":617666389588454656240433, - "Address":"287" - }, - { - "Reward":3516381009983172, - "Stock":2, - "Deposit":"859442305646212267875288278", - "Interest":859442305646212267875288, - "Address":"288" - }, - { - "Reward":3295634503387380, - "Stock":1, - "Deposit":"805489424529685638106944750", - "Interest":805489424529685638106944, - "Address":"289" - }, - { - "Reward":2359637839833082, - "Stock":2, - "Deposit":"576721515614685098511038616", - "Interest":576721515614685098511038, - "Address":"290" - }, - { - "Reward":748421497899375, - "Stock":2, - "Deposit":"182922469414913968501375135", - "Interest":182922469414913968501375, - "Address":"291" - }, - { - "Reward":981674232357632, - "Stock":2, - "Deposit":"239932010568717379863822530", - "Interest":239932010568717379863822, - "Address":"292" - }, - { - "Reward":3627135534418888, - "Stock":1, - "Deposit":"886511933076101321669046808", - "Interest":886511933076101321669046, - "Address":"293" - }, - { - "Reward":117319387863193, - "Stock":2, - "Deposit":"28674152464106095195293160", - "Interest":28674152464106095195293, - "Address":"294" - }, - { - "Reward":2004416035854197, - "Stock":2, - "Deposit":"489901388512223867626636760", - "Interest":489901388512223867626636, - "Address":"295" - }, - { - "Reward":687068605138972, - "Stock":2, - "Deposit":"167927145682256750982021219", - "Interest":167927145682256750982021, - "Address":"296" - }, - { - "Reward":4004240923011784, - "Stock":2, - "Deposit":"978680649641158750827515761", - "Interest":978680649641158750827515, - "Address":"297" - }, - { - "Reward":2915966888838907, - "Stock":1, - "Deposit":"712694471678914087682714301", - "Interest":712694471678914087682714, - "Address":"298" - }, - { - "Reward":2047663820656699, - "Stock":2, - "Deposit":"500471624154843031112020846", - "Interest":500471624154843031112020, - "Address":"299" - }, - { - "Reward":1927443184237455, - "Stock":1, - "Deposit":"471088374541939303168635494", - "Interest":471088374541939303168635, - "Address":"300" - }, - { - "Reward":243928710998366, - "Stock":1, - "Deposit":"59618867579639189813774404", - "Interest":59618867579639189813774, - "Address":"301" - }, - { - "Reward":2790266475524177, - "Stock":2, - "Deposit":"681971904149063168361230232", - "Interest":681971904149063168361230, - "Address":"302" - }, - { - "Reward":173605657016624, - "Stock":2, - "Deposit":"42431137500741678004059049", - "Interest":42431137500741678004059, - "Address":"303" - }, - { - "Reward":292316858642681, - "Stock":2, - "Deposit":"71445464600642383246767943", - "Interest":71445464600642383246767, - "Address":"304" - }, - { - "Reward":2134313831017314, - "Stock":1, - "Deposit":"521649842464283697301635131", - "Interest":521649842464283697301635, - "Address":"305" - }, - { - "Reward":395767840978311, - "Stock":2, - "Deposit":"96730025780866979446671041", - "Interest":96730025780866979446671, - "Address":"306" - }, - { - "Reward":3347428930641283, - "Stock":1, - "Deposit":"818148553859624705361500348", - "Interest":818148553859624705361500, - "Address":"307" - }, - { - "Reward":3344968068790850, - "Stock":2, - "Deposit":"817547092079286330531925646", - "Interest":817547092079286330531925, - "Address":"308" - }, - { - "Reward":2955838741902109, - "Stock":2, - "Deposit":"722439592366842298084008004", - "Interest":722439592366842298084008, - "Address":"309" - }, - { - "Reward":613169717757854, - "Stock":2, - "Deposit":"149865442477966848146385312", - "Interest":149865442477966848146385, - "Address":"310" - }, - { - "Reward":2698754029414401, - "Stock":1, - "Deposit":"659605252908307182486620140", - "Interest":659605252908307182486620, - "Address":"311" - }, - { - "Reward":2121814804480946, - "Stock":1, - "Deposit":"518594942510538170493313776", - "Interest":518594942510538170493313, - "Address":"312" - }, - { - "Reward":3980894616301178, - "Stock":1, - "Deposit":"972974554763862520277712937", - "Interest":972974554763862520277712, - "Address":"313" - }, - { - "Reward":2655328165278594, - "Stock":2, - "Deposit":"648991492712356121692441223", - "Interest":648991492712356121692441, - "Address":"314" - }, - { - "Reward":3274527235149369, - "Stock":2, - "Deposit":"800330575352401485397460333", - "Interest":800330575352401485397460, - "Address":"315" - }, - { - "Reward":1856698971947154, - "Stock":2, - "Deposit":"453797708726919490911470914", - "Interest":453797708726919490911470, - "Address":"316" - }, - { - "Reward":1769116161484518, - "Stock":2, - "Deposit":"432391503783461694791924372", - "Interest":432391503783461694791924, - "Address":"317" - }, - { - "Reward":3376745289780442, - "Stock":2, - "Deposit":"825313795402045635726725645", - "Interest":825313795402045635726725, - "Address":"318" - }, - { - "Reward":341514107402481, - "Stock":1, - "Deposit":"83469814858914026523829711", - "Interest":83469814858914026523829, - "Address":"319" - }, - { - "Reward":544864965517434, - "Stock":2, - "Deposit":"133171007607161717702036120", - "Interest":133171007607161717702036, - "Address":"320" - }, - { - "Reward":709414026413975, - "Stock":1, - "Deposit":"173388613119005552400464906", - "Interest":173388613119005552400464, - "Address":"321" - }, - { - "Reward":1599509653114081, - "Stock":1, - "Deposit":"390937802323735539293279167", - "Interest":390937802323735539293279, - "Address":"322" - }, - { - "Reward":3401563921857285, - "Stock":2, - "Deposit":"831379742839069568746659107", - "Interest":831379742839069568746659, - "Address":"323" - }, - { - "Reward":3286939998378884, - "Stock":2, - "Deposit":"803364391602440219849722992", - "Interest":803364391602440219849722, - "Address":"324" - }, - { - "Reward":247415916911863, - "Stock":2, - "Deposit":"60471179169893640726378904", - "Interest":60471179169893640726378, - "Address":"325" - }, - { - "Reward":1633550540217094, - "Stock":1, - "Deposit":"399257770613575702082879145", - "Interest":399257770613575702082879, - "Address":"326" - }, - { - "Reward":2155695795804986, - "Stock":2, - "Deposit":"526875830508295894821492685", - "Interest":526875830508295894821492, - "Address":"327" - }, - { - "Reward":1705321839958657, - "Stock":2, - "Deposit":"416799467930786926576914706", - "Interest":416799467930786926576914, - "Address":"328" - }, - { - "Reward":2687521467892893, - "Stock":1, - "Deposit":"656859890973707227785806327", - "Interest":656859890973707227785806, - "Address":"329" - }, - { - "Reward":2569333136761390, - "Stock":1, - "Deposit":"627973359190104218902796221", - "Interest":627973359190104218902796, - "Address":"330" - }, - { - "Reward":1194643627907971, - "Stock":1, - "Deposit":"291984079961714937393044279", - "Interest":291984079961714937393044, - "Address":"331" - }, - { - "Reward":1766087110243364, - "Stock":2, - "Deposit":"431651170248720239546052504", - "Interest":431651170248720239546052, - "Address":"332" - }, - { - "Reward":63365084692652, - "Stock":1, - "Deposit":"15487125636018950203420109", - "Interest":15487125636018950203420, - "Address":"333" - }, - { - "Reward":4026265603039343, - "Stock":2, - "Deposit":"984063724379153792486247564", - "Interest":984063724379153792486247, - "Address":"334" - }, - { - "Reward":683964261744123, - "Stock":2, - "Deposit":"167168409914655979877089887", - "Interest":167168409914655979877089, - "Address":"335" - }, - { - "Reward":434580815725779, - "Stock":1, - "Deposit":"106216344928663830594568319", - "Interest":106216344928663830594568, - "Address":"336" - }, - { - "Reward":1523702672373597, - "Stock":1, - "Deposit":"372409740055536953033223243", - "Interest":372409740055536953033223, - "Address":"337" - }, - { - "Reward":810595177655935, - "Stock":2, - "Deposit":"198118402542974636484122037", - "Interest":198118402542974636484122, - "Address":"338" - }, - { - "Reward":2003541482459776, - "Stock":2, - "Deposit":"489687638016023885084056825", - "Interest":489687638016023885084056, - "Address":"339" - }, - { - "Reward":1389026562945398, - "Stock":2, - "Deposit":"339493413390757670103975625", - "Interest":339493413390757670103975, - "Address":"340" - }, - { - "Reward":3893565947221773, - "Stock":2, - "Deposit":"951630464777726947654472484", - "Interest":951630464777726947654472, - "Address":"341" - }, - { - "Reward":3765509431522632, - "Stock":1, - "Deposit":"920332039836563753363621038", - "Interest":920332039836563753363621, - "Address":"342" - }, - { - "Reward":215526269873800, - "Stock":1, - "Deposit":"52676997680792592149672304", - "Interest":52676997680792592149672, - "Address":"343" - }, - { - "Reward":3018923059864328, - "Stock":2, - "Deposit":"737858095516996548298305355", - "Interest":737858095516996548298305, - "Address":"344" - }, - { - "Reward":1101093621047553, - "Stock":2, - "Deposit":"269119426398555905424660858", - "Interest":269119426398555905424660, - "Address":"345" - }, - { - "Reward":1730018544809204, - "Stock":2, - "Deposit":"422835615008807841346044819", - "Interest":422835615008807841346044, - "Address":"346" - }, - { - "Reward":2241596463541202, - "Stock":1, - "Deposit":"547870901214844718834984677", - "Interest":547870901214844718834984, - "Address":"347" - }, - { - "Reward":3857178553047444, - "Stock":2, - "Deposit":"942736984276934308911148754", - "Interest":942736984276934308911148, - "Address":"348" - }, - { - "Reward":1709186789853267, - "Stock":1, - "Deposit":"417744104316662201452369629", - "Interest":417744104316662201452369, - "Address":"349" - }, - { - "Reward":4022128073288843, - "Stock":1, - "Deposit":"983052466469856112151023051", - "Interest":983052466469856112151023, - "Address":"350" - }, - { - "Reward":1233393387842973, - "Stock":1, - "Deposit":"301454948712065462504653247", - "Interest":301454948712065462504653, - "Address":"351" - }, - { - "Reward":2868523384497775, - "Stock":2, - "Deposit":"701098755900926295943419800", - "Interest":701098755900926295943419, - "Address":"352" - }, - { - "Reward":2726304335418650, - "Stock":1, - "Deposit":"666338851584425628800097420", - "Interest":666338851584425628800097, - "Address":"353" - }, - { - "Reward":2205818879524007, - "Stock":1, - "Deposit":"539126465042856661829930534", - "Interest":539126465042856661829930, - "Address":"354" - }, - { - "Reward":2856276655220852, - "Stock":1, - "Deposit":"698105520180308358753376458", - "Interest":698105520180308358753376, - "Address":"355" - }, - { - "Reward":2727077875867762, - "Stock":1, - "Deposit":"666527913402586880138309914", - "Interest":666527913402586880138309, - "Address":"356" - }, - { - "Reward":728823302972113, - "Stock":2, - "Deposit":"178132454400337758572806566", - "Interest":178132454400337758572806, - "Address":"357" - }, - { - "Reward":523766867447775, - "Stock":2, - "Deposit":"128014399720172589171198780", - "Interest":128014399720172589171198, - "Address":"358" - }, - { - "Reward":4087705834941199, - "Stock":1, - "Deposit":"999080394761360679477525300", - "Interest":999080394761360679477525, - "Address":"359" - }, - { - "Reward":700136430555849, - "Stock":1, - "Deposit":"171121066356432094403605627", - "Interest":171121066356432094403605, - "Address":"360" - }, - { - "Reward":133385226059151, - "Stock":2, - "Deposit":"32600820530528040741883734", - "Interest":32600820530528040741883, - "Address":"361" - }, - { - "Reward":2296131201508580, - "Stock":2, - "Deposit":"561199792709660139072902868", - "Interest":561199792709660139072902, - "Address":"362" - }, - { - "Reward":3608128893768435, - "Stock":2, - "Deposit":"881866500451809920422192686", - "Interest":881866500451809920422192, - "Address":"363" - }, - { - "Reward":2737909592948392, - "Stock":2, - "Deposit":"669175304534393777806691214", - "Interest":669175304534393777806691, - "Address":"364" - }, - { - "Reward":779151689393676, - "Stock":1, - "Deposit":"190433267179954124339273653", - "Interest":190433267179954124339273, - "Address":"365" - }, - { - "Reward":1509410379644114, - "Stock":2, - "Deposit":"368916546063894901234325675", - "Interest":368916546063894901234325, - "Address":"366" - }, - { - "Reward":1885045599856839, - "Stock":1, - "Deposit":"460725937260411555489609993", - "Interest":460725937260411555489609, - "Address":"367" - }, - { - "Reward":4016340627864401, - "Stock":1, - "Deposit":"981637950970749684219500640", - "Interest":981637950970749684219500, - "Address":"368" - }, - { - "Reward":639925915054047, - "Stock":1, - "Deposit":"156404952226563476182405485", - "Interest":156404952226563476182405, - "Address":"369" - }, - { - "Reward":3500344500521320, - "Stock":1, - "Deposit":"855522805845911338282426833", - "Interest":855522805845911338282426, - "Address":"370" - }, - { - "Reward":2638033709145656, - "Stock":1, - "Deposit":"644764536870087945359178283", - "Interest":644764536870087945359178, - "Address":"371" - }, - { - "Reward":1539505847124934, - "Stock":1, - "Deposit":"376272210278831620304125389", - "Interest":376272210278831620304125, - "Address":"372" - }, - { - "Reward":781158260274325, - "Stock":1, - "Deposit":"190923695236303037072420795", - "Interest":190923695236303037072420, - "Address":"373" - }, - { - "Reward":1752183575427890, - "Stock":2, - "Deposit":"428252992979386015730385230", - "Interest":428252992979386015730385, - "Address":"374" - }, - { - "Reward":1972178016685975, - "Stock":1, - "Deposit":"482022061031856297046813485", - "Interest":482022061031856297046813, - "Address":"375" - }, - { - "Reward":493478600943065, - "Stock":1, - "Deposit":"120611613297162301173909745", - "Interest":120611613297162301173909, - "Address":"376" - }, - { - "Reward":2411951227914034, - "Stock":2, - "Deposit":"589507484695058980867293886", - "Interest":589507484695058980867293, - "Address":"377" - }, - { - "Reward":925439737547517, - "Stock":2, - "Deposit":"226187679752675729896211350", - "Interest":226187679752675729896211, - "Address":"378" - }, - { - "Reward":1573656982119393, - "Stock":2, - "Deposit":"384619124369410814172033654", - "Interest":384619124369410814172033, - "Address":"379" - }, - { - "Reward":2385270345554272, - "Stock":2, - "Deposit":"582986382747673892451841134", - "Interest":582986382747673892451841, - "Address":"380" - }, - { - "Reward":1030256785641210, - "Stock":2, - "Deposit":"251806122472312821083690938", - "Interest":251806122472312821083690, - "Address":"381" - }, - { - "Reward":1188328791451050, - "Stock":2, - "Deposit":"290440664276979343408473223", - "Interest":290440664276979343408473, - "Address":"382" - }, - { - "Reward":2524807835335136, - "Stock":2, - "Deposit":"617090884393223348964367191", - "Interest":617090884393223348964367, - "Address":"383" - }, - { - "Reward":1085388451835233, - "Stock":1, - "Deposit":"265280909810029386089333185", - "Interest":265280909810029386089333, - "Address":"384" - }, - { - "Reward":3372909420703728, - "Stock":1, - "Deposit":"824376266688835013249268791", - "Interest":824376266688835013249268, - "Address":"385" - }, - { - "Reward":4020536218995700, - "Stock":1, - "Deposit":"982663399721950270314477979", - "Interest":982663399721950270314477, - "Address":"386" - }, - { - "Reward":2987789836296434, - "Stock":1, - "Deposit":"730248792267597646173462210", - "Interest":730248792267597646173462, - "Address":"387" - }, - { - "Reward":1406961885743611, - "Stock":2, - "Deposit":"343877004114983120256592980", - "Interest":343877004114983120256592, - "Address":"388" - }, - { - "Reward":2389701203397972, - "Stock":1, - "Deposit":"584069333278452007546528604", - "Interest":584069333278452007546528, - "Address":"389" - }, - { - "Reward":440933517210033, - "Stock":1, - "Deposit":"107769015243743049304836294", - "Interest":107769015243743049304836, - "Address":"390" - }, - { - "Reward":3708131132480672, - "Stock":2, - "Deposit":"906308150649732913182350426", - "Interest":906308150649732913182350, - "Address":"391" - }, - { - "Reward":3599075390876148, - "Stock":1, - "Deposit":"879653724481904819585316361", - "Interest":879653724481904819585316, - "Address":"392" - }, - { - "Reward":3345841463461608, - "Stock":2, - "Deposit":"817760559370641848539306356", - "Interest":817760559370641848539306, - "Address":"393" - }, - { - "Reward":1066760361488363, - "Stock":2, - "Deposit":"260727999055464620961449042", - "Interest":260727999055464620961449, - "Address":"394" - }, - { - "Reward":2431789800514182, - "Stock":2, - "Deposit":"594356250664330842964742903", - "Interest":594356250664330842964742, - "Address":"395" - }, - { - "Reward":92109561138852, - "Stock":2, - "Deposit":"22512592740231762711514246", - "Interest":22512592740231762711514, - "Address":"396" - }, - { - "Reward":1739935057996673, - "Stock":1, - "Deposit":"425259320214134928232837518", - "Interest":425259320214134928232837, - "Address":"397" - }, - { - "Reward":1279479434343500, - "Stock":1, - "Deposit":"312718886820615549207784919", - "Interest":312718886820615549207784, - "Address":"398" - }, - { - "Reward":660709723700262, - "Stock":2, - "Deposit":"161484744311749972568940361", - "Interest":161484744311749972568940, - "Address":"399" - }, - { - "Reward":731416198845928, - "Stock":2, - "Deposit":"178766186752368216874141405", - "Interest":178766186752368216874141, - "Address":"400" - }, - { - "Reward":1730223421369853, - "Stock":2, - "Deposit":"422885689100084505302807469", - "Interest":422885689100084505302807, - "Address":"401" - }, - { - "Reward":385536359650064, - "Stock":2, - "Deposit":"94229338887734659381099064", - "Interest":94229338887734659381099, - "Address":"402" - }, - { - "Reward":2448840659826714, - "Stock":2, - "Deposit":"598523668756741122904270457", - "Interest":598523668756741122904270, - "Address":"403" - }, - { - "Reward":1926771699880179, - "Stock":2, - "Deposit":"470924256358334014654063379", - "Interest":470924256358334014654063, - "Address":"404" - }, - { - "Reward":2847454602975988, - "Stock":1, - "Deposit":"695949313301607919164685192", - "Interest":695949313301607919164685, - "Address":"405" - }, - { - "Reward":2863569001010863, - "Stock":1, - "Deposit":"699887849928291561070524046", - "Interest":699887849928291561070524, - "Address":"406" - }, - { - "Reward":2612528401181040, - "Stock":1, - "Deposit":"638530758271837917134645958", - "Interest":638530758271837917134645, - "Address":"407" - }, - { - "Reward":137489032399601, - "Stock":2, - "Deposit":"33603836066429471074792808", - "Interest":33603836066429471074792, - "Address":"408" - }, - { - "Reward":281517978251972, - "Stock":2, - "Deposit":"68806099118051244901272055", - "Interest":68806099118051244901272, - "Address":"409" - }, - { - "Reward":1307632207771456, - "Stock":2, - "Deposit":"319599735180496113965271808", - "Interest":319599735180496113965271, - "Address":"410" - }, - { - "Reward":2172014413588379, - "Stock":2, - "Deposit":"530864280694126500220494768", - "Interest":530864280694126500220494, - "Address":"411" - }, - { - "Reward":2677643913620959, - "Stock":1, - "Deposit":"654445707757066341698647930", - "Interest":654445707757066341698647, - "Address":"412" - }, - { - "Reward":1667761051979364, - "Stock":2, - "Deposit":"407619197041152570019826577", - "Interest":407619197041152570019826, - "Address":"413" - }, - { - "Reward":3354927237570882, - "Stock":2, - "Deposit":"819981222781940632956953117", - "Interest":819981222781940632956953, - "Address":"414" - }, - { - "Reward":2939142894928170, - "Stock":1, - "Deposit":"718358943205883671019834236", - "Interest":718358943205883671019834, - "Address":"415" - }, - { - "Reward":3963198096929228, - "Stock":2, - "Deposit":"968649330231093674835293263", - "Interest":968649330231093674835293, - "Address":"416" - }, - { - "Reward":2173935872987875, - "Stock":2, - "Deposit":"531333906565674474192541661", - "Interest":531333906565674474192541, - "Address":"417" - }, - { - "Reward":1330323273034804, - "Stock":1, - "Deposit":"325145681820560028544215889", - "Interest":325145681820560028544215, - "Address":"418" - }, - { - "Reward":432178544441729, - "Stock":2, - "Deposit":"105629203329021925662434908", - "Interest":105629203329021925662434, - "Address":"419" - }, - { - "Reward":2499718028058417, - "Stock":2, - "Deposit":"610958658746200589113038031", - "Interest":610958658746200589113038, - "Address":"420" - }, - { - "Reward":3186444739444658, - "Stock":1, - "Deposit":"778802241824092522656251648", - "Interest":778802241824092522656251, - "Address":"421" - }, - { - "Reward":1732544224411811, - "Stock":1, - "Deposit":"423452918962738289469850110", - "Interest":423452918962738289469850, - "Address":"422" - }, - { - "Reward":371600601121321, - "Stock":1, - "Deposit":"90823285787439478334645377", - "Interest":90823285787439478334645, - "Address":"423" - }, - { - "Reward":1090259676212816, - "Stock":2, - "Deposit":"266471490779072395230107104", - "Interest":266471490779072395230107, - "Address":"424" - }, - { - "Reward":628681599968663, - "Stock":2, - "Deposit":"153656717591306613003724097", - "Interest":153656717591306613003724, - "Address":"425" - }, - { - "Reward":1149724307313117, - "Stock":1, - "Deposit":"281005302533870904294098581", - "Interest":281005302533870904294098, - "Address":"426" - }, - { - "Reward":1800594426635642, - "Stock":2, - "Deposit":"440085139001720859757105687", - "Interest":440085139001720859757105, - "Address":"427" - }, - { - "Reward":2156787854751783, - "Stock":2, - "Deposit":"527142741760652233656552056", - "Interest":527142741760652233656552, - "Address":"428" - }, - { - "Reward":1871537324193419, - "Stock":2, - "Deposit":"457424365687673972762490814", - "Interest":457424365687673972762490, - "Address":"429" - }, - { - "Reward":3581555208288150, - "Stock":2, - "Deposit":"875371598604184897327448886", - "Interest":875371598604184897327448, - "Address":"430" - }, - { - "Reward":2119593815728007, - "Stock":1, - "Deposit":"518052108361104157735102016", - "Interest":518052108361104157735102, - "Address":"431" - }, - { - "Reward":3860802122205904, - "Stock":1, - "Deposit":"943622624548387856089894756", - "Interest":943622624548387856089894, - "Address":"432" - }, - { - "Reward":2609166604462662, - "Stock":2, - "Deposit":"637709098072174018773926448", - "Interest":637709098072174018773926, - "Address":"433" - }, - { - "Reward":3918374463662000, - "Stock":1, - "Deposit":"957693939841583241632936820", - "Interest":957693939841583241632936, - "Address":"434" - }, - { - "Reward":984845222269297, - "Stock":1, - "Deposit":"240707035480160258525035487", - "Interest":240707035480160258525035, - "Address":"435" - }, - { - "Reward":2766333020975655, - "Stock":1, - "Deposit":"676122303863751827897137841", - "Interest":676122303863751827897137, - "Address":"436" - }, - { - "Reward":1182698552092772, - "Stock":2, - "Deposit":"289064571674476744614469656", - "Interest":289064571674476744614469, - "Address":"437" - }, - { - "Reward":2748681859962604, - "Stock":1, - "Deposit":"671808165414215174855489788", - "Interest":671808165414215174855489, - "Address":"438" - }, - { - "Reward":2844145367100614, - "Stock":2, - "Deposit":"695140499551737178769723283", - "Interest":695140499551737178769723, - "Address":"439" - }, - { - "Reward":278190261630602, - "Stock":1, - "Deposit":"67992768470010567228425246", - "Interest":67992768470010567228425, - "Address":"440" - }, - { - "Reward":1042465866879445, - "Stock":2, - "Deposit":"254790156597005323926611215", - "Interest":254790156597005323926611, - "Address":"441" - }, - { - "Reward":916652699885392, - "Stock":2, - "Deposit":"224040030824218749929706206", - "Interest":224040030824218749929706, - "Address":"442" - }, - { - "Reward":2732416479487343, - "Stock":1, - "Deposit":"667832727013716542792132141", - "Interest":667832727013716542792132, - "Address":"443" - }, - { - "Reward":3454803800888605, - "Stock":2, - "Deposit":"844392156527204562630027737", - "Interest":844392156527204562630027, - "Address":"444" - }, - { - "Reward":1409357060729345, - "Stock":1, - "Deposit":"344462411301042159553875569", - "Interest":344462411301042159553875, - "Address":"445" - }, - { - "Reward":3193471471851210, - "Stock":2, - "Deposit":"780519652731357926896986806", - "Interest":780519652731357926896986, - "Address":"446" - }, - { - "Reward":2763099786715651, - "Stock":2, - "Deposit":"675332065746999554718496487", - "Interest":675332065746999554718496, - "Address":"447" - }, - { - "Reward":13737748066641, - "Stock":1, - "Deposit":"6715314318477494381976403", - "Interest":3357657159238747190988, - "Address":"448" - }, - { - "Reward":2463761503703055, - "Stock":1, - "Deposit":"602170487581795255144688825", - "Interest":602170487581795255144688, - "Address":"449" - }, - { - "Reward":1582462109076061, - "Stock":1, - "Deposit":"386771194520984629154326116", - "Interest":386771194520984629154326, - "Address":"450" - }, - { - "Reward":3747749203191437, - "Stock":1, - "Deposit":"915991244131425297334828863", - "Interest":915991244131425297334828, - "Address":"451" - }, - { - "Reward":2354756918298, - "Stock":1, - "Deposit":"1151057129107235788024031", - "Interest":575528564553617894012, - "Address":"452" - }, - { - "Reward":1892096108091529, - "Stock":2, - "Deposit":"462449159242328655676958680", - "Interest":462449159242328655676958, - "Address":"453" - }, - { - "Reward":1736210674536690, - "Stock":2, - "Deposit":"424349039815375195243495108", - "Interest":424349039815375195243495, - "Address":"454" - }, - { - "Reward":1885824733140241, - "Stock":2, - "Deposit":"460916366028964019645628308", - "Interest":460916366028964019645628, - "Address":"455" - }, - { - "Reward":3151084169980250, - "Stock":2, - "Deposit":"770159728608609261976048827", - "Interest":770159728608609261976048, - "Address":"456" - }, - { - "Reward":1319383199543501, - "Stock":1, - "Deposit":"322471807186778591794886745", - "Interest":322471807186778591794886, - "Address":"457" - }, - { - "Reward":3210736003750061, - "Stock":2, - "Deposit":"784739294760741556985574907", - "Interest":784739294760741556985574, - "Address":"458" - }, - { - "Reward":1928542885704777, - "Stock":1, - "Deposit":"471357153710611598289850025", - "Interest":471357153710611598289850, - "Address":"459" - }, - { - "Reward":146322092019969, - "Stock":2, - "Deposit":"35762733269117941148709056", - "Interest":35762733269117941148709, - "Address":"460" - }, - { - "Reward":719584608982507, - "Stock":1, - "Deposit":"175874415683530904709977713", - "Interest":175874415683530904709977, - "Address":"461" - }, - { - "Reward":2953050164910110, - "Stock":2, - "Deposit":"721758033391102449279336505", - "Interest":721758033391102449279336, - "Address":"462" - }, - { - "Reward":1937252964181698, - "Stock":1, - "Deposit":"473485992965320345864667075", - "Interest":473485992965320345864667, - "Address":"463" - }, - { - "Reward":624853961126621, - "Stock":2, - "Deposit":"152721200438231785591474540", - "Interest":152721200438231785591474, - "Address":"464" - }, - { - "Reward":1395700540205012, - "Stock":2, - "Deposit":"341124607049109296322908331", - "Interest":341124607049109296322908, - "Address":"465" - }, - { - "Reward":2485113756830617, - "Stock":2, - "Deposit":"607389213768347424610667420", - "Interest":607389213768347424610667, - "Address":"466" - }, - { - "Reward":784519647951553, - "Stock":2, - "Deposit":"191745255461797770026561363", - "Interest":191745255461797770026561, - "Address":"467" - }, - { - "Reward":3021250059833197, - "Stock":2, - "Deposit":"738426839976941584716302597", - "Interest":738426839976941584716302, - "Address":"468" - }, - { - "Reward":993611450353223, - "Stock":1, - "Deposit":"242849598318169102031600037", - "Interest":242849598318169102031600, - "Address":"469" - }, - { - "Reward":3753612677994858, - "Stock":1, - "Deposit":"917424342049382390849317035", - "Interest":917424342049382390849317, - "Address":"470" - }, - { - "Reward":1100856971693136, - "Stock":2, - "Deposit":"269061586686018316963343962", - "Interest":269061586686018316963343, - "Address":"471" - }, - { - "Reward":3132019105768222, - "Stock":2, - "Deposit":"765500016621438406091303277", - "Interest":765500016621438406091303, - "Address":"472" - }, - { - "Reward":771904510793974, - "Stock":2, - "Deposit":"188661976791490992868214122", - "Interest":188661976791490992868214, - "Address":"473" - }, - { - "Reward":1176289681730836, - "Stock":1, - "Deposit":"287498173066131235134465228", - "Interest":287498173066131235134465, - "Address":"474" - }, - { - "Reward":372787854817343, - "Stock":2, - "Deposit":"91113463686534945652284398", - "Interest":91113463686534945652284, - "Address":"475" - }, - { - "Reward":2357542455876767, - "Stock":2, - "Deposit":"576209380663006975892487714", - "Interest":576209380663006975892487, - "Address":"476" - }, - { - "Reward":2795959095631259, - "Stock":1, - "Deposit":"683363243294653033295282493", - "Interest":683363243294653033295282, - "Address":"477" - }, - { - "Reward":2236368439982481, - "Stock":2, - "Deposit":"546593114590322781692809269", - "Interest":546593114590322781692809, - "Address":"478" - }, - { - "Reward":1741856091005858, - "Stock":2, - "Deposit":"425728841871187868588312337", - "Interest":425728841871187868588312, - "Address":"479" - }, - { - "Reward":2636717256944907, - "Stock":1, - "Deposit":"644442781431336486625882048", - "Interest":644442781431336486625882, - "Address":"480" - }, - { - "Reward":2649707050151853, - "Stock":2, - "Deposit":"647617630172684366491684433", - "Interest":647617630172684366491684, - "Address":"481" - }, - { - "Reward":2778175572539983, - "Stock":2, - "Deposit":"679016754093201946325242926", - "Interest":679016754093201946325242, - "Address":"482" - }, - { - "Reward":2601301216572530, - "Stock":1, - "Deposit":"635786710514083641682915945", - "Interest":635786710514083641682915, - "Address":"483" - }, - { - "Reward":3867149988580776, - "Stock":2, - "Deposit":"945174113109401359276724234", - "Interest":945174113109401359276724, - "Address":"484" - }, - { - "Reward":854850626638351, - "Stock":2, - "Deposit":"208934922426022851029570321", - "Interest":208934922426022851029570, - "Address":"485" - }, - { - "Reward":2902003652548357, - "Stock":2, - "Deposit":"709281702710544803565521035", - "Interest":709281702710544803565521, - "Address":"486" - }, - { - "Reward":966529933959639, - "Stock":2, - "Deposit":"236230576993796570486467839", - "Interest":236230576993796570486467, - "Address":"487" - }, - { - "Reward":488505971441575, - "Stock":1, - "Deposit":"119396247797305510297632380", - "Interest":119396247797305510297632, - "Address":"488" - }, - { - "Reward":2484764864709827, - "Stock":1, - "Deposit":"607303940685634646718355217", - "Interest":607303940685634646718355, - "Address":"489" - }, - { - "Reward":1841724149590578, - "Stock":2, - "Deposit":"450137696965896005889596760", - "Interest":450137696965896005889596, - "Address":"490" - }, - { - "Reward":1876860848092862, - "Stock":2, - "Deposit":"458725493648867832523628073", - "Interest":458725493648867832523628, - "Address":"491" - }, - { - "Reward":2708326015565295, - "Stock":1, - "Deposit":"661944751905651940233573613", - "Interest":661944751905651940233573, - "Address":"492" - }, - { - "Reward":3151598820218770, - "Stock":1, - "Deposit":"770285514803660142931698237", - "Interest":770285514803660142931698, - "Address":"493" - }, - { - "Reward":1432905924839680, - "Stock":1, - "Deposit":"350218013441105036068936228", - "Interest":350218013441105036068936, - "Address":"494" - }, - { - "Reward":2708591332778670, - "Stock":1, - "Deposit":"662009598359134532337086422", - "Interest":662009598359134532337086, - "Address":"495" - }, - { - "Reward":1702699708051793, - "Stock":1, - "Deposit":"416158589969796488543246727", - "Interest":416158589969796488543246, - "Address":"496" - }, - { - "Reward":3444726498597153, - "Stock":2, - "Deposit":"841929152691308968500890278", - "Interest":841929152691308968500890, - "Address":"497" - }, - { - "Reward":3407852820660814, - "Stock":1, - "Deposit":"832916819075215753018221563", - "Interest":832916819075215753018221, - "Address":"498" - }, - { - "Reward":1049220208653560, - "Stock":1, - "Deposit":"256440992229147290973121100", - "Interest":256440992229147290973121, - "Address":"499" - }, - { - "Reward":2509955201329210, - "Stock":1, - "Deposit":"613460736812875273577550684", - "Interest":613460736812875273577550, - "Address":"500" - }, - { - "Reward":2382254040523019, - "Stock":1, - "Deposit":"582249164527227081050986004", - "Interest":582249164527227081050986, - "Address":"501" - }, - { - "Reward":2212417894631648, - "Stock":1, - "Deposit":"540739337124409691354005833", - "Interest":540739337124409691354005, - "Address":"502" - }, - { - "Reward":3559336218256985, - "Stock":1, - "Deposit":"869941032358007348976679259", - "Interest":869941032358007348976679, - "Address":"503" - }, - { - "Reward":1083335012046762, - "Stock":1, - "Deposit":"264779026475630008266451739", - "Interest":264779026475630008266451, - "Address":"504" - }, - { - "Reward":1301390019366775, - "Stock":1, - "Deposit":"318074075481059148632192912", - "Interest":318074075481059148632192, - "Address":"505" - }, - { - "Reward":487762524049382, - "Stock":1, - "Deposit":"119214541054191158765488228", - "Interest":119214541054191158765488, - "Address":"506" - }, - { - "Reward":3845282551757273, - "Stock":1, - "Deposit":"939829470344920592249035825", - "Interest":939829470344920592249035, - "Address":"507" - }, - { - "Reward":2641255078088809, - "Stock":1, - "Deposit":"645551874972523531688094961", - "Interest":645551874972523531688094, - "Address":"508" - }, - { - "Reward":1961708619786733, - "Stock":1, - "Deposit":"479463224948887822845294583", - "Interest":479463224948887822845294, - "Address":"509" - }, - { - "Reward":2615745124940367, - "Stock":2, - "Deposit":"639316961040108378006855778", - "Interest":639316961040108378006855, - "Address":"510" - }, - { - "Reward":2228688737224772, - "Stock":1, - "Deposit":"544716110526762831162030937", - "Interest":544716110526762831162030, - "Address":"511" - }, - { - "Reward":2648454447602956, - "Stock":2, - "Deposit":"647311480293127683445037235", - "Interest":647311480293127683445037, - "Address":"512" - }, - { - "Reward":2225292096221957, - "Stock":1, - "Deposit":"543885933999639026309330141", - "Interest":543885933999639026309330, - "Address":"513" - }, - { - "Reward":2950139441894210, - "Stock":1, - "Deposit":"721046620579811392566781200", - "Interest":721046620579811392566781, - "Address":"514" - }, - { - "Reward":2137773017420288, - "Stock":1, - "Deposit":"522495305777102125871171929", - "Interest":522495305777102125871171, - "Address":"515" - }, - { - "Reward":4065711039397482, - "Stock":1, - "Deposit":"993704624120852031420250737", - "Interest":993704624120852031420250, - "Address":"516" - }, - { - "Reward":894708524871802, - "Stock":1, - "Deposit":"218676632399633863459396013", - "Interest":218676632399633863459396, - "Address":"517" - }, - { - "Reward":432870288676779, - "Stock":1, - "Deposit":"105798273250228169751698924", - "Interest":105798273250228169751698, - "Address":"518" - }, - { - "Reward":448823706441385, - "Stock":1, - "Deposit":"109697464523194176956296873", - "Interest":109697464523194176956296, - "Address":"519" - }, - { - "Reward":260182082993370, - "Stock":1, - "Deposit":"63591370975105698804621691", - "Interest":63591370975105698804621, - "Address":"520" - }, - { - "Reward":1655326256464805, - "Stock":1, - "Deposit":"404579995857625829284876954", - "Interest":404579995857625829284876, - "Address":"521" - }, - { - "Reward":1834503587993612, - "Stock":1, - "Deposit":"448372912066495321608033946", - "Interest":448372912066495321608033, - "Address":"522" - }, - { - "Reward":1496725317019609, - "Stock":2, - "Deposit":"365816176838171247535416219", - "Interest":365816176838171247535416, - "Address":"523" - }, - { - "Reward":3123855088906888, - "Stock":2, - "Deposit":"763504640848813420647002076", - "Interest":763504640848813420647002, - "Address":"524" - }, - { - "Reward":2569018177261261, - "Stock":2, - "Deposit":"627896379614168775879668516", - "Interest":627896379614168775879668, - "Address":"525" - }, - { - "Reward":3158533330287193, - "Stock":1, - "Deposit":"771980385554245085452048869", - "Interest":771980385554245085452048, - "Address":"526" - }, - { - "Reward":3816740877279736, - "Stock":1, - "Deposit":"932853570278819543846621141", - "Interest":932853570278819543846621, - "Address":"527" - }, - { - "Reward":3979938437029960, - "Stock":1, - "Deposit":"972740854003013799565506716", - "Interest":972740854003013799565506, - "Address":"528" - }, - { - "Reward":785677917959281, - "Stock":2, - "Deposit":"192028349427774913673303669", - "Interest":192028349427774913673303, - "Address":"529" - }, - { - "Reward":568199408380083, - "Stock":1, - "Deposit":"138874202829155302120478227", - "Interest":138874202829155302120478, - "Address":"530" - }, - { - "Reward":2848751695750288, - "Stock":1, - "Deposit":"696266337082994790648477850", - "Interest":696266337082994790648477, - "Address":"531" - }, - { - "Reward":383861672086521, - "Stock":1, - "Deposit":"93820026774865561415111319", - "Interest":93820026774865561415111, - "Address":"532" - }, - { - "Reward":2149675500210977, - "Stock":1, - "Deposit":"525404403859335733533973095", - "Interest":525404403859335733533973, - "Address":"533" - }, - { - "Reward":2169886595131974, - "Stock":1, - "Deposit":"530344218392863386851457574", - "Interest":530344218392863386851457, - "Address":"534" - }, - { - "Reward":3523326301056576, - "Stock":2, - "Deposit":"861139811393332399455934970", - "Interest":861139811393332399455934, - "Address":"535" - }, - { - "Reward":1983762078651360, - "Stock":1, - "Deposit":"484853333552101917196934009", - "Interest":484853333552101917196934, - "Address":"536" - }, - { - "Reward":1609814257158496, - "Stock":2, - "Deposit":"393456361215266392509827031", - "Interest":393456361215266392509827, - "Address":"537" - }, - { - "Reward":2747139271071685, - "Stock":2, - "Deposit":"671431139674026011838805881", - "Interest":671431139674026011838805, - "Address":"538" - }, - { - "Reward":3032833430164573, - "Stock":1, - "Deposit":"741257943454206480467706089", - "Interest":741257943454206480467706, - "Address":"539" - }, - { - "Reward":2127778221426338, - "Stock":2, - "Deposit":"520052467390386796713608377", - "Interest":520052467390386796713608, - "Address":"540" - }, - { - "Reward":1422655396619640, - "Stock":2, - "Deposit":"347712671277525142702479336", - "Interest":347712671277525142702479, - "Address":"541" - }, - { - "Reward":613709019742482, - "Stock":2, - "Deposit":"149997253831683052817502604", - "Interest":149997253831683052817502, - "Address":"542" - }, - { - "Reward":2397977155389030, - "Stock":2, - "Deposit":"586092067231461899551619282", - "Interest":586092067231461899551619, - "Address":"543" - }, - { - "Reward":1072559276007440, - "Stock":1, - "Deposit":"262145317727807358745683137", - "Interest":262145317727807358745683, - "Address":"544" - }, - { - "Reward":181882512504085, - "Stock":2, - "Deposit":"44454092278238488411990004", - "Interest":44454092278238488411990, - "Address":"545" - }, - { - "Reward":3088785584856983, - "Stock":1, - "Deposit":"754933267231179150343660422", - "Interest":754933267231179150343660, - "Address":"546" - }, - { - "Reward":993348612390782, - "Stock":1, - "Deposit":"242785357820961888999572311", - "Interest":242785357820961888999572, - "Address":"547" - }, - { - "Reward":1810075070766934, - "Stock":2, - "Deposit":"442402313001943325869703986", - "Interest":442402313001943325869703, - "Address":"548" - }, - { - "Reward":2814095927752370, - "Stock":2, - "Deposit":"687796085120107147943479663", - "Interest":687796085120107147943479, - "Address":"549" - }, - { - "Reward":1469770860718286, - "Stock":1, - "Deposit":"359228210401860592607939674", - "Interest":359228210401860592607939, - "Address":"550" - }, - { - "Reward":3012712124073869, - "Stock":1, - "Deposit":"736340074301201741320961853", - "Interest":736340074301201741320961, - "Address":"551" - }, - { - "Reward":1614933150777416, - "Stock":2, - "Deposit":"394707475278763153529517691", - "Interest":394707475278763153529517, - "Address":"552" - }, - { - "Reward":2796174403726219, - "Stock":2, - "Deposit":"683415866967978402619799051", - "Interest":683415866967978402619799, - "Address":"553" - }, - { - "Reward":2880587792677243, - "Stock":2, - "Deposit":"704047430334265977876313356", - "Interest":704047430334265977876313, - "Address":"554" - }, - { - "Reward":1809678609042413, - "Stock":2, - "Deposit":"442305413383370815698625735", - "Interest":442305413383370815698625, - "Address":"555" - }, - { - "Reward":80101227541651, - "Stock":1, - "Deposit":"19577623553318712623845446", - "Interest":19577623553318712623845, - "Address":"556" - }, - { - "Reward":1353694552088953, - "Stock":2, - "Deposit":"330857880214071031769160151", - "Interest":330857880214071031769160, - "Address":"557" - }, - { - "Reward":1736048885675581, - "Stock":1, - "Deposit":"424309496833137456133020973", - "Interest":424309496833137456133020, - "Address":"558" - }, - { - "Reward":1105802889004913, - "Stock":2, - "Deposit":"270270423432065309834939865", - "Interest":270270423432065309834939, - "Address":"559" - }, - { - "Reward":806239382231617, - "Stock":1, - "Deposit":"197053798095455756646835837", - "Interest":197053798095455756646835, - "Address":"560" - }, - { - "Reward":3362046237793966, - "Stock":2, - "Deposit":"821721184961309858438166328", - "Interest":821721184961309858438166, - "Address":"561" - }, - { - "Reward":1759009848373504, - "Stock":2, - "Deposit":"429921409383266395214239159", - "Interest":429921409383266395214239, - "Address":"562" - }, - { - "Reward":3632286779755918, - "Stock":1, - "Deposit":"887770954256353772580100638", - "Interest":887770954256353772580100, - "Address":"563" - }, - { - "Reward":1600512853080576, - "Stock":1, - "Deposit":"391182995461163307563979087", - "Interest":391182995461163307563979, - "Address":"564" - }, - { - "Reward":3146807189440760, - "Stock":1, - "Deposit":"769114387388295628341562846", - "Interest":769114387388295628341562, - "Address":"565" - }, - { - "Reward":1623459941618764, - "Stock":1, - "Deposit":"396791517013616590329817327", - "Interest":396791517013616590329817, - "Address":"566" - }, - { - "Reward":3308009850578972, - "Stock":1, - "Deposit":"808514095887345130017371779", - "Interest":808514095887345130017371, - "Address":"567" - }, - { - "Reward":3089374068018795, - "Stock":2, - "Deposit":"755077099007083529798917225", - "Interest":755077099007083529798917, - "Address":"568" - }, - { - "Reward":1544101934931619, - "Stock":1, - "Deposit":"377395544835102847440073964", - "Interest":377395544835102847440073, - "Address":"569" - }, - { - "Reward":883834562126486, - "Stock":2, - "Deposit":"216018915961394331051108603", - "Interest":216018915961394331051108, - "Address":"570" - }, - { - "Reward":3233926132275605, - "Stock":1, - "Deposit":"790407217966913377979035789", - "Interest":790407217966913377979035, - "Address":"571" - }, - { - "Reward":3884046929504414, - "Stock":1, - "Deposit":"949303911849796899789558600", - "Interest":949303911849796899789558, - "Address":"572" - }, - { - "Reward":1340223612849587, - "Stock":1, - "Deposit":"327565434075205219602797495", - "Interest":327565434075205219602797, - "Address":"573" - }, - { - "Reward":2746456940073496, - "Stock":1, - "Deposit":"671264370451739811336323390", - "Interest":671264370451739811336323, - "Address":"574" - }, - { - "Reward":1794702072215785, - "Stock":2, - "Deposit":"438644982586955611840670522", - "Interest":438644982586955611840670, - "Address":"575" - }, - { - "Reward":3410241323802412, - "Stock":2, - "Deposit":"833500595588975268243615382", - "Interest":833500595588975268243615, - "Address":"576" - }, - { - "Reward":3145742855485207, - "Stock":2, - "Deposit":"768854252429614914995291771", - "Interest":768854252429614914995291, - "Address":"577" - }, - { - "Reward":684312591277182, - "Stock":2, - "Deposit":"167253545494721711507929592", - "Interest":167253545494721711507929, - "Address":"578" - }, - { - "Reward":3526765864760557, - "Stock":1, - "Deposit":"861980478702072172589595676", - "Interest":861980478702072172589595, - "Address":"579" - }, - { - "Reward":4050030607608717, - "Stock":1, - "Deposit":"989872153631503937108902014", - "Interest":989872153631503937108902, - "Address":"580" - }, - { - "Reward":2104747301433398, - "Stock":1, - "Deposit":"514423456505704423951807364", - "Interest":514423456505704423951807, - "Address":"581" - }, - { - "Reward":3618007836924102, - "Stock":1, - "Deposit":"884281023126955334498997335", - "Interest":884281023126955334498997, - "Address":"582" - }, - { - "Reward":2405890006435510, - "Stock":1, - "Deposit":"588026055308497497270727460", - "Interest":588026055308497497270727, - "Address":"583" - }, - { - "Reward":633164339815983, - "Stock":2, - "Deposit":"154752348656044702581039025", - "Interest":154752348656044702581039, - "Address":"584" - }, - { - "Reward":817732418197806, - "Stock":2, - "Deposit":"199862822857452049343017335", - "Interest":199862822857452049343017, - "Address":"585" - }, - { - "Reward":1665042844452572, - "Stock":2, - "Deposit":"406954837138906788677930342", - "Interest":406954837138906788677930, - "Address":"586" - }, - { - "Reward":3063305765033202, - "Stock":1, - "Deposit":"748705718215691429236733064", - "Interest":748705718215691429236733, - "Address":"587" - }, - { - "Reward":3377850069641469, - "Stock":1, - "Deposit":"825583815786155583724059234", - "Interest":825583815786155583724059, - "Address":"588" - }, - { - "Reward":3232108751031388, - "Stock":2, - "Deposit":"789963029944530825695713260", - "Interest":789963029944530825695713, - "Address":"589" - }, - { - "Reward":1303231875347434, - "Stock":2, - "Deposit":"318524245398992156278324362", - "Interest":318524245398992156278324, - "Address":"590" - }, - { - "Reward":2185106485056741, - "Stock":2, - "Deposit":"534064127370726393634121793", - "Interest":534064127370726393634121, - "Address":"591" - }, - { - "Reward":368030357111803, - "Stock":2, - "Deposit":"89950678770581049549026046", - "Interest":89950678770581049549026, - "Address":"592" - }, - { - "Reward":457040519190725, - "Stock":2, - "Deposit":"111705744193203448945134483", - "Interest":111705744193203448945134, - "Address":"593" - }, - { - "Reward":557636653141578, - "Stock":2, - "Deposit":"136292548938298674344989395", - "Interest":136292548938298674344989, - "Address":"594" - }, - { - "Reward":2776684439784897, - "Stock":1, - "Deposit":"678652304800188233009480634", - "Interest":678652304800188233009480, - "Address":"595" - }, - { - "Reward":2026001111497217, - "Stock":2, - "Deposit":"495177019089660608313581350", - "Interest":495177019089660608313581, - "Address":"596" - }, - { - "Reward":776194125811423, - "Stock":1, - "Deposit":"189710406017580157646781602", - "Interest":189710406017580157646781, - "Address":"597" - }, - { - "Reward":2025300676254111, - "Stock":1, - "Deposit":"495005824990220832942327714", - "Interest":495005824990220832942327, - "Address":"598" - }, - { - "Reward":603934371471205, - "Stock":1, - "Deposit":"147608221976688658296037853", - "Interest":147608221976688658296037, - "Address":"599" - }, - { - "Reward":224924983272258, - "Stock":1, - "Deposit":"54974146906188181561086739", - "Interest":54974146906188181561086, - "Address":"600" - }, - { - "Reward":3480663999397397, - "Stock":2, - "Deposit":"850712674289007431136128953", - "Interest":850712674289007431136128, - "Address":"601" - }, - { - "Reward":2293511576060669, - "Stock":1, - "Deposit":"560559527354884790112437657", - "Interest":560559527354884790112437, - "Address":"602" - }, - { - "Reward":3803465275446572, - "Stock":2, - "Deposit":"929608866756663210227224746", - "Interest":929608866756663210227224, - "Address":"603" - }, - { - "Reward":2850391815967893, - "Stock":1, - "Deposit":"696667200555227572607319078", - "Interest":696667200555227572607319, - "Address":"604" - }, - { - "Reward":2384470800740038, - "Stock":1, - "Deposit":"582790965175840058881956027", - "Interest":582790965175840058881956, - "Address":"605" - }, - { - "Reward":3336171900307562, - "Stock":2, - "Deposit":"815397211477421168809673797", - "Interest":815397211477421168809673, - "Address":"606" - }, - { - "Reward":3596457588054850, - "Stock":1, - "Deposit":"879013904597177764275073758", - "Interest":879013904597177764275073, - "Address":"607" - }, - { - "Reward":4046100598596198, - "Stock":2, - "Deposit":"988911616079589106408253458", - "Interest":988911616079589106408253, - "Address":"608" - }, - { - "Reward":534320562641, - "Stock":2, - "Deposit":"522375356944770885552987", - "Interest":130593839236192721388, - "Address":"609" - }, - { - "Reward":3540914621903107, - "Stock":1, - "Deposit":"865438591013024560725006849", - "Interest":865438591013024560725006, - "Address":"610" - }, - { - "Reward":2506296334838171, - "Stock":1, - "Deposit":"612566469483998732321064610", - "Interest":612566469483998732321064, - "Address":"611" - }, - { - "Reward":4050349955214366, - "Stock":2, - "Deposit":"989950205708830854877021413", - "Interest":989950205708830854877021, - "Address":"612" - }, - { - "Reward":2158986313541010, - "Stock":2, - "Deposit":"527680069338442359066774994", - "Interest":527680069338442359066774, - "Address":"613" - }, - { - "Reward":1961954763593141, - "Stock":2, - "Deposit":"479523385210218755508110669", - "Interest":479523385210218755508110, - "Address":"614" - }, - { - "Reward":3278688381920122, - "Stock":1, - "Deposit":"801347605521952277571008906", - "Interest":801347605521952277571008, - "Address":"615" - }, - { - "Reward":932212164926109, - "Stock":1, - "Deposit":"227842935706041860302096149", - "Interest":227842935706041860302096, - "Address":"616" - }, - { - "Reward":2037937038050591, - "Stock":2, - "Deposit":"498094291196389704628447122", - "Interest":498094291196389704628447, - "Address":"617" - }, - { - "Reward":3685809463484823, - "Stock":2, - "Deposit":"900852488532004835884000543", - "Interest":900852488532004835884000, - "Address":"618" - }, - { - "Reward":2351208201932520, - "Stock":2, - "Deposit":"574661219130187639342523516", - "Interest":574661219130187639342523, - "Address":"619" - }, - { - "Reward":3458019811744597, - "Stock":2, - "Deposit":"845178185054036634768610449", - "Interest":845178185054036634768610, - "Address":"620" - }, - { - "Reward":3022123392015387, - "Stock":2, - "Deposit":"738640291995401820919927755", - "Interest":738640291995401820919927, - "Address":"621" - }, - { - "Reward":2397547422717600, - "Stock":1, - "Deposit":"585987035826475821670726207", - "Interest":585987035826475821670726, - "Address":"622" - }, - { - "Reward":1009506509028463, - "Stock":2, - "Deposit":"246734525985974895159436494", - "Interest":246734525985974895159436, - "Address":"623" - }, - { - "Reward":2726620874876551, - "Stock":1, - "Deposit":"666416217319467985020772458", - "Interest":666416217319467985020772, - "Address":"624" - }, - { - "Reward":341567291351223, - "Stock":1, - "Deposit":"83482813602622663041454040", - "Interest":83482813602622663041454, - "Address":"625" - }, - { - "Reward":2561094662352571, - "Stock":2, - "Deposit":"625959785171583238400786633", - "Interest":625959785171583238400786, - "Address":"626" - }, - { - "Reward":2704233753620317, - "Stock":1, - "Deposit":"660944557947342303811875083", - "Interest":660944557947342303811875, - "Address":"627" - }, - { - "Reward":2985756634481742, - "Stock":2, - "Deposit":"729751855317221087567433254", - "Interest":729751855317221087567433, - "Address":"628" - }, - { - "Reward":3644484110068999, - "Stock":2, - "Deposit":"890752116325322251819702812", - "Interest":890752116325322251819702, - "Address":"629" - }, - { - "Reward":4019062566853761, - "Stock":1, - "Deposit":"982303222883606386171928477", - "Interest":982303222883606386171928, - "Address":"630" - }, - { - "Reward":3146458178791412, - "Stock":1, - "Deposit":"769029085335896200888906194", - "Interest":769029085335896200888906, - "Address":"631" - }, - { - "Reward":2378969914390169, - "Stock":1, - "Deposit":"581446487875397766137677889", - "Interest":581446487875397766137677, - "Address":"632" - }, - { - "Reward":3798163532555586, - "Stock":2, - "Deposit":"928313062314187975597017463", - "Interest":928313062314187975597017, - "Address":"633" - }, - { - "Reward":2373421383641852, - "Stock":1, - "Deposit":"580090365758441639526777172", - "Interest":580090365758441639526777, - "Address":"634" - }, - { - "Reward":69485155048259, - "Stock":1, - "Deposit":"16982938337261277439608023", - "Interest":16982938337261277439608, - "Address":"635" - }, - { - "Reward":494493112444742, - "Stock":1, - "Deposit":"120859571098558160607936027", - "Interest":120859571098558160607936, - "Address":"636" - }, - { - "Reward":3529753618613739, - "Stock":1, - "Deposit":"862710718699669643081144543", - "Interest":862710718699669643081144, - "Address":"637" - }, - { - "Reward":1981483857659160, - "Stock":1, - "Deposit":"484296511212102487325246477", - "Interest":484296511212102487325246, - "Address":"638" - }, - { - "Reward":3456700270325572, - "Stock":1, - "Deposit":"844855674576263204764273749", - "Interest":844855674576263204764273, - "Address":"639" - }, - { - "Reward":856774277933045, - "Stock":1, - "Deposit":"209405084020934717516798070", - "Interest":209405084020934717516798, - "Address":"640" - }, - { - "Reward":2259682555311079, - "Stock":1, - "Deposit":"552291341538775015790297047", - "Interest":552291341538775015790297, - "Address":"641" - }, - { - "Reward":2577147947213355, - "Stock":2, - "Deposit":"629883385064421208460925740", - "Interest":629883385064421208460925, - "Address":"642" - }, - { - "Reward":130890229138743, - "Stock":1, - "Deposit":"31991015762566910041506555", - "Interest":31991015762566910041506, - "Address":"643" - }, - { - "Reward":2515080511355632, - "Stock":2, - "Deposit":"614713419117140502662723827", - "Interest":614713419117140502662723, - "Address":"644" - }, - { - "Reward":1482795035065204, - "Stock":2, - "Deposit":"362411462273052653596818085", - "Interest":362411462273052653596818, - "Address":"645" - }, - { - "Reward":202660980469227, - "Stock":1, - "Deposit":"49532579042061208874298820", - "Interest":49532579042061208874298, - "Address":"646" - }, - { - "Reward":2003060125957378, - "Stock":1, - "Deposit":"489569989177321751588240744", - "Interest":489569989177321751588240, - "Address":"647" - }, - { - "Reward":787650196516716, - "Stock":2, - "Deposit":"192510396062074762293084215", - "Interest":192510396062074762293084, - "Address":"648" - }, - { - "Reward":503593260030056, - "Stock":1, - "Deposit":"123083747545945199065706326", - "Interest":123083747545945199065706, - "Address":"649" - }, - { - "Reward":840772900629652, - "Stock":1, - "Deposit":"205494170907679851725113097", - "Interest":205494170907679851725113, - "Address":"650" - }, - { - "Reward":599461122615091, - "Stock":2, - "Deposit":"146514910614889859454066951", - "Interest":146514910614889859454066, - "Address":"651" - }, - { - "Reward":773582821632018, - "Stock":1, - "Deposit":"189072174472613818709489371", - "Interest":189072174472613818709489, - "Address":"652" - }, - { - "Reward":174510990176556, - "Stock":2, - "Deposit":"42652410911143356920120869", - "Interest":42652410911143356920120, - "Address":"653" - }, - { - "Reward":2598892185959502, - "Stock":2, - "Deposit":"635197916859882028013069308", - "Interest":635197916859882028013069, - "Address":"654" - }, - { - "Reward":1153249325580224, - "Stock":2, - "Deposit":"281866855880429922900961086", - "Interest":281866855880429922900961, - "Address":"655" - }, - { - "Reward":2203651272780467, - "Stock":2, - "Deposit":"538596678045340393486791680", - "Interest":538596678045340393486791, - "Address":"656" - }, - { - "Reward":2844237588358244, - "Stock":1, - "Deposit":"695163039444331998246990773", - "Interest":695163039444331998246990, - "Address":"657" - }, - { - "Reward":2042117382468205, - "Stock":2, - "Deposit":"499116013482589493404630466", - "Interest":499116013482589493404630, - "Address":"658" - }, - { - "Reward":2192213072587245, - "Stock":1, - "Deposit":"535801055751113253228037099", - "Interest":535801055751113253228037, - "Address":"659" - }, - { - "Reward":1821452839971797, - "Stock":2, - "Deposit":"445183165296042293594965021", - "Interest":445183165296042293594965, - "Address":"660" - }, - { - "Reward":507064993899904, - "Stock":2, - "Deposit":"123932277598070128555990721", - "Interest":123932277598070128555990, - "Address":"661" - }, - { - "Reward":2006281356560869, - "Stock":2, - "Deposit":"490357293468018151654700198", - "Interest":490357293468018151654700, - "Address":"662" - }, - { - "Reward":3490014972832681, - "Stock":1, - "Deposit":"852998155340816244249420357", - "Interest":852998155340816244249420, - "Address":"663" - }, - { - "Reward":3575646339361231, - "Stock":1, - "Deposit":"873927405861733341838464995", - "Interest":873927405861733341838464, - "Address":"664" - }, - { - "Reward":1105900711351969, - "Stock":1, - "Deposit":"270294332292697614408752338", - "Interest":270294332292697614408752, - "Address":"665" - }, - { - "Reward":852913055841772, - "Stock":2, - "Deposit":"208461358751313774464315446", - "Interest":208461358751313774464315, - "Address":"666" - }, - { - "Reward":2311596043760579, - "Stock":2, - "Deposit":"564979570738201153373796836", - "Interest":564979570738201153373796, - "Address":"667" - }, - { - "Reward":2619815580031321, - "Stock":2, - "Deposit":"640311825162758085922834238", - "Interest":640311825162758085922834, - "Address":"668" - }, - { - "Reward":1706260765308298, - "Stock":2, - "Deposit":"417028951642886003274571708", - "Interest":417028951642886003274571, - "Address":"669" - }, - { - "Reward":842742306936454, - "Stock":1, - "Deposit":"205975515532243358409584936", - "Interest":205975515532243358409584, - "Address":"670" - }, - { - "Reward":3878438383299131, - "Stock":2, - "Deposit":"947933121293168645680771869", - "Interest":947933121293168645680771, - "Address":"671" - }, - { - "Reward":335791747984580, - "Stock":2, - "Deposit":"82071207097725862312496774", - "Interest":82071207097725862312496, - "Address":"672" - }, - { - "Reward":432506775342743, - "Stock":1, - "Deposit":"105709426581721444017238131", - "Interest":105709426581721444017238, - "Address":"673" - }, - { - "Reward":581156757607334, - "Stock":2, - "Deposit":"142041121903998202037653636", - "Interest":142041121903998202037653, - "Address":"674" - }, - { - "Reward":681067628816757, - "Stock":1, - "Deposit":"166460440876420756596829619", - "Interest":166460440876420756596829, - "Address":"675" - }, - { - "Reward":2540632651167005, - "Stock":1, - "Deposit":"620958643935308307610463492", - "Interest":620958643935308307610463, - "Address":"676" - }, - { - "Reward":2347315356802963, - "Stock":2, - "Deposit":"573709764841198177626372306", - "Interest":573709764841198177626372, - "Address":"677" - }, - { - "Reward":213075040916827, - "Stock":1, - "Deposit":"52077890285869621323465338", - "Interest":52077890285869621323465, - "Address":"678" - }, - { - "Reward":3809981011866094, - "Stock":2, - "Deposit":"931201384608249638228794143", - "Interest":931201384608249638228794, - "Address":"679" - }, - { - "Reward":2981296223519420, - "Stock":2, - "Deposit":"728661681678271166980384440", - "Interest":728661681678271166980384, - "Address":"680" - }, - { - "Reward":3018855789089417, - "Stock":2, - "Deposit":"737841653797590146808982302", - "Interest":737841653797590146808982, - "Address":"681" - }, - { - "Reward":259417509143969, - "Stock":2, - "Deposit":"63404500692818221985825421", - "Interest":63404500692818221985825, - "Address":"682" - }, - { - "Reward":3520465348528426, - "Stock":2, - "Deposit":"860440563038231909240564377", - "Interest":860440563038231909240564, - "Address":"683" - }, - { - "Reward":3823088989639334, - "Stock":2, - "Deposit":"934405118961213365667460730", - "Interest":934405118961213365667460, - "Address":"684" - }, - { - "Reward":4027634558693187, - "Stock":1, - "Deposit":"984398312240971629104423257", - "Interest":984398312240971629104423, - "Address":"685" - }, - { - "Reward":3514321000818742, - "Stock":1, - "Deposit":"858938816683866179788308943", - "Interest":858938816683866179788308, - "Address":"686" - }, - { - "Reward":3214089757887987, - "Stock":2, - "Deposit":"785558989265030538370415010", - "Interest":785558989265030538370415, - "Address":"687" - }, - { - "Reward":2100467470376830, - "Stock":1, - "Deposit":"513377418587574907432169426", - "Interest":513377418587574907432169, - "Address":"688" - }, - { - "Reward":726654849716220, - "Stock":1, - "Deposit":"177602460505865034081194629", - "Interest":177602460505865034081194, - "Address":"689" - }, - { - "Reward":1630816318783393, - "Stock":1, - "Deposit":"398589496735843096257386734", - "Interest":398589496735843096257386, - "Address":"690" - }, - { - "Reward":547975477264042, - "Stock":2, - "Deposit":"133931250987971206535493166", - "Interest":133931250987971206535493, - "Address":"691" - }, - { - "Reward":126383611674813, - "Stock":2, - "Deposit":"30889548744951533798850352", - "Interest":30889548744951533798850, - "Address":"692" - }, - { - "Reward":3842468585978096, - "Stock":2, - "Deposit":"939141706069547943523336283", - "Interest":939141706069547943523336, - "Address":"693" - }, - { - "Reward":1232784233151883, - "Stock":1, - "Deposit":"301306064586392197138477468", - "Interest":301306064586392197138477, - "Address":"694" - }, - { - "Reward":1209167336224244, - "Stock":1, - "Deposit":"295533834475356416152291367", - "Interest":295533834475356416152291, - "Address":"695" - }, - { - "Reward":1362198266587380, - "Stock":2, - "Deposit":"332936281836175296259257192", - "Interest":332936281836175296259257, - "Address":"696" - }, - { - "Reward":1910994714183422, - "Stock":2, - "Deposit":"467068187028852443991814565", - "Interest":467068187028852443991814, - "Address":"697" - }, - { - "Reward":2652083277987042, - "Stock":2, - "Deposit":"648198406466157117662244838", - "Interest":648198406466157117662244, - "Address":"698" - }, - { - "Reward":103220306628749, - "Stock":1, - "Deposit":"25228181493036294647222021", - "Interest":25228181493036294647222, - "Address":"699" - }, - { - "Reward":3445861716298509, - "Stock":1, - "Deposit":"842206612419334477168208130", - "Interest":842206612419334477168208, - "Address":"700" - }, - { - "Reward":2287263976006804, - "Stock":2, - "Deposit":"559032544988695034865501078", - "Interest":559032544988695034865501, - "Address":"701" - }, - { - "Reward":3494522927859040, - "Stock":2, - "Deposit":"854099949273443126438116979", - "Interest":854099949273443126438116, - "Address":"702" - }, - { - "Reward":1423336720410626, - "Stock":2, - "Deposit":"347879194327261109801619633", - "Interest":347879194327261109801619, - "Address":"703" - }, - { - "Reward":1824903923001714, - "Stock":1, - "Deposit":"446026648055102836747402994", - "Interest":446026648055102836747402, - "Address":"704" - }, - { - "Reward":221919135033338, - "Stock":2, - "Deposit":"54239484441129581782634740", - "Interest":54239484441129581782634, - "Address":"705" - }, - { - "Reward":724629872708804, - "Stock":1, - "Deposit":"177107533789109150569977907", - "Interest":177107533789109150569977, - "Address":"706" - }, - { - "Reward":2711858221350744, - "Stock":2, - "Deposit":"662808061960974415078823016", - "Interest":662808061960974415078823, - "Address":"707" - }, - { - "Reward":1353576369981015, - "Stock":1, - "Deposit":"330828995203304554454356793", - "Interest":330828995203304554454356, - "Address":"708" - }, - { - "Reward":3676127614451205, - "Stock":1, - "Deposit":"898486137834299536395572138", - "Interest":898486137834299536395572, - "Address":"709" - }, - { - "Reward":483428257277152, - "Stock":1, - "Deposit":"118155198446710629768333979", - "Interest":118155198446710629768333, - "Address":"710" - }, - { - "Reward":4044080692645297, - "Stock":2, - "Deposit":"988417928784980581734415054", - "Interest":988417928784980581734415, - "Address":"711" - }, - { - "Reward":2209319678951732, - "Stock":2, - "Deposit":"539982099037929152990211049", - "Interest":539982099037929152990211, - "Address":"712" - }, - { - "Reward":2892330261847902, - "Stock":1, - "Deposit":"706917419322762752294366446", - "Interest":706917419322762752294366, - "Address":"713" - }, - { - "Reward":4089388350398077, - "Stock":1, - "Deposit":"999491620097704647217578674", - "Interest":999491620097704647217578, - "Address":"714" - }, - { - "Reward":1177726489834574, - "Stock":1, - "Deposit":"287849344815137242473246827", - "Interest":287849344815137242473246, - "Address":"715" - }, - { - "Reward":1696005856818693, - "Stock":2, - "Deposit":"414522538893108416506428213", - "Interest":414522538893108416506428, - "Address":"716" - }, - { - "Reward":1901877918591990, - "Stock":2, - "Deposit":"464839941625137309526775357", - "Interest":464839941625137309526775, - "Address":"717" - }, - { - "Reward":3125706223213517, - "Stock":1, - "Deposit":"763957078491956598228357352", - "Interest":763957078491956598228357, - "Address":"718" - }, - { - "Reward":3347655945960409, - "Stock":1, - "Deposit":"818204038907670794253238683", - "Interest":818204038907670794253238, - "Address":"719" - }, - { - "Reward":410053261771551, - "Stock":1, - "Deposit":"100221540195491565229282030", - "Interest":100221540195491565229282, - "Address":"720" - }, - { - "Reward":728759883111106, - "Stock":2, - "Deposit":"178116953886766404837164078", - "Interest":178116953886766404837164, - "Address":"721" - }, - { - "Reward":1471434873507267, - "Stock":2, - "Deposit":"359634913482080320616103756", - "Interest":359634913482080320616103, - "Address":"722" - }, - { - "Reward":232005441792645, - "Stock":1, - "Deposit":"56704689068291180831804850", - "Interest":56704689068291180831804, - "Address":"723" - }, - { - "Reward":2135278726900642, - "Stock":1, - "Deposit":"521885673661279247964258132", - "Interest":521885673661279247964258, - "Address":"724" - }, - { - "Reward":1374115457218837, - "Stock":2, - "Deposit":"335848974676924538765890170", - "Interest":335848974676924538765890, - "Address":"725" - }, - { - "Reward":718744278627525, - "Stock":1, - "Deposit":"175669029675660781643721097", - "Interest":175669029675660781643721, - "Address":"726" - }, - { - "Reward":854898707803498, - "Stock":1, - "Deposit":"208946673993135378923780400", - "Interest":208946673993135378923780, - "Address":"727" - }, - { - "Reward":3703407157282993, - "Stock":2, - "Deposit":"905153559004464036705945474", - "Interest":905153559004464036705945, - "Address":"728" - }, - { - "Reward":2763341639913397, - "Stock":1, - "Deposit":"675391177336246872904366140", - "Interest":675391177336246872904366, - "Address":"729" - }, - { - "Reward":1916722822580635, - "Stock":2, - "Deposit":"468468199903997351012625389", - "Interest":468468199903997351012625, - "Address":"730" - }, - { - "Reward":3731961168229362, - "Stock":2, - "Deposit":"912132474239622847998152872", - "Interest":912132474239622847998152, - "Address":"731" - }, - { - "Reward":425560068395340, - "Stock":2, - "Deposit":"104011574779378501710498406", - "Interest":104011574779378501710498, - "Address":"732" - }, - { - "Reward":3050378179441657, - "Stock":1, - "Deposit":"745546073701717326727932758", - "Interest":745546073701717326727932, - "Address":"733" - }, - { - "Reward":3012415006941028, - "Stock":2, - "Deposit":"736267455596638531474946512", - "Interest":736267455596638531474946, - "Address":"734" - }, - { - "Reward":2298838250249842, - "Stock":2, - "Deposit":"561861425281637405510011595", - "Interest":561861425281637405510011, - "Address":"735" - }, - { - "Reward":753624324052310, - "Stock":1, - "Deposit":"184194097515526511445635547", - "Interest":184194097515526511445635, - "Address":"736" - }, - { - "Reward":2443471350523569, - "Stock":2, - "Deposit":"597211350337854884890303375", - "Interest":597211350337854884890303, - "Address":"737" - }, - { - "Reward":1227182708151915, - "Stock":1, - "Deposit":"299936990089788912963951962", - "Interest":299936990089788912963951, - "Address":"738" - }, - { - "Reward":548759737452547, - "Stock":1, - "Deposit":"134122932828682372986780488", - "Interest":134122932828682372986780, - "Address":"739" - }, - { - "Reward":869852449297605, - "Stock":1, - "Deposit":"212601533358842909040468385", - "Interest":212601533358842909040468, - "Address":"740" - }, - { - "Reward":3661625558677165, - "Stock":2, - "Deposit":"894941675440814377049451869", - "Interest":894941675440814377049451, - "Address":"741" - }, - { - "Reward":292346923514927, - "Stock":2, - "Deposit":"71452812787044517329352341", - "Interest":71452812787044517329352, - "Address":"742" - }, - { - "Reward":992126086206707, - "Stock":1, - "Deposit":"242486558936719442949516904", - "Interest":242486558936719442949516, - "Address":"743" - }, - { - "Reward":219934395507542, - "Stock":2, - "Deposit":"53754392208713808188318135", - "Interest":53754392208713808188318, - "Address":"744" - }, - { - "Reward":1807291825114600, - "Stock":1, - "Deposit":"441722057064423911936196389", - "Interest":441722057064423911936196, - "Address":"745" - }, - { - "Reward":54347794573279, - "Stock":2, - "Deposit":"13283200467252509469195429", - "Interest":13283200467252509469195, - "Address":"746" - }, - { - "Reward":3670830034963755, - "Stock":2, - "Deposit":"897191350973572054892184455", - "Interest":897191350973572054892184, - "Address":"747" - }, - { - "Reward":804620769817494, - "Stock":1, - "Deposit":"196658191367631962622486169", - "Interest":196658191367631962622486, - "Address":"748" - }, - { - "Reward":382022516058314, - "Stock":2, - "Deposit":"93370516755093002637489195", - "Interest":93370516755093002637489, - "Address":"749" - }, - { - "Reward":1257581947860597, - "Stock":1, - "Deposit":"307366899587920072714781809", - "Interest":307366899587920072714781, - "Address":"750" - }, - { - "Reward":1865945519101212, - "Stock":2, - "Deposit":"456057666843741493783008945", - "Interest":456057666843741493783008, - "Address":"751" - }, - { - "Reward":415977108282776, - "Stock":1, - "Deposit":"101669393624755133310649737", - "Interest":101669393624755133310649, - "Address":"752" - }, - { - "Reward":4072605587209159, - "Stock":1, - "Deposit":"995389727655091705048559740", - "Interest":995389727655091705048559, - "Address":"753" - }, - { - "Reward":1358747324203261, - "Stock":2, - "Deposit":"332092833452499069938333517", - "Interest":332092833452499069938333, - "Address":"754" - }, - { - "Reward":1216585092330401, - "Stock":2, - "Deposit":"297346815887921667179356478", - "Interest":297346815887921667179356, - "Address":"755" - }, - { - "Reward":253856060581651, - "Stock":1, - "Deposit":"62045221319632637425110340", - "Interest":62045221319632637425110, - "Address":"756" - }, - { - "Reward":1220255777727329, - "Stock":1, - "Deposit":"298243971887763859032953689", - "Interest":298243971887763859032953, - "Address":"757" - }, - { - "Reward":189644734272315, - "Stock":2, - "Deposit":"46351264898180755125630807", - "Interest":46351264898180755125630, - "Address":"758" - }, - { - "Reward":2067943258521589, - "Stock":1, - "Deposit":"505428142457702955786023541", - "Interest":505428142457702955786023, - "Address":"759" - }, - { - "Reward":3115349932016129, - "Stock":2, - "Deposit":"761425886690113351570166309", - "Interest":761425886690113351570166, - "Address":"760" - }, - { - "Reward":2582002941472905, - "Stock":2, - "Deposit":"631069999213593524351661035", - "Interest":631069999213593524351661, - "Address":"761" - }, - { - "Reward":367788845939365, - "Stock":2, - "Deposit":"89891650776091736042349103", - "Interest":89891650776091736042349, - "Address":"762" - }, - { - "Reward":330846046614917, - "Stock":1, - "Deposit":"80862423130313665354504611", - "Interest":80862423130313665354504, - "Address":"763" - }, - { - "Reward":3180055071707047, - "Stock":1, - "Deposit":"777240536548943206093247912", - "Interest":777240536548943206093247, - "Address":"764" - }, - { - "Reward":3703330177202067, - "Stock":2, - "Deposit":"905134744223570875130297477", - "Interest":905134744223570875130297, - "Address":"765" - }, - { - "Reward":2183911057815408, - "Stock":2, - "Deposit":"533771951767000207849993028", - "Interest":533771951767000207849993, - "Address":"766" - }, - { - "Reward":446601006099157, - "Stock":2, - "Deposit":"109154212042458564902982831", - "Interest":109154212042458564902982, - "Address":"767" - }, - { - "Reward":3378770822150668, - "Stock":2, - "Deposit":"825808857855598321692704569", - "Interest":825808857855598321692704, - "Address":"768" - }, - { - "Reward":1383316122681058, - "Stock":2, - "Deposit":"338097718802171876010301384", - "Interest":338097718802171876010301, - "Address":"769" - }, - { - "Reward":1202781448292625, - "Stock":1, - "Deposit":"293973053026484021369053057", - "Interest":293973053026484021369053, - "Address":"770" - }, - { - "Reward":3053517784069806, - "Stock":2, - "Deposit":"746313427703679366239337931", - "Interest":746313427703679366239337, - "Address":"771" - }, - { - "Reward":42291947011886, - "Stock":1, - "Deposit":"10336618343396386521352316", - "Interest":10336618343396386521352, - "Address":"772" - }, - { - "Reward":198220756198579, - "Stock":1, - "Deposit":"48447339253222088118406837", - "Interest":48447339253222088118406, - "Address":"773" - }, - { - "Reward":2732757685691491, - "Stock":1, - "Deposit":"667916121573623677860632403", - "Interest":667916121573623677860632, - "Address":"774" - }, - { - "Reward":2469070168566820, - "Stock":2, - "Deposit":"603467983830769494352697895", - "Interest":603467983830769494352697, - "Address":"775" - }, - { - "Reward":2152531598543826, - "Stock":2, - "Deposit":"526102465795561191624612470", - "Interest":526102465795561191624612, - "Address":"776" - }, - { - "Reward":2985583127197975, - "Stock":2, - "Deposit":"729709448223227696857592134", - "Interest":729709448223227696857592, - "Address":"777" - }, - { - "Reward":2893705265227330, - "Stock":2, - "Deposit":"707253485315421537300966903", - "Interest":707253485315421537300966, - "Address":"778" - }, - { - "Reward":3196979493018660, - "Stock":2, - "Deposit":"781377051799277189133609858", - "Interest":781377051799277189133609, - "Address":"779" - }, - { - "Reward":1178248687211947, - "Stock":2, - "Deposit":"287976975614171237796802893", - "Interest":287976975614171237796802, - "Address":"780" - }, - { - "Reward":2833472717990598, - "Stock":2, - "Deposit":"692531986386518805261216767", - "Interest":692531986386518805261216, - "Address":"781" - }, - { - "Reward":2277597022671707, - "Stock":1, - "Deposit":"556669834964012566486124077", - "Interest":556669834964012566486124, - "Address":"782" - }, - { - "Reward":1622352281167965, - "Stock":1, - "Deposit":"396520792581592562701740386", - "Interest":396520792581592562701740, - "Address":"783" - }, - { - "Reward":251996266180909, - "Stock":1, - "Deposit":"61590667053964653910374267", - "Interest":61590667053964653910374, - "Address":"784" - }, - { - "Reward":3192063510681314, - "Stock":2, - "Deposit":"780175531491173579475862875", - "Interest":780175531491173579475862, - "Address":"785" - }, - { - "Reward":1381213702223786, - "Stock":2, - "Deposit":"337583864052045101725771905", - "Interest":337583864052045101725771, - "Address":"786" - }, - { - "Reward":2487064133186279, - "Stock":2, - "Deposit":"607865907262945759376682522", - "Interest":607865907262945759376682, - "Address":"787" - }, - { - "Reward":3032817498183175, - "Stock":2, - "Deposit":"741254049502217959862394245", - "Interest":741254049502217959862394, - "Address":"788" - }, - { - "Reward":428840064363905, - "Stock":1, - "Deposit":"104813241973499615690083291", - "Interest":104813241973499615690083, - "Address":"789" - }, - { - "Reward":523251260860737, - "Stock":2, - "Deposit":"127888379782995165180493493", - "Interest":127888379782995165180493, - "Address":"790" - }, - { - "Reward":2248425966277517, - "Stock":2, - "Deposit":"549540107015197953904623215", - "Interest":549540107015197953904623, - "Address":"791" - }, - { - "Reward":1985300777753302, - "Stock":1, - "Deposit":"485229408584959331923032924", - "Interest":485229408584959331923032, - "Address":"792" - }, - { - "Reward":3643353076250588, - "Stock":2, - "Deposit":"890475679184438262412386102", - "Interest":890475679184438262412386, - "Address":"793" - }, - { - "Reward":3268920710199450, - "Stock":1, - "Deposit":"798960278812879343143460439", - "Interest":798960278812879343143460, - "Address":"794" - }, - { - "Reward":3004533317239259, - "Stock":1, - "Deposit":"734341083695969731877771199", - "Interest":734341083695969731877771, - "Address":"795" - }, - { - "Reward":210022788436556, - "Stock":1, - "Deposit":"51331886112371050146465584", - "Interest":51331886112371050146465, - "Address":"796" - }, - { - "Reward":298207895951640, - "Stock":1, - "Deposit":"72885299098976119581312259", - "Interest":72885299098976119581312, - "Address":"797" - }, - { - "Reward":362207301196530, - "Stock":2, - "Deposit":"88527459674720421213041849", - "Interest":88527459674720421213041, - "Address":"798" - }, - { - "Reward":3266427309234158, - "Stock":1, - "Deposit":"798350864113952396480460863", - "Interest":798350864113952396480460, - "Address":"799" - }, - { - "Reward":3858287976355442, - "Stock":1, - "Deposit":"943008139570702730312674946", - "Interest":943008139570702730312674, - "Address":"800" - }, - { - "Reward":2797400639056056, - "Stock":1, - "Deposit":"683715572408358118756846897", - "Interest":683715572408358118756846, - "Address":"801" - }, - { - "Reward":540413235609106, - "Stock":1, - "Deposit":"132082955713562766321343566", - "Interest":132082955713562766321343, - "Address":"802" - }, - { - "Reward":2957004594726145, - "Stock":1, - "Deposit":"722724539656765863078762210", - "Interest":722724539656765863078762, - "Address":"803" - }, - { - "Reward":451507775643567, - "Stock":2, - "Deposit":"110353480642348622532403870", - "Interest":110353480642348622532403, - "Address":"804" - }, - { - "Reward":480718288361217, - "Stock":1, - "Deposit":"117492852151832916086712611", - "Interest":117492852151832916086712, - "Address":"805" - }, - { - "Reward":2621477116348387, - "Stock":1, - "Deposit":"640717922965925557050332832", - "Interest":640717922965925557050332, - "Address":"806" - }, - { - "Reward":1345332959510271, - "Stock":1, - "Deposit":"328814214756802725151362334", - "Interest":328814214756802725151362, - "Address":"807" - }, - { - "Reward":2675051210826556, - "Stock":2, - "Deposit":"653812022595773645334697766", - "Interest":653812022595773645334697, - "Address":"808" - }, - { - "Reward":3065047686775731, - "Stock":1, - "Deposit":"749131463103519079645688603", - "Interest":749131463103519079645688, - "Address":"809" - }, - { - "Reward":2386085974484528, - "Stock":2, - "Deposit":"583185731454876177265731707", - "Interest":583185731454876177265731, - "Address":"810" - }, - { - "Reward":3027818863249053, - "Stock":2, - "Deposit":"740032327987777627250242866", - "Interest":740032327987777627250242, - "Address":"811" - }, - { - "Reward":960786894277441, - "Stock":1, - "Deposit":"234826914747904291760464415", - "Interest":234826914747904291760464, - "Address":"812" - }, - { - "Reward":3007055535648454, - "Stock":2, - "Deposit":"734957541696052207854232856", - "Interest":734957541696052207854232, - "Address":"813" - }, - { - "Reward":3971173166028900, - "Stock":2, - "Deposit":"970598525086614483124696887", - "Interest":970598525086614483124696, - "Address":"814" - }, - { - "Reward":3547017868294814, - "Stock":1, - "Deposit":"866930291751915937945362681", - "Interest":866930291751915937945362, - "Address":"815" - }, - { - "Reward":352825851397697, - "Stock":2, - "Deposit":"86234529863496334201906680", - "Interest":86234529863496334201906, - "Address":"816" - }, - { - "Reward":1499263825532160, - "Stock":2, - "Deposit":"366436616319198882333660487", - "Interest":366436616319198882333660, - "Address":"817" - }, - { - "Reward":1510565230412323, - "Stock":1, - "Deposit":"369198804330018170997498851", - "Interest":369198804330018170997498, - "Address":"818" - }, - { - "Reward":2802772328916103, - "Stock":1, - "Deposit":"685028472661609266765219920", - "Interest":685028472661609266765219, - "Address":"819" - }, - { - "Reward":2446459288691005, - "Stock":2, - "Deposit":"597941635383889114058609806", - "Interest":597941635383889114058609, - "Address":"820" - }, - { - "Reward":3229657608372884, - "Stock":2, - "Deposit":"789363943641905430056553026", - "Interest":789363943641905430056553, - "Address":"821" - }, - { - "Reward":1504240287179933, - "Stock":2, - "Deposit":"367652918437876952143859665", - "Interest":367652918437876952143859, - "Address":"822" - }, - { - "Reward":842956470646181, - "Stock":1, - "Deposit":"206027859505194643754249033", - "Interest":206027859505194643754249, - "Address":"823" - }, - { - "Reward":354593437465605, - "Stock":2, - "Deposit":"86666547395532256282435411", - "Interest":86666547395532256282435, - "Address":"824" - }, - { - "Reward":3158343206072762, - "Stock":2, - "Deposit":"771933917099107302924817266", - "Interest":771933917099107302924817, - "Address":"825" - }, - { - "Reward":841510799229580, - "Stock":2, - "Deposit":"205674521464759840762960179", - "Interest":205674521464759840762960, - "Address":"826" - }, - { - "Reward":1588601097667759, - "Stock":2, - "Deposit":"388271631047801712992011559", - "Interest":388271631047801712992011, - "Address":"827" - }, - { - "Reward":2257584411127991, - "Stock":1, - "Deposit":"551778531957227480481093585", - "Interest":551778531957227480481093, - "Address":"828" - }, - { - "Reward":936754989018812, - "Stock":1, - "Deposit":"228953252023100017889035034", - "Interest":228953252023100017889035, - "Address":"829" - }, - { - "Reward":2626479744223499, - "Stock":1, - "Deposit":"641940620399187311668517338", - "Interest":641940620399187311668517, - "Address":"830" - }, - { - "Reward":1982236119886595, - "Stock":1, - "Deposit":"484480372398180425546465524", - "Interest":484480372398180425546465, - "Address":"831" - }, - { - "Reward":621271163243808, - "Stock":1, - "Deposit":"151845525116266588662579647", - "Interest":151845525116266588662579, - "Address":"832" - }, - { - "Reward":3199249909325154, - "Stock":1, - "Deposit":"781931966588001903247825148", - "Interest":781931966588001903247825, - "Address":"833" - }, - { - "Reward":411627585837150, - "Stock":2, - "Deposit":"100606322362421507500169077", - "Interest":100606322362421507500169, - "Address":"834" - }, - { - "Reward":1203163103457789, - "Stock":2, - "Deposit":"294066333758628450925794294", - "Interest":294066333758628450925794, - "Address":"835" - }, - { - "Reward":971204202180222, - "Stock":1, - "Deposit":"237373019705579224594300852", - "Interest":237373019705579224594300, - "Address":"836" - }, - { - "Reward":2172047048505844, - "Stock":1, - "Deposit":"530872257027928395883595215", - "Interest":530872257027928395883595, - "Address":"837" - }, - { - "Reward":374364165233339, - "Stock":1, - "Deposit":"91498731339412220365607158", - "Interest":91498731339412220365607, - "Address":"838" - }, - { - "Reward":1658335220593813, - "Stock":1, - "Deposit":"405315419880591276684142511", - "Interest":405315419880591276684142, - "Address":"839" - }, - { - "Reward":428975103859519, - "Stock":1, - "Deposit":"104846247115756519009348059", - "Interest":104846247115756519009348, - "Address":"840" - }, - { - "Reward":459406279696980, - "Stock":1, - "Deposit":"112283962156026650981444597", - "Interest":112283962156026650981444, - "Address":"841" - }, - { - "Reward":3209461904064701, - "Stock":2, - "Deposit":"784427890743912725753993717", - "Interest":784427890743912725753993, - "Address":"842" - }, - { - "Reward":1192950733547831, - "Stock":1, - "Deposit":"291570317906930887022625029", - "Interest":291570317906930887022625, - "Address":"843" - }, - { - "Reward":2469337975302186, - "Stock":2, - "Deposit":"603533438750886830354493232", - "Interest":603533438750886830354493, - "Address":"844" - }, - { - "Reward":3945904838889009, - "Stock":1, - "Deposit":"964422667215901308078372961", - "Interest":964422667215901308078372, - "Address":"845" - }, - { - "Reward":1769498673627187, - "Stock":1, - "Deposit":"432484993970360998010051840", - "Interest":432484993970360998010051, - "Address":"846" - }, - { - "Reward":2842556629745801, - "Stock":1, - "Deposit":"694752194617940133099245568", - "Interest":694752194617940133099245, - "Address":"847" - }, - { - "Reward":3101739206688760, - "Stock":1, - "Deposit":"758099275289454088707444025", - "Interest":758099275289454088707444, - "Address":"848" - }, - { - "Reward":1770142393252008, - "Stock":1, - "Deposit":"432642326147100519943992571", - "Interest":432642326147100519943992, - "Address":"849" - }, - { - "Reward":2681949496904558, - "Stock":2, - "Deposit":"655498039803537380094565715", - "Interest":655498039803537380094565, - "Address":"850" - }, - { - "Reward":449059318556689, - "Stock":1, - "Deposit":"109755050723051583717579612", - "Interest":109755050723051583717579, - "Address":"851" - }, - { - "Reward":3820448885487581, - "Stock":2, - "Deposit":"933759848385332436047526854", - "Interest":933759848385332436047526, - "Address":"852" - }, - { - "Reward":766989960218110, - "Stock":2, - "Deposit":"187460806421686498881226108", - "Interest":187460806421686498881226, - "Address":"853" - }, - { - "Reward":1089062300337223, - "Stock":2, - "Deposit":"266178838907638826152707739", - "Interest":266178838907638826152707, - "Address":"854" - }, - { - "Reward":3264297274834014, - "Stock":1, - "Deposit":"797830260211597086525059184", - "Interest":797830260211597086525059, - "Address":"855" - }, - { - "Reward":1995015424616251, - "Stock":1, - "Deposit":"487603775433923636311459626", - "Interest":487603775433923636311459, - "Address":"856" - }, - { - "Reward":3146168415776484, - "Stock":1, - "Deposit":"768958264058869134246387848", - "Interest":768958264058869134246387, - "Address":"857" - }, - { - "Reward":1620249072638280, - "Stock":2, - "Deposit":"396006745217875155699664692", - "Interest":396006745217875155699664, - "Address":"858" - }, - { - "Reward":1116720443290970, - "Stock":2, - "Deposit":"272938794123690597895288943", - "Interest":272938794123690597895288, - "Address":"859" - }, - { - "Reward":152344327592911, - "Stock":1, - "Deposit":"37234634070328009869771481", - "Interest":37234634070328009869771, - "Address":"860" - }, - { - "Reward":2754764845221060, - "Stock":1, - "Deposit":"673294914108653164148753490", - "Interest":673294914108653164148753, - "Address":"861" - }, - { - "Reward":1757549398200913, - "Stock":2, - "Deposit":"429564459251853048020592644", - "Interest":429564459251853048020592, - "Address":"862" - }, - { - "Reward":1848276791411798, - "Stock":2, - "Deposit":"451739234904735553759530839", - "Interest":451739234904735553759530, - "Address":"863" - }, - { - "Reward":2495211318788609, - "Stock":1, - "Deposit":"609857169290216050156470364", - "Interest":609857169290216050156470, - "Address":"864" - }, - { - "Reward":243046710210267, - "Stock":2, - "Deposit":"59403296858277165882238992", - "Interest":59403296858277165882238, - "Address":"865" - }, - { - "Reward":1292132511065147, - "Stock":2, - "Deposit":"315811438338866046219124470", - "Interest":315811438338866046219124, - "Address":"866" - }, - { - "Reward":3161568157756804, - "Stock":1, - "Deposit":"772722130862934730729467553", - "Interest":772722130862934730729467, - "Address":"867" - }, - { - "Reward":2849433546822567, - "Stock":2, - "Deposit":"696432989006094849145109087", - "Interest":696432989006094849145109, - "Address":"868" - }, - { - "Reward":512792654837626, - "Stock":1, - "Deposit":"125332181109179985335630878", - "Interest":125332181109179985335630, - "Address":"869" - }, - { - "Reward":532510542667574, - "Stock":1, - "Deposit":"130151450389423550825419859", - "Interest":130151450389423550825419, - "Address":"870" - }, - { - "Reward":377856672828734, - "Stock":2, - "Deposit":"92352338719201565454354315", - "Interest":92352338719201565454354, - "Address":"871" - }, - { - "Reward":15998241894216, - "Stock":2, - "Deposit":"7820293569334890726530291", - "Interest":3910146784667445363265, - "Address":"872" - }, - { - "Reward":1731138666740692, - "Stock":1, - "Deposit":"423109385164166518227055350", - "Interest":423109385164166518227055, - "Address":"873" - }, - { - "Reward":2682256909930388, - "Stock":2, - "Deposit":"655573174937914338051725004", - "Interest":655573174937914338051725, - "Address":"874" - }, - { - "Reward":2957814644235774, - "Stock":2, - "Deposit":"722922524692024337518720632", - "Interest":722922524692024337518720, - "Address":"875" - }, - { - "Reward":2173426022908389, - "Stock":2, - "Deposit":"531209293582438735198159534", - "Interest":531209293582438735198159, - "Address":"876" - }, - { - "Reward":445225152607711, - "Stock":1, - "Deposit":"108817938273045422549167053", - "Interest":108817938273045422549167, - "Address":"877" - }, - { - "Reward":2584852134956459, - "Stock":1, - "Deposit":"631766373528488855988089353", - "Interest":631766373528488855988089, - "Address":"878" - }, - { - "Reward":517570197891211, - "Stock":1, - "Deposit":"126499865329302907392004403", - "Interest":126499865329302907392004, - "Address":"879" - }, - { - "Reward":549497721677958, - "Stock":2, - "Deposit":"134303304313574622953729310", - "Interest":134303304313574622953729, - "Address":"880" - }, - { - "Reward":403394611863787, - "Stock":1, - "Deposit":"98594092710997727203467174", - "Interest":98594092710997727203467, - "Address":"881" - }, - { - "Reward":581099994735168, - "Stock":1, - "Deposit":"142027248431928376783160018", - "Interest":142027248431928376783160, - "Address":"882" - }, - { - "Reward":688394866105374, - "Stock":2, - "Deposit":"168251298491527756519563625", - "Interest":168251298491527756519563, - "Address":"883" - }, - { - "Reward":802946258196061, - "Stock":2, - "Deposit":"196248922256955338207802343", - "Interest":196248922256955338207802, - "Address":"884" - }, - { - "Reward":1298958458357247, - "Stock":1, - "Deposit":"317479775149435372586356265", - "Interest":317479775149435372586356, - "Address":"885" - }, - { - "Reward":1294659241575703, - "Stock":1, - "Deposit":"316428999146290967917458220", - "Interest":316428999146290967917458, - "Address":"886" - }, - { - "Reward":890153399125810, - "Stock":1, - "Deposit":"217563309422820649887639781", - "Interest":217563309422820649887639, - "Address":"887" - }, - { - "Reward":1027129772692665, - "Stock":2, - "Deposit":"251041846015736092037350573", - "Interest":251041846015736092037350, - "Address":"888" - }, - { - "Reward":3653363778706772, - "Stock":1, - "Deposit":"892922405285976994457936651", - "Interest":892922405285976994457936, - "Address":"889" - }, - { - "Reward":2877215580805720, - "Stock":1, - "Deposit":"703223224556291048877119599", - "Interest":703223224556291048877119, - "Address":"890" - }, - { - "Reward":2273784215027929, - "Stock":2, - "Deposit":"555737942719386590623155345", - "Interest":555737942719386590623155, - "Address":"891" - }, - { - "Reward":754604518120530, - "Stock":1, - "Deposit":"184433667757653241283288541", - "Interest":184433667757653241283288, - "Address":"892" - }, - { - "Reward":867517485831448, - "Stock":2, - "Deposit":"212030842532320740192362092", - "Interest":212030842532320740192362, - "Address":"893" - }, - { - "Reward":316462018966738, - "Stock":2, - "Deposit":"77346808112676801450708973", - "Interest":77346808112676801450708, - "Address":"894" - }, - { - "Reward":3738785477826863, - "Stock":1, - "Deposit":"913800410779567862116471961", - "Interest":913800410779567862116471, - "Address":"895" - }, - { - "Reward":2891502960291308, - "Stock":1, - "Deposit":"706715217696930575470970333", - "Interest":706715217696930575470970, - "Address":"896" - }, - { - "Reward":2282175914996657, - "Stock":2, - "Deposit":"557788966754876214265723322", - "Interest":557788966754876214265723, - "Address":"897" - }, - { - "Reward":1282384798782442, - "Stock":2, - "Deposit":"313428989936591295698354428", - "Interest":313428989936591295698354, - "Address":"898" - }, - { - "Reward":680016620709904, - "Stock":2, - "Deposit":"166203562902150658865947028", - "Interest":166203562902150658865947, - "Address":"899" - }, - { - "Reward":2546927847184039, - "Stock":2, - "Deposit":"622497259279895187595423836", - "Interest":622497259279895187595423, - "Address":"900" - }, - { - "Reward":4042103720362772, - "Stock":1, - "Deposit":"987934734952495396963379609", - "Interest":987934734952495396963379, - "Address":"901" - }, - { - "Reward":697317231689710, - "Stock":2, - "Deposit":"170432023056883319435710067", - "Interest":170432023056883319435710, - "Address":"902" - }, - { - "Reward":1054748839424024, - "Stock":1, - "Deposit":"257792250572013048606567677", - "Interest":257792250572013048606567, - "Address":"903" - }, - { - "Reward":1623491861698299, - "Stock":1, - "Deposit":"396799318633143660588003946", - "Interest":396799318633143660588003, - "Address":"904" - }, - { - "Reward":302747259320433, - "Stock":1, - "Deposit":"73994769576937957645441527", - "Interest":73994769576937957645441, - "Address":"905" - }, - { - "Reward":2798957420487538, - "Stock":2, - "Deposit":"684096066962008975138771829", - "Interest":684096066962008975138771, - "Address":"906" - }, - { - "Reward":1646359135960472, - "Stock":2, - "Deposit":"402388332696161921124412741", - "Interest":402388332696161921124412, - "Address":"907" - }, - { - "Reward":4021239140102722, - "Stock":2, - "Deposit":"982835201393950974600826868", - "Interest":982835201393950974600826, - "Address":"908" - }, - { - "Reward":1645523054735292, - "Stock":2, - "Deposit":"402183985222484663428343200", - "Interest":402183985222484663428343, - "Address":"909" - }, - { - "Reward":2539459640540787, - "Stock":1, - "Deposit":"620671947199578410986992634", - "Interest":620671947199578410986992, - "Address":"910" - }, - { - "Reward":631599176507796, - "Stock":2, - "Deposit":"154369805479272370620102087", - "Interest":154369805479272370620102, - "Address":"911" - }, - { - "Reward":1560261842298339, - "Stock":1, - "Deposit":"381345204444471952424579929", - "Interest":381345204444471952424579, - "Address":"912" - }, - { - "Reward":659274549265089, - "Stock":2, - "Deposit":"161133971849360846386123386", - "Interest":161133971849360846386123, - "Address":"913" - }, - { - "Reward":3101793034201975, - "Stock":2, - "Deposit":"758112431327418567768930301", - "Interest":758112431327418567768930, - "Address":"914" - }, - { - "Reward":3564123602671886, - "Stock":2, - "Deposit":"871111121915389197143219420", - "Interest":871111121915389197143219, - "Address":"915" - }, - { - "Reward":1435191956873738, - "Stock":1, - "Deposit":"350776744885892610707097358", - "Interest":350776744885892610707097, - "Address":"916" - }, - { - "Reward":2804847669318149, - "Stock":1, - "Deposit":"685535708747537220204747740", - "Interest":685535708747537220204747, - "Address":"917" - }, - { - "Reward":1203499831342424, - "Stock":2, - "Deposit":"294148633767849609913111020", - "Interest":294148633767849609913111, - "Address":"918" - }, - { - "Reward":2171053013290964, - "Stock":2, - "Deposit":"530629303856885559126127777", - "Interest":530629303856885559126127, - "Address":"919" - }, - { - "Reward":3405833956007338, - "Stock":2, - "Deposit":"832423386285183863905746835", - "Interest":832423386285183863905746, - "Address":"920" - }, - { - "Reward":2444612221843328, - "Stock":2, - "Deposit":"597490191872579345939017125", - "Interest":597490191872579345939017, - "Address":"921" - }, - { - "Reward":1371915703914023, - "Stock":2, - "Deposit":"335311330705246102293923295", - "Interest":335311330705246102293923, - "Address":"922" - }, - { - "Reward":1224269718685967, - "Stock":2, - "Deposit":"299225023333106632253622673", - "Interest":299225023333106632253622, - "Address":"923" - }, - { - "Reward":1851768068640460, - "Stock":2, - "Deposit":"452592541569324047228209914", - "Interest":452592541569324047228209, - "Address":"924" - }, - { - "Reward":1729241322160549, - "Stock":1, - "Deposit":"422645653220462436121311300", - "Interest":422645653220462436121311, - "Address":"925" - }, - { - "Reward":1471317875883193, - "Stock":2, - "Deposit":"359606317972235633998719002", - "Interest":359606317972235633998719, - "Address":"926" - }, - { - "Reward":2284345347013402, - "Stock":1, - "Deposit":"558319199869297122523797341", - "Interest":558319199869297122523797, - "Address":"927" - }, - { - "Reward":3038100877570892, - "Stock":1, - "Deposit":"742545365701939075194418014", - "Interest":742545365701939075194418, - "Address":"928" - }, - { - "Reward":1736152345787509, - "Stock":2, - "Deposit":"424334783625690659118821679", - "Interest":424334783625690659118821, - "Address":"929" - }, - { - "Reward":1756695628731609, - "Stock":1, - "Deposit":"429355788576205044120141902", - "Interest":429355788576205044120141, - "Address":"930" - }, - { - "Reward":510912942662744, - "Stock":1, - "Deposit":"124872758719812848583612112", - "Interest":124872758719812848583612, - "Address":"931" - }, - { - "Reward":99971003839003, - "Stock":2, - "Deposit":"24434016050373985607069167", - "Interest":24434016050373985607069, - "Address":"932" - }, - { - "Reward":1187283833922259, - "Stock":1, - "Deposit":"290185265130727176877258247", - "Interest":290185265130727176877258, - "Address":"933" - }, - { - "Reward":1299125421974796, - "Stock":1, - "Deposit":"317520582899226355702967859", - "Interest":317520582899226355702967, - "Address":"934" - }, - { - "Reward":2674552507355034, - "Stock":1, - "Deposit":"653690133966475128708276324", - "Interest":653690133966475128708276, - "Address":"935" - }, - { - "Reward":3915273066110883, - "Stock":1, - "Deposit":"956935924070684063034843592", - "Interest":956935924070684063034843, - "Address":"936" - }, - { - "Reward":3828513269476187, - "Stock":1, - "Deposit":"935730872784880429736032805", - "Interest":935730872784880429736032, - "Address":"937" - }, - { - "Reward":1873427452335708, - "Stock":2, - "Deposit":"457886333854366833766703201", - "Interest":457886333854366833766703, - "Address":"938" - }, - { - "Reward":983909754472378, - "Stock":1, - "Deposit":"240478396832084606595985167", - "Interest":240478396832084606595985, - "Address":"939" - }, - { - "Reward":3125464277482177, - "Stock":1, - "Deposit":"763897944286478280958435044", - "Interest":763897944286478280958435, - "Address":"940" - }, - { - "Reward":3106763971078634, - "Stock":1, - "Deposit":"759327383131096267384433732", - "Interest":759327383131096267384433, - "Address":"941" - }, - { - "Reward":3030338131671724, - "Stock":1, - "Deposit":"740648064978614240068860702", - "Interest":740648064978614240068860, - "Address":"942" - }, - { - "Reward":3042777326845265, - "Stock":2, - "Deposit":"743688341487325987884885008", - "Interest":743688341487325987884885, - "Address":"943" - }, - { - "Reward":433370034872266, - "Stock":1, - "Deposit":"105920416732765310109335652", - "Interest":105920416732765310109335, - "Address":"944" - }, - { - "Reward":2788582943982211, - "Stock":2, - "Deposit":"681560430470315670177387505", - "Interest":681560430470315670177387, - "Address":"945" - }, - { - "Reward":1895416004703107, - "Stock":2, - "Deposit":"463260578593719163369623016", - "Interest":463260578593719163369623, - "Address":"946" - }, - { - "Reward":868059043724479, - "Stock":2, - "Deposit":"212163205254934372769769820", - "Interest":212163205254934372769769, - "Address":"947" - }, - { - "Reward":403086299171063, - "Stock":2, - "Deposit":"98518737688108370954427993", - "Interest":98518737688108370954427, - "Address":"948" - }, - { - "Reward":3369628910982264, - "Stock":1, - "Deposit":"823574473927838557338234066", - "Interest":823574473927838557338234, - "Address":"949" - }, - { - "Reward":716046805061299, - "Stock":1, - "Deposit":"175009737382079588742883553", - "Interest":175009737382079588742883, - "Address":"950" - }, - { - "Reward":669241112281689, - "Stock":2, - "Deposit":"163569909784993194891669073", - "Interest":163569909784993194891669, - "Address":"951" - }, - { - "Reward":2724865631229010, - "Stock":1, - "Deposit":"665987216411110583009761828", - "Interest":665987216411110583009761, - "Address":"952" - }, - { - "Reward":3659365840341829, - "Stock":2, - "Deposit":"894389375354242788249746512", - "Interest":894389375354242788249746, - "Address":"953" - }, - { - "Reward":2113481571088801, - "Stock":2, - "Deposit":"516558208351270420349453223", - "Interest":516558208351270420349453, - "Address":"954" - }, - { - "Reward":2875084262897790, - "Stock":2, - "Deposit":"702702306950475308340657580", - "Interest":702702306950475308340657, - "Address":"955" - }, - { - "Reward":628410167980427, - "Stock":1, - "Deposit":"153590376619400226233949290", - "Interest":153590376619400226233949, - "Address":"956" - }, - { - "Reward":3901039444249024, - "Stock":2, - "Deposit":"953457069886247676758306672", - "Interest":953457069886247676758306, - "Address":"957" - }, - { - "Reward":2213010110608470, - "Stock":1, - "Deposit":"540884081241476466500447983", - "Interest":540884081241476466500447, - "Address":"958" - }, - { - "Reward":2781109745012998, - "Stock":1, - "Deposit":"679733898210466924723191013", - "Interest":679733898210466924723191, - "Address":"959" - }, - { - "Reward":149596431882161, - "Stock":1, - "Deposit":"36563018048452855524398416", - "Interest":36563018048452855524398, - "Address":"960" - }, - { - "Reward":3310831963007966, - "Stock":2, - "Deposit":"809203851293793352547381238", - "Interest":809203851293793352547381, - "Address":"961" - }, - { - "Reward":3062950435572904, - "Stock":2, - "Deposit":"748618871776197125641180114", - "Interest":748618871776197125641180, - "Address":"962" - }, - { - "Reward":491741382661523, - "Stock":2, - "Deposit":"120187017987080646542842983", - "Interest":120187017987080646542842, - "Address":"963" - }, - { - "Reward":2148205684809204, - "Stock":2, - "Deposit":"525045164762608762570567069", - "Interest":525045164762608762570567, - "Address":"964" - }, - { - "Reward":1333137986191529, - "Stock":1, - "Deposit":"325833628763249172347529469", - "Interest":325833628763249172347529, - "Address":"965" - }, - { - "Reward":2235780599543912, - "Stock":2, - "Deposit":"546449439903068490137402872", - "Interest":546449439903068490137402, - "Address":"966" - }, - { - "Reward":1632007982052334, - "Stock":1, - "Deposit":"398880752383198977643707477", - "Interest":398880752383198977643707, - "Address":"967" - }, - { - "Reward":1698341462209300, - "Stock":2, - "Deposit":"415093386613046622106421585", - "Interest":415093386613046622106421, - "Address":"968" - }, - { - "Reward":739482829471592, - "Stock":2, - "Deposit":"180737760254794377347694049", - "Interest":180737760254794377347694, - "Address":"969" - }, - { - "Reward":1044906771000120, - "Stock":2, - "Deposit":"255386740488050767441728122", - "Interest":255386740488050767441728, - "Address":"970" - }, - { - "Reward":84021472481550, - "Stock":2, - "Deposit":"20535774658184569041657680", - "Interest":20535774658184569041657, - "Address":"971" - }, - { - "Reward":3779189553812823, - "Stock":2, - "Deposit":"923675612620407204831698794", - "Interest":923675612620407204831698, - "Address":"972" - }, - { - "Reward":2674592419799923, - "Stock":1, - "Deposit":"653699889008252932327417163", - "Interest":653699889008252932327417, - "Address":"973" - }, - { - "Reward":3815758932111625, - "Stock":1, - "Deposit":"932613572048564098980075486", - "Interest":932613572048564098980075, - "Address":"974" - }, - { - "Reward":669005684046751, - "Stock":2, - "Deposit":"163512368527525597807183420", - "Interest":163512368527525597807183, - "Address":"975" - }, - { - "Reward":3768640288811000, - "Stock":1, - "Deposit":"921097255892197486213711789", - "Interest":921097255892197486213711, - "Address":"976" - }, - { - "Reward":3251317603586379, - "Stock":1, - "Deposit":"794657885388753149066455616", - "Interest":794657885388753149066455, - "Address":"977" - }, - { - "Reward":2362390093244412, - "Stock":1, - "Deposit":"577394196706648710210259080", - "Interest":577394196706648710210259, - "Address":"978" - }, - { - "Reward":1800391722030197, - "Stock":1, - "Deposit":"440035595760253639423487076", - "Interest":440035595760253639423487, - "Address":"979" - }, - { - "Reward":1054018455613842, - "Stock":2, - "Deposit":"257613736712437702005915957", - "Interest":257613736712437702005915, - "Address":"980" - }, - { - "Reward":3076564886962033, - "Stock":2, - "Deposit":"751946393867449991440262591", - "Interest":751946393867449991440262, - "Address":"981" - }, - { - "Reward":935593953376404, - "Stock":2, - "Deposit":"228669482105501420401491952", - "Interest":228669482105501420401491, - "Address":"982" - }, - { - "Reward":262619437870578, - "Stock":1, - "Deposit":"64187087391898600686277056", - "Interest":64187087391898600686277, - "Address":"983" - }, - { - "Reward":3139504423238320, - "Stock":2, - "Deposit":"767329510776574408311595905", - "Interest":767329510776574408311595, - "Address":"984" - }, - { - "Reward":2746202511723340, - "Stock":2, - "Deposit":"671202185356535530054200886", - "Interest":671202185356535530054200, - "Address":"985" - }, - { - "Reward":2926269382566926, - "Stock":2, - "Deposit":"715212514785840136617918555", - "Interest":715212514785840136617918, - "Address":"986" - }, - { - "Reward":2626971571595234, - "Stock":2, - "Deposit":"642060828433852259784251380", - "Interest":642060828433852259784251, - "Address":"987" - }, - { - "Reward":1714522839157243, - "Stock":1, - "Deposit":"419048293624883050338704278", - "Interest":419048293624883050338704, - "Address":"988" - }, - { - "Reward":1598790699802803, - "Stock":2, - "Deposit":"390762082204174521219993180", - "Interest":390762082204174521219993, - "Address":"989" - }, - { - "Reward":3339211416964932, - "Stock":1, - "Deposit":"816140102875322681627406453", - "Interest":816140102875322681627406, - "Address":"990" - }, - { - "Reward":1298746064123166, - "Stock":2, - "Deposit":"317427863655849629157375651", - "Interest":317427863655849629157375, - "Address":"991" - }, - { - "Reward":3332663717490899, - "Stock":2, - "Deposit":"814539772900651271045158408", - "Interest":814539772900651271045158, - "Address":"992" - }, - { - "Reward":3228469328520835, - "Stock":2, - "Deposit":"789073514938958275885095866", - "Interest":789073514938958275885095, - "Address":"993" - }, - { - "Reward":3487010750821872, - "Stock":1, - "Deposit":"852263890343845642591691021", - "Interest":852263890343845642591691, - "Address":"994" - }, - { - "Reward":2068796227856814, - "Stock":2, - "Deposit":"505636617571756152860807189", - "Interest":505636617571756152860807, - "Address":"995" - }, - { - "Reward":2600788466994318, - "Stock":1, - "Deposit":"635661388861376908116751981", - "Interest":635661388861376908116751, - "Address":"996" - }, - { - "Reward":3890554424384079, - "Stock":1, - "Deposit":"950894415378135238202169967", - "Interest":950894415378135238202169, - "Address":"997" - }, - { - "Reward":1816465297978958, - "Stock":2, - "Deposit":"443964155018810369139887005", - "Interest":443964155018810369139887, - "Address":"998" - }, - { - "Reward":245565102773786, - "Stock":2, - "Deposit":"60018819779475984788663779", - "Interest":60018819779475984788663, - "Address":"999" - }, - { - "Reward":3546279788870324, - "Stock":1, - "Deposit":"866749896999318703025627696", - "Interest":866749896999318703025627, - "Address":"1000" - } - ] - -}` - testData2 = `{ - "vipcfg":[ - { - "MinMoney":"0", - "InterestRate":1, - "ElectUserNum":0, - "StockScale":100 - }, - { - "MinMoney":"100000", - "InterestRate":5, - "ElectUserNum":0, - "StockScale":100 - }, - { - "MinMoney":"1000000", - "InterestRate":15, - "ElectUserNum":0, - "StockScale":100 - } - ], - - "node":[ - { - "Reward":2906041615899227, - "Stock":1, - "Deposit":"74486785624167273230592744", - "Interest":1117301784362509098, - "Address":"1" - }, - { - "Reward":3481108172104688, - "Stock":1, - "Deposit":"89226718823110739995418599", - "Interest":1338400782346661099, - "Address":"2" - }, - { - "Reward":946497463649516, - "Stock":2, - "Deposit":"24260338627966970828290487", - "Interest":363905079419504562, - "Address":"3" - }, - { - "Reward":505612105452951, - "Stock":2, - "Deposit":"12959697583754026252352029", - "Interest":194395463756310393, - "Address":"4" - }, - { - "Reward":878084114363781, - "Stock":1, - "Deposit":"22506788212791328798207312", - "Interest":337601823191869931, - "Address":"5" - }, - { - "Reward":1365550958115437, - "Stock":1, - "Deposit":"35001391900076617162029627", - "Interest":525020878501149257, - "Address":"6" - }, - { - "Reward":1120037367831369, - "Stock":2, - "Deposit":"28708461314617605977898595", - "Interest":430626919719264089, - "Address":"7" - }, - { - "Reward":3618519344774036, - "Stock":2, - "Deposit":"92748800717942792024957747", - "Interest":1391232010769141880, - "Address":"8" - }, - { - "Reward":200196466431165, - "Stock":1, - "Deposit":"5131375681679550826943295", - "Interest":76970635225193262, - "Address":"9" - }, - { - "Reward":2312241346646208, - "Stock":1, - "Deposit":"59266675520638656410691871", - "Interest":889000132809579846, - "Address":"10" - }, - { - "Reward":635536866371844, - "Stock":2, - "Deposit":"16289890021773234531317030", - "Interest":244348350326598517, - "Address":"11" - }, - { - "Reward":3270972209719496, - "Stock":1, - "Deposit":"83840576967303026564898277", - "Interest":1257608654509545398, - "Address":"12" - }, - { - "Reward":653725398823964, - "Stock":1, - "Deposit":"16756093021127083099739333", - "Interest":251341395316906246, - "Address":"13" - }, - { - "Reward":1959295028884455, - "Stock":1, - "Deposit":"50220061540947269490019922", - "Interest":753300923114209042, - "Address":"14" - }, - { - "Reward":3898803028897786, - "Stock":1, - "Deposit":"99932947902571933617147557", - "Interest":1498994218538579004, - "Address":"15" - }, - { - "Reward":1386592217019435, - "Stock":2, - "Deposit":"35540715126788124948118838", - "Interest":533110726901821874, - "Address":"16" - }, - { - "Reward":183669871083468, - "Stock":1, - "Deposit":"4707770954883394587868374", - "Interest":70616564323250918, - "Address":"17" - }, - { - "Reward":833579468942700, - "Stock":2, - "Deposit":"21366058512079910693873566", - "Interest":320490877681198660, - "Address":"18" - }, - { - "Reward":1552137122561306, - "Stock":1, - "Deposit":"39783912410270527719258460", - "Interest":596758686154057915, - "Address":"19" - }, - { - "Reward":1301779382693488, - "Stock":1, - "Deposit":"33366818038029477658804316", - "Interest":500502270570442164, - "Address":"20" - }, - { - "Reward":895775683464222, - "Stock":2, - "Deposit":"22960253196819757628495392", - "Interest":344403797952296364, - "Address":"21" - }, - { - "Reward":3652197058187118, - "Stock":1, - "Deposit":"93612017750206832920527950", - "Interest":1404180266253102493, - "Address":"22" - }, - { - "Reward":2665405713533181, - "Stock":1, - "Deposit":"68318878469998267639771313", - "Interest":1024783177049974014, - "Address":"23" - }, - { - "Reward":3753609054508943, - "Stock":2, - "Deposit":"96211379572286337423412669", - "Interest":1443170693584295061, - "Address":"24" - }, - { - "Reward":1708716882039256, - "Stock":1, - "Deposit":"43797317763279808304700996", - "Interest":656959766449197124, - "Address":"25" - }, - { - "Reward":3668647301402672, - "Stock":1, - "Deposit":"94033665442090708106961683", - "Interest":1410504981631360621, - "Address":"26" - }, - { - "Reward":7587381603282, - "Stock":2, - "Deposit":"583432457237087476245589", - "Interest":2917162286185437, - "Address":"27" - }, - { - "Reward":2381063450378614, - "Stock":2, - "Deposit":"61030703006987530040974599", - "Interest":915460545104812950, - "Address":"28" - }, - { - "Reward":3125332188420023, - "Stock":2, - "Deposit":"80107575696611954549030171", - "Interest":1201613635449179318, - "Address":"29" - }, - { - "Reward":908958583945670, - "Stock":1, - "Deposit":"23298153341364813420196362", - "Interest":349472300120472201, - "Address":"30" - }, - { - "Reward":3637951020495667, - "Stock":1, - "Deposit":"93246867592097859587675873", - "Interest":1398703013881467893, - "Address":"31" - }, - { - "Reward":2977807902972445, - "Stock":1, - "Deposit":"76326277533374187197333370", - "Interest":1144894163000612807, - "Address":"32" - }, - { - "Reward":3224325946799242, - "Stock":1, - "Deposit":"82644953970268164597442893", - "Interest":1239674309554022468, - "Address":"33" - }, - { - "Reward":2237321747373074, - "Stock":2, - "Deposit":"57346358860486612579921660", - "Interest":860195382907299188, - "Address":"34" - }, - { - "Reward":3092193173099875, - "Stock":2, - "Deposit":"79258166412022590393707361", - "Interest":1188872496180338855, - "Address":"35" - }, - { - "Reward":1283727577236007, - "Stock":1, - "Deposit":"32904119583924751338789410", - "Interest":493561793758871270, - "Address":"36" - }, - { - "Reward":871818802155576, - "Stock":2, - "Deposit":"22346197612585250171791636", - "Interest":335192964188778752, - "Address":"37" - }, - { - "Reward":1218750013897688, - "Stock":1, - "Deposit":"31238634201925352676733310", - "Interest":468579513028880290, - "Address":"38" - }, - { - "Reward":2280471012193917, - "Stock":2, - "Deposit":"58452347852855557347751246", - "Interest":876785217792833360, - "Address":"39" - }, - { - "Reward":3237842808254176, - "Stock":1, - "Deposit":"82991414102152283324663259", - "Interest":1244871211532284249, - "Address":"40" - }, - { - "Reward":1133215886846205, - "Stock":2, - "Deposit":"29046249154726810906683640", - "Interest":435693737320902163, - "Address":"41" - }, - { - "Reward":1570533358629577, - "Stock":2, - "Deposit":"40255439206312249038191746", - "Interest":603831588094683735, - "Address":"42" - }, - { - "Reward":3363246733691214, - "Stock":2, - "Deposit":"86205729843314615754310348", - "Interest":1293085947649719236, - "Address":"43" - }, - { - "Reward":2398356568750112, - "Stock":1, - "Deposit":"61473955021639958846182593", - "Interest":922109325324599382, - "Address":"44" - }, - { - "Reward":3867038882025451, - "Stock":1, - "Deposit":"99118778832979281833059792", - "Interest":1486781682494689227, - "Address":"45" - }, - { - "Reward":794714664407829, - "Stock":1, - "Deposit":"20369887518562213026643987", - "Interest":305548312778433195, - "Address":"46" - }, - { - "Reward":3227289251054687, - "Stock":1, - "Deposit":"82720908494665490459589978", - "Interest":1240813627419982356, - "Address":"47" - }, - { - "Reward":2636819369781666, - "Stock":2, - "Deposit":"67586161895277430129527439", - "Interest":1013792428429161451, - "Address":"48" - }, - { - "Reward":971256195484174, - "Stock":1, - "Deposit":"24894947003980805180490092", - "Interest":373424205059712077, - "Address":"49" - }, - { - "Reward":1856239089217925, - "Stock":2, - "Deposit":"47578562656953260483796082", - "Interest":713678439854298907, - "Address":"50" - }, - { - "Reward":1556959676839917, - "Stock":2, - "Deposit":"39907522672679185408818719", - "Interest":598612840090187781, - "Address":"51" - }, - { - "Reward":2338659781630072, - "Stock":2, - "Deposit":"59943824909141207874390633", - "Interest":899157373637118118, - "Address":"52" - }, - { - "Reward":3123174738185984, - "Stock":2, - "Deposit":"80052276580385095535956695", - "Interest":1200784148705776433, - "Address":"53" - }, - { - "Reward":409917301901230, - "Stock":1, - "Deposit":"10506877129117075942927355", - "Interest":157603156936756139, - "Address":"54" - }, - { - "Reward":3204790193567375, - "Stock":1, - "Deposit":"82144219412639185592830766", - "Interest":1232163291189587783, - "Address":"55" - }, - { - "Reward":3281430198919630, - "Stock":2, - "Deposit":"84108633004542254782497476", - "Interest":1261629495068133821, - "Address":"56" - }, - { - "Reward":1383077401838597, - "Stock":2, - "Deposit":"35450624440043909672215816", - "Interest":531759366600658645, - "Address":"57" - }, - { - "Reward":1677881178005258, - "Stock":1, - "Deposit":"43006946261583345329915537", - "Interest":645104193923750179, - "Address":"58" - }, - { - "Reward":2232544966227357, - "Stock":2, - "Deposit":"57223921841268465821206058", - "Interest":858358827619026987, - "Address":"59" - }, - { - "Reward":2734210928833263, - "Stock":1, - "Deposit":"70082473077123674805374139", - "Interest":1051237096156855122, - "Address":"60" - }, - { - "Reward":2896685625875057, - "Stock":2, - "Deposit":"74246975698728012734363833", - "Interest":1113704635480920191, - "Address":"61" - }, - { - "Reward":2956823634257963, - "Stock":1, - "Deposit":"75788415062078540181756231", - "Interest":1136826225931178102, - "Address":"62" - }, - { - "Reward":1518154356373096, - "Stock":2, - "Deposit":"38912876356922687652308661", - "Interest":583693145353840314, - "Address":"63" - }, - { - "Reward":1674888876952298, - "Stock":1, - "Deposit":"42930248499983747483125657", - "Interest":643953727499756212, - "Address":"64" - }, - { - "Reward":3731101228964969, - "Stock":1, - "Deposit":"95634465750065866816560877", - "Interest":1434516986250988002, - "Address":"65" - }, - { - "Reward":2235401385700918, - "Stock":1, - "Deposit":"57297136727048425536464071", - "Interest":859457050905726383, - "Address":"66" - }, - { - "Reward":3315121777393050, - "Stock":2, - "Deposit":"84972205421867363925477537", - "Interest":1274583081328010458, - "Address":"67" - }, - { - "Reward":1078138870931377, - "Stock":1, - "Deposit":"27634531629822345347154849", - "Interest":414517974447335180, - "Address":"68" - }, - { - "Reward":2427945183881189, - "Stock":1, - "Deposit":"62232361515245038236621611", - "Interest":933485422728675573, - "Address":"69" - }, - { - "Reward":2295445462386517, - "Stock":2, - "Deposit":"58836168461353888231907016", - "Interest":882542526920308323, - "Address":"70" - }, - { - "Reward":3758894190130386, - "Stock":2, - "Deposit":"96346846580699152538718664", - "Interest":1445202698710487288, - "Address":"71" - }, - { - "Reward":335142407342294, - "Stock":1, - "Deposit":"8590269496725100318604900", - "Interest":128854042450876504, - "Address":"72" - }, - { - "Reward":1952655891276120, - "Stock":1, - "Deposit":"50049889160395055758838818", - "Interest":750748337405925836, - "Address":"73" - }, - { - "Reward":2034939880443670, - "Stock":2, - "Deposit":"52158967649805487725937920", - "Interest":782384514747082315, - "Address":"74" - }, - { - "Reward":351775355113798, - "Stock":2, - "Deposit":"9016600216896353271258025", - "Interest":135249003253445299, - "Address":"75" - }, - { - "Reward":3529483003540398, - "Stock":1, - "Deposit":"90466647969012514716326287", - "Interest":1356999719535187720, - "Address":"76" - }, - { - "Reward":3450371818859554, - "Stock":2, - "Deposit":"88438893850986044506921930", - "Interest":1326583407764790667, - "Address":"77" - }, - { - "Reward":1712682632223657, - "Stock":1, - "Deposit":"43898966680559026181052742", - "Interest":658484500208385392, - "Address":"78" - }, - { - "Reward":3049827464282078, - "Stock":1, - "Deposit":"78172261291716627081876814", - "Interest":1172583919375749406, - "Address":"79" - }, - { - "Reward":579224263154397, - "Stock":1, - "Deposit":"14846502294340846452120958", - "Interest":222697534415112696, - "Address":"80" - }, - { - "Reward":2418161642664381, - "Stock":1, - "Deposit":"61981592726087098028184655", - "Interest":929723890891306470, - "Address":"81" - }, - { - "Reward":1016802177812370, - "Stock":1, - "Deposit":"26062367939442065980887755", - "Interest":390935519091630989, - "Address":"82" - }, - { - "Reward":1738691616204199, - "Stock":1, - "Deposit":"44565621143957523391255277", - "Interest":668484317159362850, - "Address":"83" - }, - { - "Reward":3292795740334649, - "Stock":1, - "Deposit":"84399951147493612610523199", - "Interest":1265999267212404189, - "Address":"84" - }, - { - "Reward":765477600220339, - "Stock":1, - "Deposit":"19620491873125200934253260", - "Interest":294307378096878014, - "Address":"85" - }, - { - "Reward":1185452497984931, - "Stock":2, - "Deposit":"30385162277765243035981178", - "Interest":455777434166478645, - "Address":"86" - }, - { - "Reward":1885534615039395, - "Stock":2, - "Deposit":"48329456773428558507387521", - "Interest":724941851601428377, - "Address":"87" - }, - { - "Reward":1317946330500075, - "Stock":1, - "Deposit":"33781204387102370393414258", - "Interest":506718065806535555, - "Address":"88" - }, - { - "Reward":3115227796247623, - "Stock":1, - "Deposit":"79848582952154911759541064", - "Interest":1197728744282323676, - "Address":"89" - }, - { - "Reward":3852602800130239, - "Stock":2, - "Deposit":"98748757518935292863833764", - "Interest":1481231362784029392, - "Address":"90" - }, - { - "Reward":620511153833878, - "Stock":1, - "Deposit":"15904755472239451298745227", - "Interest":238571332083591769, - "Address":"91" - }, - { - "Reward":924167289878000, - "Stock":1, - "Deposit":"23687978322605474093145135", - "Interest":355319674839082111, - "Address":"92" - }, - { - "Reward":2739719349736193, - "Stock":2, - "Deposit":"70223663266789038146864013", - "Interest":1053354949001835572, - "Address":"93" - }, - { - "Reward":1464872283381135, - "Stock":1, - "Deposit":"37547166269754739257734568", - "Interest":563207494046321088, - "Address":"94" - }, - { - "Reward":3798830819544100, - "Stock":2, - "Deposit":"97370490267498399648851756", - "Interest":1460557354012475994, - "Address":"95" - }, - { - "Reward":3793371380606233, - "Stock":1, - "Deposit":"97230555568845700174784824", - "Interest":1458458333532685502, - "Address":"96" - }, - { - "Reward":2511335808112571, - "Stock":1, - "Deposit":"64369804942140473886561261", - "Interest":965547074132107108, - "Address":"97" - }, - { - "Reward":3355606110509106, - "Stock":2, - "Deposit":"86009887685416064337640346", - "Interest":1290148315281240965, - "Address":"98" - }, - { - "Reward":1567915529666200, - "Stock":2, - "Deposit":"40188339800808559058716425", - "Interest":602825097012128385, - "Address":"99" - }, - { - "Reward":2465426829608111, - "Stock":1, - "Deposit":"63193079797745710386099723", - "Interest":947896196966185655, - "Address":"100" - }, - { - "Reward":3843820956504332, - "Stock":2, - "Deposit":"98523663941483030647002044", - "Interest":1477854959122245459, - "Address":"101" - }, - { - "Reward":2182755788601055, - "Stock":2, - "Deposit":"55947740598727546684803929", - "Interest":839216108980913200, - "Address":"102" - }, - { - "Reward":3642333250079590, - "Stock":1, - "Deposit":"93359191584220901925396744", - "Interest":1400387873763313528, - "Address":"103" - }, - { - "Reward":2810360679182344, - "Stock":2, - "Deposit":"72034320600074808201276907", - "Interest":1080514809001122123, - "Address":"104" - }, - { - "Reward":1888437072116613, - "Stock":2, - "Deposit":"48403851681234177922026291", - "Interest":726057775218512668, - "Address":"105" - }, - { - "Reward":2493128054357456, - "Stock":2, - "Deposit":"63903109268123026171782590", - "Interest":958546639021845392, - "Address":"106" - }, - { - "Reward":3463043344489049, - "Stock":1, - "Deposit":"88763686588960410981372656", - "Interest":1331455298834406164, - "Address":"107" - }, - { - "Reward":775355335253784, - "Stock":1, - "Deposit":"19873675009892122213837584", - "Interest":298105125148381833, - "Address":"108" - }, - { - "Reward":1542489497981609, - "Stock":1, - "Deposit":"39536627395521017906474511", - "Interest":593049410932815268, - "Address":"109" - }, - { - "Reward":3870891588565573, - "Stock":1, - "Deposit":"99217530249530527807132226", - "Interest":1488262953742957917, - "Address":"110" - }, - { - "Reward":1569742247893223, - "Stock":2, - "Deposit":"40235161693594811986441728", - "Interest":603527425403922179, - "Address":"111" - }, - { - "Reward":2570475201552590, - "Stock":1, - "Deposit":"65885648107293115500670195", - "Interest":988284721609396732, - "Address":"112" - }, - { - "Reward":3516536703795010, - "Stock":1, - "Deposit":"90134812303451161694791033", - "Interest":1352022184551767425, - "Address":"113" - }, - { - "Reward":3883401387279315, - "Stock":1, - "Deposit":"99538177651788628540427553", - "Interest":1493072664776829428, - "Address":"114" - }, - { - "Reward":2548263642917367, - "Stock":2, - "Deposit":"65316328109469035119036764", - "Interest":979744921642035526, - "Address":"115" - }, - { - "Reward":423055941247838, - "Stock":1, - "Deposit":"10843642785551477204481863", - "Interest":162654641783272158, - "Address":"116" - }, - { - "Reward":140895966351272, - "Stock":2, - "Deposit":"3611403079535602245547784", - "Interest":54171046193034033, - "Address":"117" - }, - { - "Reward":2411432911276608, - "Stock":1, - "Deposit":"61809123904697371727004287", - "Interest":927136858570460575, - "Address":"118" - }, - { - "Reward":2212667796156645, - "Stock":1, - "Deposit":"56714436189799555260275633", - "Interest":850716542846993328, - "Address":"119" - }, - { - "Reward":3753027205002027, - "Stock":1, - "Deposit":"96196465780532602894600141", - "Interest":1442946986707989043, - "Address":"120" - }, - { - "Reward":2910870063478532, - "Stock":2, - "Deposit":"74610546941888766799515882", - "Interest":1119158204128331501, - "Address":"121" - }, - { - "Reward":2584752902306570, - "Stock":1, - "Deposit":"66251609843508174619810657", - "Interest":993774147652622619, - "Address":"122" - }, - { - "Reward":2041664529776954, - "Stock":1, - "Deposit":"52331331841200956494730031", - "Interest":784969977618014347, - "Address":"123" - }, - { - "Reward":1013956490938764, - "Stock":2, - "Deposit":"25989428148439741586382777", - "Interest":389841422226596123, - "Address":"124" - }, - { - "Reward":3753140771840512, - "Stock":2, - "Deposit":"96199376691617277677811745", - "Interest":1442990650374259165, - "Address":"125" - }, - { - "Reward":2107562302408893, - "Stock":1, - "Deposit":"54020403751352008564336371", - "Interest":810306056270280128, - "Address":"126" - }, - { - "Reward":118096591067527, - "Stock":2, - "Deposit":"3027016341976873637112274", - "Interest":45405245129653104, - "Address":"127" - }, - { - "Reward":2716614486004540, - "Stock":2, - "Deposit":"69631446341112723803797055", - "Interest":1044471695116690857, - "Address":"128" - }, - { - "Reward":2027630499447010, - "Stock":1, - "Deposit":"51971615792087810797502707", - "Interest":779574236881317161, - "Address":"129" - }, - { - "Reward":230302932168667, - "Stock":1, - "Deposit":"5903055566448411895542877", - "Interest":88545833496726178, - "Address":"130" - }, - { - "Reward":3472404281841090, - "Stock":2, - "Deposit":"89003623322821312511276667", - "Interest":1335054349842319687, - "Address":"131" - }, - { - "Reward":1288257306806989, - "Stock":2, - "Deposit":"33020224251402052754146902", - "Interest":495303363771030791, - "Address":"132" - }, - { - "Reward":896160620493736, - "Stock":1, - "Deposit":"22970119787111953348976018", - "Interest":344551796806679300, - "Address":"133" - }, - { - "Reward":444561398291543, - "Stock":1, - "Deposit":"11394864199518917048409789", - "Interest":170922962992783755, - "Address":"134" - }, - { - "Reward":1213039785584908, - "Stock":2, - "Deposit":"31092271345360578130632204", - "Interest":466384070180408671, - "Address":"135" - }, - { - "Reward":891210204575628, - "Stock":2, - "Deposit":"22843232213573738678186971", - "Interest":342648483203606080, - "Address":"136" - }, - { - "Reward":2543714144064598, - "Stock":2, - "Deposit":"65199716721700318184792797", - "Interest":977995750825504772, - "Address":"137" - }, - { - "Reward":258118367955772, - "Stock":1, - "Deposit":"6616012459832676385168989", - "Interest":99240186897490145, - "Address":"138" - }, - { - "Reward":1074573221938950, - "Stock":2, - "Deposit":"27543137986091692506727857", - "Interest":413147069791375387, - "Address":"139" - }, - { - "Reward":1099498832835614, - "Stock":2, - "Deposit":"28182023756086682644879276", - "Interest":422730356341300239, - "Address":"140" - }, - { - "Reward":3433507237668895, - "Stock":2, - "Deposit":"88006625972605623262534508", - "Interest":1320099389589084348, - "Address":"141" - }, - { - "Reward":1733518909115690, - "Stock":1, - "Deposit":"44433035869923465104312637", - "Interest":666495538048851976, - "Address":"142" - }, - { - "Reward":2949137722881801, - "Stock":1, - "Deposit":"75591412090796117347671475", - "Interest":1133871181361941760, - "Address":"143" - }, - { - "Reward":2353711950582218, - "Stock":1, - "Deposit":"60329637581534845131502531", - "Interest":904944563723022676, - "Address":"144" - }, - { - "Reward":3055848619777107, - "Stock":2, - "Deposit":"78326593740403627216305216", - "Interest":1174898906106054408, - "Address":"145" - }, - { - "Reward":444491159809240, - "Stock":2, - "Deposit":"11393063867842589954621250", - "Interest":170895958017638849, - "Address":"146" - }, - { - "Reward":3817787746190880, - "Stock":1, - "Deposit":"97856388515997794207208798", - "Interest":1467845827739966913, - "Address":"147" - }, - { - "Reward":3310731203384332, - "Stock":2, - "Deposit":"84859667547954897867819795", - "Interest":1272895013219323468, - "Address":"148" - }, - { - "Reward":197593208911930, - "Stock":2, - "Deposit":"5064649767054341112322044", - "Interest":75969746505815116, - "Address":"149" - }, - { - "Reward":1818848697861593, - "Stock":2, - "Deposit":"46620183379063595556996357", - "Interest":699302750685953933, - "Address":"150" - }, - { - "Reward":1270509878259280, - "Stock":1, - "Deposit":"32565327494803353317521362", - "Interest":488479912422050299, - "Address":"151" - }, - { - "Reward":2458694256244087, - "Stock":1, - "Deposit":"63020512499974967741324480", - "Interest":945307687499624516, - "Address":"152" - }, - { - "Reward":898493536050199, - "Stock":2, - "Deposit":"23029916377767378767940649", - "Interest":345448745666510681, - "Address":"153" - }, - { - "Reward":2262374259634158, - "Stock":2, - "Deposit":"57988497328128896241248853", - "Interest":869827459921933443, - "Address":"154" - }, - { - "Reward":2353165535877672, - "Stock":1, - "Deposit":"60315632043989653172020215", - "Interest":904734480659844797, - "Address":"155" - }, - { - "Reward":2340379709488601, - "Stock":1, - "Deposit":"59987909583285703446929235", - "Interest":899818643749285551, - "Address":"156" - }, - { - "Reward":1749505058119101, - "Stock":2, - "Deposit":"44842788038391523390874803", - "Interest":672641820575872850, - "Address":"157" - }, - { - "Reward":138201762984861, - "Stock":1, - "Deposit":"3542346068278845461561912", - "Interest":53135191024182681, - "Address":"158" - }, - { - "Reward":2004606966155845, - "Stock":2, - "Deposit":"51381483503827651842659117", - "Interest":770722252557414777, - "Address":"159" - }, - { - "Reward":1590726204976916, - "Stock":2, - "Deposit":"40773016177263698982168585", - "Interest":611595242658955484, - "Address":"160" - }, - { - "Reward":421532861442087, - "Stock":1, - "Deposit":"10804603661555889361181400", - "Interest":162069054923338340, - "Address":"161" - }, - { - "Reward":1794167521991436, - "Stock":1, - "Deposit":"45987562894231392989373163", - "Interest":689813443413470894, - "Address":"162" - }, - { - "Reward":1759082547452660, - "Stock":1, - "Deposit":"45088275367583041668481747", - "Interest":676324130513745625, - "Address":"163" - }, - { - "Reward":2150229384483822, - "Stock":2, - "Deposit":"55114033580441879062128205", - "Interest":826710503706628185, - "Address":"164" - }, - { - "Reward":3142219714862747, - "Stock":2, - "Deposit":"80540431700799763889140324", - "Interest":1208106475511996458, - "Address":"165" - }, - { - "Reward":2734309798651704, - "Stock":2, - "Deposit":"70085007278606059617839335", - "Interest":1051275109179090894, - "Address":"166" - }, - { - "Reward":3402956178093682, - "Stock":1, - "Deposit":"87223550392159787678469279", - "Interest":1308353255882396815, - "Address":"167" - }, - { - "Reward":203623455772444, - "Stock":2, - "Deposit":"5219215242890096196315060", - "Interest":78288228643351442, - "Address":"168" - }, - { - "Reward":857068844936333, - "Stock":2, - "Deposit":"21968131140534608027855505", - "Interest":329521967108019120, - "Address":"169" - }, - { - "Reward":1793256077042776, - "Stock":1, - "Deposit":"45964201011136651691276097", - "Interest":689463015167049775, - "Address":"170" - }, - { - "Reward":3739641195746101, - "Stock":1, - "Deposit":"95853359612900956863852407", - "Interest":1437800394193514352, - "Address":"171" - }, - { - "Reward":3082297976200091, - "Stock":2, - "Deposit":"79004535697943822921806867", - "Interest":1185068035469157343, - "Address":"172" - }, - { - "Reward":1762952190837516, - "Stock":2, - "Deposit":"45187460904250087439034130", - "Interest":677811913563751311, - "Address":"173" - }, - { - "Reward":1300843065853424, - "Stock":2, - "Deposit":"33342818646086647141891328", - "Interest":500142279691299707, - "Address":"174" - }, - { - "Reward":230555576420487, - "Stock":1, - "Deposit":"5909531268008061389331653", - "Interest":88642969020120920, - "Address":"175" - }, - { - "Reward":2890582034930250, - "Stock":1, - "Deposit":"74090530289358758072224053", - "Interest":1111357954340381371, - "Address":"176" - }, - { - "Reward":1977217791416270, - "Stock":1, - "Deposit":"50679452405550251553113240", - "Interest":760191786083253773, - "Address":"177" - }, - { - "Reward":779992807838801, - "Stock":2, - "Deposit":"19992541313935463522576582", - "Interest":299888119709031952, - "Address":"178" - }, - { - "Reward":1666661042145078, - "Stock":1, - "Deposit":"42719355110128809376140332", - "Interest":640790326651932140, - "Address":"179" - }, - { - "Reward":658131460537138, - "Stock":1, - "Deposit":"16869027871227115779626611", - "Interest":253035418068406736, - "Address":"180" - }, - { - "Reward":2932675568109514, - "Stock":1, - "Deposit":"75169459085468726130279831", - "Interest":1127541886282030891, - "Address":"181" - }, - { - "Reward":1437090976681230, - "Stock":2, - "Deposit":"36835084162880049611160493", - "Interest":552526262443200744, - "Address":"182" - }, - { - "Reward":3674425852353538, - "Stock":1, - "Deposit":"94181779523988429235176855", - "Interest":1412726692859826438, - "Address":"183" - }, - { - "Reward":66997277596423, - "Stock":2, - "Deposit":"1717254091071729327382987", - "Interest":25758811366075939, - "Address":"184" - }, - { - "Reward":3234494484665558, - "Stock":2, - "Deposit":"82905590877880064323802537", - "Interest":1243583863168200964, - "Address":"185" - }, - { - "Reward":2444593942547724, - "Stock":2, - "Deposit":"62659097495527593674900860", - "Interest":939886462432913905, - "Address":"186" - }, - { - "Reward":2101875896977351, - "Stock":2, - "Deposit":"53874651515721916355925773", - "Interest":808119772735828745, - "Address":"187" - }, - { - "Reward":2537902856236710, - "Stock":1, - "Deposit":"65050763538006051163014080", - "Interest":975761453070090767, - "Address":"188" - }, - { - "Reward":2834886272148395, - "Stock":2, - "Deposit":"72662953230651416987638890", - "Interest":1089944298459771254, - "Address":"189" - }, - { - "Reward":368639479712848, - "Stock":2, - "Deposit":"9448856392057847220889233", - "Interest":141732845880867708, - "Address":"190" - }, - { - "Reward":3423783631897036, - "Stock":2, - "Deposit":"87757393430765984207894644", - "Interest":1316360901461489763, - "Address":"191" - }, - { - "Reward":56032741446461, - "Stock":2, - "Deposit":"1436214394598578358996085", - "Interest":21543215918978675, - "Address":"192" - }, - { - "Reward":1148197863710927, - "Stock":2, - "Deposit":"29430262684623720306929513", - "Interest":441453940269355804, - "Address":"193" - }, - { - "Reward":701923327569581, - "Stock":2, - "Deposit":"17991487850424014995475251", - "Interest":269872317756360224, - "Address":"194" - }, - { - "Reward":3613862068816124, - "Stock":1, - "Deposit":"92629426819795002155206620", - "Interest":1389441402296925032, - "Address":"195" - }, - { - "Reward":266000452495382, - "Stock":1, - "Deposit":"6818043682703456288122866", - "Interest":102270655240551844, - "Address":"196" - }, - { - "Reward":2267088165920806, - "Stock":1, - "Deposit":"58109322757849146695840325", - "Interest":871639841367737200, - "Address":"197" - }, - { - "Reward":2485793893190396, - "Stock":1, - "Deposit":"63715122252522471419637735", - "Interest":955726833787837071, - "Address":"198" - }, - { - "Reward":2540874291599119, - "Stock":1, - "Deposit":"65126926476494229063375238", - "Interest":976903897147413435, - "Address":"199" - }, - { - "Reward":3373252758043334, - "Stock":2, - "Deposit":"86462201253355297500858722", - "Interest":1296933018800329462, - "Address":"200" - }, - { - "Reward":218294262007826, - "Stock":1, - "Deposit":"5595252940702089006767580", - "Interest":83928794110531335, - "Address":"201" - }, - { - "Reward":3186894305154736, - "Stock":1, - "Deposit":"81685517377385019618775171", - "Interest":1225282760660775294, - "Address":"202" - }, - { - "Reward":2063548166100173, - "Stock":1, - "Deposit":"52892246632842854220113299", - "Interest":793383699492642813, - "Address":"203" - }, - { - "Reward":2708952478326698, - "Stock":2, - "Deposit":"69435056062244160386685670", - "Interest":1041525840933662405, - "Address":"204" - }, - { - "Reward":828680500632986, - "Stock":2, - "Deposit":"21240489628183401029550250", - "Interest":318607344422751015, - "Address":"205" - }, - { - "Reward":2119562711232530, - "Stock":1, - "Deposit":"54327994624985109789349159", - "Interest":814919919374776646, - "Address":"206" - }, - { - "Reward":2740825946217813, - "Stock":1, - "Deposit":"70252027215346379847373942", - "Interest":1053780408230195697, - "Address":"207" - }, - { - "Reward":3731451965597083, - "Stock":2, - "Deposit":"95643455726046888730315241", - "Interest":1434651835890703330, - "Address":"208" - }, - { - "Reward":1734345245947915, - "Stock":2, - "Deposit":"44454216287347136931096836", - "Interest":666813244310207053, - "Address":"209" - }, - { - "Reward":333172720730949, - "Stock":2, - "Deposit":"8539783081264495923932713", - "Interest":128096746218967438, - "Address":"210" - }, - { - "Reward":223707941778376, - "Stock":2, - "Deposit":"5734014754125749125397443", - "Interest":86010221311886236, - "Address":"211" - }, - { - "Reward":2455750093691245, - "Stock":2, - "Deposit":"62945048609947928947754898", - "Interest":944175729149218934, - "Address":"212" - }, - { - "Reward":3106228147132754, - "Stock":2, - "Deposit":"79617906649845815455673846", - "Interest":1194268599747687231, - "Address":"213" - }, - { - "Reward":2696627007063275, - "Stock":1, - "Deposit":"69119133285814349239273473", - "Interest":1036786999287215238, - "Address":"214" - }, - { - "Reward":1347190658699719, - "Stock":2, - "Deposit":"34530786221516551751772863", - "Interest":517961793322748276, - "Address":"215" - }, - { - "Reward":3693928546308325, - "Stock":1, - "Deposit":"94681666716159451633894701", - "Interest":1420225000742391774, - "Address":"216" - }, - { - "Reward":2029480397419571, - "Stock":2, - "Deposit":"52019031821147720956101437", - "Interest":780285477317215814, - "Address":"217" - }, - { - "Reward":3721224270567255, - "Stock":2, - "Deposit":"95381302519792687820236517", - "Interest":1430719537796890317, - "Address":"218" - }, - { - "Reward":287127412755211, - "Stock":2, - "Deposit":"7359563580819994400197604", - "Interest":110393453712299916, - "Address":"219" - }, - { - "Reward":807718378339899, - "Stock":1, - "Deposit":"20703194807307401250476975", - "Interest":310547922109611018, - "Address":"220" - }, - { - "Reward":3023708248433604, - "Stock":1, - "Deposit":"77502781398196740622024841", - "Interest":1162541720972951109, - "Address":"221" - }, - { - "Reward":3566629746499213, - "Stock":1, - "Deposit":"91418782124377351303831043", - "Interest":1371281731865660269, - "Address":"222" - }, - { - "Reward":3053057974966750, - "Stock":1, - "Deposit":"78255064771029958511408346", - "Interest":1173825971565449377, - "Address":"223" - }, - { - "Reward":1153002731665475, - "Stock":1, - "Deposit":"29553419616487597301923228", - "Interest":443301294247313959, - "Address":"224" - }, - { - "Reward":592413787955161, - "Stock":1, - "Deposit":"15184572231448456582210680", - "Interest":227768583471726848, - "Address":"225" - }, - { - "Reward":3308054232378145, - "Stock":1, - "Deposit":"84791052231378216683255766", - "Interest":1271865783470673250, - "Address":"226" - }, - { - "Reward":3062046623483576, - "Stock":2, - "Deposit":"78485459109314958955420158", - "Interest":1177281886639724384, - "Address":"227" - }, - { - "Reward":1056627171589038, - "Stock":2, - "Deposit":"27083150215131734930770496", - "Interest":406247253226976023, - "Address":"228" - }, - { - "Reward":888785014946629, - "Stock":2, - "Deposit":"22781070481613374669793828", - "Interest":341716057224200620, - "Address":"229" - }, - { - "Reward":1252446082500386, - "Stock":2, - "Deposit":"32102321708895109611968609", - "Interest":481534825633426644, - "Address":"230" - }, - { - "Reward":3236468195457033, - "Stock":1, - "Deposit":"82956180439916749066970188", - "Interest":1244342706598751236, - "Address":"231" - }, - { - "Reward":3207677245487936, - "Stock":2, - "Deposit":"82218219460097585757239997", - "Interest":1233273291901463786, - "Address":"232" - }, - { - "Reward":2226472922792169, - "Stock":1, - "Deposit":"57068285048187827884919803", - "Interest":856024275722817418, - "Address":"233" - }, - { - "Reward":2230947014508286, - "Stock":1, - "Deposit":"57182963622884752658166457", - "Interest":857744454343271289, - "Address":"234" - }, - { - "Reward":1115877126158505, - "Stock":2, - "Deposit":"28601827249938027722480009", - "Interest":429027408749070415, - "Address":"235" - }, - { - "Reward":2727612960307249, - "Stock":2, - "Deposit":"69913355930120901778103845", - "Interest":1048700338951813526, - "Address":"236" - }, - { - "Reward":3106535878514033, - "Stock":1, - "Deposit":"79625794328157706311228290", - "Interest":1194386914922365594, - "Address":"237" - }, - { - "Reward":1722823939236753, - "Stock":2, - "Deposit":"44158905615122279191246895", - "Interest":662383584226834187, - "Address":"238" - }, - { - "Reward":1740874070981387, - "Stock":2, - "Deposit":"44621561169122159200579136", - "Interest":669323417536832388, - "Address":"239" - }, - { - "Reward":1816744173250798, - "Stock":1, - "Deposit":"46566240836511063610137590", - "Interest":698493612547665954, - "Address":"240" - }, - { - "Reward":1088648790375016, - "Stock":1, - "Deposit":"27903918727461485274633642", - "Interest":418558780911922279, - "Address":"241" - }, - { - "Reward":2634922107624184, - "Stock":1, - "Deposit":"67537531841659470550707036", - "Interest":1013062977624892058, - "Address":"242" - }, - { - "Reward":3525573963782746, - "Stock":2, - "Deposit":"90366452636353988845532571", - "Interest":1355496789545309832, - "Address":"243" - }, - { - "Reward":3544540214820345, - "Stock":2, - "Deposit":"90852589884837464682316720", - "Interest":1362788848272561970, - "Address":"244" - }, - { - "Reward":2915128363670555, - "Stock":1, - "Deposit":"74719694413071302559719210", - "Interest":1120795416196069538, - "Address":"245" - }, - { - "Reward":1016364546626084, - "Stock":2, - "Deposit":"26051150708354609000610306", - "Interest":390767260625319135, - "Address":"246" - }, - { - "Reward":2690566180780366, - "Stock":2, - "Deposit":"68963784007410899874697322", - "Interest":1034456760111163498, - "Address":"247" - }, - { - "Reward":514326664673834, - "Stock":1, - "Deposit":"13183066547551236526099460", - "Interest":197745998213268547, - "Address":"248" - }, - { - "Reward":481828495231895, - "Stock":1, - "Deposit":"12350083231980057975176076", - "Interest":185251248479700869, - "Address":"249" - }, - { - "Reward":744792021126494, - "Stock":2, - "Deposit":"19090285324449118855258924", - "Interest":286354279866736782, - "Address":"250" - }, - { - "Reward":568561983658996, - "Stock":2, - "Deposit":"14573209949629140071216094", - "Interest":218598149244437101, - "Address":"251" - }, - { - "Reward":2282500283560908, - "Stock":1, - "Deposit":"58504361526871551119360815", - "Interest":877565422903073266, - "Address":"252" - }, - { - "Reward":286214692445216, - "Stock":1, - "Deposit":"7336169008046677931411889", - "Interest":110042535120700168, - "Address":"253" - }, - { - "Reward":3208239157443720, - "Stock":1, - "Deposit":"82232622218530615495924198", - "Interest":1233489333277959232, - "Address":"254" - }, - { - "Reward":2820347403867358, - "Stock":1, - "Deposit":"72290297326846519883620282", - "Interest":1084354459902697798, - "Address":"255" - }, - { - "Reward":3612160152096376, - "Stock":1, - "Deposit":"92585803801748578499100056", - "Interest":1388787057026228677, - "Address":"256" - }, - { - "Reward":1921989594169992, - "Stock":2, - "Deposit":"49263859846178115203178371", - "Interest":738957897692671728, - "Address":"257" - }, - { - "Reward":2554972590759745, - "Stock":1, - "Deposit":"65488289844966851578226726", - "Interest":982324347674502773, - "Address":"258" - }, - { - "Reward":3472744660102977, - "Stock":1, - "Deposit":"89012347796168689315632774", - "Interest":1335185216942530339, - "Address":"259" - }, - { - "Reward":2101013914775852, - "Stock":1, - "Deposit":"53852557446902116216998263", - "Interest":807788361703531743, - "Address":"260" - }, - { - "Reward":1101000594341396, - "Stock":2, - "Deposit":"28220516455822231008431909", - "Interest":423307746837333465, - "Address":"261" - }, - { - "Reward":3807619215331923, - "Stock":1, - "Deposit":"97595751787996409830386690", - "Interest":1463936276819946147, - "Address":"262" - }, - { - "Reward":142111198799380, - "Stock":2, - "Deposit":"3642551552548012328367255", - "Interest":54638273288220184, - "Address":"263" - }, - { - "Reward":1272816779956388, - "Stock":1, - "Deposit":"32624457306031240392192247", - "Interest":489366859590468605, - "Address":"264" - }, - { - "Reward":3796133851360653, - "Stock":1, - "Deposit":"97301362389282042296430416", - "Interest":1459520435839230634, - "Address":"265" - }, - { - "Reward":1424145224431962, - "Stock":1, - "Deposit":"36503262530574742687244914", - "Interest":547548937958621140, - "Address":"266" - }, - { - "Reward":1206122200767158, - "Stock":2, - "Deposit":"30914961889591729974105068", - "Interest":463724428343875949, - "Address":"267" - }, - { - "Reward":471729876010267, - "Stock":1, - "Deposit":"12091238458062825157455348", - "Interest":181368576870942377, - "Address":"268" - }, - { - "Reward":3572785728442475, - "Stock":2, - "Deposit":"91576570404078960772321806", - "Interest":1373648556061184411, - "Address":"269" - }, - { - "Reward":528557247381154, - "Stock":1, - "Deposit":"13547820568150192867239661", - "Interest":203217308522252893, - "Address":"270" - }, - { - "Reward":1295731057462537, - "Stock":1, - "Deposit":"33211789182834072778881299", - "Interest":498176837742511091, - "Address":"271" - }, - { - "Reward":3501445115253598, - "Stock":2, - "Deposit":"89747989239988423824186497", - "Interest":1346219838599826357, - "Address":"272" - }, - { - "Reward":1949339241303308, - "Stock":1, - "Deposit":"49964877784727335102151130", - "Interest":749473166770910026, - "Address":"273" - }, - { - "Reward":2400497246145501, - "Stock":2, - "Deposit":"61528824221505673547946255", - "Interest":922932363322585103, - "Address":"274" - }, - { - "Reward":2275046048327035, - "Stock":2, - "Deposit":"58313296808864822923510169", - "Interest":874699452132972343, - "Address":"275" - }, - { - "Reward":2724181144669975, - "Stock":2, - "Deposit":"69825392662741392342566595", - "Interest":1047380889941120885, - "Address":"276" - }, - { - "Reward":114437759693498, - "Stock":2, - "Deposit":"2933234275436202853919417", - "Interest":43998514131543042, - "Address":"277" - }, - { - "Reward":2059491554141548, - "Stock":2, - "Deposit":"52788268773864732713308487", - "Interest":791824031607970990, - "Address":"278" - }, - { - "Reward":125129612797497, - "Stock":1, - "Deposit":"3207284641998542351935685", - "Interest":48109269629978135, - "Address":"279" - }, - { - "Reward":3227028784088112, - "Stock":1, - "Deposit":"82714232283631461414778588", - "Interest":1240713484254471921, - "Address":"280" - }, - { - "Reward":1326428649846756, - "Stock":2, - "Deposit":"33998620648216859588885531", - "Interest":509979309723252893, - "Address":"281" - }, - { - "Reward":3303374232793346, - "Stock":1, - "Deposit":"84671095888053016240281895", - "Interest":1270066438320795243, - "Address":"282" - }, - { - "Reward":960020487425381, - "Stock":2, - "Deposit":"24606956710609839691599662", - "Interest":369104350659147595, - "Address":"283" - }, - { - "Reward":2268641027402429, - "Stock":2, - "Deposit":"58149125236813259404425826", - "Interest":872236878552198891, - "Address":"284" - }, - { - "Reward":3658270403299159, - "Stock":2, - "Deposit":"93767687907477537133036732", - "Interest":1406515318612163056, - "Address":"285" - }, - { - "Reward":186438251051458, - "Stock":2, - "Deposit":"4778729238506618238113751", - "Interest":71680938577599273, - "Address":"286" - }, - { - "Reward":210589465719465, - "Stock":1, - "Deposit":"5397765917023855664609039", - "Interest":80966488755357834, - "Address":"287" - }, - { - "Reward":80439590309403, - "Stock":1, - "Deposit":"2061803411999085789069791", - "Interest":30927051179986286, - "Address":"288" - }, - { - "Reward":2658733231673810, - "Stock":2, - "Deposit":"68147851419621241493432557", - "Interest":1022217771294318622, - "Address":"289" - }, - { - "Reward":2335500715037154, - "Stock":2, - "Deposit":"59862852663323462560226643", - "Interest":897942789949851938, - "Address":"290" - }, - { - "Reward":444878944618340, - "Stock":2, - "Deposit":"11403003451565585369993558", - "Interest":171045051773483780, - "Address":"291" - }, - { - "Reward":3106486749677689, - "Stock":2, - "Deposit":"79624535072584523573053300", - "Interest":1194368026088767853, - "Address":"292" - }, - { - "Reward":2410494027348611, - "Stock":2, - "Deposit":"61785058713927876190075312", - "Interest":926775880708918142, - "Address":"293" - }, - { - "Reward":273932377394518, - "Stock":2, - "Deposit":"7021352398695834829558243", - "Interest":105320285980437522, - "Address":"294" - }, - { - "Reward":270286300720744, - "Stock":2, - "Deposit":"6927897256800130688229549", - "Interest":103918458852001960, - "Address":"295" - }, - { - "Reward":530621811758678, - "Stock":1, - "Deposit":"13600738862008965314425120", - "Interest":204011082930134479, - "Address":"296" - }, - { - "Reward":3077795593049605, - "Stock":2, - "Deposit":"78889131965700876055857399", - "Interest":1183336979485513140, - "Address":"297" - }, - { - "Reward":360485100439672, - "Stock":1, - "Deposit":"9239845792382961332335779", - "Interest":138597686885744419, - "Address":"298" - }, - { - "Reward":928025827540383, - "Stock":2, - "Deposit":"23786879200730637331662883", - "Interest":356803188010959559, - "Address":"299" - }, - { - "Reward":950572598559854, - "Stock":1, - "Deposit":"24364791261678475644761470", - "Interest":365471868925177134, - "Address":"300" - }, - { - "Reward":408955373365653, - "Stock":2, - "Deposit":"10482221265889479778702714", - "Interest":157233318988342196, - "Address":"301" - }, - { - "Reward":3348793777909285, - "Stock":1, - "Deposit":"85835276022875783849790922", - "Interest":1287529140343136757, - "Address":"302" - }, - { - "Reward":2723969842069034, - "Stock":1, - "Deposit":"69819976617956625027131816", - "Interest":1047299649269349375, - "Address":"303" - }, - { - "Reward":2862635508747139, - "Stock":2, - "Deposit":"73374213326328119329614681", - "Interest":1100613199894921789, - "Address":"304" - }, - { - "Reward":2537992546250410, - "Stock":2, - "Deposit":"65053062445491260940959866", - "Interest":975795936682368914, - "Address":"305" - }, - { - "Reward":2014187800737482, - "Stock":2, - "Deposit":"51627056577412899778962727", - "Interest":774405848661193496, - "Address":"306" - }, - { - "Reward":1273376875584076, - "Stock":2, - "Deposit":"32638813508888198103782529", - "Interest":489582202633322971, - "Address":"307" - }, - { - "Reward":2581866235916447, - "Stock":2, - "Deposit":"66177619677850130226421323", - "Interest":992664295167751953, - "Address":"308" - }, - { - "Reward":458672216878876, - "Stock":2, - "Deposit":"11756548462175631099067001", - "Interest":176348226932634466, - "Address":"309" - }, - { - "Reward":576697670018651, - "Stock":2, - "Deposit":"14781741418160632141421115", - "Interest":221726121272409482, - "Address":"310" - }, - { - "Reward":77110234840850, - "Stock":2, - "Deposit":"1976466372881702238315366", - "Interest":29646995593225533, - "Address":"311" - }, - { - "Reward":3762106089873738, - "Stock":2, - "Deposit":"96429173029955939098953717", - "Interest":1446437595449339086, - "Address":"312" - }, - { - "Reward":3785831288814074, - "Stock":2, - "Deposit":"97037290201331216642191638", - "Interest":1455559353019968249, - "Address":"313" - }, - { - "Reward":483231737440228, - "Stock":1, - "Deposit":"12386050714681973162883559", - "Interest":185790760720229597, - "Address":"314" - }, - { - "Reward":1823562364939059, - "Stock":2, - "Deposit":"46741002677445964157650141", - "Interest":701115040161689462, - "Address":"315" - }, - { - "Reward":2562038469673324, - "Stock":1, - "Deposit":"65669400330447358366991701", - "Interest":985041004956710375, - "Address":"316" - }, - { - "Reward":1132135486720216, - "Stock":2, - "Deposit":"29018556663286709798711888", - "Interest":435278349949300646, - "Address":"317" - }, - { - "Reward":2943763591571720, - "Stock":1, - "Deposit":"75453663971629481029601805", - "Interest":1131804959574442215, - "Address":"318" - }, - { - "Reward":2177452376609902, - "Stock":1, - "Deposit":"55811805135897152313509530", - "Interest":837177077038457284, - "Address":"319" - }, - { - "Reward":1668998165540396, - "Stock":2, - "Deposit":"42779259554845605610762002", - "Interest":641688893322684084, - "Address":"320" - }, - { - "Reward":1042435974989715, - "Stock":2, - "Deposit":"26719405727420009191602246", - "Interest":400791085911300137, - "Address":"321" - }, - { - "Reward":2940640249784800, - "Stock":2, - "Deposit":"75373607413306131793432358", - "Interest":1130604111199591976, - "Address":"322" - }, - { - "Reward":3504942474464792, - "Stock":1, - "Deposit":"89837632500563102686635576", - "Interest":1347564487508446540, - "Address":"323" - }, - { - "Reward":2841965403388289, - "Stock":2, - "Deposit":"72844403395778600803284650", - "Interest":1092666050936679012, - "Address":"324" - }, - { - "Reward":1587214822066698, - "Stock":2, - "Deposit":"40683013465448836236305777", - "Interest":610245201981732543, - "Address":"325" - }, - { - "Reward":3660763258590647, - "Stock":1, - "Deposit":"93831584025369718658420398", - "Interest":1407473760380545779, - "Address":"326" - }, - { - "Reward":996529528925791, - "Stock":2, - "Deposit":"25542745493780250057079418", - "Interest":383141182406703750, - "Address":"327" - }, - { - "Reward":2080093203504044, - "Stock":2, - "Deposit":"53316324060882258622837735", - "Interest":799744860913233879, - "Address":"328" - }, - { - "Reward":3724898803252959, - "Stock":1, - "Deposit":"95475487037637019059435087", - "Interest":1432132305564555285, - "Address":"329" - }, - { - "Reward":1044595329130384, - "Stock":2, - "Deposit":"26774753644009618994036871", - "Interest":401621304660144284, - "Address":"330" - }, - { - "Reward":975684893420772, - "Stock":1, - "Deposit":"25008462058958946807874567", - "Interest":375126930884384202, - "Address":"331" - }, - { - "Reward":3619239987817804, - "Stock":1, - "Deposit":"92767272023934754808070286", - "Interest":1391509080359021322, - "Address":"332" - }, - { - "Reward":267568478553860, - "Stock":1, - "Deposit":"6858234855545564113274077", - "Interest":102873522833183461, - "Address":"333" - }, - { - "Reward":1168086360381074, - "Stock":2, - "Deposit":"29940038656086487292789357", - "Interest":449100579841297309, - "Address":"334" - }, - { - "Reward":2308015247447274, - "Stock":2, - "Deposit":"59158353415636710798479496", - "Interest":887375301234550661, - "Address":"335" - }, - { - "Reward":793155150852120, - "Stock":2, - "Deposit":"20329914535633630825272631", - "Interest":304948718034504462, - "Address":"336" - }, - { - "Reward":2480846801659900, - "Stock":2, - "Deposit":"63588319888688737974960435", - "Interest":953824798330331069, - "Address":"337" - }, - { - "Reward":3114776902653952, - "Stock":2, - "Deposit":"79837025783025850075507942", - "Interest":1197555386745387751, - "Address":"338" - }, - { - "Reward":1957346024121919, - "Stock":2, - "Deposit":"50170105236421824739817437", - "Interest":752551578546327371, - "Address":"339" - }, - { - "Reward":2539090840546142, - "Stock":2, - "Deposit":"65081213594914189008840725", - "Interest":976218203923712835, - "Address":"340" - }, - { - "Reward":3105353913484076, - "Stock":1, - "Deposit":"79595498555612687060681845", - "Interest":1193932478334190305, - "Address":"341" - }, - { - "Reward":910488855697309, - "Stock":2, - "Deposit":"23337376807156728910741722", - "Interest":350060652107350933, - "Address":"342" - }, - { - "Reward":2344124457664487, - "Stock":1, - "Deposit":"60083893843479241342783254", - "Interest":901258407652188620, - "Address":"343" - }, - { - "Reward":438762861178961, - "Stock":1, - "Deposit":"11246237838328643211540736", - "Interest":168693567574929648, - "Address":"344" - }, - { - "Reward":2012217925205349, - "Stock":1, - "Deposit":"51576565319591438646009112", - "Interest":773648479793871579, - "Address":"345" - }, - { - "Reward":3268767600534891, - "Stock":1, - "Deposit":"83784069087023427266402875", - "Interest":1256761036305351408, - "Address":"346" - }, - { - "Reward":3592388033568732, - "Stock":2, - "Deposit":"92079010799870464341372730", - "Interest":1381185161998056965, - "Address":"347" - }, - { - "Reward":1943795916373663, - "Stock":2, - "Deposit":"49822792945535587799103681", - "Interest":747341894183033816, - "Address":"348" - }, - { - "Reward":1083077310393497, - "Stock":1, - "Deposit":"27761112226438833253115174", - "Interest":416416683396582498, - "Address":"349" - }, - { - "Reward":2545753780687018, - "Stock":1, - "Deposit":"65251996074829410339060046", - "Interest":978779941122441155, - "Address":"350" - }, - { - "Reward":3578766992993224, - "Stock":2, - "Deposit":"91729880380066752829931685", - "Interest":1375948205701001292, - "Address":"351" - }, - { - "Reward":1989097337099253, - "Stock":1, - "Deposit":"50983945351473547452179228", - "Interest":764759180272103211, - "Address":"352" - }, - { - "Reward":3800729176406338, - "Stock":1, - "Deposit":"97419148380259790186171883", - "Interest":1461287225703896852, - "Address":"353" - }, - { - "Reward":769667815400213, - "Stock":2, - "Deposit":"19727894209731389187662377", - "Interest":295918413145970837, - "Address":"354" - }, - { - "Reward":433779209622504, - "Stock":2, - "Deposit":"11118498378893360013509122", - "Interest":166777475683400400, - "Address":"355" - }, - { - "Reward":1160103693500176, - "Stock":1, - "Deposit":"29735429336862195806774287", - "Interest":446031440052932937, - "Address":"356" - }, - { - "Reward":1546594811419054, - "Stock":1, - "Deposit":"39641853556172668153276202", - "Interest":594627803342590022, - "Address":"357" - }, - { - "Reward":1641544222496452, - "Stock":1, - "Deposit":"42075568334849211553401706", - "Interest":631133525022738173, - "Address":"358" - }, - { - "Reward":1215195882161454, - "Stock":2, - "Deposit":"31147535765045253345121330", - "Interest":467213036475678800, - "Address":"359" - }, - { - "Reward":2706972938542710, - "Stock":2, - "Deposit":"69384317093222613877228109", - "Interest":1040764756398339208, - "Address":"360" - }, - { - "Reward":358430517008791, - "Stock":2, - "Deposit":"9187183327149950341302422", - "Interest":137807749907249255, - "Address":"361" - }, - { - "Reward":1568716182890286, - "Stock":1, - "Deposit":"40208861903704640198962653", - "Interest":603132928555569602, - "Address":"362" - }, - { - "Reward":1151624000871569, - "Stock":2, - "Deposit":"29518080402996216274509754", - "Interest":442771206044943244, - "Address":"363" - }, - { - "Reward":1195772360863886, - "Stock":1, - "Deposit":"30649677902637917362447498", - "Interest":459745168539568760, - "Address":"364" - }, - { - "Reward":411838202397282, - "Stock":2, - "Deposit":"10556113073527484403857329", - "Interest":158341696102912266, - "Address":"365" - }, - { - "Reward":2316770306401318, - "Stock":2, - "Deposit":"59382760456426819667790050", - "Interest":890741406846402295, - "Address":"366" - }, - { - "Reward":1103038507142290, - "Stock":1, - "Deposit":"28272751624475833678911484", - "Interest":424091274367137505, - "Address":"367" - }, - { - "Reward":605584583033973, - "Stock":1, - "Deposit":"15522162093950031548802292", - "Interest":232832431409250473, - "Address":"368" - }, - { - "Reward":171315882877, - "Stock":1, - "Deposit":"65866758611232700821788", - "Interest":65866758611232, - "Address":"369" - }, - { - "Reward":1106424551955269, - "Stock":2, - "Deposit":"28359541707838142879429954", - "Interest":425393125617572143, - "Address":"370" - }, - { - "Reward":2148944019758106, - "Stock":1, - "Deposit":"55081087497959979609692796", - "Interest":826216312469399694, - "Address":"371" - }, - { - "Reward":3397754367677263, - "Stock":1, - "Deposit":"87090219150368386466884348", - "Interest":1306353287255525797, - "Address":"372" - }, - { - "Reward":164848316921700, - "Stock":1, - "Deposit":"4225342533249276666818257", - "Interest":63380137998739150, - "Address":"373" - }, - { - "Reward":3529699539225281, - "Stock":2, - "Deposit":"90472198146632687452297369", - "Interest":1357082972199490311, - "Address":"374" - }, - { - "Reward":510984790647298, - "Stock":2, - "Deposit":"13097408636516638670486868", - "Interest":196461129547749580, - "Address":"375" - }, - { - "Reward":3252725969207915, - "Stock":2, - "Deposit":"83372894812306563858131810", - "Interest":1250593422184598457, - "Address":"376" - }, - { - "Reward":3122962536475953, - "Stock":1, - "Deposit":"80046837489906241821739440", - "Interest":1200702562348593627, - "Address":"377" - }, - { - "Reward":3581034841820344, - "Stock":1, - "Deposit":"91788009199863929153129426", - "Interest":1376820137997958937, - "Address":"378" - }, - { - "Reward":535679103501914, - "Stock":2, - "Deposit":"13730365844587710812114280", - "Interest":205955487668815662, - "Address":"379" - }, - { - "Reward":1969172259777732, - "Stock":1, - "Deposit":"50473231755744862874804227", - "Interest":757098476336172943, - "Address":"380" - }, - { - "Reward":1579912713471077, - "Stock":2, - "Deposit":"40495848011729729258472487", - "Interest":607437720175945938, - "Address":"381" - }, - { - "Reward":677177730995839, - "Stock":1, - "Deposit":"17357216153471721755210409", - "Interest":260358242302075826, - "Address":"382" - }, - { - "Reward":2244032281173527, - "Stock":1, - "Deposit":"57518361246785343349392714", - "Interest":862775418701780150, - "Address":"383" - }, - { - "Reward":2365110167660822, - "Stock":1, - "Deposit":"60621793257278322470344402", - "Interest":909326898859174837, - "Address":"384" - }, - { - "Reward":836642688738822, - "Stock":2, - "Deposit":"21444574041597819216076013", - "Interest":321668610623967288, - "Address":"385" - }, - { - "Reward":2028473584920160, - "Stock":2, - "Deposit":"51993225505643814182342688", - "Interest":779898382584657212, - "Address":"386" - }, - { - "Reward":3859228324300730, - "Stock":2, - "Deposit":"98918580963938651527846827", - "Interest":1483778714459079772, - "Address":"387" - }, - { - "Reward":1911364328992374, - "Stock":1, - "Deposit":"48991516241339450048918148", - "Interest":734872743620091750, - "Address":"388" - }, - { - "Reward":2710991557176313, - "Stock":1, - "Deposit":"69487321118708256235955487", - "Interest":1042309816780623843, - "Address":"389" - }, - { - "Reward":1605128939394368, - "Stock":1, - "Deposit":"41142182738776489352108783", - "Interest":617132741081647340, - "Address":"390" - }, - { - "Reward":135678635006616, - "Stock":1, - "Deposit":"3477674009974662805780812", - "Interest":52165110149619942, - "Address":"391" - }, - { - "Reward":1142458599820402, - "Stock":2, - "Deposit":"29283155596853482907787888", - "Interest":439247333952802243, - "Address":"392" - }, - { - "Reward":3126760032915770, - "Stock":2, - "Deposit":"80144173777753469075882196", - "Interest":1202162606666302036, - "Address":"393" - }, - { - "Reward":1351849453739240, - "Stock":2, - "Deposit":"34650199056307740001068571", - "Interest":519752985844616100, - "Address":"394" - }, - { - "Reward":325050411153170, - "Stock":2, - "Deposit":"8331594482387216783203261", - "Interest":124973917235808251, - "Address":"395" - }, - { - "Reward":1994040112840193, - "Stock":1, - "Deposit":"51110637094285982234386827", - "Interest":766659556414289733, - "Address":"396" - }, - { - "Reward":1431170831695823, - "Stock":2, - "Deposit":"36683340785228668593843886", - "Interest":550250111778430028, - "Address":"397" - }, - { - "Reward":2885019399481728, - "Stock":1, - "Deposit":"73947950488748681604106137", - "Interest":1109219257331230224, - "Address":"398" - }, - { - "Reward":2047231252055076, - "Stock":2, - "Deposit":"52474016394199485274454628", - "Interest":787110245912992279, - "Address":"399" - }, - { - "Reward":3138773047009132, - "Stock":2, - "Deposit":"80452087745873113186201351", - "Interest":1206781316188096697, - "Address":"400" - }, - { - "Reward":3187112805202061, - "Stock":2, - "Deposit":"81691117904953136638459044", - "Interest":1225366768574297049, - "Address":"401" - }, - { - "Reward":739207640912521, - "Stock":1, - "Deposit":"18947148168543892501009085", - "Interest":284207222528158387, - "Address":"402" - }, - { - "Reward":482580004292263, - "Stock":1, - "Deposit":"12369345686436317156690224", - "Interest":185540185296544757, - "Address":"403" - }, - { - "Reward":3203051272064228, - "Stock":2, - "Deposit":"82099647899102157219562220", - "Interest":1231494718486532358, - "Address":"404" - }, - { - "Reward":2488705902533740, - "Stock":2, - "Deposit":"63789762001143590637020701", - "Interest":956846430017153859, - "Address":"405" - }, - { - "Reward":62890101535767, - "Stock":2, - "Deposit":"1611980188221517895802509", - "Interest":24179702823322768, - "Address":"406" - }, - { - "Reward":3495494418319745, - "Stock":2, - "Deposit":"89595462763973332540671088", - "Interest":1343931941459599988, - "Address":"407" - }, - { - "Reward":2010694046248614, - "Stock":2, - "Deposit":"51537505711997888551854040", - "Interest":773062585679968328, - "Address":"408" - }, - { - "Reward":2124408242810379, - "Stock":2, - "Deposit":"54452193834624673668299019", - "Interest":816782907519370105, - "Address":"409" - }, - { - "Reward":2365985161046137, - "Stock":2, - "Deposit":"60644220824852690394043952", - "Interest":909663312372790355, - "Address":"410" - }, - { - "Reward":2966780317828054, - "Stock":1, - "Deposit":"76043621784017934047520750", - "Interest":1140654326760269010, - "Address":"411" - }, - { - "Reward":3337066547944873, - "Stock":2, - "Deposit":"85534687187690039431250878", - "Interest":1283020307815350591, - "Address":"412" - }, - { - "Reward":1493730243483443, - "Stock":1, - "Deposit":"38286844833176225670274280", - "Interest":574302672497643385, - "Address":"413" - }, - { - "Reward":330251953836422, - "Stock":1, - "Deposit":"8464918861722536825588941", - "Interest":126973782925838052, - "Address":"414" - }, - { - "Reward":2863147240392769, - "Stock":2, - "Deposit":"73387329878127183232066363", - "Interest":1100809948171907748, - "Address":"415" - }, - { - "Reward":1295229494140212, - "Stock":1, - "Deposit":"33198933262443053319165771", - "Interest":497983998936645799, - "Address":"416" - }, - { - "Reward":3276214800824974, - "Stock":2, - "Deposit":"83974953487464487630950258", - "Interest":1259624302311967314, - "Address":"417" - }, - { - "Reward":1450248381164345, - "Stock":1, - "Deposit":"37172330801655728564175895", - "Interest":557584962024835928, - "Address":"418" - }, - { - "Reward":3231214800682776, - "Stock":2, - "Deposit":"82821527003362938054668328", - "Interest":1242322905050444070, - "Address":"419" - }, - { - "Reward":688673135033679, - "Stock":1, - "Deposit":"17651862896156023110081939", - "Interest":264777943442340346, - "Address":"420" - }, - { - "Reward":505311248294900, - "Stock":1, - "Deposit":"12951986103466672785217788", - "Interest":194279791552000091, - "Address":"421" - }, - { - "Reward":3432794536945678, - "Stock":2, - "Deposit":"87988358241787867361958499", - "Interest":1319825373626818010, - "Address":"422" - }, - { - "Reward":171971149843971, - "Stock":1, - "Deposit":"4407912846769657111863556", - "Interest":66118692701544856, - "Address":"423" - }, - { - "Reward":2679182536142107, - "Stock":1, - "Deposit":"68672001848080277415431378", - "Interest":1030080027721204161, - "Address":"424" - }, - { - "Reward":2862755561926726, - "Stock":1, - "Deposit":"73377290493359204067273364", - "Interest":1100659357400388061, - "Address":"425" - }, - { - "Reward":1705592858265152, - "Stock":1, - "Deposit":"43717243724465848502196639", - "Interest":655758655866987727, - "Address":"426" - }, - { - "Reward":1481910771987345, - "Stock":1, - "Deposit":"37983891690762816576907571", - "Interest":569758375361442248, - "Address":"427" - }, - { - "Reward":3822054161236020, - "Stock":2, - "Deposit":"97965743984657438502079569", - "Interest":1469486159769861577, - "Address":"428" - }, - { - "Reward":1556640524709748, - "Stock":2, - "Deposit":"39899342261162940030495137", - "Interest":598490133917444100, - "Address":"429" - }, - { - "Reward":1717353596241116, - "Stock":2, - "Deposit":"44018691426936762405254607", - "Interest":660280371404051436, - "Address":"430" - }, - { - "Reward":611773273724689, - "Stock":2, - "Deposit":"15680788754439556333299004", - "Interest":235211831316593344, - "Address":"431" - }, - { - "Reward":1271996354477562, - "Stock":1, - "Deposit":"32603428406641921103374987", - "Interest":489051426099628816, - "Address":"432" - }, - { - "Reward":1225287179526975, - "Stock":2, - "Deposit":"31406192867346482969577507", - "Interest":471092893010197244, - "Address":"433" - }, - { - "Reward":3489821896559138, - "Stock":2, - "Deposit":"89450066390425542204367408", - "Interest":1341750995856383133, - "Address":"434" - }, - { - "Reward":963744829447627, - "Stock":2, - "Deposit":"24702417926403974493235769", - "Interest":370536268896059617, - "Address":"435" - }, - { - "Reward":1212089019365400, - "Stock":1, - "Deposit":"31067901591264923680575216", - "Interest":466018523868973855, - "Address":"436" - }, - { - "Reward":1595168931322919, - "Stock":2, - "Deposit":"40886890804217101984185378", - "Interest":613303362063256529, - "Address":"437" - }, - { - "Reward":2762247162928450, - "Stock":1, - "Deposit":"70801089406405304245563677", - "Interest":1062016341096079563, - "Address":"438" - }, - { - "Reward":560390444228184, - "Stock":1, - "Deposit":"14363759505949247331827026", - "Interest":215456392589238709, - "Address":"439" - }, - { - "Reward":3399392476255517, - "Stock":1, - "Deposit":"87132206657302180294700994", - "Interest":1306983099859532704, - "Address":"440" - }, - { - "Reward":324425996568402, - "Stock":2, - "Deposit":"8315589675345991250430639", - "Interest":124733845130189868, - "Address":"441" - }, - { - "Reward":1801432781249971, - "Stock":2, - "Deposit":"46173783836813131480520131", - "Interest":692606757552196972, - "Address":"442" - }, - { - "Reward":118560314673049, - "Stock":1, - "Deposit":"3038902366115137088390914", - "Interest":45583535491727056, - "Address":"443" - }, - { - "Reward":2938550878290591, - "Stock":1, - "Deposit":"75320053270885423132050769", - "Interest":1129800799063281346, - "Address":"444" - }, - { - "Reward":2731159780236532, - "Stock":1, - "Deposit":"70004266952961946575473083", - "Interest":1050064004294429198, - "Address":"445" - }, - { - "Reward":836902155528538, - "Stock":2, - "Deposit":"21451224616399100499831084", - "Interest":321768369245986507, - "Address":"446" - }, - { - "Reward":2652593066567866, - "Stock":1, - "Deposit":"67990468552341865045150585", - "Interest":1019857028285127975, - "Address":"447" - }, - { - "Reward":2174232259789607, - "Stock":2, - "Deposit":"55729268068992876555850717", - "Interest":835939021034893148, - "Address":"448" - }, - { - "Reward":3318854843821113, - "Stock":2, - "Deposit":"85067890259010292561442837", - "Interest":1276018353885154388, - "Address":"449" - }, - { - "Reward":2179198029264605, - "Stock":1, - "Deposit":"55856549180288561645720422", - "Interest":837848237704328424, - "Address":"450" - }, - { - "Reward":3518196917593789, - "Stock":1, - "Deposit":"90177366404756298399320296", - "Interest":1352660496071344475, - "Address":"451" - }, - { - "Reward":1636714346381005, - "Stock":2, - "Deposit":"41951770401318511098693121", - "Interest":629276556019777666, - "Address":"452" - }, - { - "Reward":1397208764370028, - "Stock":2, - "Deposit":"35812835278903631945038716", - "Interest":537192529183554479, - "Address":"453" - }, - { - "Reward":1907745197020535, - "Stock":1, - "Deposit":"48898751737948631395536672", - "Interest":733481276069229470, - "Address":"454" - }, - { - "Reward":998615563302941, - "Stock":1, - "Deposit":"25596214100219083500746211", - "Interest":383943211503286252, - "Address":"455" - }, - { - "Reward":3625078651575595, - "Stock":1, - "Deposit":"92916926899239649105101982", - "Interest":1393753903488594736, - "Address":"456" - }, - { - "Reward":1821013909022784, - "Stock":2, - "Deposit":"46675681421043568879670132", - "Interest":700135221315653533, - "Address":"457" - }, - { - "Reward":990991057404547, - "Stock":1, - "Deposit":"25400785055694485861417081", - "Interest":381011775835417287, - "Address":"458" - }, - { - "Reward":1682363848611220, - "Stock":2, - "Deposit":"43121844727807390200569745", - "Interest":646827670917110853, - "Address":"459" - }, - { - "Reward":2740863942523341, - "Stock":1, - "Deposit":"70253001125234282316170067", - "Interest":1053795016878514234, - "Address":"460" - }, - { - "Reward":1569657396128747, - "Stock":1, - "Deposit":"40232986798660141940087879", - "Interest":603494801979902129, - "Address":"461" - }, - { - "Reward":709434340081696, - "Stock":1, - "Deposit":"18184007866568818736082062", - "Interest":272760117998532281, - "Address":"462" - }, - { - "Reward":3340594383730649, - "Stock":2, - "Deposit":"85625111614668203427697755", - "Interest":1284376674220023051, - "Address":"463" - }, - { - "Reward":2279213764342947, - "Stock":2, - "Deposit":"58420122453659850686743903", - "Interest":876301836804897760, - "Address":"464" - }, - { - "Reward":1457487365292510, - "Stock":1, - "Deposit":"37357878267989763635805630", - "Interest":560368174019846454, - "Address":"465" - }, - { - "Reward":864923319657726, - "Stock":2, - "Deposit":"22169454676839783771041894", - "Interest":332541820152596756, - "Address":"466" - }, - { - "Reward":854387814395417, - "Stock":2, - "Deposit":"21899411771183374677519373", - "Interest":328491176567750620, - "Address":"467" - }, - { - "Reward":2037447581994234, - "Stock":2, - "Deposit":"52223244302549998168916001", - "Interest":783348664538249972, - "Address":"468" - }, - { - "Reward":1690963614709590, - "Stock":2, - "Deposit":"43342271348776151289495189", - "Interest":650134070231642269, - "Address":"469" - }, - { - "Reward":2892137473749059, - "Stock":1, - "Deposit":"74130398829855304051096462", - "Interest":1111955982447829560, - "Address":"470" - }, - { - "Reward":274853534966796, - "Stock":1, - "Deposit":"7044963232841139345190561", - "Interest":105674448492617090, - "Address":"471" - }, - { - "Reward":3305802778411462, - "Stock":1, - "Deposit":"84733343639718172743552712", - "Interest":1271000154595772591, - "Address":"472" - }, - { - "Reward":2652497673106154, - "Stock":2, - "Deposit":"67988023455790724820644725", - "Interest":1019820351836860872, - "Address":"473" - }, - { - "Reward":533134845577754, - "Stock":1, - "Deposit":"13665152189857976418296551", - "Interest":204977282847869646, - "Address":"474" - }, - { - "Reward":3348986618613437, - "Stock":2, - "Deposit":"85840218857868666466309689", - "Interest":1287603282868029996, - "Address":"475" - }, - { - "Reward":779636653257456, - "Stock":1, - "Deposit":"19983412466707495271698686", - "Interest":299751187000612429, - "Address":"476" - }, - { - "Reward":2369487517623717, - "Stock":2, - "Deposit":"60733992176421203185682850", - "Interest":911009882646318047, - "Address":"477" - }, - { - "Reward":2118646023695441, - "Stock":2, - "Deposit":"54304498365438813595059659", - "Interest":814567475481582203, - "Address":"478" - }, - { - "Reward":633296639641044, - "Stock":1, - "Deposit":"16232469203250321500521015", - "Interest":243487038048754822, - "Address":"479" - }, - { - "Reward":7351662489065, - "Stock":2, - "Deposit":"565306812684551740545294", - "Interest":2826534063422758, - "Address":"480" - }, - { - "Reward":3009886820761683, - "Stock":1, - "Deposit":"77148514716540916865631087", - "Interest":1157227720748113752, - "Address":"481" - }, - { - "Reward":2983756712249369, - "Stock":2, - "Deposit":"76478755625533989544886893", - "Interest":1147181334383009843, - "Address":"482" - }, - { - "Reward":1642767976748821, - "Stock":1, - "Deposit":"42106935236188192121830380", - "Interest":631604028542822881, - "Address":"483" - }, - { - "Reward":221652024392663, - "Stock":1, - "Deposit":"5681318097363241559917571", - "Interest":85219771460448623, - "Address":"484" - }, - { - "Reward":2285244463531140, - "Stock":1, - "Deposit":"58574699523422779640381696", - "Interest":878620492851341694, - "Address":"485" - }, - { - "Reward":679452581704897, - "Stock":1, - "Deposit":"17415524443403129774629319", - "Interest":261232866651046946, - "Address":"486" - }, - { - "Reward":2842615483606719, - "Stock":1, - "Deposit":"72861066056631007555385201", - "Interest":1092915990849465113, - "Address":"487" - }, - { - "Reward":2084493260274823, - "Stock":2, - "Deposit":"53429104994102916142759904", - "Interest":801436574911543742, - "Address":"488" - }, - { - "Reward":987309823535862, - "Stock":2, - "Deposit":"25306428775141265321876742", - "Interest":379596431627118979, - "Address":"489" - }, - { - "Reward":3577822633004678, - "Stock":1, - "Deposit":"91705674828558481080090525", - "Interest":1375585122428377216, - "Address":"490" - }, - { - "Reward":2958034553158736, - "Stock":1, - "Deposit":"75819452971541612126075303", - "Interest":1137291794573124181, - "Address":"491" - }, - { - "Reward":3460678563097799, - "Stock":2, - "Deposit":"88703073222801309691812399", - "Interest":1330546098342019645, - "Address":"492" - }, - { - "Reward":268410492746902, - "Stock":2, - "Deposit":"6879817110371666544898081", - "Interest":103197256655574998, - "Address":"493" - }, - { - "Reward":716020391302468, - "Stock":1, - "Deposit":"18352819552783994351998326", - "Interest":275292293291759915, - "Address":"494" - }, - { - "Reward":2875629267958345, - "Stock":2, - "Deposit":"73707265458658877140411046", - "Interest":1105608981879883157, - "Address":"495" - }, - { - "Reward":2718176572192262, - "Stock":2, - "Deposit":"69671485264972166102947905", - "Interest":1045072278974582491, - "Address":"496" - }, - { - "Reward":3031374894646525, - "Stock":2, - "Deposit":"77699290570602874702590755", - "Interest":1165489358559043120, - "Address":"497" - }, - { - "Reward":1958135541762007, - "Stock":2, - "Deposit":"50190341915374370179177804", - "Interest":752855128730615552, - "Address":"498" - }, - { - "Reward":1660041414389564, - "Stock":1, - "Deposit":"42549682800262667030454375", - "Interest":638245242003940005, - "Address":"499" - }, - { - "Reward":2384692162950099, - "Stock":1, - "Deposit":"61123713077430130719559110", - "Interest":916855696161451960, - "Address":"500" - }, - { - "Reward":3338724727043556, - "Stock":2, - "Deposit":"85577189136173625891525214", - "Interest":1283657837042604388, - "Address":"501" - }, - { - "Reward":2617060594287405, - "Stock":1, - "Deposit":"67079710898022315575014032", - "Interest":1006195663470334733, - "Address":"502" - }, - { - "Reward":2042751957859655, - "Stock":1, - "Deposit":"52359204471116060913517993", - "Interest":785388067066740913, - "Address":"503" - }, - { - "Reward":1165804122122378, - "Stock":1, - "Deposit":"29881541010702217245552755", - "Interest":448223115160533258, - "Address":"504" - }, - { - "Reward":2746478347433023, - "Stock":2, - "Deposit":"70396907865119462417807964", - "Interest":1055953617976791936, - "Address":"505" - }, - { - "Reward":1488823926835746, - "Stock":2, - "Deposit":"38161087598888232545395682", - "Interest":572416313983323488, - "Address":"506" - }, - { - "Reward":2214777043349190, - "Stock":2, - "Deposit":"56768499780148662387078924", - "Interest":851527496702229935, - "Address":"507" - }, - { - "Reward":3463917611218999, - "Stock":2, - "Deposit":"88786095531122766208997933", - "Interest":1331791432966841493, - "Address":"508" - }, - { - "Reward":3288698382385539, - "Stock":2, - "Deposit":"84294928899528864815844223", - "Interest":1264423933492932972, - "Address":"509" - }, - { - "Reward":3506589773839054, - "Stock":1, - "Deposit":"89879855583218981616254141", - "Interest":1348197833748284724, - "Address":"510" - }, - { - "Reward":3663444513460602, - "Stock":2, - "Deposit":"93900309144655502722687534", - "Interest":1408504637169832540, - "Address":"511" - }, - { - "Reward":3181354220575239, - "Stock":2, - "Deposit":"81543515593874749133694044", - "Interest":1223152733908121237, - "Address":"512" - }, - { - "Reward":1765819680366, - "Stock":1, - "Deposit":"135782878603107892714584", - "Interest":678914393015539, - "Address":"513" - }, - { - "Reward":4019368737192, - "Stock":1, - "Deposit":"309069755746516072778333", - "Interest":1545348778732580, - "Address":"514" - }, - { - "Reward":341252502958411, - "Stock":1, - "Deposit":"8746881631875147445661809", - "Interest":131203224478127211, - "Address":"515" - }, - { - "Reward":1017206644982536, - "Stock":1, - "Deposit":"26072735120431966840233534", - "Interest":391091026806479502, - "Address":"516" - }, - { - "Reward":88947167090851, - "Stock":1, - "Deposit":"2279867064093343831615767", - "Interest":34198005961400157, - "Address":"517" - }, - { - "Reward":1654532574864008, - "Stock":1, - "Deposit":"42408481880587944883105789", - "Interest":636127228208819173, - "Address":"518" - }, - { - "Reward":1330637354089308, - "Stock":1, - "Deposit":"34106496890922877177697924", - "Interest":511597453363843157, - "Address":"519" - }, - { - "Reward":2112048527722344, - "Stock":1, - "Deposit":"54135393330770442693457842", - "Interest":812030899961556640, - "Address":"520" - }, - { - "Reward":3613373667278191, - "Stock":1, - "Deposit":"92616908258307284472027081", - "Interest":1389253623874609267, - "Address":"521" - }, - { - "Reward":1164571417880614, - "Stock":2, - "Deposit":"29849944705923958657363408", - "Interest":447749170588859379, - "Address":"522" - }, - { - "Reward":1319010442458625, - "Stock":2, - "Deposit":"33808479385128187292333657", - "Interest":507127190776922809, - "Address":"523" - }, - { - "Reward":3353192030842696, - "Stock":2, - "Deposit":"85948010720678957871914857", - "Interest":1289220160810184368, - "Address":"524" - }, - { - "Reward":1328348554853454, - "Stock":2, - "Deposit":"34047831076543255693982492", - "Interest":510717466148148835, - "Address":"525" - }, - { - "Reward":538865566428868, - "Stock":2, - "Deposit":"13812040305008643771559309", - "Interest":207180604575129656, - "Address":"526" - }, - { - "Reward":1981136498775201, - "Stock":2, - "Deposit":"50779895535260277666466977", - "Interest":761698433028904164, - "Address":"527" - }, - { - "Reward":3342175865848012, - "Stock":2, - "Deposit":"85665647689168988873863704", - "Interest":1284984715337534833, - "Address":"528" - }, - { - "Reward":1499368455444951, - "Stock":1, - "Deposit":"38431361788261364513206732", - "Interest":576470426823920467, - "Address":"529" - }, - { - "Reward":2714181808527342, - "Stock":2, - "Deposit":"69569092682876931828262652", - "Interest":1043536390243153977, - "Address":"530" - }, - { - "Reward":2449717297056099, - "Stock":1, - "Deposit":"62790417779054874542644249", - "Interest":941856266685823118, - "Address":"531" - }, - { - "Reward":1757152908246968, - "Stock":2, - "Deposit":"45038815435192547380675176", - "Interest":675582231527888210, - "Address":"532" - }, - { - "Reward":1847782043811741, - "Stock":1, - "Deposit":"47361794209888441469516106", - "Interest":710426913148326622, - "Address":"533" - }, - { - "Reward":3705202423541984, - "Stock":1, - "Deposit":"94970635350353249669093747", - "Interest":1424559530255298745, - "Address":"534" - }, - { - "Reward":325758975035144, - "Stock":1, - "Deposit":"8349756178933087636674826", - "Interest":125246342683996314, - "Address":"535" - }, - { - "Reward":1091729868645200, - "Stock":1, - "Deposit":"27982892000021253323136776", - "Interest":419743380000318799, - "Address":"536" - }, - { - "Reward":1743962815219565, - "Stock":2, - "Deposit":"44700730933470433918789038", - "Interest":670510964002056508, - "Address":"537" - }, - { - "Reward":2292361700358957, - "Stock":2, - "Deposit":"58757126399531345312441018", - "Interest":881356895992970179, - "Address":"538" - }, - { - "Reward":3424018513344159, - "Stock":1, - "Deposit":"87763413841452175843003134", - "Interest":1316451207621782637, - "Address":"539" - }, - { - "Reward":1830157688242634, - "Stock":2, - "Deposit":"46910052022901915784982047", - "Interest":703650780343528736, - "Address":"540" - }, - { - "Reward":1706552757379260, - "Stock":2, - "Deposit":"43741847570172065489054095", - "Interest":656127713552580982, - "Address":"541" - }, - { - "Reward":2911180111416453, - "Stock":2, - "Deposit":"74618493997484525167246463", - "Interest":1119277409962267877, - "Address":"542" - }, - { - "Reward":1825514787297957, - "Stock":1, - "Deposit":"46791046580774608991915926", - "Interest":701865698711619134, - "Address":"543" - }, - { - "Reward":3358448193617356, - "Stock":2, - "Deposit":"86082735105787489002512059", - "Interest":1291241026586812335, - "Address":"544" - }, - { - "Reward":1820058834513110, - "Stock":2, - "Deposit":"46651201238148731769370937", - "Interest":699768018572230976, - "Address":"545" - }, - { - "Reward":1943314316110169, - "Stock":2, - "Deposit":"49810448712270927190107248", - "Interest":747156730684063907, - "Address":"546" - }, - { - "Reward":1901671222253275, - "Stock":1, - "Deposit":"48743065441544541909631418", - "Interest":731145981623168128, - "Address":"547" - }, - { - "Reward":895253840502394, - "Stock":2, - "Deposit":"22946877474801685716859804", - "Interest":344203162122025285, - "Address":"548" - }, - { - "Reward":333775106054701, - "Stock":1, - "Deposit":"8555223240905718285775783", - "Interest":128328348613585774, - "Address":"549" - }, - { - "Reward":262890540817132, - "Stock":2, - "Deposit":"6738331360890659205827186", - "Interest":101074970413359888, - "Address":"550" - }, - { - "Reward":3465985283290418, - "Stock":2, - "Deposit":"88839093480457798088772759", - "Interest":1332586402206866971, - "Address":"551" - }, - { - "Reward":909684841896433, - "Stock":2, - "Deposit":"23316768566965984102011067", - "Interest":349751528504489761, - "Address":"552" - }, - { - "Reward":3361446078812298, - "Stock":1, - "Deposit":"86159575998436721553101665", - "Interest":1292393639976550823, - "Address":"553" - }, - { - "Reward":2776776823493170, - "Stock":2, - "Deposit":"71173509300791892869148026", - "Interest":1067602639511878393, - "Address":"554" - }, - { - "Reward":3405209205130674, - "Stock":2, - "Deposit":"87281299304285375759542966", - "Interest":1309219489564280636, - "Address":"555" - }, - { - "Reward":3659538863254464, - "Stock":1, - "Deposit":"93800200691963042674494111", - "Interest":1407003010379445640, - "Address":"556" - }, - { - "Reward":544986407122214, - "Stock":1, - "Deposit":"13968927854750046170525624", - "Interest":209533917821250692, - "Address":"557" - }, - { - "Reward":1536769514020154, - "Stock":2, - "Deposit":"39390014485100344203188686", - "Interest":590850217276505163, - "Address":"558" - }, - { - "Reward":3825586466482337, - "Stock":1, - "Deposit":"98056282971505392974469776", - "Interest":1470844244572580894, - "Address":"559" - }, - { - "Reward":2515611671916147, - "Stock":1, - "Deposit":"64479402598537605146636481", - "Interest":967191038978064077, - "Address":"560" - }, - { - "Reward":3497270156261092, - "Stock":2, - "Deposit":"89640977945393385271163305", - "Interest":1344614669180900779, - "Address":"561" - }, - { - "Reward":1881382872019939, - "Stock":2, - "Deposit":"48223040543679851493252468", - "Interest":723345608155197772, - "Address":"562" - }, - { - "Reward":54982991482465, - "Stock":2, - "Deposit":"1409307518902325195993914", - "Interest":21139612783534877, - "Address":"563" - }, - { - "Reward":2430117218087965, - "Stock":1, - "Deposit":"62288034443479545216432647", - "Interest":934320516652193178, - "Address":"564" - }, - { - "Reward":901599843267244, - "Stock":1, - "Deposit":"23109536311113476616618447", - "Interest":346643044666702149, - "Address":"565" - }, - { - "Reward":2057740890043512, - "Stock":1, - "Deposit":"52743396277663401333353743", - "Interest":791150944164951020, - "Address":"566" - }, - { - "Reward":2828497421713107, - "Stock":2, - "Deposit":"72499196135723886776385629", - "Interest":1087487942035858301, - "Address":"567" - }, - { - "Reward":2369783515868113, - "Stock":2, - "Deposit":"60741579114493537978021477", - "Interest":911123686717403069, - "Address":"568" - }, - { - "Reward":2295464037751367, - "Stock":2, - "Deposit":"58836644579525065884889415", - "Interest":882549668692875988, - "Address":"569" - }, - { - "Reward":1691010925443961, - "Stock":1, - "Deposit":"43343484003305798872741143", - "Interest":650152260049586983, - "Address":"570" - }, - { - "Reward":952620768986066, - "Stock":1, - "Deposit":"24417289350702509056697929", - "Interest":366259340260537635, - "Address":"571" - }, - { - "Reward":1673554079698792, - "Stock":2, - "Deposit":"42896035377800745273924373", - "Interest":643440530667011179, - "Address":"572" - }, - { - "Reward":39706518468225, - "Stock":1, - "Deposit":"1017745552177706791598486", - "Interest":15266183282665601, - "Address":"573" - }, - { - "Reward":2375267576321542, - "Stock":2, - "Deposit":"60882144904436008576141705", - "Interest":913232173566540128, - "Address":"574" - }, - { - "Reward":3737462612425006, - "Stock":2, - "Deposit":"95797518819735794091819739", - "Interest":1436962782296036911, - "Address":"575" - }, - { - "Reward":372376881622411, - "Stock":2, - "Deposit":"9544652354960059260479067", - "Interest":143169785324400888, - "Address":"576" - }, - { - "Reward":138853700625324, - "Stock":1, - "Deposit":"3559056338014765508504273", - "Interest":53385845070221482, - "Address":"577" - }, - { - "Reward":3457574512583231, - "Stock":2, - "Deposit":"88623511132575139024298183", - "Interest":1329352666988627085, - "Address":"578" - }, - { - "Reward":963421736527741, - "Stock":1, - "Deposit":"24694136505749653134580726", - "Interest":370412047586244797, - "Address":"579" - }, - { - "Reward":11593789987125, - "Stock":2, - "Deposit":"891505625333699480794789", - "Interest":4457528126668497, - "Address":"580" - }, - { - "Reward":3179345440434115, - "Stock":1, - "Deposit":"81492027144803902424611968", - "Interest":1222380407172058536, - "Address":"581" - }, - { - "Reward":548147172951220, - "Stock":1, - "Deposit":"14049943654876662081659046", - "Interest":210749154823149931, - "Address":"582" - }, - { - "Reward":3432727658298665, - "Stock":2, - "Deposit":"87986644028400262671405593", - "Interest":1319799660426003940, - "Address":"583" - }, - { - "Reward":372104806573712, - "Stock":1, - "Deposit":"9537678609052469004112933", - "Interest":143065179135787035, - "Address":"584" - }, - { - "Reward":1375484681945752, - "Stock":1, - "Deposit":"35256010124863956804089633", - "Interest":528840151872959352, - "Address":"585" - }, - { - "Reward":2315182285381746, - "Stock":1, - "Deposit":"59342056778749130436057319", - "Interest":890130851681236956, - "Address":"586" - }, - { - "Reward":2283038769936043, - "Stock":2, - "Deposit":"58518163847859250298617708", - "Interest":877772457717888754, - "Address":"587" - }, - { - "Reward":2604906328871903, - "Stock":1, - "Deposit":"66768176418450320148699313", - "Interest":1001522646276754802, - "Address":"588" - }, - { - "Reward":2528225307083182, - "Stock":1, - "Deposit":"64802711505570465006877657", - "Interest":972040672583556975, - "Address":"589" - }, - { - "Reward":1690754318603290, - "Stock":2, - "Deposit":"43336906733859192901614467", - "Interest":650053601007887893, - "Address":"590" - }, - { - "Reward":545257479867815, - "Stock":1, - "Deposit":"13975875909925750130444428", - "Interest":209638138648886251, - "Address":"591" - }, - { - "Reward":2933592078229315, - "Stock":1, - "Deposit":"75192950797508373302643079", - "Interest":1127894261962625599, - "Address":"592" - }, - { - "Reward":943311593393984, - "Stock":2, - "Deposit":"24178679358721855143983121", - "Interest":362680190380827827, - "Address":"593" - }, - { - "Reward":2537714367362321, - "Stock":2, - "Deposit":"65045932247806237398283900", - "Interest":975688983717093560, - "Address":"594" - }, - { - "Reward":3344975461485193, - "Stock":1, - "Deposit":"85737406083446665591946882", - "Interest":1286061091251699983, - "Address":"595" - }, - { - "Reward":329164559801696, - "Stock":2, - "Deposit":"8437047104514894258774655", - "Interest":126555706567723413, - "Address":"596" - }, - { - "Reward":3792527137035648, - "Stock":2, - "Deposit":"97208916171284165406993890", - "Interest":1458133742569262481, - "Address":"597" - }, - { - "Reward":122738390712132, - "Stock":1, - "Deposit":"3145993555911585915255817", - "Interest":47189903338673788, - "Address":"598" - }, - { - "Reward":3259263195963002, - "Stock":2, - "Deposit":"83540455044485861799150557", - "Interest":1253106825667287926, - "Address":"599" - }, - { - "Reward":3260467945282142, - "Stock":2, - "Deposit":"83571334817086051502422467", - "Interest":1253570022256290772, - "Address":"600" - }, - { - "Reward":194515003649232, - "Stock":2, - "Deposit":"4985750134559296942669745", - "Interest":74786252018389454, - "Address":"601" - }, - { - "Reward":2129730833850766, - "Stock":2, - "Deposit":"54588620889082983827958512", - "Interest":818829313336244757, - "Address":"602" - }, - { - "Reward":3679700744141843, - "Stock":2, - "Deposit":"94316983965547873678944864", - "Interest":1414754759483218105, - "Address":"603" - }, - { - "Reward":1254201146693007, - "Stock":2, - "Deposit":"32147306986998902548094967", - "Interest":482209604804983538, - "Address":"604" - }, - { - "Reward":3146364921007242, - "Stock":1, - "Deposit":"80646680379333357543700289", - "Interest":1209700205690000363, - "Address":"605" - }, - { - "Reward":2346308537641633, - "Stock":1, - "Deposit":"60139875525280916962924785", - "Interest":902098132879213754, - "Address":"606" - }, - { - "Reward":3080640295033415, - "Stock":1, - "Deposit":"78962046512303840647535254", - "Interest":1184430697684557609, - "Address":"607" - }, - { - "Reward":3117955689967562, - "Stock":1, - "Deposit":"79918503504431559488976355", - "Interest":1198777552566473392, - "Address":"608" - }, - { - "Reward":193372918760824, - "Stock":2, - "Deposit":"4956476557821098972096466", - "Interest":74347148367316484, - "Address":"609" - }, - { - "Reward":1104876534289025, - "Stock":1, - "Deposit":"28319863384094556838009370", - "Interest":424797950761418352, - "Address":"610" - }, - { - "Reward":2549408876710865, - "Stock":2, - "Deposit":"65345682397996451846600800", - "Interest":980185235969946777, - "Address":"611" - }, - { - "Reward":1910350673677566, - "Stock":1, - "Deposit":"48965534532847110332117182", - "Interest":734483017992706654, - "Address":"612" - }, - { - "Reward":3795504213510835, - "Stock":1, - "Deposit":"97285223701080292278703259", - "Interest":1459278355516204384, - "Address":"613" - }, - { - "Reward":2920172765205672, - "Stock":2, - "Deposit":"74848990997708197977207117", - "Interest":1122734864965622969, - "Address":"614" - }, - { - "Reward":2215386257486240, - "Stock":2, - "Deposit":"56784114973880728266653186", - "Interest":851761724608210923, - "Address":"615" - }, - { - "Reward":1166384471270875, - "Stock":2, - "Deposit":"29896416345719711851958639", - "Interest":448446245185795677, - "Address":"616" - }, - { - "Reward":999191569038608, - "Stock":1, - "Deposit":"25610978106183812655133082", - "Interest":384164671592757189, - "Address":"617" - }, - { - "Reward":3458856843023134, - "Stock":1, - "Deposit":"88656379441154697937908356", - "Interest":1329845691617320469, - "Address":"618" - }, - { - "Reward":1743157380716969, - "Stock":2, - "Deposit":"44680086278280051197443308", - "Interest":670201294174200767, - "Address":"619" - }, - { - "Reward":3183508183702204, - "Stock":1, - "Deposit":"81598725329620735999095722", - "Interest":1223980879944311039, - "Address":"620" - }, - { - "Reward":383655018632510, - "Stock":2, - "Deposit":"9833730174463772844989324", - "Interest":147505952616956592, - "Address":"621" - }, - { - "Reward":3353634242129514, - "Stock":2, - "Deposit":"85959345347527238443125660", - "Interest":1289390180212908576, - "Address":"622" - }, - { - "Reward":107792337727544, - "Stock":1, - "Deposit":"2762900816117508373813292", - "Interest":41443512241762625, - "Address":"623" - }, - { - "Reward":3507986007527176, - "Stock":2, - "Deposit":"89915643425636437866645602", - "Interest":1348734651384546567, - "Address":"624" - }, - { - "Reward":3511025471483962, - "Stock":2, - "Deposit":"89993550052617554699917127", - "Interest":1349903250789263320, - "Address":"625" - }, - { - "Reward":2044757150316304, - "Stock":2, - "Deposit":"52410600961736297792277795", - "Interest":786159014426044466, - "Address":"626" - }, - { - "Reward":468948663895689, - "Stock":1, - "Deposit":"12019951264713479856062970", - "Interest":180299268970702197, - "Address":"627" - }, - { - "Reward":693649250087810, - "Stock":1, - "Deposit":"17779409182227889909100330", - "Interest":266691137733418348, - "Address":"628" - }, - { - "Reward":2754821593856998, - "Stock":1, - "Deposit":"70610759450861437798557139", - "Interest":1059161391762921566, - "Address":"629" - }, - { - "Reward":3243482759525533, - "Stock":1, - "Deposit":"83135975638704928689072877", - "Interest":1247039634580573930, - "Address":"630" - }, - { - "Reward":135901329829627, - "Stock":2, - "Deposit":"3483382056772899027300956", - "Interest":52250730851593485, - "Address":"631" - }, - { - "Reward":2956646352861790, - "Stock":2, - "Deposit":"75783871038593253473902785", - "Interest":1136758065578898802, - "Address":"632" - }, - { - "Reward":3734095648037875, - "Stock":1, - "Deposit":"95711217800116410457504075", - "Interest":1435668267001746156, - "Address":"633" - }, - { - "Reward":1337681545922902, - "Stock":2, - "Deposit":"34287051499684761960524201", - "Interest":514305772495271429, - "Address":"634" - }, - { - "Reward":2490056142350584, - "Stock":2, - "Deposit":"63824370942470587404197954", - "Interest":957365564137058811, - "Address":"635" - }, - { - "Reward":1338209396107517, - "Stock":1, - "Deposit":"34300581197032509187624133", - "Interest":514508717955487637, - "Address":"636" - }, - { - "Reward":844545620658611, - "Stock":1, - "Deposit":"21647139618254085393576144", - "Interest":324707094273811280, - "Address":"637" - }, - { - "Reward":3067298073680799, - "Stock":2, - "Deposit":"78620062703054449667700221", - "Interest":1179300940545816745, - "Address":"638" - }, - { - "Reward":2821076915683486, - "Stock":1, - "Deposit":"72308995954547150571420062", - "Interest":1084634939318207258, - "Address":"639" - }, - { - "Reward":1087867404471814, - "Stock":1, - "Deposit":"27883890478745720911690014", - "Interest":418258357181185813, - "Address":"640" - }, - { - "Reward":2272309049235852, - "Stock":2, - "Deposit":"58243142870448005871388167", - "Interest":873647143056720088, - "Address":"641" - }, - { - "Reward":1642519959665760, - "Stock":2, - "Deposit":"42100578136828015200819566", - "Interest":631508672052420228, - "Address":"642" - }, - { - "Reward":359198602957846, - "Stock":1, - "Deposit":"9206870675436773511033976", - "Interest":138103060131551602, - "Address":"643" - }, - { - "Reward":93740662593034, - "Stock":2, - "Deposit":"2402732500674853444407015", - "Interest":36040987510122801, - "Address":"644" - }, - { - "Reward":1916165577519871, - "Stock":1, - "Deposit":"49114580401136542780382483", - "Interest":736718706017048141, - "Address":"645" - }, - { - "Reward":1085636242881799, - "Stock":1, - "Deposit":"27826702015187909647347040", - "Interest":417400530227818644, - "Address":"646" - }, - { - "Reward":1325535059741594, - "Stock":2, - "Deposit":"33975716415106471671789312", - "Interest":509635746226597075, - "Address":"647" - }, - { - "Reward":1121071229703152, - "Stock":2, - "Deposit":"28734960951507593221549890", - "Interest":431024414272613898, - "Address":"648" - }, - { - "Reward":666765131244515, - "Stock":1, - "Deposit":"17090323524947836910146116", - "Interest":256354852874217553, - "Address":"649" - }, - { - "Reward":1557693485201534, - "Stock":2, - "Deposit":"39926331428142947114859948", - "Interest":598894971422144206, - "Address":"650" - }, - { - "Reward":2721823290217263, - "Stock":2, - "Deposit":"69764956845789827262514263", - "Interest":1046474352686847408, - "Address":"651" - }, - { - "Reward":794627124147186, - "Stock":1, - "Deposit":"20367643712901495336257044", - "Interest":305514655693522430, - "Address":"652" - }, - { - "Reward":2599618830508718, - "Stock":2, - "Deposit":"66632648848950992721547504", - "Interest":999489732734264890, - "Address":"653" - }, - { - "Reward":1728586464867423, - "Stock":2, - "Deposit":"44306608940827307834261758", - "Interest":664599134112409617, - "Address":"654" - }, - { - "Reward":1690466387002397, - "Stock":1, - "Deposit":"43329526557569630900056742", - "Interest":649942898363544463, - "Address":"655" - }, - { - "Reward":683682492241202, - "Stock":2, - "Deposit":"17523944239459510187703076", - "Interest":262859163591892652, - "Address":"656" - }, - { - "Reward":753763172298130, - "Stock":1, - "Deposit":"19320231176039037725698693", - "Interest":289803467640585565, - "Address":"657" - }, - { - "Reward":2404917902796847, - "Stock":1, - "Deposit":"61642133164676105045506664", - "Interest":924631997470141575, - "Address":"658" - }, - { - "Reward":1049523100033960, - "Stock":1, - "Deposit":"26901060787338682003723009", - "Interest":403515911810080230, - "Address":"659" - }, - { - "Reward":2183538123101029, - "Stock":2, - "Deposit":"55967793161590762013353927", - "Interest":839516897423861430, - "Address":"660" - }, - { - "Reward":3685998227828749, - "Stock":1, - "Deposit":"94478399175430594079674643", - "Interest":1417175987631458911, - "Address":"661" - }, - { - "Reward":2787453223370648, - "Stock":1, - "Deposit":"71447163574894756450850050", - "Interest":1071707453623421346, - "Address":"662" - }, - { - "Reward":2649920476997067, - "Stock":1, - "Deposit":"67921965539400697149510697", - "Interest":1018829483091010457, - "Address":"663" - }, - { - "Reward":3742945639822880, - "Stock":1, - "Deposit":"95938058130708625546738289", - "Interest":1439070871960629383, - "Address":"664" - }, - { - "Reward":3024904025468340, - "Stock":2, - "Deposit":"77533431195898649964634444", - "Interest":1163001467938479749, - "Address":"665" - }, - { - "Reward":2370997540620441, - "Stock":2, - "Deposit":"60772696632210543305451291", - "Interest":911590449483158149, - "Address":"666" - }, - { - "Reward":3698554428289803, - "Stock":2, - "Deposit":"94800235933335108571874689", - "Interest":1422003539000026628, - "Address":"667" - }, - { - "Reward":232686964172925, - "Stock":2, - "Deposit":"5964162358536584385745012", - "Interest":89462435378048765, - "Address":"668" - }, - { - "Reward":1048359452536342, - "Stock":1, - "Deposit":"26871234524279352664975155", - "Interest":403068517864190289, - "Address":"669" - }, - { - "Reward":3849452282518249, - "Stock":1, - "Deposit":"98668004398028297262523227", - "Interest":1480020065970424458, - "Address":"670" - }, - { - "Reward":3012702025921089, - "Stock":2, - "Deposit":"77220673209402646016640533", - "Interest":1158310098141039690, - "Address":"671" - }, - { - "Reward":1854556303374434, - "Stock":2, - "Deposit":"47535429995779476813086766", - "Interest":713031449936692152, - "Address":"672" - }, - { - "Reward":2656474471419636, - "Stock":2, - "Deposit":"68089955555395298432283575", - "Interest":1021349333330929476, - "Address":"673" - }, - { - "Reward":1626637179725934, - "Stock":1, - "Deposit":"41693475493142173608776075", - "Interest":625402132397132604, - "Address":"674" - }, - { - "Reward":1483121327630593, - "Stock":1, - "Deposit":"38014920289318121508405119", - "Interest":570223804339771822, - "Address":"675" - }, - { - "Reward":832057150671959, - "Stock":1, - "Deposit":"21327038907520878832001788", - "Interest":319905583612813182, - "Address":"676" - }, - { - "Reward":1494001551291973, - "Stock":1, - "Deposit":"38293798913414311972320961", - "Interest":574406983701214679, - "Address":"677" - }, - { - "Reward":115746329789999, - "Stock":2, - "Deposit":"2966775151010381250967757", - "Interest":44501627265155718, - "Address":"678" - }, - { - "Reward":1842722383169705, - "Stock":1, - "Deposit":"47232106508407345484557580", - "Interest":708481597626110182, - "Address":"679" - }, - { - "Reward":1300626538592182, - "Stock":1, - "Deposit":"33337268684378718045513517", - "Interest":500059030265680770, - "Address":"680" - }, - { - "Reward":3807179471686809, - "Stock":2, - "Deposit":"97584480410998919462685980", - "Interest":1463767206164983791, - "Address":"681" - }, - { - "Reward":2167017981760827, - "Stock":1, - "Deposit":"55544353861975714897745763", - "Interest":833165307929635723, - "Address":"682" - }, - { - "Reward":3301785102521615, - "Stock":1, - "Deposit":"84630363778357242674061977", - "Interest":1269455456675358640, - "Address":"683" - }, - { - "Reward":1592026675234143, - "Stock":2, - "Deposit":"40806349440191080905817868", - "Interest":612095241602866213, - "Address":"684" - }, - { - "Reward":1802526448117603, - "Stock":2, - "Deposit":"46201816377389237637982367", - "Interest":693027245660838564, - "Address":"685" - }, - { - "Reward":3223768750598171, - "Stock":2, - "Deposit":"82630672084643164162982668", - "Interest":1239460081269647462, - "Address":"686" - }, - { - "Reward":3867099008896526, - "Stock":1, - "Deposit":"99120319986874516625574603", - "Interest":1486804799803117749, - "Address":"687" - }, - { - "Reward":2044139320221393, - "Stock":2, - "Deposit":"52394764926360881679107246", - "Interest":785921473895413225, - "Address":"688" - }, - { - "Reward":3610517075776143, - "Stock":1, - "Deposit":"92543688963144821189397354", - "Interest":1388155334447172317, - "Address":"689" - }, - { - "Reward":2883233940954528, - "Stock":2, - "Deposit":"73902186152192483888535124", - "Interest":1108532792282887258, - "Address":"690" - }, - { - "Reward":2213782409228607, - "Stock":2, - "Deposit":"56743005617192088246965489", - "Interest":851145084257881323, - "Address":"691" - }, - { - "Reward":3779607592775833, - "Stock":2, - "Deposit":"96877766294290768032924329", - "Interest":1453166494414361520, - "Address":"692" - }, - { - "Reward":3216717712008722, - "Stock":1, - "Deposit":"82449941981892205253212667", - "Interest":1236749129728383078, - "Address":"693" - }, - { - "Reward":3743837885341799, - "Stock":1, - "Deposit":"95960927899788395221842517", - "Interest":1439413918496825928, - "Address":"694" - }, - { - "Reward":2521666828167756, - "Stock":1, - "Deposit":"64634606544402273271350925", - "Interest":969519098166034099, - "Address":"695" - }, - { - "Reward":1480875212614237, - "Stock":2, - "Deposit":"37957348544028879370655199", - "Interest":569360228160433190, - "Address":"696" - }, - { - "Reward":1859317520707705, - "Stock":1, - "Deposit":"47657468088032928226525960", - "Interest":714862021320493923, - "Address":"697" - }, - { - "Reward":3557664251498915, - "Stock":1, - "Deposit":"91188981250071876614400636", - "Interest":1367834718751078149, - "Address":"698" - }, - { - "Reward":57951115296885, - "Stock":2, - "Deposit":"1485385576787345840592183", - "Interest":22280783651810187, - "Address":"699" - }, - { - "Reward":611328354689411, - "Stock":1, - "Deposit":"15669384723396240223680784", - "Interest":235040770850943603, - "Address":"700" - }, - { - "Reward":1839783879024499, - "Stock":2, - "Deposit":"47156787652984832886197941", - "Interest":707351814794772493, - "Address":"701" - }, - { - "Reward":2118438121722359, - "Stock":2, - "Deposit":"54299169484525655621094938", - "Interest":814487542267884834, - "Address":"702" - }, - { - "Reward":232879728606340, - "Stock":2, - "Deposit":"5969103238580830695411329", - "Interest":89536548578712460, - "Address":"703" - }, - { - "Reward":2567251944964665, - "Stock":1, - "Deposit":"65803030562808251253594506", - "Interest":987045458442123768, - "Address":"704" - }, - { - "Reward":3470840086504988, - "Stock":1, - "Deposit":"88963530337904261910970670", - "Interest":1334452955068563928, - "Address":"705" - }, - { - "Reward":427722733852170, - "Stock":2, - "Deposit":"10963260611521186139712519", - "Interest":164448909172817792, - "Address":"706" - }, - { - "Reward":1707936350829565, - "Stock":1, - "Deposit":"43777311421811371254730454", - "Interest":656659671327170568, - "Address":"707" - }, - { - "Reward":1093294999377491, - "Stock":2, - "Deposit":"28023008960732387342986543", - "Interest":420345134410985810, - "Address":"708" - }, - { - "Reward":3843858695072342, - "Stock":2, - "Deposit":"98524631245120297694380286", - "Interest":1477869468676804465, - "Address":"709" - }, - { - "Reward":2375022794621462, - "Stock":2, - "Deposit":"60875870733440362598230352", - "Interest":913138061001605438, - "Address":"710" - }, - { - "Reward":989981980195930, - "Stock":2, - "Deposit":"25374920691844626843595753", - "Interest":380623810377669402, - "Address":"711" - }, - { - "Reward":517385616620583, - "Stock":2, - "Deposit":"13261472684836250747412639", - "Interest":198922090272543761, - "Address":"712" - }, - { - "Reward":2126292444327872, - "Stock":2, - "Deposit":"54500489121842310430326565", - "Interest":817507336827634656, - "Address":"713" - }, - { - "Reward":3229609996593789, - "Stock":2, - "Deposit":"82780393147092223857185863", - "Interest":1241705897206383357, - "Address":"714" - }, - { - "Reward":3265512179078068, - "Stock":2, - "Deposit":"83700627102282409994252066", - "Interest":1255509406534236149, - "Address":"715" - }, - { - "Reward":3251242255310333, - "Stock":1, - "Deposit":"83334864703442290698175948", - "Interest":1250022970551634360, - "Address":"716" - }, - { - "Reward":794779268427752, - "Stock":1, - "Deposit":"20371543429391625325922981", - "Interest":305573151440874379, - "Address":"717" - }, - { - "Reward":2124001562413684, - "Stock":1, - "Deposit":"54441769924877336800261095", - "Interest":816626548873160052, - "Address":"718" - }, - { - "Reward":3413518168389374, - "Stock":2, - "Deposit":"87494272154234853386826940", - "Interest":1312414082313522800, - "Address":"719" - }, - { - "Reward":472072036657141, - "Stock":1, - "Deposit":"12100008616966728692930680", - "Interest":181500129254500930, - "Address":"720" - }, - { - "Reward":3340983169461882, - "Stock":2, - "Deposit":"85635076853726599397050273", - "Interest":1284526152805898990, - "Address":"721" - }, - { - "Reward":3510403267078674, - "Stock":2, - "Deposit":"89977601896232761733537561", - "Interest":1349664028443491426, - "Address":"722" - }, - { - "Reward":849983136615588, - "Stock":1, - "Deposit":"21786512393647039511580099", - "Interest":326797685904705592, - "Address":"723" - }, - { - "Reward":300327665504814, - "Stock":2, - "Deposit":"7697908493489191706574403", - "Interest":115468627402337875, - "Address":"724" - }, - { - "Reward":1850112042965550, - "Stock":2, - "Deposit":"47421516048187206675854136", - "Interest":711322740722808100, - "Address":"725" - }, - { - "Reward":3257792030505444, - "Stock":2, - "Deposit":"83502746573466279941827054", - "Interest":1252541198601994199, - "Address":"726" - }, - { - "Reward":1831300733057375, - "Stock":2, - "Deposit":"46939350204183472041990124", - "Interest":704090253062752080, - "Address":"727" - }, - { - "Reward":1614289907654436, - "Stock":2, - "Deposit":"41376993924949523333238316", - "Interest":620654908874242849, - "Address":"728" - }, - { - "Reward":1961423832084286, - "Stock":1, - "Deposit":"50274626384999865363361404", - "Interest":754119395774997980, - "Address":"729" - }, - { - "Reward":489393844829114, - "Stock":2, - "Deposit":"12543995999965518174522459", - "Interest":188159939999482772, - "Address":"730" - }, - { - "Reward":516100483656304, - "Stock":2, - "Deposit":"13228532542793869365638738", - "Interest":198427988141908040, - "Address":"731" - }, - { - "Reward":3396089139191326, - "Stock":1, - "Deposit":"87047536514108581071440057", - "Interest":1305713047711628716, - "Address":"732" - }, - { - "Reward":2352361300725488, - "Stock":1, - "Deposit":"60295018130188693389810500", - "Interest":904425271952830400, - "Address":"733" - }, - { - "Reward":1035053197989111, - "Stock":2, - "Deposit":"26530172605379920283560914", - "Interest":397952589080698804, - "Address":"734" - }, - { - "Reward":3373957227612037, - "Stock":1, - "Deposit":"86480258005693477771672089", - "Interest":1297203870085402166, - "Address":"735" - }, - { - "Reward":226709345102201, - "Stock":2, - "Deposit":"5810945822397561855735468", - "Interest":87164187335963427, - "Address":"736" - }, - { - "Reward":1785889710234206, - "Stock":1, - "Deposit":"45775388510208614438878233", - "Interest":686630827653129216, - "Address":"737" - }, - { - "Reward":2817642436265931, - "Stock":1, - "Deposit":"72220964409951771141859326", - "Interest":1083314466149276567, - "Address":"738" - }, - { - "Reward":1322577735148109, - "Stock":2, - "Deposit":"33899915159607985074619838", - "Interest":508498727394119776, - "Address":"739" - }, - { - "Reward":1565326777874411, - "Stock":1, - "Deposit":"40121985692631256807517309", - "Interest":601829785389468852, - "Address":"740" - }, - { - "Reward":2055968824244119, - "Stock":2, - "Deposit":"52697975219482706693277398", - "Interest":790469628292240600, - "Address":"741" - }, - { - "Reward":3488788217777667, - "Stock":1, - "Deposit":"89423571446451433084642745", - "Interest":1341353571696771496, - "Address":"742" - }, - { - "Reward":3036711070672526, - "Stock":1, - "Deposit":"77836065831331058281211252", - "Interest":1167540987469965874, - "Address":"743" - }, - { - "Reward":270632083881840, - "Stock":2, - "Deposit":"6936760266900243721704125", - "Interest":104051404003503655, - "Address":"744" - }, - { - "Reward":1087655260262364, - "Stock":2, - "Deposit":"27878452862104496914895474", - "Interest":418176792931567453, - "Address":"745" - }, - { - "Reward":1480080685689866, - "Stock":2, - "Deposit":"37936983468606533257865301", - "Interest":569054752029097998, - "Address":"746" - }, - { - "Reward":3373449911764470, - "Stock":2, - "Deposit":"86467254638303725497762547", - "Interest":1297008819574555882, - "Address":"747" - }, - { - "Reward":1638441369578898, - "Stock":2, - "Deposit":"41996036941069914143231161", - "Interest":629940554116048712, - "Address":"748" - }, - { - "Reward":935862535673715, - "Stock":2, - "Deposit":"23987747349188315306898981", - "Interest":359816210237824729, - "Address":"749" - }, - { - "Reward":2331700693048525, - "Stock":2, - "Deposit":"59765451641367850494222411", - "Interest":896481774620517757, - "Address":"750" - }, - { - "Reward":1870357454733185, - "Stock":1, - "Deposit":"47940440360199232388354331", - "Interest":719106605402988485, - "Address":"751" - }, - { - "Reward":3505610307002122, - "Stock":1, - "Deposit":"89854750183520148985134803", - "Interest":1347821252752802234, - "Address":"752" - }, - { - "Reward":3646692391652457, - "Stock":2, - "Deposit":"93470923791381022037074309", - "Interest":1402063856870715330, - "Address":"753" - }, - { - "Reward":3190919243238232, - "Stock":1, - "Deposit":"81788683381111748635206383", - "Interest":1226830250716676229, - "Address":"754" - }, - { - "Reward":2765750968189063, - "Stock":1, - "Deposit":"70890897890182080772069737", - "Interest":1063363468352731211, - "Address":"755" - }, - { - "Reward":2899614863615625, - "Stock":2, - "Deposit":"74322057040450772998561462", - "Interest":1114830855606761594, - "Address":"756" - }, - { - "Reward":3510144850949816, - "Stock":2, - "Deposit":"89970978251654942790090554", - "Interest":1349564673774824141, - "Address":"757" - }, - { - "Reward":254527814952155, - "Stock":1, - "Deposit":"6523980483969205047086854", - "Interest":97859707259538075, - "Address":"758" - }, - { - "Reward":1310530230290677, - "Stock":2, - "Deposit":"33591117134585901652402616", - "Interest":503866757018788524, - "Address":"759" - }, - { - "Reward":5637644898374, - "Stock":1, - "Deposit":"433507260879828493259649", - "Interest":2167536304399142, - "Address":"760" - }, - { - "Reward":3230747930025461, - "Stock":1, - "Deposit":"82809560314938601707726242", - "Interest":1242143404724079025, - "Address":"761" - }, - { - "Reward":1979718028460758, - "Stock":1, - "Deposit":"50743537730317611616566729", - "Interest":761153065954764174, - "Address":"762" - }, - { - "Reward":1428553089936231, - "Stock":1, - "Deposit":"36616243614906218709953618", - "Interest":549243654223593280, - "Address":"763" - }, - { - "Reward":884216503331699, - "Stock":1, - "Deposit":"22663971764437029767824210", - "Interest":339959576466555446, - "Address":"764" - }, - { - "Reward":2086602600135342, - "Stock":1, - "Deposit":"53483170959689707585141886", - "Interest":802247564395345613, - "Address":"765" - }, - { - "Reward":1129401761469161, - "Stock":2, - "Deposit":"28948486638956505426329013", - "Interest":434227299584347581, - "Address":"766" - }, - { - "Reward":266743519172179, - "Stock":2, - "Deposit":"6837089744520385981702318", - "Interest":102556346167805789, - "Address":"767" - }, - { - "Reward":331506482233483, - "Stock":1, - "Deposit":"8497074556692640890670129", - "Interest":127456118350389613, - "Address":"768" - }, - { - "Reward":266620900259916, - "Stock":1, - "Deposit":"6833946813400204601379739", - "Interest":102509202201003069, - "Address":"769" - }, - { - "Reward":1598865881288730, - "Stock":1, - "Deposit":"40981649915050211156684076", - "Interest":614724748725753167, - "Address":"770" - }, - { - "Reward":481362470690238, - "Stock":1, - "Deposit":"12338138230938067164810615", - "Interest":185072073464071007, - "Address":"771" - }, - { - "Reward":1728393357321394, - "Stock":1, - "Deposit":"44301659266223625270860510", - "Interest":664524888993354379, - "Address":"772" - }, - { - "Reward":3507140580592029, - "Stock":1, - "Deposit":"89893973696429974049692792", - "Interest":1348409605446449610, - "Address":"773" - }, - { - "Reward":1379693925013132, - "Stock":1, - "Deposit":"35363900178566065605403851", - "Interest":530458502678490984, - "Address":"774" - }, - { - "Reward":468865200469661, - "Stock":1, - "Deposit":"12017811955252799550699089", - "Interest":180267179328791993, - "Address":"775" - }, - { - "Reward":2220340574704440, - "Stock":2, - "Deposit":"56911102544370828498900327", - "Interest":853666538165562427, - "Address":"776" - }, - { - "Reward":3413869314917572, - "Stock":2, - "Deposit":"87503272636549167548952286", - "Interest":1312549089548237513, - "Address":"777" - }, - { - "Reward":1359937042841556, - "Stock":2, - "Deposit":"34857497710389195869781101", - "Interest":522862465655837938, - "Address":"778" - }, - { - "Reward":163551405560551, - "Stock":2, - "Deposit":"4192100490876959906635662", - "Interest":62881507363154398, - "Address":"779" - }, - { - "Reward":555326887409512, - "Stock":2, - "Deposit":"14233971938839162786650741", - "Interest":213509579082587441, - "Address":"780" - }, - { - "Reward":298820742183226, - "Stock":1, - "Deposit":"7659283487641710409176447", - "Interest":114889252314625656, - "Address":"781" - }, - { - "Reward":2889104514519518, - "Stock":2, - "Deposit":"74052658930088666185591763", - "Interest":1110789883951329992, - "Address":"782" - }, - { - "Reward":1781095811257917, - "Stock":2, - "Deposit":"45652512731900019020812428", - "Interest":684787690978500285, - "Address":"783" - }, - { - "Reward":2607120583644869, - "Stock":2, - "Deposit":"66824931531552911330178128", - "Interest":1002373972973293669, - "Address":"784" - }, - { - "Reward":2728051933546733, - "Stock":1, - "Deposit":"69924607560312745942235513", - "Interest":1048869113404691189, - "Address":"785" - }, - { - "Reward":2229103891164559, - "Stock":2, - "Deposit":"57135721239075809580067748", - "Interest":857035818586137143, - "Address":"786" - }, - { - "Reward":2452796157128838, - "Stock":1, - "Deposit":"62869334195444170904807071", - "Interest":943040012931662563, - "Address":"787" - }, - { - "Reward":3424524865547596, - "Stock":2, - "Deposit":"87776392509005118922503959", - "Interest":1316645887635076783, - "Address":"788" - }, - { - "Reward":2584111669731954, - "Stock":2, - "Deposit":"66235173962803883813644379", - "Interest":993527609442058257, - "Address":"789" - }, - { - "Reward":3415355308885055, - "Stock":1, - "Deposit":"87541361187480148950832443", - "Interest":1313120417812202234, - "Address":"790" - }, - { - "Reward":1823979785810794, - "Stock":2, - "Deposit":"46751701883822749388438828", - "Interest":701275528257341240, - "Address":"791" - }, - { - "Reward":551411068057955, - "Stock":1, - "Deposit":"14133602833666469857112246", - "Interest":212004042504997047, - "Address":"792" - }, - { - "Reward":265821066831438, - "Stock":1, - "Deposit":"6813445723258848563800466", - "Interest":102201685848882728, - "Address":"793" - }, - { - "Reward":2786558905658754, - "Stock":1, - "Deposit":"71424240691987184177977449", - "Interest":1071363610379807762, - "Address":"794" - }, - { - "Reward":1201582545837341, - "Stock":1, - "Deposit":"30798602818298692621347829", - "Interest":461979042274480389, - "Address":"795" - }, - { - "Reward":2618491879522311, - "Stock":1, - "Deposit":"67116397171156250152135240", - "Interest":1006745957567343752, - "Address":"796" - }, - { - "Reward":2545367051255457, - "Stock":2, - "Deposit":"65242083542226425591915873", - "Interest":978631253133396383, - "Address":"797" - }, - { - "Reward":2071844034312978, - "Stock":2, - "Deposit":"53104883834510174805719774", - "Interest":796573257517652622, - "Address":"798" - }, - { - "Reward":2789932169457422, - "Stock":2, - "Deposit":"71510703176230516760409223", - "Interest":1072660547643457751, - "Address":"799" - }, - { - "Reward":1969477762210110, - "Stock":2, - "Deposit":"50481062302308155059263770", - "Interest":757215934534622325, - "Address":"800" - }, - { - "Reward":1903889975201456, - "Stock":2, - "Deposit":"48799935850522835339306393", - "Interest":731999037757842530, - "Address":"801" - }, - { - "Reward":1942275843838653, - "Stock":2, - "Deposit":"49783830903000114714274263", - "Interest":746757463545001720, - "Address":"802" - }, - { - "Reward":3651632818670851, - "Stock":2, - "Deposit":"93597555332442783369487653", - "Interest":1403963329986641750, - "Address":"803" - }, - { - "Reward":1518750958353805, - "Stock":2, - "Deposit":"38928168279652541898253860", - "Interest":583922524194788128, - "Address":"804" - }, - { - "Reward":457032376753946, - "Stock":2, - "Deposit":"11714516572757627256356163", - "Interest":175717748591364408, - "Address":"805" - }, - { - "Reward":937993024438051, - "Stock":2, - "Deposit":"24042355397123882368064082", - "Interest":360635330956858235, - "Address":"806" - }, - { - "Reward":2672115022546245, - "Stock":1, - "Deposit":"68490849462914615848511816", - "Interest":1027362741943719237, - "Address":"807" - }, - { - "Reward":3274280009830028, - "Stock":2, - "Deposit":"83925361505959605876228796", - "Interest":1258880422589394088, - "Address":"808" - }, - { - "Reward":3784940715347838, - "Stock":1, - "Deposit":"97014463289803465349792642", - "Interest":1455216949347051980, - "Address":"809" - }, - { - "Reward":839466818235969, - "Stock":2, - "Deposit":"21516961280403346103913656", - "Interest":322754419206050191, - "Address":"810" - }, - { - "Reward":2966417987496802, - "Stock":2, - "Deposit":"76034334641823742025715211", - "Interest":1140515019627356130, - "Address":"811" - }, - { - "Reward":2278829963501674, - "Stock":2, - "Deposit":"58410284985803273555556252", - "Interest":876154274787049103, - "Address":"812" - }, - { - "Reward":1572082945722312, - "Stock":1, - "Deposit":"40295157757124133727917579", - "Interest":604427366356862005, - "Address":"813" - }, - { - "Reward":1989881070703483, - "Stock":1, - "Deposit":"51004033775756707496762344", - "Interest":765060506636350612, - "Address":"814" - }, - { - "Reward":1933715779612991, - "Stock":1, - "Deposit":"49564421908504818775021314", - "Interest":743466328627572281, - "Address":"815" - }, - { - "Reward":2541260835482084, - "Stock":2, - "Deposit":"65136834253171371773418517", - "Interest":977052513797570576, - "Address":"816" - }, - { - "Reward":2901509292103253, - "Stock":2, - "Deposit":"74370614462294359910613245", - "Interest":1115559216934415398, - "Address":"817" - }, - { - "Reward":1178047005245151, - "Stock":1, - "Deposit":"30195346912723197710623310", - "Interest":452930203690847965, - "Address":"818" - }, - { - "Reward":349613707715351, - "Stock":1, - "Deposit":"8961193520212384911801034", - "Interest":134417902803185773, - "Address":"819" - }, - { - "Reward":3222437436764249, - "Stock":2, - "Deposit":"82596548248424395141579237", - "Interest":1238948223726365927, - "Address":"820" - }, - { - "Reward":1519942163503448, - "Stock":2, - "Deposit":"38958700892169317868136656", - "Interest":584380513382539768, - "Address":"821" - }, - { - "Reward":3024789094774526, - "Stock":2, - "Deposit":"77530485326883946680639600", - "Interest":1162957279903259200, - "Address":"822" - }, - { - "Reward":699793998537518, - "Stock":1, - "Deposit":"17936909528397648740509958", - "Interest":269053642925964731, - "Address":"823" - }, - { - "Reward":426663902787425, - "Stock":1, - "Deposit":"10936120971778806599799163", - "Interest":164041814576682098, - "Address":"824" - }, - { - "Reward":3531401949259355, - "Stock":2, - "Deposit":"90515833809163703813800088", - "Interest":1357737507137455557, - "Address":"825" - }, - { - "Reward":3419012468041810, - "Stock":1, - "Deposit":"87635100392250053777816689", - "Interest":1314526505883750806, - "Address":"826" - }, - { - "Reward":3900609719155859, - "Stock":1, - "Deposit":"99979256444475161923476720", - "Interest":1499688846667127428, - "Address":"827" - }, - { - "Reward":3371819663544361, - "Stock":1, - "Deposit":"86425468605708355438219208", - "Interest":1296382029085625331, - "Address":"828" - }, - { - "Reward":143874666560204, - "Stock":2, - "Deposit":"3687752228387264353073180", - "Interest":55316283425808965, - "Address":"829" - }, - { - "Reward":2125034434844930, - "Stock":1, - "Deposit":"54468244200724713627194908", - "Interest":817023663010870704, - "Address":"830" - }, - { - "Reward":3892118740024338, - "Stock":2, - "Deposit":"99761618218357317476849544", - "Interest":1496424273275359762, - "Address":"831" - }, - { - "Reward":1993656928351932, - "Stock":1, - "Deposit":"51100815424604628672387752", - "Interest":766512231369069430, - "Address":"832" - }, - { - "Reward":3407937010561897, - "Stock":2, - "Deposit":"87351217593572172423877946", - "Interest":1310268263903582586, - "Address":"833" - }, - { - "Reward":273963387236686, - "Stock":2, - "Deposit":"7022147233653885934492252", - "Interest":105332208504808289, - "Address":"834" - }, - { - "Reward":3852802403119937, - "Stock":2, - "Deposit":"98753873682799653287308684", - "Interest":1481308105241994799, - "Address":"835" - }, - { - "Reward":3599891716822631, - "Stock":2, - "Deposit":"92271342954670632084183874", - "Interest":1384070144320059481, - "Address":"836" - }, - { - "Reward":2201418279553869, - "Stock":1, - "Deposit":"56426091959977786599675800", - "Interest":846391379399666798, - "Address":"837" - }, - { - "Reward":1683314259237118, - "Stock":2, - "Deposit":"43146205367434475878999145", - "Interest":647193080511517138, - "Address":"838" - }, - { - "Reward":1318073210051642, - "Stock":1, - "Deposit":"33784456525649175787684806", - "Interest":506766847884737636, - "Address":"839" - }, - { - "Reward":2811844083923136, - "Stock":1, - "Deposit":"72072342784725140781272233", - "Interest":1081085141770877111, - "Address":"840" - }, - { - "Reward":53276087402357, - "Stock":1, - "Deposit":"1365556666333511692948842", - "Interest":20483349995002675, - "Address":"841" - }, - { - "Reward":1459365547793409, - "Stock":2, - "Deposit":"37406019277582380770226499", - "Interest":561090289163735711, - "Address":"842" - }, - { - "Reward":3599781661090798, - "Stock":1, - "Deposit":"92268522039216793748987368", - "Interest":1384027830588251906, - "Address":"843" - }, - { - "Reward":2132046088588054, - "Stock":1, - "Deposit":"54647964802927240240879442", - "Interest":819719472043908603, - "Address":"844" - }, - { - "Reward":1848831243270995, - "Stock":1, - "Deposit":"47388686975212535039974736", - "Interest":710830304628188025, - "Address":"845" - }, - { - "Reward":1937200134416921, - "Stock":2, - "Deposit":"49653731844019466384297295", - "Interest":744805977660291995, - "Address":"846" - }, - { - "Reward":1205425650481574, - "Stock":1, - "Deposit":"30897108121939242944865012", - "Interest":463456621829088644, - "Address":"847" - }, - { - "Reward":3709615729551894, - "Stock":1, - "Deposit":"95083755884090781505598466", - "Interest":1426256338261361722, - "Address":"848" - }, - { - "Reward":3831167255826013, - "Stock":2, - "Deposit":"98199328087301995814192453", - "Interest":1472989921309529937, - "Address":"849" - }, - { - "Reward":2003624856112565, - "Stock":2, - "Deposit":"51356310354257828093140384", - "Interest":770344655313867421, - "Address":"850" - }, - { - "Reward":3872508789078182, - "Stock":2, - "Deposit":"99258981847207217185027902", - "Interest":1488884727708108257, - "Address":"851" - }, - { - "Reward":1778437285817563, - "Stock":1, - "Deposit":"45584370206525071105410324", - "Interest":683765553097876066, - "Address":"852" - }, - { - "Reward":1662163992676178, - "Stock":1, - "Deposit":"42604088089209868343936209", - "Interest":639061321338148025, - "Address":"853" - }, - { - "Reward":831840191678837, - "Stock":2, - "Deposit":"21321477879791106426664316", - "Interest":319822168196866596, - "Address":"854" - }, - { - "Reward":753947197039696, - "Stock":2, - "Deposit":"19324948042927514448562453", - "Interest":289874220643912716, - "Address":"855" - }, - { - "Reward":3248923247698038, - "Stock":2, - "Deposit":"83275424597033365090019825", - "Interest":1249131368955500476, - "Address":"856" - }, - { - "Reward":2834915795350425, - "Stock":1, - "Deposit":"72663709960496081226620942", - "Interest":1089955649407441218, - "Address":"857" - }, - { - "Reward":2066759921821779, - "Stock":1, - "Deposit":"52974569390577497257374432", - "Interest":794618540858662458, - "Address":"858" - }, - { - "Reward":3234591351907878, - "Stock":1, - "Deposit":"82908073749932964532872789", - "Interest":1243621106248994467, - "Address":"859" - }, - { - "Reward":1997036638269282, - "Stock":2, - "Deposit":"51187443133825372148633610", - "Interest":767811647007380582, - "Address":"860" - }, - { - "Reward":2153434440972650, - "Stock":2, - "Deposit":"55196184625454636224447758", - "Interest":827942769381819543, - "Address":"861" - }, - { - "Reward":832113740523327, - "Stock":2, - "Deposit":"21328489401589612042186452", - "Interest":319927341023844180, - "Address":"862" - }, - { - "Reward":2293334567284059, - "Stock":1, - "Deposit":"58782062632272980013159359", - "Interest":881730939484094700, - "Address":"863" - }, - { - "Reward":556979161612646, - "Stock":1, - "Deposit":"14276322534814056554358378", - "Interest":214144838022210848, - "Address":"864" - }, - { - "Reward":203745864339887, - "Stock":1, - "Deposit":"5222352782515049530143135", - "Interest":78335291737725742, - "Address":"865" - }, - { - "Reward":2665870491944175, - "Stock":1, - "Deposit":"68330791530593493206146260", - "Interest":1024961872958902398, - "Address":"866" - }, - { - "Reward":2374245519115540, - "Stock":2, - "Deposit":"60855947841192803433015328", - "Interest":912839217617892051, - "Address":"867" - }, - { - "Reward":856969840092272, - "Stock":2, - "Deposit":"21965593478116085537329123", - "Interest":329483902171741283, - "Address":"868" - }, - { - "Reward":1585068291159791, - "Stock":2, - "Deposit":"40627994230134489854373782", - "Interest":609419913452017347, - "Address":"869" - }, - { - "Reward":2457534831616361, - "Stock":2, - "Deposit":"62990794476248024309127008", - "Interest":944861917143720364, - "Address":"870" - }, - { - "Reward":2166487724709572, - "Stock":2, - "Deposit":"55530762472545336377868574", - "Interest":832961437088180045, - "Address":"871" - }, - { - "Reward":497739378191520, - "Stock":2, - "Deposit":"12757906203826274717125897", - "Interest":191368593057394120, - "Address":"872" - }, - { - "Reward":660113587949486, - "Stock":2, - "Deposit":"16919833165561370959564966", - "Interest":253797497483420564, - "Address":"873" - }, - { - "Reward":259943256120, - "Stock":1, - "Deposit":"99941811675341440955870", - "Interest":99941811675341, - "Address":"874" - }, - { - "Reward":1631427015306499, - "Stock":2, - "Deposit":"41816247119712346429224597", - "Interest":627243706795685196, - "Address":"875" - }, - { - "Reward":1905787314743727, - "Stock":1, - "Deposit":"48848567887644456236180242", - "Interest":732728518314666843, - "Address":"876" - }, - { - "Reward":623715344129455, - "Stock":2, - "Deposit":"15986884315247029688043734", - "Interest":239803264728705445, - "Address":"877" - }, - { - "Reward":2601616703232436, - "Stock":1, - "Deposit":"66683857722375861072362522", - "Interest":1000257865835637916, - "Address":"878" - }, - { - "Reward":69914868521758, - "Stock":1, - "Deposit":"1792036905125549140117856", - "Interest":26880553576883237, - "Address":"879" - }, - { - "Reward":466903711212980, - "Stock":2, - "Deposit":"11967535651924188223690339", - "Interest":179513034778862823, - "Address":"880" - }, - { - "Reward":3714639782029506, - "Stock":1, - "Deposit":"95212530887799273769465501", - "Interest":1428187963316989106, - "Address":"881" - }, - { - "Reward":3807215235301233, - "Stock":2, - "Deposit":"97585397093219217189188239", - "Interest":1463780956398288257, - "Address":"882" - }, - { - "Reward":120610568913534, - "Stock":2, - "Deposit":"3091453866840576658912238", - "Interest":46371808002608649, - "Address":"883" - }, - { - "Reward":1926840014987654, - "Stock":1, - "Deposit":"49388184375343668902008140", - "Interest":740822765630155033, - "Address":"884" - }, - { - "Reward":3365840512944826, - "Stock":2, - "Deposit":"86272212813882975810124479", - "Interest":1294083192208244637, - "Address":"885" - }, - { - "Reward":947561692780093, - "Stock":1, - "Deposit":"24287616629310992968566395", - "Interest":364314249439664894, - "Address":"886" - }, - { - "Reward":3254837478022794, - "Stock":2, - "Deposit":"83427016371879902942318716", - "Interest":1251405245578198544, - "Address":"887" - }, - { - "Reward":3174160146178602, - "Stock":2, - "Deposit":"81359119240286825744192427", - "Interest":1220386788604302386, - "Address":"888" - }, - { - "Reward":2453887626387332, - "Stock":1, - "Deposit":"62897310407563078455584204", - "Interest":943459656113446176, - "Address":"889" - }, - { - "Reward":2910716806085, - "Stock":1, - "Deposit":"223819856083329327156741", - "Interest":1119099280416646, - "Address":"890" - }, - { - "Reward":1481462197828620, - "Stock":1, - "Deposit":"37972393972693441192475481", - "Interest":569585909590401617, - "Address":"891" - }, - { - "Reward":3528465579014875, - "Stock":1, - "Deposit":"90440569649243518499813677", - "Interest":1356608544738652777, - "Address":"892" - }, - { - "Reward":2654336921048215, - "Stock":1, - "Deposit":"68035166506468469645033243", - "Interest":1020527497597027044, - "Address":"893" - }, - { - "Reward":1477947764466699, - "Stock":2, - "Deposit":"37882313072616979891426128", - "Interest":568234696089254698, - "Address":"894" - }, - { - "Reward":2465520123167579, - "Stock":1, - "Deposit":"63195471070233411043578588", - "Interest":947932066053501165, - "Address":"895" - }, - { - "Reward":949096340049470, - "Stock":2, - "Deposit":"24326952247058997172090265", - "Interest":364904283705884957, - "Address":"896" - }, - { - "Reward":2229321821360703, - "Stock":1, - "Deposit":"57141307160389664959889995", - "Interest":857119607405844974, - "Address":"897" - }, - { - "Reward":3830135302810493, - "Stock":2, - "Deposit":"98172877377642264749940411", - "Interest":1472593160664633971, - "Address":"898" - }, - { - "Reward":3314965582861141, - "Stock":1, - "Deposit":"84968201890551675612036022", - "Interest":1274523028358275134, - "Address":"899" - }, - { - "Reward":1105834534937735, - "Stock":2, - "Deposit":"28344418568906060154678226", - "Interest":425166278533590902, - "Address":"900" - }, - { - "Reward":2662553307090563, - "Stock":2, - "Deposit":"68245766445021804898087367", - "Interest":1023686496675327073, - "Address":"901" - }, - { - "Reward":1397193853899397, - "Stock":2, - "Deposit":"35812453098200036642165624", - "Interest":537186796473000549, - "Address":"902" - }, - { - "Reward":3850414863953533, - "Stock":1, - "Deposit":"98692676996185024772413934", - "Interest":1480390154942775371, - "Address":"903" - }, - { - "Reward":327665731025339, - "Stock":2, - "Deposit":"8398629575618876686733181", - "Interest":125979443634283150, - "Address":"904" - }, - { - "Reward":976548143910830, - "Stock":2, - "Deposit":"25030588636170048036092062", - "Interest":375458829542550720, - "Address":"905" - }, - { - "Reward":3165403110453723, - "Stock":2, - "Deposit":"81134661531500573702692618", - "Interest":1217019922972508605, - "Address":"906" - }, - { - "Reward":329369902536779, - "Stock":1, - "Deposit":"8442310387808538153242276", - "Interest":126634655817128072, - "Address":"907" - }, - { - "Reward":2072644314435759, - "Stock":1, - "Deposit":"53125396374185707154303833", - "Interest":796880945612785607, - "Address":"908" - }, - { - "Reward":3123565712431927, - "Stock":2, - "Deposit":"80062297914795022010464543", - "Interest":1200934468721925330, - "Address":"909" - }, - { - "Reward":2882459042667537, - "Stock":1, - "Deposit":"73882324192106352274854522", - "Interest":1108234862881595284, - "Address":"910" - }, - { - "Reward":552686644673372, - "Stock":1, - "Deposit":"14166298030245894069872716", - "Interest":212494470453688411, - "Address":"911" - }, - { - "Reward":1708408983112878, - "Stock":1, - "Deposit":"43789425790502289896833570", - "Interest":656841386857534348, - "Address":"912" - }, - { - "Reward":1366980646426833, - "Stock":2, - "Deposit":"35038037241346919884624911", - "Interest":525570558620203798, - "Address":"913" - }, - { - "Reward":1866819232845175, - "Stock":2, - "Deposit":"47849749719768952532013107", - "Interest":717746245796534287, - "Address":"914" - }, - { - "Reward":2291706793060324, - "Stock":1, - "Deposit":"58740340012409397735566769", - "Interest":881105100186140966, - "Address":"915" - }, - { - "Reward":568849111412820, - "Stock":2, - "Deposit":"14580569521952135848899138", - "Interest":218708542829282037, - "Address":"916" - }, - { - "Reward":3532074043407014, - "Stock":2, - "Deposit":"90533060724436387198984782", - "Interest":1357995910866545807, - "Address":"917" - }, - { - "Reward":2497666011928354, - "Stock":2, - "Deposit":"64019424833222204902229125", - "Interest":960291372498333073, - "Address":"918" - }, - { - "Reward":635695541854260, - "Stock":2, - "Deposit":"16293957144066983923587437", - "Interest":244409357161004758, - "Address":"919" - }, - { - "Reward":2207854338925003, - "Stock":2, - "Deposit":"56591059100165730383450156", - "Interest":848865886502485955, - "Address":"920" - }, - { - "Reward":3634624908851769, - "Stock":2, - "Deposit":"93161613697719469771456372", - "Interest":1397424205465792046, - "Address":"921" - }, - { - "Reward":3055208577477202, - "Stock":1, - "Deposit":"78310188368463107274672113", - "Interest":1174652825526946609, - "Address":"922" - }, - { - "Reward":2675152832613606, - "Stock":2, - "Deposit":"68568713697898875387893447", - "Interest":1028530705468483130, - "Address":"923" - }, - { - "Reward":1818916782274261, - "Stock":1, - "Deposit":"46621928498274223256143230", - "Interest":699328927474113348, - "Address":"924" - }, - { - "Reward":1015609967646564, - "Stock":2, - "Deposit":"26031809566652963641544996", - "Interest":390477143499794454, - "Address":"925" - }, - { - "Reward":2220953665665919, - "Stock":2, - "Deposit":"56926817107701910286724438", - "Interest":853902256615528654, - "Address":"926" - }, - { - "Reward":970558593862897, - "Stock":1, - "Deposit":"24877066288807681007354250", - "Interest":373155994332115215, - "Address":"927" - }, - { - "Reward":1245729299777333, - "Stock":2, - "Deposit":"31930159152089698796210211", - "Interest":478952387281345481, - "Address":"928" - }, - { - "Reward":3553421145102516, - "Stock":1, - "Deposit":"91080223221694056610294159", - "Interest":1366203348325410849, - "Address":"929" - }, - { - "Reward":3453614297893843, - "Stock":1, - "Deposit":"88522004099441053979153999", - "Interest":1327830061491615809, - "Address":"930" - }, - { - "Reward":3100026286313766, - "Stock":1, - "Deposit":"79458942416585209852664854", - "Interest":1191884136248778147, - "Address":"931" - }, - { - "Reward":3611971983338838, - "Stock":2, - "Deposit":"92580980716687710794600741", - "Interest":1388714710750315661, - "Address":"932" - }, - { - "Reward":697729584093434, - "Stock":2, - "Deposit":"17883995077587799828588338", - "Interest":268259926163816997, - "Address":"933" - }, - { - "Reward":2019144875312576, - "Stock":1, - "Deposit":"51754114823646513171181929", - "Interest":776311722354697697, - "Address":"934" - }, - { - "Reward":2446210462174023, - "Stock":2, - "Deposit":"62700531640930945449111157", - "Interest":940507974613964181, - "Address":"935" - }, - { - "Reward":3562706965880270, - "Stock":2, - "Deposit":"91318234590090441314089613", - "Interest":1369773518851356619, - "Address":"936" - }, - { - "Reward":2590418369007299, - "Stock":1, - "Deposit":"66396825383880786481921785", - "Interest":995952380758211797, - "Address":"937" - }, - { - "Reward":1518404279025403, - "Stock":1, - "Deposit":"38919282299261304118312333", - "Interest":583789234488919561, - "Address":"938" - }, - { - "Reward":2887079647290546, - "Stock":2, - "Deposit":"74000758141615208270568916", - "Interest":1110011372124228124, - "Address":"939" - }, - { - "Reward":3189936186684605, - "Stock":2, - "Deposit":"81763485970873084349006602", - "Interest":1226452289563096265, - "Address":"940" - }, - { - "Reward":2342196589958982, - "Stock":2, - "Deposit":"60034479317649303015572280", - "Interest":900517189764739545, - "Address":"941" - }, - { - "Reward":331609163429901, - "Stock":1, - "Deposit":"8499706450270283487352546", - "Interest":127495596754054252, - "Address":"942" - }, - { - "Reward":3598505041484380, - "Stock":1, - "Deposit":"92235800109005416933861096", - "Interest":1383537001635081254, - "Address":"943" - }, - { - "Reward":209107535687059, - "Stock":1, - "Deposit":"5359781531655816167439107", - "Interest":80396722974837242, - "Address":"944" - }, - { - "Reward":2056145170266056, - "Stock":1, - "Deposit":"52702495267736593214927597", - "Interest":790537429016048898, - "Address":"945" - }, - { - "Reward":463696433063566, - "Stock":2, - "Deposit":"11885327661974764980123512", - "Interest":178279914929621474, - "Address":"946" - }, - { - "Reward":1483097089471276, - "Stock":1, - "Deposit":"38014299024100484118339182", - "Interest":570214485361507261, - "Address":"947" - }, - { - "Reward":3171200298019434, - "Stock":2, - "Deposit":"81283253301510915997190972", - "Interest":1219248799522663739, - "Address":"948" - }, - { - "Reward":952320445805632, - "Stock":2, - "Deposit":"24409591557168996980516546", - "Interest":366143873357534954, - "Address":"949" - }, - { - "Reward":3450503376985959, - "Stock":1, - "Deposit":"88442265909357487005903009", - "Interest":1326633988640362305, - "Address":"950" - }, - { - "Reward":2780333754038855, - "Stock":2, - "Deposit":"71264679475914971547482463", - "Interest":1068970192138724573, - "Address":"951" - }, - { - "Reward":1475315505757919, - "Stock":2, - "Deposit":"37814843808214326785103221", - "Interest":567222657123214901, - "Address":"952" - }, - { - "Reward":971139702842715, - "Stock":1, - "Deposit":"24891961099593318265377290", - "Interest":373379416493899773, - "Address":"953" - }, - { - "Reward":986488408976130, - "Stock":2, - "Deposit":"25285374523927306447429996", - "Interest":379280617858909596, - "Address":"954" - }, - { - "Reward":2993338746656799, - "Stock":1, - "Deposit":"76724359452693502444580812", - "Interest":1150865391790402536, - "Address":"955" - }, - { - "Reward":194532106306183, - "Stock":2, - "Deposit":"4986188504724031745284037", - "Interest":74792827570860476, - "Address":"956" - }, - { - "Reward":2673597846495507, - "Stock":2, - "Deposit":"68528856760890910500191357", - "Interest":1027932851413363657, - "Address":"957" - }, - { - "Reward":2419964858596065, - "Stock":2, - "Deposit":"62027812215100130994274166", - "Interest":930417183226501964, - "Address":"958" - }, - { - "Reward":2913129611458769, - "Stock":1, - "Deposit":"74668462996872508881906548", - "Interest":1120026944953087633, - "Address":"959" - }, - { - "Reward":3812683766211109, - "Stock":1, - "Deposit":"97725564834566935888731666", - "Interest":1465883472518504038, - "Address":"960" - }, - { - "Reward":1497807477324976, - "Stock":2, - "Deposit":"38391351266061535256140970", - "Interest":575870268990923028, - "Address":"961" - }, - { - "Reward":1015171083941179, - "Stock":1, - "Deposit":"26020560231372236173299095", - "Interest":390308403470583542, - "Address":"962" - }, - { - "Reward":3423376330409797, - "Stock":1, - "Deposit":"87746953601412391874233029", - "Interest":1316204304021185878, - "Address":"963" - }, - { - "Reward":3144918195706266, - "Stock":2, - "Deposit":"80609598351064659657321490", - "Interest":1209143975265969894, - "Address":"964" - }, - { - "Reward":1799026547567141, - "Stock":2, - "Deposit":"46112107977969940546702740", - "Interest":691681619669549108, - "Address":"965" - }, - { - "Reward":354879658647077, - "Stock":2, - "Deposit":"9096168792422121286221450", - "Interest":136442531886331819, - "Address":"966" - }, - { - "Reward":2201449122898455, - "Stock":1, - "Deposit":"56426882527319810473140875", - "Interest":846403237909797157, - "Address":"967" - }, - { - "Reward":731059166280637, - "Stock":1, - "Deposit":"18738288914860679048242414", - "Interest":281074333722910185, - "Address":"968" - }, - { - "Reward":2074343858985112, - "Stock":2, - "Deposit":"53168958589473258596652424", - "Interest":797534378842098878, - "Address":"969" - }, - { - "Reward":1385133751522286, - "Stock":2, - "Deposit":"35503332177338264855842601", - "Interest":532549982660073972, - "Address":"970" - }, - { - "Reward":1228102350172134, - "Stock":1, - "Deposit":"31478350475549399248667900", - "Interest":472175257133240988, - "Address":"971" - }, - { - "Reward":2835322983478803, - "Stock":1, - "Deposit":"72674146884269374975828899", - "Interest":1090112203264040624, - "Address":"972" - }, - { - "Reward":2012246034685977, - "Stock":1, - "Deposit":"51577285813353823678719155", - "Interest":773659287200307355, - "Address":"973" - }, - { - "Reward":3084637036594829, - "Stock":2, - "Deposit":"79064489791247793978440545", - "Interest":1185967346868716909, - "Address":"974" - }, - { - "Reward":797811244762556, - "Stock":2, - "Deposit":"20449258135895642676072312", - "Interest":306738872038434640, - "Address":"975" - }, - { - "Reward":2645575943263138, - "Stock":1, - "Deposit":"67810607755979557260797471", - "Interest":1017159116339693358, - "Address":"976" - }, - { - "Reward":204768093912302, - "Stock":2, - "Deposit":"5248554263802363007398818", - "Interest":78728313957035445, - "Address":"977" - }, - { - "Reward":3125709086550137, - "Stock":2, - "Deposit":"80117236236249889111082805", - "Interest":1201758543543748336, - "Address":"978" - }, - { - "Reward":2647380588555318, - "Stock":1, - "Deposit":"67856863881931384081654468", - "Interest":1017852958228970761, - "Address":"979" - }, - { - "Reward":3690777284038487, - "Stock":1, - "Deposit":"94600894508406219172728453", - "Interest":1419013417626093287, - "Address":"980" - }, - { - "Reward":357206679331288, - "Stock":2, - "Deposit":"9155814287483010628170220", - "Interest":137337214312245159, - "Address":"981" - }, - { - "Reward":3544198730362897, - "Stock":1, - "Deposit":"90843837057817811162702361", - "Interest":1362657555867267167, - "Address":"982" - }, - { - "Reward":1989540474075705, - "Stock":2, - "Deposit":"50995303705320405023947622", - "Interest":764929555579806075, - "Address":"983" - }, - { - "Reward":2398996459691542, - "Stock":2, - "Deposit":"61490356514005506400370610", - "Interest":922355347710082596, - "Address":"984" - }, - { - "Reward":1233126192337437, - "Stock":1, - "Deposit":"31607120088595974663863581", - "Interest":474106801328939619, - "Address":"985" - }, - { - "Reward":302311133589818, - "Stock":1, - "Deposit":"7748748151542173002389951", - "Interest":116231222273132595, - "Address":"986" - }, - { - "Reward":3318601889130262, - "Stock":1, - "Deposit":"85061406600370670369642800", - "Interest":1275921099005560055, - "Address":"987" - }, - { - "Reward":563860022539758, - "Stock":2, - "Deposit":"14452690694851200171933831", - "Interest":216790360422768002, - "Address":"988" - }, - { - "Reward":1445420315201052, - "Stock":1, - "Deposit":"37048579265401193620170864", - "Interest":555728688981017904, - "Address":"989" - }, - { - "Reward":2428209770037979, - "Stock":1, - "Deposit":"62239143308125099991025020", - "Interest":933587149621876499, - "Address":"990" - }, - { - "Reward":3891867957776995, - "Stock":2, - "Deposit":"99755190243137026327976581", - "Interest":1496327853647055394, - "Address":"991" - }, - { - "Reward":2018376237281893, - "Stock":2, - "Deposit":"51734413324569261676994713", - "Interest":776016199868538925, - "Address":"992" - }, - { - "Reward":3864399286559910, - "Stock":1, - "Deposit":"99051121515031537177924160", - "Interest":1485766822725473057, - "Address":"993" - }, - { - "Reward":883805859128173, - "Stock":2, - "Deposit":"22653446255583864490422282", - "Interest":339801693833757967, - "Address":"994" - }, - { - "Reward":1552785001244040, - "Stock":1, - "Deposit":"39800518642021398556065354", - "Interest":597007779630320978, - "Address":"995" - }, - { - "Reward":2717606328546471, - "Stock":1, - "Deposit":"69656868951163986032635917", - "Interest":1044853034267459790, - "Address":"996" - }, - { - "Reward":252190687893398, - "Stock":1, - "Deposit":"6464075945352265595935342", - "Interest":96961139180283983, - "Address":"997" - }, - { - "Reward":2916941112163722, - "Stock":1, - "Deposit":"74766158237836355401038480", - "Interest":1121492373567545331, - "Address":"998" - }, - { - "Reward":1640158235138226, - "Stock":1, - "Deposit":"42040043123281312102727263", - "Interest":630600646849219681, - "Address":"999" - }, - { - "Reward":3165289208225322, - "Stock":2, - "Deposit":"81131742023802333471428573", - "Interest":1216976130357035002, - "Address":"1000" - } - ] -}` -) -type State struct { - balance int64 -} - -func (st *State) GetBalance(addr common.Address) common.BalanceType { - return []common.BalanceSlice{{common.MainAccount, big.NewInt(st.balance)}} -} -func (st *State) GetBalanceByType(addr common.Address, accType uint32) *big.Int { - return big.NewInt(st.balance) -} - -func (st *State) CreateAccount(common.Address) { - -} - -func (st *State) SubBalance(uint32, common.Address, *big.Int) {} -func (st *State) AddBalance(uint32, common.Address, *big.Int) {} - -func (st *State) GetNonce(common.Address) uint64 { return 0 } -func (st *State) SetNonce(common.Address, uint64) {} - -func (st *State) GetCodeHash(common.Address) common.Hash { return common.Hash{} } -func (st *State) GetCode(common.Address) []byte { return nil } -func (st *State) SetCode(common.Address, []byte) {} -func (st *State) GetCodeSize(common.Address) int { return 0 } - -func (st *State) AddRefund(uint64) {} -func (st *State) GetRefund() uint64 { return 0 } - -func (st *State) GetState(common.Address, common.Hash) common.Hash { return common.Hash{} } -func (st *State) SetState(common.Address, common.Hash, common.Hash) {} - -func (st *State) Suicide(common.Address) bool { return true } -func (st *State) HasSuicided(common.Address) bool { return true } - -// Exist reports whether the given account exists in state. -// Notably this should also return true for suicided accounts. -func (st *State) Exist(common.Address) bool { return true } - -// Empty returns whether the given account is empty. Empty -// is defined according to EIP161 (balance = nonce = code = 0). -func (st *State) Empty(common.Address) bool { return true } - -func (st *State) RevertToSnapshot(int) {} -func (st *State) Snapshot() int { return 0 } - -func (st *State) AddLog(*types.Log) {} -func (st *State) AddPreimage(common.Hash, []byte) {} - -func (st *State) ForEachStorage(common.Address, func(common.Hash, common.Hash) bool) {} - -func (st *State) GetMatrixData(hash common.Hash) (val []byte) { - return nil - -} -func (st *State) SetMatrixData(hash common.Hash, val []byte) { - return -} - -func (st *State) CommitSaveTx() { - return -} -func (st *State) DeleteMxData(hash common.Hash, val []byte) { - -} -func (st *State) Dump() []byte { - return nil -} - -func (st *State) Finalise(deleteEmptyObjects bool) { - return -} - -func (st *State) GetAllEntrustSignFrom(authFrom common.Address) []common.Address { - return nil -} -func (st *State) GetAllEntrustGasFrom(authFrom common.Address) []common.Address { - return nil -} - -func (st *State) GetGasAuthFrom(entrustFrom common.Address, height uint64) common.Address { - return common.Address{} -} -func (st *State) GetAuthFrom(entrustFrom common.Address, height uint64) common.Address { - return common.Address{} -} -func (st *State) GetEntrustFrom(authFrom common.Address, height uint64) []common.Address { - return nil -} - -func (st *State) GetLogs(hash common.Hash) []*types.Log { - return nil -} - -func (st *State) GetSaveTx(typ byte, key uint32, hash []common.Hash, isdel bool) { - -} -func (st *State) SaveTx(typ byte, key uint32, data map[common.Hash][]byte) { - -} - -func (st *State) GetStateByteArray(common.Address, common.Hash) []byte { - return nil -} -func (st *State) SetStateByteArray(common.Address, common.Hash, []byte) { - -} - -func (self *State) GetAuthStateByteArray(addr common.Address) []byte { - //hashkey := append([]byte("AU"), addr[:]...) - return nil -} - -func (self *State) GetEntrustStateByteArray(addr common.Address) []byte { - //hashkey := append([]byte("AU"), addr[:]...) - return nil -} -func (self *State) SetAuthStateByteArray(addr common.Address, value []byte) { - -} -func (st *State) NewBTrie(typ byte) { - -} -func (st *State) SetEntrustStateByteArray(addr common.Address, value []byte) { - -} -func Test_interest_Calc(t *testing.T) { - //monkey.Patch(manparams.IsBroadcastNumber, func(number uint64, stateNumber uint64) bool { - // fmt.Println("use monkey manparams.IsBroadcastNumber") - // - // return false - //}) - // - monkey.Patch(matrixstate.GetInterestCalc, func(st matrixstate.StateDB) (string, error) { - - return "1", nil - }) - - monkey.Patch(matrixstate.GetInterestCfg, func(st matrixstate.StateDB) (*mc.InterestCfg, error) { - fmt.Println("use monkey GetInterestCfg") - - return &mc.InterestCfg{3600}, nil - }) - // - var Precision *big.Int = big.NewInt(1e+7) - Deposit := make([]vm.DepositDetail, 0) - monkey.Patch(ca.GetElectedByHeight, func(height *big.Int) ([]vm.DepositDetail, error) { - fmt.Println("use monkey ca.GetElectedByHeightAndRole") - - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x82799145a60b4d1e88d5a895601508f2b7f4ee9b"), Deposit: new(big.Int).Mul(big.NewInt(10000), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x519437b21e2a0b62788ab9235d0728dd7f1a7269"), Deposit: new(big.Int).Mul(big.NewInt(40000), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bce"), Deposit: new(big.Int).Mul(big.NewInt(100000), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bc0"), Deposit: new(big.Int).Mul(big.NewInt(200000), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bc1"), Deposit: new(big.Int).Mul(big.NewInt(2e10), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bc2"), Deposit: new(big.Int).Mul(big.NewInt(4e10), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bc3"), Deposit: new(big.Int).Mul(big.NewInt(6e10), util.ManPrice)}) - - A := new(big.Int).Mul(big.NewInt(10000336253100004), Precision) - D := new(big.Int).Add(A, big.NewInt(9350016)) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bc4"), Deposit: D}) - return Deposit, nil - }) - ////insterestMap := make(map[common.Address]*big.Int, 0) - ////monkey.Patch(depoistInfo.AddInterest, func(stateDB vm.StateDB, address common.Address, reward *big.Int) error { - //// insterestMap[address] = reward - //// return nil - ////}) - ////monkey.Patch(depoistInfo.GetAllInterest, func(stateDB vm.StateDB) map[common.Address]*big.Int { - //// return insterestMap - ////}) - // - monkey.Patch(matrixstate.GetVIPConfig, func(st matrixstate.StateDB) ([]mc.VIPConfig, error) { - vip := make([]mc.VIPConfig, 0) - vip = append(vip, mc.VIPConfig{MinMoney: 0, InterestRate: 5}) - vip = append(vip, mc.VIPConfig{MinMoney: 40000, InterestRate: 10}) - vip = append(vip, mc.VIPConfig{MinMoney: 100000, InterestRate: 15}) - return vip, nil - }) - - Convey("利息测试计算利息", t, func() { - log.InitLog(3) - - interestTest := New(&State{5e+18}) - - result := interestTest.GetInterest(&State{0}, 101) - for _, v := range Deposit { - if value, ok := result[v.Address]; ok { - log.INFO(PackageName, "地址", v.Address.String(), "抵押", v.Deposit.String(), "利息", value.String()) - } - } - - }) - - //Convey("利息测试支付利息", t, func() { - // log.InitLog(3) - // - // interestTest := New(&State{5e+18}) - // - // interestTest.InterestCalc(&State{5e+18}, 3601) - // - //}) - -} - -func Test_interest_Calc2(t *testing.T) { - //monkey.Patch(manparams.IsBroadcastNumber, func(number uint64, stateNumber uint64) bool { - // fmt.Println("use monkey manparams.IsBroadcastNumber") - // - // return false - //}) - // - monkey.Patch(matrixstate.GetInterestCalc, func(st matrixstate.StateDB) (string, error) { - - return "1", nil - }) - - monkey.Patch(matrixstate.GetInterestCfg, func(st matrixstate.StateDB) (*mc.InterestCfg, error) { - fmt.Println("use monkey GetInterestCfg") - - return &mc.InterestCfg{3600}, nil - }) - // - var Precision *big.Int = big.NewInt(1e+7) - Deposit := make([]vm.DepositDetail, 0) - monkey.Patch(ca.GetElectedByHeight, func(height *big.Int) ([]vm.DepositDetail, error) { - fmt.Println("use monkey ca.GetElectedByHeightAndRole") - - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x82799145a60b4d1e88d5a895601508f2b7f4ee9b"), Deposit: new(big.Int).Mul(big.NewInt(10000), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x519437b21e2a0b62788ab9235d0728dd7f1a7269"), Deposit: new(big.Int).Mul(big.NewInt(40000), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bce"), Deposit: new(big.Int).Mul(big.NewInt(100000), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bc0"), Deposit: new(big.Int).Mul(big.NewInt(200000), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bc1"), Deposit: new(big.Int).Mul(big.NewInt(2e10), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bc2"), Deposit: new(big.Int).Mul(big.NewInt(4e10), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bc3"), Deposit: new(big.Int).Mul(big.NewInt(6e10), util.ManPrice)}) - - A := new(big.Int).Mul(big.NewInt(10000336253100004), Precision) - D := new(big.Int).Add(A, big.NewInt(9350016)) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bc4"), Deposit: D}) - return Deposit, nil - }) - ////insterestMap := make(map[common.Address]*big.Int, 0) - ////monkey.Patch(depoistInfo.AddInterest, func(stateDB vm.StateDB, address common.Address, reward *big.Int) error { - //// insterestMap[address] = reward - //// return nil - ////}) - ////monkey.Patch(depoistInfo.GetAllInterest, func(stateDB vm.StateDB) map[common.Address]*big.Int { - //// return insterestMap - ////}) - // - monkey.Patch(matrixstate.GetVIPConfig, func(st matrixstate.StateDB) ([]mc.VIPConfig, error) { - vip := make([]mc.VIPConfig, 0) - vip = append(vip, mc.VIPConfig{MinMoney: 0, InterestRate: 5}) - return vip, nil - }) - - Convey("利息测试计算利息", t, func() { - log.InitLog(3) - - interestTest := New(&State{5e+18}) - - result := interestTest.GetInterest(&State{0}, 101) - for _, v := range Deposit { - if value, ok := result[v.Address]; ok { - log.INFO(PackageName, "地址", v.Address.String(), "抵押", v.Deposit.String(), "利息", value.String()) - } - } - - }) - - //Convey("利息测试支付利息", t, func() { - // log.InitLog(3) - // - // interestTest := New(&State{5e+18}) - // - // interestTest.InterestCalc(&State{5e+18}, 3601) - // - //}) - -} - -type RewardTestOringin struct { - Address string - Deposit string - Stock uint64 - Interest *big.Int - Reward *big.Int -} -type RewardTestFinal struct { - Address common.Address - Stock uint64 - Reward *big.Int - Deposit *big.Int -} -type VIPConfig1 struct { - MinMoney string - InterestRate uint64 //(分母待定为1000w) - ElectUserNum uint8 - StockScale uint16 //千分比 -} -type InterestCfg struct { - Vipcfg []VIPConfig1 - Node []RewardTestOringin -} - -func Test_TestData1(t *testing.T) { - //monkey.Patch(manparams.IsBroadcastNumber, func(number uint64, stateNumber uint64) bool { - // fmt.Println("use monkey manparams.IsBroadcastNumber") - // - // return false - //}) - // - log.InitLog(3) - - cfg := new(InterestCfg) - err := json.Unmarshal([]byte(testData1), cfg) - if err != nil { - t.Log(err) - } - rewardTestFinal := make([]RewardTestFinal, 0) - deposit := make([]vm.DepositDetail, 0) - for _, v := range cfg.Node { - var tmp RewardTestFinal - tmp.Address = common.HexToAddress(v.Address) - tmp.Stock = v.Stock - tmp.Reward = v.Reward - tmp.Deposit, _ = new(big.Int).SetString(v.Deposit, 10) - rewardTestFinal = append(rewardTestFinal, tmp) - tmp1 := vm.DepositDetail{Address: tmp.Address, Deposit: tmp.Deposit} - deposit = append(deposit, tmp1) - } - monkey.Patch(matrixstate.GetBroadcastInterval, func(st matrixstate.StateDB) (*mc.BCIntervalInfo, error) { - - return &mc.BCIntervalInfo{BCInterval: 50}, nil - }) - monkey.Patch(matrixstate.GetInterestCalc, func(st matrixstate.StateDB) (string, error) { - - return "1", nil - }) - - monkey.Patch(matrixstate.GetInterestCfg, func(st matrixstate.StateDB) (*mc.InterestCfg, error) { - fmt.Println("use monkey GetInterestCfg") - - return &mc.InterestCfg{2, 1000000, 3600}, nil - }) - // - - monkey.Patch(ca.GetElectedByHeight, func(height *big.Int) ([]vm.DepositDetail, error) { - fmt.Println("use monkey ca.GetElectedByHeightAndRole") - - return deposit, nil - }) - ////insterestMap := make(map[common.Address]*big.Int, 0) - ////monkey.Patch(depoistInfo.AddInterest, func(stateDB vm.StateDB, address common.Address, reward *big.Int) error { - //// insterestMap[address] = reward - //// return nil - ////}) - ////monkey.Patch(depoistInfo.GetAllInterest, func(stateDB vm.StateDB) map[common.Address]*big.Int { - //// return insterestMap - ////}) - // - monkey.Patch(matrixstate.GetVIPConfig, func(st matrixstate.StateDB) ([]mc.VIPConfig, error) { - vip := make([]mc.VIPConfig, 0) - for _, v := range cfg.Vipcfg { - MinMoney, _ := strconv.ParseUint(v.MinMoney, 10, 64) - - vip = append(vip, mc.VIPConfig{MinMoney: MinMoney, InterestRate: v.InterestRate}) - } - return vip, nil - }) - - Convey("利息测试计算利息", t, func() { - log.InitLog(5) - - interestTest := New(&State{5e+18}) - - result := interestTest.GetReward(&State{5e+18}, 101) - sum := new(big.Int).SetUint64(0) - for _, v := range cfg.Node { - if value, ok := result[common.HexToAddress(v.Address)]; ok { - if 0 != v.Reward.Cmp(value) { - log.ERROR(PackageName, "鏁版嵁涓嶄竴鑷?鍦板潃", v.Address, "璁$畻缁撴灉", value, "鐩爣缁撴灉", v.Reward.String()) - t.Fail() - } - sum.Add(sum, value) - } - } - log.INFO(PackageName, "鍒╂伅鍜?, sum) - - }) - -} -func Test_interest_Calc5(t *testing.T) { - //monkey.Patch(manparams.IsBroadcastNumber, func(number uint64, stateNumber uint64) bool { - // fmt.Println("use monkey manparams.IsBroadcastNumber") - // - // return false - //}) - // - log.InitLog(3) - - cfg := new(InterestCfg) - err := json.Unmarshal([]byte(testData2), cfg) - if err != nil { - t.Log(err) - } - rewardTestFinal := make([]RewardTestFinal, 0) - deposit := make([]vm.DepositDetail, 0) - for _, v := range cfg.Node { - var tmp RewardTestFinal - tmp.Address = common.HexToAddress(v.Address) - tmp.Stock = v.Stock - tmp.Reward = v.Reward - tmp.Deposit, _ = new(big.Int).SetString(v.Deposit, 10) - rewardTestFinal = append(rewardTestFinal, tmp) - tmp1 := vm.DepositDetail{Address: tmp.Address, Deposit: tmp.Deposit} - deposit = append(deposit, tmp1) - } - - monkey.Patch(matrixstate.GetInterestCalc, func(st matrixstate.StateDB) (string, error) { - - return "1", nil - }) - monkey.Patch(matrixstate.GetBroadcastInterval, func(st matrixstate.StateDB) (*mc.BCIntervalInfo, error) { - - return &mc.BCIntervalInfo{BCInterval: 50}, nil - }) - monkey.Patch(matrixstate.GetInterestCfg, func(st matrixstate.StateDB) (*mc.InterestCfg, error) { - fmt.Println("use monkey GetInterestCfg") - - return &mc.InterestCfg{2, 1000000, 3600}, nil - }) - // - - monkey.Patch(ca.GetElectedByHeight, func(height *big.Int) ([]vm.DepositDetail, error) { - fmt.Println("use monkey ca.GetElectedByHeightAndRole") - - return deposit, nil - }) - ////insterestMap := make(map[common.Address]*big.Int, 0) - ////monkey.Patch(depoistInfo.AddInterest, func(stateDB vm.StateDB, address common.Address, reward *big.Int) error { - //// insterestMap[address] = reward - //// return nil - ////}) - ////monkey.Patch(depoistInfo.GetAllInterest, func(stateDB vm.StateDB) map[common.Address]*big.Int { - //// return insterestMap - ////}) - // - monkey.Patch(matrixstate.GetVIPConfig, func(st matrixstate.StateDB) ([]mc.VIPConfig, error) { - vip := make([]mc.VIPConfig, 0) - for _, v := range cfg.Vipcfg { - MinMoney, _ := strconv.ParseUint(v.MinMoney, 10, 64) - - vip = append(vip, mc.VIPConfig{MinMoney: MinMoney, InterestRate: v.InterestRate}) - } - return vip, nil - }) - - Convey("利息测试计算利息", t, func() { - log.InitLog(3) - - interestTest := New(&State{5e+18}) - - result := interestTest.GetInterest(&State{0}, 101) - for _, v := range cfg.Node { - if value, ok := result[common.HexToAddress(v.Address)]; ok { - reward, _ := new(big.Int).SetString(v.Reward, 10) - if 0 != value.Cmp(reward) { - log.ERROR(PackageName, "数据不一致,地址", v.Address, "计算结果", value, "目标结果", reward.String()) - t.Fail() - } - log.INFO(PackageName, "地址", v.Address, "抵押", v.Deposit, "利息", value.String()) - } - } - - }) - -} -func Test_interest_Calc3(t *testing.T) { - //monkey.Patch(manparams.IsBroadcastNumber, func(number uint64, stateNumber uint64) bool { - // fmt.Println("use monkey manparams.IsBroadcastNumber") - // - // return false - //}) - // - monkey.Patch(matrixstate.GetInterestCalc, func(st matrixstate.StateDB) (string, error) { - - return "1", nil - }) - - monkey.Patch(matrixstate.GetInterestCfg, func(st matrixstate.StateDB) (*mc.InterestCfg, error) { - fmt.Println("use monkey GetInterestCfg") - - return &mc.InterestCfg{3600}, nil - }) - // - var Precision *big.Int = big.NewInt(1e+7) - Deposit := make([]vm.DepositDetail, 0) - monkey.Patch(ca.GetElectedByHeight, func(height *big.Int) ([]vm.DepositDetail, error) { - fmt.Println("use monkey ca.GetElectedByHeightAndRole") - - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x82799145a60b4d1e88d5a895601508f2b7f4ee9b"), Deposit: new(big.Int).Mul(big.NewInt(10000), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x519437b21e2a0b62788ab9235d0728dd7f1a7269"), Deposit: new(big.Int).Mul(big.NewInt(40000), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bce"), Deposit: new(big.Int).Mul(big.NewInt(100000), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bc0"), Deposit: new(big.Int).Mul(big.NewInt(200000), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bc1"), Deposit: new(big.Int).Mul(big.NewInt(2e10), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bc2"), Deposit: new(big.Int).Mul(big.NewInt(4e10), util.ManPrice)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bc3"), Deposit: new(big.Int).Mul(big.NewInt(6e10), util.ManPrice)}) - - A := new(big.Int).Mul(big.NewInt(10000336253100004), Precision) - D := new(big.Int).Add(A, big.NewInt(9350016)) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bc4"), Deposit: D}) - return Deposit, nil - }) - - monkey.Patch(matrixstate.GetVIPConfig, func(st matrixstate.StateDB) ([]mc.VIPConfig, error) { - vip := make([]mc.VIPConfig, 0) - return vip, nil - }) - - Convey("利息测试计算利息", t, func() { - log.InitLog(3) - - interestTest := New(&State{5e+18}) - - result := interestTest.GetInterest(&State{0}, 101) - for _, v := range Deposit { - if value, ok := result[v.Address]; ok { - log.INFO(PackageName, "地址", v.Address.String(), "抵押", v.Deposit.String(), "利息", value.String()) - } - } - - }) - -} - - diff --git a/reward/mineroutreward/mineroutreward.go b/reward/mineroutreward/mineroutreward.go index 01e5259e..e2aa3172 100644 --- a/reward/mineroutreward/mineroutreward.go +++ b/reward/mineroutreward/mineroutreward.go @@ -60,16 +60,17 @@ func SetPreMinerReward(state util.StateDB, reward *big.Int, rewardType uint8, co var err error if util.TxsReward == rewardType { version := matrixstate.GetVersionInfo(state) - if version == manparams.VersionAlpha { + switch version { + case manparams.VersionAlpha: err = matrixstate.SetPreMinerTxsReward(state, minerOutReward) - } else if version == manparams.VersionBeta { + case manparams.VersionBeta, manparams.VersionGamma: multiCoinMinerOut, err := matrixstate.GetPreMinerMultiCoinTxsReward(state) if err != nil { log.Error(PackageName, "获取前矿工奖励值错误", err) } multiCoinMinerOut = addMultiCoinMinerOutReward(coinType, reward, multiCoinMinerOut) err = matrixstate.SetPreMinerMultiCoinTxsReward(state, multiCoinMinerOut) - } else { + default: log.Error(PackageName, "设置前矿工奖励值版本号错误", version) return } diff --git a/reward/multicoinreward/multicoinreward.go b/reward/multicoinreward/multicoinreward.go deleted file mode 100644 index 9501ee57..00000000 --- a/reward/multicoinreward/multicoinreward.go +++ /dev/null @@ -1,81 +0,0 @@ -package multicoinreward - -import ( - "math/big" - - "github.com/MatrixAINetwork/go-matrix/mc" - - "github.com/MatrixAINetwork/go-matrix/common" - "github.com/MatrixAINetwork/go-matrix/log" - "github.com/MatrixAINetwork/go-matrix/reward" - "github.com/MatrixAINetwork/go-matrix/reward/cfg" - "github.com/MatrixAINetwork/go-matrix/reward/rewardexec" - "github.com/MatrixAINetwork/go-matrix/reward/util" -) - -const ( - PackageName = "多币种奖励" - - //todo: 分母10000, 加法做参数检查 - ValidatorsTxsRewardRate = uint64(util.RewardFullRate) //验证者交易奖励比例100% - MinerTxsRewardRate = uint64(0) //矿工交易奖励比例0% - FoundationTxsRewardRate = uint64(0) //基金会交易奖励比例0% - - MinerOutRewardRate = uint64(4000) //出块矿工奖励40% - ElectedMinerRewardRate = uint64(6000) //当选矿工奖励60% - - LeaderRewardRate = uint64(4000) //出块验证者(leader)奖励40% - ElectedValidatorsRewardRate = uint64(6000) //当选验证者奖励60% - - OriginElectOfflineRewardRate = uint64(util.RewardFullRate) //初选下线验证者奖励50% - BackupRate = uint64(0) //当前替补验证者奖励50% - -) - -type MultiCoinReward struct { - chain util.ChainReader - reward reward.Reward -} - -func New(chain util.ChainReader) *MultiCoinReward { - - RewardMount := &mc.RewardRateCfg{ - MinerOutRate: MinerOutRewardRate, - ElectedMinerRate: ElectedMinerRewardRate, - FoundationMinerRate: FoundationTxsRewardRate, - - LeaderRate: LeaderRewardRate, - ElectedValidatorsRate: ElectedValidatorsRewardRate, - FoundationValidatorRate: FoundationTxsRewardRate, - OriginElectOfflineRate: OriginElectOfflineRewardRate, - BackupRewardRate: BackupRate, - } - rewardCfg := cfg.New(RewardMount, nil) - return &MultiCoinReward{chain, rewardexec.New(chain, rewardCfg)} -} - -func (mcr *MultiCoinReward) CalcNodesReward(rewardMount *big.Int, currentnum uint64) map[common.Address]*big.Int { - - if !common.IsReElectionNumber(currentnum - 1) { - return nil - } - var originNum uint64 - if currentnum < common.GetReElectionInterval() { - originNum = 1 - } else { - originNum = currentnum - common.GetReElectionInterval() - 2 - } - - rewardMap := make(map[common.Address]*big.Int) - for originNum < currentnum-1 { - header := mcr.chain.GetBlockByNumber(originNum).Header() - tempMap := mcr.reward.CalcNodesRewards(rewardMount, header.Leader, header.Number.Uint64()) - for i, v := range tempMap { - util.SetAccountRewards(rewardMap, i, v) - } - originNum++ - } - - log.INFO(PackageName, "多币种", rewardMap) - return rewardMap -} diff --git a/reward/multicoinreward/multicoinreward_test.go b/reward/multicoinreward/multicoinreward_test.go deleted file mode 100644 index 1e11958c..00000000 --- a/reward/multicoinreward/multicoinreward_test.go +++ /dev/null @@ -1,95 +0,0 @@ -package multicoinreward - -import ( - "bou.ke/monkey" - "fmt" - "github.com/MatrixAINetwork/go-matrix/ca" - "github.com/MatrixAINetwork/go-matrix/common" - "github.com/MatrixAINetwork/go-matrix/consensus/manash" - "github.com/MatrixAINetwork/go-matrix/core" - "github.com/MatrixAINetwork/go-matrix/core/types" - "github.com/MatrixAINetwork/go-matrix/core/vm" - "github.com/MatrixAINetwork/go-matrix/log" - "github.com/MatrixAINetwork/go-matrix/mc" - "github.com/MatrixAINetwork/go-matrix/reward/util" - . "github.com/smartystreets/goconvey/convey" - "math/big" - "sync" - "testing" -) - -type FakeEth struct { - blockchain *core.BlockChain - once *sync.Once -} - -const ( - testAddress = "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182" -) - -func (s *FakeEth) BlockChain() *core.BlockChain { return s.blockchain } - -func fakeEthNew(n int) *FakeEth { - eth := &FakeEth{once: new(sync.Once)} - eth.once.Do(func() { - _, blockchain, err := core.NewCanonical(manash.NewFaker(), n, true) - if err != nil { - fmt.Println("failed to create pristine chain: ", err) - return - } - defer blockchain.Stop() - eth.blockchain = blockchain - monkey.Patch(ca.GetTopologyByNumber, func(reqTypes common.RoleType, number uint64) (*mc.TopologyGraph, error) { - fmt.Println("use monkey ca.GetTopologyByNumber") - newGraph := &mc.TopologyGraph{ - Number: number, - NodeList: make([]mc.TopologyNodeInfo, 0), - CurNodeNumber: 0, - } - if common.RoleValidator == reqTypes&common.RoleValidator { - newGraph.NodeList = append(newGraph.NodeList, mc.TopologyNodeInfo{Account: common.HexToAddress("0x475baee143cf541ff3ee7b00c1c933129238d793"), Position: 8192}) - newGraph.NodeList = append(newGraph.NodeList, mc.TopologyNodeInfo{Account: common.HexToAddress("0x82799145a60b4d1e88d5a895601508f2b7f4ee9b"), Position: 8193}) - newGraph.NodeList = append(newGraph.NodeList, mc.TopologyNodeInfo{Account: common.HexToAddress("0x519437b21e2a0b62788ab9235d0728dd7f1a7269"), Position: 8194}) - newGraph.NodeList = append(newGraph.NodeList, mc.TopologyNodeInfo{Account: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bce"), Position: 8195}) - newGraph.CurNodeNumber = 4 - } - - return newGraph, nil - }) - monkey.Patch(ca.GetElectedByHeightAndRole, func(height *big.Int, roleType common.RoleType) ([]vm.DepositDetail, error) { - fmt.Println("use monkey ca.GetTopologyByNumber") - Deposit := make([]vm.DepositDetail, 0) - if common.RoleValidator == roleType&common.RoleValidator { - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x475baee143cf541ff3ee7b00c1c933129238d793"), Deposit: big.NewInt(1e+18)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x82799145a60b4d1e88d5a895601508f2b7f4ee9b"), Deposit: big.NewInt(2e+18)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x519437b21e2a0b62788ab9235d0728dd7f1a7269"), Deposit: big.NewInt(3e+18)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bce"), Deposit: big.NewInt(4e+18)}) - Deposit = append(Deposit, vm.DepositDetail{Address: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bcf"), Deposit: big.NewInt(2e+18)}) - - } - - return Deposit, nil - }) - - }) - return eth -} - -func TestNew(t *testing.T) { - Convey("计算交易费", t, func() { - - log.InitLog(3) - eth := fakeEthNew(0) - header := eth.BlockChain().CurrentHeader() - newheader := types.CopyHeader(header) - newheader.Number = big.NewInt(1) - newheader.NetTopology.Type = common.NetTopoTypeAll - newheader.NetTopology.NetTopologyData = append(newheader.NetTopology.NetTopologyData, common.NetTopologyData{Account: common.HexToAddress("0x475baee143cf541ff3ee7b00c1c933129238d793"), Position: 8192}) - newheader.NetTopology.NetTopologyData = append(newheader.NetTopology.NetTopologyData, common.NetTopologyData{Account: common.HexToAddress("0x82799145a60b4d1e88d5a895601508f2b7f4ee9b"), Position: 8193}) - newheader.NetTopology.NetTopologyData = append(newheader.NetTopology.NetTopologyData, common.NetTopologyData{Account: common.HexToAddress("0x519437b21e2a0b62788ab9235d0728dd7f1a7269"), Position: 8194}) - newheader.NetTopology.NetTopologyData = append(newheader.NetTopology.NetTopologyData, common.NetTopologyData{Account: common.HexToAddress("0x29216818d3788c2505a593cbbb248907d47d9bce"), Position: 8195}) - rewardtest := New(eth.blockchain) - rewardtest.CalcNodesReward(util.ByzantiumTxsRewardDen, newheader.Number.Uint64()) - - }) -} diff --git a/reward/reward_test.go b/reward/reward_test.go index 276b5f78..2ed2c693 100644 --- a/reward/reward_test.go +++ b/reward/reward_test.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/binary" "fmt" + "math" "math/rand" "testing" ) @@ -183,3 +184,14 @@ func Test(t *testing.T) { fmt.Println("随机数2", rand.Uint64()) } } +func TestPower(t *testing.T) { + + data := make([]uint64, 10000) + for i := 1; i < 10000; i++ { + data[i] = uint64(i) + } + + for i := 1; i < 10000; i++ { + math.Pow(float64(i), 1.3) + } +} diff --git a/reward/rewardexec/rewardexec.go b/reward/rewardexec/rewardexec.go index 802e3f32..2b88c514 100644 --- a/reward/rewardexec/rewardexec.go +++ b/reward/rewardexec/rewardexec.go @@ -72,7 +72,7 @@ func (br *BlockReward) CalcMinerRateMount(blockReward *big.Int) (*big.Int, *big. func (br *BlockReward) CalcValidatorRewards(Leader common.Address, num uint64) map[common.Address]*big.Int { //广播区块不给矿工发钱 - RewardMan := new(big.Int).Mul(new(big.Int).SetUint64(br.rewardCfg.RewardMount.ValidatorMount), util.ManPrice) + RewardMan := new(big.Int).Mul(new(big.Int).SetUint64(br.rewardCfg.RewardMount.ValidatorMount), util.GetPrice(br.rewardCfg.Calc)) halfNum := br.rewardCfg.RewardMount.ValidatorAttenuationNum attenuationRate := br.rewardCfg.RewardMount.ValidatorAttenuationRate blockReward := util.CalcRewardMountByNumber(br.st, RewardMan, num-1, halfNum, common.BlkValidatorRewardAddress, attenuationRate) @@ -122,7 +122,7 @@ func (br *BlockReward) getMinerRewards(blockReward *big.Int, num uint64, rewardT func (br *BlockReward) CalcMinerRewards(num uint64, parentHash common.Hash) map[common.Address]*big.Int { //广播区块不给矿工发钱 - RewardMan := new(big.Int).Mul(new(big.Int).SetUint64(br.rewardCfg.RewardMount.MinerMount), util.ManPrice) + RewardMan := new(big.Int).Mul(new(big.Int).SetUint64(br.rewardCfg.RewardMount.MinerMount), util.GetPrice(br.rewardCfg.Calc)) halfNum := br.rewardCfg.RewardMount.MinerAttenuationNum attenuationRate := br.rewardCfg.RewardMount.MinerAttenuationRate blockReward := util.CalcRewardMountByNumber(br.st, RewardMan, num-1, halfNum, common.BlkMinerRewardAddress, attenuationRate) diff --git a/reward/txsreward/txsreward.go b/reward/txsreward/txsreward.go index d3b2d33a..d46f5805 100644 --- a/reward/txsreward/txsreward.go +++ b/reward/txsreward/txsreward.go @@ -71,7 +71,7 @@ func New(chain util.ChainReader, st util.StateDB, preSt util.StateDB, ppreSt uti log.Error(PackageName, "获取前一个矿工奖励错误", err) } - cfg := cfg.New(&mc.BlkRewardCfg{RewardRate: rate}, nil, preMiner, innerMinerAccounts, util.TxsReward) + cfg := cfg.New(&mc.BlkRewardCfg{RewardRate: rate}, nil, preMiner, innerMinerAccounts, util.TxsReward, data) cfg.ValidatorsRate = TC.ValidatorsRate cfg.MinersRate = TC.MinersRate return rewardexec.New(chain, cfg, st, interval, foundationAccount, currentTop, originElectNodes) diff --git a/reward/util/util.go b/reward/util/util.go index ada6262a..bbf7941e 100644 --- a/reward/util/util.go +++ b/reward/util/util.go @@ -38,7 +38,11 @@ var ( ManPrice *big.Int = big.NewInt(1e18) + ThousandthManPrice *big.Int = big.NewInt(1e15) + Precision *big.Int = big.NewInt(1) + + CalcGamma = "2" ) type ChainReader interface { @@ -145,7 +149,7 @@ func CalcInterestReward(reward *big.Int, interest map[common.Address]*big.Int) m log.ERROR(PackageName, "计算的总利息值非法", totalInterest) return nil } - log.Trace(PackageName, "计算的总利息值", totalInterest) + //log.Trace(PackageName, "计算的总利息值", totalInterest) if 0 == reward.Cmp(big.NewInt(0)) { log.ERROR(PackageName, "定点化奖励金额为0", "") @@ -156,7 +160,7 @@ func CalcInterestReward(reward *big.Int, interest map[common.Address]*big.Int) m for k, v := range interest { temp := new(big.Int).Mul(reward, v) rewards[k] = new(big.Int).Div(temp, totalInterest) - log.Trace(PackageName, "计算奖励金额,账户", k, "金额", rewards[k]) + //log.Trace(PackageName, "计算奖励金额,账户", k, "金额", rewards[k]) } return rewards } @@ -384,13 +388,14 @@ func GetPreMinerReward(state StateDB, rewardType uint8) ([]mc.MultiCoinMinerOutR var err error if TxsReward == rewardType { version := matrixstate.GetVersionInfo(state) - if version == manparams.VersionAlpha { + switch version { + case manparams.VersionAlpha: currentReward, err = matrixstate.GetPreMinerTxsReward(state) if err != nil { log.Error(PackageName, "获取矿工交易奖励金额错误", err) return nil, errors.New("获取矿工交易金额错误") } - } else if version == manparams.VersionBeta { + case manparams.VersionBeta, manparams.VersionGamma: multiCoin, err := matrixstate.GetPreMinerMultiCoinTxsReward(state) if err != nil { log.Error(PackageName, "获取矿工交易奖励金额错误", err) @@ -399,9 +404,8 @@ func GetPreMinerReward(state StateDB, rewardType uint8) ([]mc.MultiCoinMinerOutR for _, v := range multiCoin { log.Trace(PackageName, "获取前一个矿工奖励值为", v.Reward, "type", v.CoinType) } - return multiCoin, nil - } else { + default: log.Error(PackageName, "获取前矿工奖励值版本号错误", version) } } else { @@ -418,3 +422,10 @@ func GetPreMinerReward(state StateDB, rewardType uint8) ([]mc.MultiCoinMinerOutR return multiCoinMinerOut, nil } +func GetPrice(calc string) *big.Int { + if calc >= CalcGamma { + return ThousandthManPrice + } else { + return ManPrice + } +} diff --git a/rlp/decode.go b/rlp/decode.go index dda5bd64..5456995d 100644 --- a/rlp/decode.go +++ b/rlp/decode.go @@ -500,24 +500,24 @@ func decodeInterfaceRLP(s *Stream, val reflect.Value) error { if !val.Type().Implements(typerInterface) { return decodeInterface(s, val) } -// valRLP := InterfaceRLP{} -// val1 := reflect.ValueOf(&valRLP).Elem() -// typ := reflect.TypeOf(valRLP) -// typeCacheMutex.Lock() -// fields, err := structFields(typ) -// typeCacheMutex.Unlock() -// if err != nil { -// return err -// } + // valRLP := InterfaceRLP{} + // val1 := reflect.ValueOf(&valRLP).Elem() + // typ := reflect.TypeOf(valRLP) + // typeCacheMutex.Lock() + // fields, err := structFields(typ) + // typeCacheMutex.Unlock() + // if err != nil { + // return err + // } if _, err := s.List(); err != nil { return wrapStreamError(err, val.Type()) } var typeKind uint16 val1 := reflect.ValueOf(&typeKind).Elem() -// valueField := fields[0] -// err = valueField.info.decoder(s, val1.Field(0)) - err := decodeUint(s,val1) + // valueField := fields[0] + // err = valueField.info.decoder(s, val1.Field(0)) + err := decodeUint(s, val1) if err == EOL { return &decodeError{msg: "too few elements", typ: val.Type()} } else if err != nil { diff --git a/rlp/decode_test.go b/rlp/decode_test.go index ba920986..e91ed18a 100644 --- a/rlp/decode_test.go +++ b/rlp/decode_test.go @@ -9,28 +9,29 @@ import ( "encoding/hex" "errors" "fmt" + "github.com/MatrixAINetwork/go-matrix/common" "io" "math/big" "reflect" "strings" "testing" - "github.com/MatrixAINetwork/go-matrix/common" ) -func TestRlpTestFunc(t *testing.T){ - buff := []byte{248,124,135,16,0,0,0,0,0,0,133,9,139,202,90,0,131,3,52,80,161,77,65,78,46,51,66,121,78,66,106,119,52,69,55,103,99,120,68,51,117,71,75,116,65,90,89,76,89,85,68,53,120,105,136,13,224,182,179,167,100,0,0,128,20,128,128,128,128,134,1,103,252,105,4,0,241,240,128,128,237,236,161,77,65,78,46,50,122,88,87,115,68,116,121,116,55,118,104,86,65,68,71,84,122,50,121,88,68,54,104,55,87,74,110,70,136,13,224,182,179,167,100,0,0,128} + +func TestRlpTestFunc(t *testing.T) { + buff := []byte{248, 124, 135, 16, 0, 0, 0, 0, 0, 0, 133, 9, 139, 202, 90, 0, 131, 3, 52, 80, 161, 77, 65, 78, 46, 51, 66, 121, 78, 66, 106, 119, 52, 69, 55, 103, 99, 120, 68, 51, 117, 71, 75, 116, 65, 90, 89, 76, 89, 85, 68, 53, 120, 105, 136, 13, 224, 182, 179, 167, 100, 0, 0, 128, 20, 128, 128, 128, 128, 134, 1, 103, 252, 105, 4, 0, 241, 240, 128, 128, 237, 236, 161, 77, 65, 78, 46, 50, 122, 88, 87, 115, 68, 116, 121, 116, 55, 118, 104, 86, 65, 68, 71, 84, 122, 50, 121, 88, 68, 54, 104, 55, 87, 74, 110, 70, 136, 13, 224, 182, 179, 167, 100, 0, 0, 128} var test1 interface{} - DecodeBytes(buff,&test1) + DecodeBytes(buff, &test1) t.Log(test1) buff2 := common.Hex2Bytes("f8a08710000000000066850430e2340083200b20a04d414e2e4372736e51534a4a6647787062327461476843684c75795a775a4a6f80b85b7b22436f696e4e616d65223a22414243222c2241646472416d6f756e74223a7b224142432e4372736e51534a4a6647787062327461476843684c75795a775a4a58223a223078303536626337356532643633313030303030227d7d1480808080845c46881cc4c30980c0") var test2 interface{} - DecodeBytes(buff2,&test2) + DecodeBytes(buff2, &test2) t.Log(test2) } func TestStreamKind(t *testing.T) { temp := make(map[int][]int) - temp[10] = append(temp[10],1) + temp[10] = append(temp[10], 1) tests := []struct { input string wantKind Kind diff --git a/rlp/encode.go b/rlp/encode.go index e79b5e0d..4fbd9a36 100644 --- a/rlp/encode.go +++ b/rlp/encode.go @@ -375,20 +375,20 @@ func writeRawValue(val reflect.Value, w *encbuf) error { return nil } -func EncodeUint(i uint64)([]byte, error) { - uintBuff := make([]byte,16) +func EncodeUint(i uint64) ([]byte, error) { + uintBuff := make([]byte, 16) if i == 0 { uintBuff[0] = 0x80 - return uintBuff[:1],nil + return uintBuff[:1], nil } else if i < 128 { // fits single byte uintBuff[0] = byte(i) - return uintBuff[:1],nil + return uintBuff[:1], nil } else { // TODO: encode int to w.str directly s := putint(uintBuff[1:], i) uintBuff[0] = 0x80 + byte(s) - return uintBuff[:s+1],nil + return uintBuff[:s+1], nil } } func writeUint(val reflect.Value, w *encbuf) error { @@ -496,7 +496,7 @@ func writeTypeInterface(val reflect.Value, w *encbuf) error { lh := w.list() defer w.listEnd(lh) rlpType := val.Interface().(InterfaceTyper).GetConstructorType() - writeUint(reflect.ValueOf(rlpType),w) + writeUint(reflect.ValueOf(rlpType), w) return writeInterface(val, w) //valRLP := InterfaceRLP{val.Interface().(InterfaceTyper).GetConstructorType(), val.Interface()} //info, _ := cachedTypeInfo(reflect.TypeOf(valRLP), tags{}) diff --git a/rlp/encode_test.go b/rlp/encode_test.go index 42bcd258..aa1219ac 100644 --- a/rlp/encode_test.go +++ b/rlp/encode_test.go @@ -18,15 +18,16 @@ import ( type testEncoder struct { err error } -func TestEncodeUint(t *testing.T){ - for i:=uint64(100353345353445453);i<10000000000000000000;i+=24957 { - buff,_ := EncodeUint(i) - buff1,_ := EncodeToBytes(i) - if bytes.Compare(buff1,buff) != 0{ + +func TestEncodeUint(t *testing.T) { + for i := uint64(100353345353445453); i < 10000000000000000000; i += 24957 { + buff, _ := EncodeUint(i) + buff1, _ := EncodeToBytes(i) + if bytes.Compare(buff1, buff) != 0 { t.Error("Encode Error") t.Fail() } - fmt.Println(buff,buff1) + fmt.Println(buff, buff1) } } func (e *testEncoder) EncodeRLP(w io.Writer) error { diff --git a/rpc/client_test.go b/rpc/client_test.go index b517d7d4..41abbc1f 100644 --- a/rpc/client_test.go +++ b/rpc/client_test.go @@ -18,8 +18,8 @@ import ( "testing" "time" - "github.com/davecgh/go-spew/spew" "github.com/MatrixAINetwork/go-matrix/log" + "github.com/davecgh/go-spew/spew" ) func TestClientRequest(t *testing.T) { diff --git a/run/gman/accountcmd.go b/run/gman/accountcmd.go index 780b2127..e8c7e8f2 100644 --- a/run/gman/accountcmd.go +++ b/run/gman/accountcmd.go @@ -1,6 +1,6 @@ -// Copyright (c) 2018 The MATRIX Authors +// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying -// file COPYING or or http://www.opensource.org/licenses/mit-license.php +// file COPYING or http://www.opensource.org/licenses/mit-license.php package main diff --git a/run/gman/bugcmd.go b/run/gman/bugcmd.go index faf15002..b6ec59ea 100644 --- a/run/gman/bugcmd.go +++ b/run/gman/bugcmd.go @@ -1,6 +1,6 @@ -// Copyright (c) 2018 The MATRIX Authors +// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying -// file COPYING or or http://www.opensource.org/licenses/mit-license.php +// file COPYING or http://www.opensource.org/licenses/mit-license.php package main diff --git a/run/gman/chaincmd.go b/run/gman/chaincmd.go index af284e9e..04115c58 100644 --- a/run/gman/chaincmd.go +++ b/run/gman/chaincmd.go @@ -1,6 +1,6 @@ -// Copyright (c) 2018 The MATRIX Authors +// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying -// file COPYING or or http://www.opensource.org/licenses/mit-license.php +// file COPYING or http://www.opensource.org/licenses/mit-license.php package main @@ -72,6 +72,7 @@ It expects the genesis file as argument.`, utils.GCModeFlag, utils.CacheDatabaseFlag, utils.CacheGCFlag, + utils.DbTableSizeFlag, }, Category: "BLOCKCHAIN COMMANDS", Description: ` @@ -520,7 +521,7 @@ func copyDb(ctx *cli.Context) error { dl := downloader.New(syncmode, chainDb, new(event.TypeMux), chain, nil, nil, nil) // Create a source peer to satisfy downloader requests from - db, err := mandb.NewLDBDatabase(ctx.Args().First(), ctx.GlobalInt(utils.CacheFlag.Name), 256) + db, err := mandb.NewLDBDatabase(ctx.Args().First(), ctx.GlobalInt(utils.CacheFlag.Name), 256,2) if err != nil { return err } diff --git a/run/gman/config.go b/run/gman/config.go index c51bdaae..86e95c4b 100644 --- a/run/gman/config.go +++ b/run/gman/config.go @@ -1,6 +1,6 @@ -// Copyright (c) 2018 The MATRIX Authors +// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying -// file COPYING or or http://www.opensource.org/licenses/mit-license.php +// file COPYING or http://www.opensource.org/licenses/mit-license.php package main @@ -8,12 +8,13 @@ import ( "bufio" "errors" "fmt" - "github.com/MatrixAINetwork/go-matrix/log" "io" "os" "reflect" "unicode" + "github.com/MatrixAINetwork/go-matrix/log" + "github.com/MatrixAINetwork/go-matrix/params/manparams" "crypto/sha256" @@ -97,7 +98,7 @@ func loadConfig(file string, cfg *gmanConfig) error { func defaultNodeConfig() pod.Config { cfg := pod.DefaultConfig cfg.Name = clientIdentifier - cfg.Version = manparams.VersionAlpha + "_" + gitCommit + cfg.Version = manparams.VersionGamma + "_" + gitCommit cfg.HTTPModules = append(cfg.HTTPModules, "man", "eth", "shh") cfg.WSModules = append(cfg.WSModules, "man", "eth", "shh") cfg.IPCPath = "gman.ipc" @@ -208,8 +209,8 @@ func CheckEntrust(ctx *cli.Context) error { entrustValue := make(map[common.Address]string, 0) for _, v := range anss { - addr ,err := base58.Base58DecodeToAddress(v.Address) - if err != nil{ + addr, err := base58.Base58DecodeToAddress(v.Address) + if err != nil { return err } entrustValue[addr] = v.Password diff --git a/run/gman/consolecmd.go b/run/gman/consolecmd.go index 6441b39f..79113b15 100644 --- a/run/gman/consolecmd.go +++ b/run/gman/consolecmd.go @@ -1,6 +1,6 @@ -// Copyright (c) 2018 The MATRIX Authors +// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying -// file COPYING or or http://www.opensource.org/licenses/mit-license.php +// file COPYING or http://www.opensource.org/licenses/mit-license.php package main diff --git a/run/gman/main.go b/run/gman/main.go index 7ba70fe0..c488f078 100644 --- a/run/gman/main.go +++ b/run/gman/main.go @@ -1,6 +1,6 @@ -// Copyright (c) 2018 The MATRIX Authors +// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying -// file COPYING or or http://www.opensource.org/licenses/mit-license.php +// file COPYING or http://www.opensource.org/licenses/mit-license.php // gman is the official command-line client for Matrix. package main @@ -29,15 +29,16 @@ import ( _ "github.com/MatrixAINetwork/go-matrix/random/ereryblockseed" _ "github.com/MatrixAINetwork/go-matrix/random/everybroadcastseed" + "github.com/MatrixAINetwork/go-matrix/common" _ "github.com/MatrixAINetwork/go-matrix/crypto" _ "github.com/MatrixAINetwork/go-matrix/crypto/vrf" _ "github.com/MatrixAINetwork/go-matrix/election/layered" + _ "github.com/MatrixAINetwork/go-matrix/election/layeredbss" _ "github.com/MatrixAINetwork/go-matrix/election/layeredmep" _ "github.com/MatrixAINetwork/go-matrix/election/nochoice" _ "github.com/MatrixAINetwork/go-matrix/election/stock" "github.com/MatrixAINetwork/go-matrix/params/manparams" "github.com/MatrixAINetwork/go-matrix/run/utils" - "github.com/MatrixAINetwork/go-matrix/common" ) const ( @@ -357,6 +358,6 @@ func Init_Config_PATH(ctx *cli.Context) { } manparams.Config_Init(config_dir + "/man.json") - manparams.ReadBlacklist(config_dir +"/blacklist.txt") + manparams.ReadBlacklist(config_dir + "/blacklist.txt") common.WorkPath = config_dir } diff --git a/run/gman/misccmd.go b/run/gman/misccmd.go index f51f6736..ac21a76d 100644 --- a/run/gman/misccmd.go +++ b/run/gman/misccmd.go @@ -1,6 +1,6 @@ -// Copyright (c) 2018 The MATRIX Authors +// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying -// file COPYING or or http://www.opensource.org/licenses/mit-license.php +// file COPYING or http://www.opensource.org/licenses/mit-license.php package main @@ -96,7 +96,7 @@ func makedag(ctx *cli.Context) error { func version(ctx *cli.Context) error { fmt.Println(strings.Title(clientIdentifier)) - fmt.Println("Version:", manparams.VersionAlpha) + fmt.Println("Version:", manparams.VersionGamma) if gitCommit != "" { fmt.Println("Git Commit:", gitCommit) } diff --git a/run/gman/monitorcmd.go b/run/gman/monitorcmd.go index da4bf012..52d6de10 100644 --- a/run/gman/monitorcmd.go +++ b/run/gman/monitorcmd.go @@ -1,6 +1,6 @@ -// Copyright (c) 2018 The MATRIX Authors +// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying -// file COPYING or or http://www.opensource.org/licenses/mit-license.php +// file COPYING or http://www.opensource.org/licenses/mit-license.php package main @@ -13,10 +13,10 @@ import ( "strings" "time" - "github.com/gizak/termui" "github.com/MatrixAINetwork/go-matrix/pod" "github.com/MatrixAINetwork/go-matrix/rpc" "github.com/MatrixAINetwork/go-matrix/run/utils" + "github.com/gizak/termui" "gopkg.in/urfave/cli.v1" ) diff --git a/run/gman/usage.go b/run/gman/usage.go index 6b51bce1..d1c0ae1c 100644 --- a/run/gman/usage.go +++ b/run/gman/usage.go @@ -1,6 +1,6 @@ -// Copyright (c) 2018 The MATRIX Authors +// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying -// file COPYING or or http://www.opensource.org/licenses/mit-license.php +// file COPYING or http://www.opensource.org/licenses/mit-license.php // Contains the gman command usage template and generator. @@ -78,6 +78,7 @@ var AppHelpFlagGroups = []flagGroup{ utils.SnapModeFlg, utils.GetGenesisFlag, utils.LessDiskEnabledFlag, + //utils.DbTableSizeFlag, }, }, /* {Name: "DEVELOPER CHAIN", @@ -129,6 +130,7 @@ var AppHelpFlagGroups = []flagGroup{ utils.CacheDatabaseFlag, utils.CacheGCFlag, utils.TrieCacheGenFlag, + utils.DbTableSizeFlag, }, }, { diff --git a/run/internal/browser/browser.go b/run/internal/browser/browser.go index 5f4340ed..1bebec96 100644 --- a/run/internal/browser/browser.go +++ b/run/internal/browser/browser.go @@ -1,6 +1,6 @@ -// Copyright (c) 2018 The MATRIX Authors +// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying -// file COPYING or or http://www.opensource.org/licenses/mit-license.php +// file COPYING or http://www.opensource.org/licenses/mit-license.php // Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/run/utils/cmd.go b/run/utils/cmd.go index fb78f693..28b58b6f 100644 --- a/run/utils/cmd.go +++ b/run/utils/cmd.go @@ -1,6 +1,6 @@ -// Copyright (c) 2018 The MATRIX Authors +// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying -// file COPYING or or http://www.opensource.org/licenses/mit-license.php +// file COPYING or http://www.opensource.org/licenses/mit-license.php // Package utils contains internal helper functions for go-matrix commands. package utils diff --git a/run/utils/customflags.go b/run/utils/customflags.go index be41a137..8e4d9ce2 100644 --- a/run/utils/customflags.go +++ b/run/utils/customflags.go @@ -1,6 +1,6 @@ -// Copyright (c) 2018 The MATRIX Authors +// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying -// file COPYING or or http://www.opensource.org/licenses/mit-license.php +// file COPYING or http://www.opensource.org/licenses/mit-license.php package utils diff --git a/run/utils/flags.go b/run/utils/flags.go index 5dac2942..91e18758 100644 --- a/run/utils/flags.go +++ b/run/utils/flags.go @@ -1,6 +1,6 @@ -// Copyright (c) 2018 The MATRIX Authors +// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying -// file COPYING or or http://www.opensource.org/licenses/mit-license.php +// file COPYING or http://www.opensource.org/licenses/mit-license.php // Package utils contains internal helper functions for go-matrix commands. package utils @@ -168,6 +168,11 @@ var ( Usage: `Blockchain garbage collection mode ("full", "archive")`, Value: "archive", } + DbTableSizeFlag = cli.IntFlag{ + Name: "dbsize", + Usage: "db store size ", + Value: 2, + } LightServFlag = cli.IntFlag{ Name: "lightserv", Usage: "Maximum percentage of time allowed for serving LES requests (0-90)", diff --git a/snapshot/snapshot.go b/snapshot/snapshot.go index 91e8c26c..41c53891 100644 --- a/snapshot/snapshot.go +++ b/snapshot/snapshot.go @@ -17,13 +17,12 @@ SnapStartLimit=4 )*/ type SnapshotData struct { - CoinTries []state.CoinTrie - Td *big.Int - Block types.Block + CoinTries []state.CoinTrie + Td *big.Int + Block types.Block } type SnapshotDatas struct { Datas []SnapshotData OtherTries [][]state.CoinTrie } - diff --git a/trie/trie_test.go b/trie/trie_test.go index a05e7845..82ef6f7f 100644 --- a/trie/trie_test.go +++ b/trie/trie_test.go @@ -17,11 +17,11 @@ import ( "testing" "testing/quick" - "github.com/davecgh/go-spew/spew" "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/crypto" "github.com/MatrixAINetwork/go-matrix/mandb" "github.com/MatrixAINetwork/go-matrix/rlp" + "github.com/davecgh/go-spew/spew" ) func init() {