|
|
|
package apiv1
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"math/big"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/ethereum/go-ethereum/ethdb"
|
|
|
|
"github.com/ethereum/go-ethereum/event"
|
|
|
|
"github.com/ethereum/go-ethereum/rpc"
|
|
|
|
"github.com/harmony-one/harmony/block"
|
|
|
|
"github.com/harmony-one/harmony/consensus/quorum"
|
|
|
|
"github.com/harmony-one/harmony/core"
|
|
|
|
"github.com/harmony-one/harmony/core/state"
|
|
|
|
"github.com/harmony-one/harmony/core/types"
|
|
|
|
"github.com/harmony-one/harmony/core/vm"
|
|
|
|
"github.com/harmony-one/harmony/internal/params"
|
|
|
|
"github.com/harmony-one/harmony/shard"
|
[rpc][availability][apr] Richer validator information, implement APR, unify EPoS computation, remove fall 2019 tech debt (#2484)
* [rpc][validator] Extend hmy blockchain validator information
* [availability] Optimize bump count
* [staking][validator][rpc] Remove validator stats rpc, fold into validator information, make existing pattern default behavior
* [slash] Reimplement SetDifference
* [reward][engine][network] Remove bad API from fall, begin setup for Per validator awards
* [header] Custom Marshal header for downstream, remove dev code
* [effective][committee] Factor out EPoS round of computation thereby unification in codebase of EPoS
* [unit-test] Fix semantically wrong validator unit tests, punt on maxBLS key wrt tx-pool test
* [reward] Use excellent singleflight package for caching lookup of subcommittees
* [apr][reward] Begin APR package itself, iterate on iterface signatures
* [reward] Handle possible error from singleflight
* [rpc][validator][reward] Adjust RPC committees, singleflight on votingPower, foldStats into Validator Information
* [apr] Stub out computation of APR
* [effective][committee] Upgrade SlotPurchase with named fields, provide marshal
* [effective] Update Tests
* [blockchain] TODO Remove the validators no longer in committee
* [validator][effective] More expressive string representation of eligibilty, ValidatorRPC explicit say if in committee now
* [rpc] Median-stake more semantic meaningful
* [validator] Iterate on semantic meaning of JSON representation
* [offchain] Make validator stats return explicit error
* [availability] Small typo
* [rpc] Quick visual hack until fix delete out kicked out validators
* [offchain] Delete validator from offchain that lost their slot
* [apr] Forgot to update interface signature
* [apr] Mul instead of Div
* [protocol][validator] Fold block reward accum per vaidator into validator-wrapper, off-chain => on-chain
* [votepower] Refactor votepower Roster, simplify aggregation of network wide rosters
* [votepower][shard] Adjust roster, optimize usage of BLSPublicKey as key, use MarshalText trick
* [shard] Granular errors
* [votepower][validator] Unify votepower data structure with off-chain usage
* [votepower][consensus][validator] Further simplify and unify votepower with off-chain, validator stats
* [votepower] Use RJs naming convention group,overall
* [votepower] Remove Println, do keep enforcing order
* [effective][reward] Expand semantics of eligibility as it was overloaded and confusing, evict old voting power computations
* [apr] Adjust json field name
* [votepower] Only aggregate on external validator
* [votepower] Mistake on aggregation, custom presentation network-wide
* [rpc][validator][availability] Remove parameter, take into account empty snapshot
* [apr] Use snapshots from two, one epochs ago. Still have question on header
* [apr] Use GetHeaderByNumber for the header needed for time stamp
* [chain] Evict > 3 epoch old voting power
* [blockchain] Leave Delete Validator snapshot as TODO
* [validator][rpc][effective] Undo changes to Protocol field, use virtual construct at RPC layer for meaning
* [project] Address PR comments
* [committee][rpc] Move +1 to computation of epos round rather than hack mutation
* [reward] Remove entire unnecessary loop, hook on AddReward. Remove unnecessary new big int
* [votepower][rpc][validator] Stick with numeric.Dec for token involved with computation, expose accumulate block-reward in RPC
* [effective][committee] Track the candidates for the EPoS auction, RPC median-stake benefits
* [node] Add hack way to get real error reason of why cannot load shardchain
* [consensus] Expand log on current issue on nil block
* [apr] Do the actual call to compute for validator's APR
* [committee] Wrap SlotOrder with validator address, manifests in median-stake RPC
* [apr] Incorrect error handle order
* [quorum] Remove incorrect compare on bls Key, (typo), remove redundant error check
* [shard] Add log if stakedSlots is 0
* [apr] More sanity check on div by zero, more lenient on error when dont have historical data yet
* [committee] Remove + 1 on seat count
* [apr] Use int64() directly
* [apr] Log when odd empty nil header
* [apr] Do not crash on empty header, figure out later
5 years ago
|
|
|
"github.com/harmony-one/harmony/shard/committee"
|
|
|
|
"github.com/harmony-one/harmony/staking/network"
|
|
|
|
staking "github.com/harmony-one/harmony/staking/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Backend interface provides the common API services (that are provided by
|
|
|
|
// both full and light clients) with access to necessary functions.
|
|
|
|
// implementations:
|
|
|
|
// * hmy/api_backend.go
|
|
|
|
type Backend interface {
|
|
|
|
NetVersion() uint64
|
|
|
|
ProtocolVersion() int
|
|
|
|
ChainDb() ethdb.Database
|
|
|
|
EventMux() *event.TypeMux
|
|
|
|
RPCGasCap() *big.Int // global gas cap for hmy_call over rpc: DoS protection
|
|
|
|
HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*block.Header, error)
|
|
|
|
BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Block, error)
|
|
|
|
StateAndHeaderByNumber(
|
|
|
|
ctx context.Context, blockNr rpc.BlockNumber,
|
|
|
|
) (*state.DB, *block.Header, error)
|
|
|
|
GetBlock(ctx context.Context, blockHash common.Hash) (*types.Block, error)
|
|
|
|
GetReceipts(ctx context.Context, blockHash common.Hash) (types.Receipts, error)
|
|
|
|
|
|
|
|
GetEVM(ctx context.Context, msg core.Message, state *state.DB, header *block.Header) (*vm.EVM, func() error, error)
|
|
|
|
SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription
|
|
|
|
SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription
|
|
|
|
SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription
|
|
|
|
// TxPool API
|
|
|
|
SendTx(ctx context.Context, signedTx *types.Transaction) error
|
|
|
|
// GetTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error)
|
|
|
|
GetPoolTransactions() (types.PoolTransactions, error)
|
|
|
|
GetPoolTransaction(txHash common.Hash) types.PoolTransaction
|
|
|
|
GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)
|
|
|
|
// Stats() (pending int, queued int)
|
|
|
|
// TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
|
|
|
|
SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription
|
|
|
|
ChainConfig() *params.ChainConfig
|
|
|
|
CurrentBlock() *types.Block
|
|
|
|
// Get balance
|
|
|
|
GetBalance(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (*big.Int, error)
|
|
|
|
// Get validators for a particular epoch
|
|
|
|
GetValidators(epoch *big.Int) (*shard.Committee, error)
|
|
|
|
GetShardID() uint32
|
|
|
|
// Get transactions history for an address
|
|
|
|
GetTransactionsHistory(address, txType, order string) ([]common.Hash, error)
|
|
|
|
// Get staking transactions history for an address
|
|
|
|
GetStakingTransactionsHistory(address, txType, order string) ([]common.Hash, error)
|
|
|
|
// retrieve the blockHash using txID and add blockHash to CxPool for resending
|
|
|
|
ResendCx(ctx context.Context, txID common.Hash) (uint64, bool)
|
|
|
|
IsLeader() bool
|
|
|
|
SendStakingTx(ctx context.Context, newStakingTx *staking.StakingTransaction) error
|
|
|
|
GetElectedValidatorAddresses() []common.Address
|
|
|
|
GetAllValidatorAddresses() []common.Address
|
|
|
|
GetValidatorInformation(addr common.Address, block *types.Block) (*staking.ValidatorRPCEnchanced, error)
|
|
|
|
GetDelegationsByValidator(validator common.Address) []*staking.Delegation
|
|
|
|
GetDelegationsByDelegator(delegator common.Address) ([]common.Address, []*staking.Delegation)
|
|
|
|
GetValidatorSelfDelegation(addr common.Address) *big.Int
|
|
|
|
GetShardState() (*shard.State, error)
|
|
|
|
GetCurrentStakingErrorSink() []staking.RPCTransactionError
|
|
|
|
GetCurrentTransactionErrorSink() []types.RPCTransactionError
|
[rpc][availability][apr] Richer validator information, implement APR, unify EPoS computation, remove fall 2019 tech debt (#2484)
* [rpc][validator] Extend hmy blockchain validator information
* [availability] Optimize bump count
* [staking][validator][rpc] Remove validator stats rpc, fold into validator information, make existing pattern default behavior
* [slash] Reimplement SetDifference
* [reward][engine][network] Remove bad API from fall, begin setup for Per validator awards
* [header] Custom Marshal header for downstream, remove dev code
* [effective][committee] Factor out EPoS round of computation thereby unification in codebase of EPoS
* [unit-test] Fix semantically wrong validator unit tests, punt on maxBLS key wrt tx-pool test
* [reward] Use excellent singleflight package for caching lookup of subcommittees
* [apr][reward] Begin APR package itself, iterate on iterface signatures
* [reward] Handle possible error from singleflight
* [rpc][validator][reward] Adjust RPC committees, singleflight on votingPower, foldStats into Validator Information
* [apr] Stub out computation of APR
* [effective][committee] Upgrade SlotPurchase with named fields, provide marshal
* [effective] Update Tests
* [blockchain] TODO Remove the validators no longer in committee
* [validator][effective] More expressive string representation of eligibilty, ValidatorRPC explicit say if in committee now
* [rpc] Median-stake more semantic meaningful
* [validator] Iterate on semantic meaning of JSON representation
* [offchain] Make validator stats return explicit error
* [availability] Small typo
* [rpc] Quick visual hack until fix delete out kicked out validators
* [offchain] Delete validator from offchain that lost their slot
* [apr] Forgot to update interface signature
* [apr] Mul instead of Div
* [protocol][validator] Fold block reward accum per vaidator into validator-wrapper, off-chain => on-chain
* [votepower] Refactor votepower Roster, simplify aggregation of network wide rosters
* [votepower][shard] Adjust roster, optimize usage of BLSPublicKey as key, use MarshalText trick
* [shard] Granular errors
* [votepower][validator] Unify votepower data structure with off-chain usage
* [votepower][consensus][validator] Further simplify and unify votepower with off-chain, validator stats
* [votepower] Use RJs naming convention group,overall
* [votepower] Remove Println, do keep enforcing order
* [effective][reward] Expand semantics of eligibility as it was overloaded and confusing, evict old voting power computations
* [apr] Adjust json field name
* [votepower] Only aggregate on external validator
* [votepower] Mistake on aggregation, custom presentation network-wide
* [rpc][validator][availability] Remove parameter, take into account empty snapshot
* [apr] Use snapshots from two, one epochs ago. Still have question on header
* [apr] Use GetHeaderByNumber for the header needed for time stamp
* [chain] Evict > 3 epoch old voting power
* [blockchain] Leave Delete Validator snapshot as TODO
* [validator][rpc][effective] Undo changes to Protocol field, use virtual construct at RPC layer for meaning
* [project] Address PR comments
* [committee][rpc] Move +1 to computation of epos round rather than hack mutation
* [reward] Remove entire unnecessary loop, hook on AddReward. Remove unnecessary new big int
* [votepower][rpc][validator] Stick with numeric.Dec for token involved with computation, expose accumulate block-reward in RPC
* [effective][committee] Track the candidates for the EPoS auction, RPC median-stake benefits
* [node] Add hack way to get real error reason of why cannot load shardchain
* [consensus] Expand log on current issue on nil block
* [apr] Do the actual call to compute for validator's APR
* [committee] Wrap SlotOrder with validator address, manifests in median-stake RPC
* [apr] Incorrect error handle order
* [quorum] Remove incorrect compare on bls Key, (typo), remove redundant error check
* [shard] Add log if stakedSlots is 0
* [apr] More sanity check on div by zero, more lenient on error when dont have historical data yet
* [committee] Remove + 1 on seat count
* [apr] Use int64() directly
* [apr] Log when odd empty nil header
* [apr] Do not crash on empty header, figure out later
5 years ago
|
|
|
GetMedianRawStakeSnapshot() (*committee.CompletedEPoSRound, error)
|
|
|
|
GetPendingCXReceipts() []*types.CXReceiptsProof
|
|
|
|
GetCurrentUtilityMetrics() (*network.UtilityMetric, error)
|
|
|
|
GetSuperCommittees() (*quorum.Transition, error)
|
|
|
|
GetTotalStakingSnapshot() *big.Int
|
|
|
|
GetCurrentBadBlocks() []core.BadBlock
|
|
|
|
GetLastCrossLinks() ([]*types.CrossLink, error)
|
|
|
|
GetLatestChainHeaders() *block.HeaderPair
|
|
|
|
}
|