Compare commits
2 Commits
v1.4.14
...
stale-peer
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af34894fc3 | ||
|
|
7dcd01e9be |
17
CHANGELOG.md
17
CHANGELOG.md
@@ -1,21 +1,4 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
## v1.4.14
|
|
||||||
|
|
||||||
### BUGFIX
|
|
||||||
* [\#2643](https://github.com/bnb-chain/bsc/pull/2643)core: fix cache for receipts
|
|
||||||
* [\#2656](https://github.com/bnb-chain/bsc/pull/2656)ethclient: fix BlobSidecars api
|
|
||||||
* [\#2657](https://github.com/bnb-chain/bsc/pull/2657)fix: update prunefreezer’s offset when pruneancient and the dataset has pruned block
|
|
||||||
|
|
||||||
### FEATURE
|
|
||||||
* [\#2661](https://github.com/bnb-chain/bsc/pull/2661)config: setup Mainnet 2 hardfork date: HaberFix & Bohr
|
|
||||||
|
|
||||||
### IMPROVEMENT
|
|
||||||
* [\#2578](https://github.com/bnb-chain/bsc/pull/2578)core/systemcontracts: use vm.StateDB in UpgradeBuildInSystemContract
|
|
||||||
* [\#2649](https://github.com/bnb-chain/bsc/pull/2649)internal/debug: remove memsize
|
|
||||||
* [\#2655](https://github.com/bnb-chain/bsc/pull/2655)internal/ethapi: make GetFinalizedHeader monotonically increasing
|
|
||||||
* [\#2658](https://github.com/bnb-chain/bsc/pull/2658)core: improve readability of the fork choice logic
|
|
||||||
* [\#2665](https://github.com/bnb-chain/bsc/pull/2665)faucet: bump and resend faucet transaction if it has been pending for a while
|
|
||||||
|
|
||||||
## v1.4.13
|
## v1.4.13
|
||||||
|
|
||||||
### BUGFIX
|
### BUGFIX
|
||||||
|
|||||||
@@ -371,6 +371,8 @@ func geth(ctx *cli.Context) error {
|
|||||||
// it unlocks any requested accounts, and starts the RPC/IPC interfaces and the
|
// it unlocks any requested accounts, and starts the RPC/IPC interfaces and the
|
||||||
// miner.
|
// miner.
|
||||||
func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, isConsole bool) {
|
func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, isConsole bool) {
|
||||||
|
debug.Memsize.Add("node", stack)
|
||||||
|
|
||||||
// Start up the node itself
|
// Start up the node itself
|
||||||
utils.StartNode(ctx, stack, isConsole)
|
utils.StartNode(ctx, stack, isConsole)
|
||||||
|
|
||||||
|
|||||||
@@ -121,19 +121,12 @@ func (f *ForkChoice) ReorgNeeded(current *types.Header, extern *types.Header) (b
|
|||||||
if f.preserve != nil {
|
if f.preserve != nil {
|
||||||
currentPreserve, externPreserve = f.preserve(current), f.preserve(extern)
|
currentPreserve, externPreserve = f.preserve(current), f.preserve(extern)
|
||||||
}
|
}
|
||||||
choiceRules := func() bool {
|
doubleSign := (extern.Coinbase == current.Coinbase)
|
||||||
if extern.Time == current.Time {
|
reorg = !currentPreserve && (externPreserve ||
|
||||||
doubleSign := (extern.Coinbase == current.Coinbase)
|
extern.Time < current.Time ||
|
||||||
if doubleSign {
|
extern.Time == current.Time &&
|
||||||
return extern.Hash().Cmp(current.Hash()) < 0
|
((doubleSign && extern.Hash().Cmp(current.Hash()) < 0) ||
|
||||||
} else {
|
(!doubleSign && f.rand.Float64() < 0.5)))
|
||||||
return f.rand.Float64() < 0.5
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return extern.Time < current.Time
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reorg = !currentPreserve && (externPreserve || choiceRules())
|
|
||||||
}
|
}
|
||||||
return reorg, nil
|
return reorg, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ func newPrunedFreezer(datadir string, db ethdb.KeyValueStore, offset uint64) (*p
|
|||||||
|
|
||||||
// repair init frozen , compatible disk-ancientdb and pruner-block-tool.
|
// repair init frozen , compatible disk-ancientdb and pruner-block-tool.
|
||||||
func (f *prunedfreezer) repair(datadir string) error {
|
func (f *prunedfreezer) repair(datadir string) error {
|
||||||
offset := atomic.LoadUint64(&f.frozen)
|
|
||||||
// compatible freezer
|
// compatible freezer
|
||||||
minItems := uint64(math.MaxUint64)
|
minItems := uint64(math.MaxUint64)
|
||||||
for name, disableSnappy := range chainFreezerNoSnappy {
|
for name, disableSnappy := range chainFreezerNoSnappy {
|
||||||
@@ -97,14 +96,19 @@ func (f *prunedfreezer) repair(datadir string) error {
|
|||||||
table.Close()
|
table.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the dataset has undergone a prune block, the offset is a non-zero value, otherwise the offset is a zero value.
|
// If minItems is non-zero, it indicates that the chain freezer was previously enabled, and we should use minItems as the current frozen value.
|
||||||
// The minItems is the value relative to offset
|
// If minItems is zero, it indicates that the pruneAncient was previously enabled, and we should continue using frozen
|
||||||
offset += minItems
|
// (retrieved from CurrentAncientFreezer) as the current frozen value.
|
||||||
|
offset := minItems
|
||||||
|
if offset == 0 {
|
||||||
|
// no item in ancientDB, init `offset` to the `f.frozen`
|
||||||
|
offset = atomic.LoadUint64(&f.frozen)
|
||||||
|
}
|
||||||
|
log.Info("Read ancientdb item counts", "items", minItems, "offset", offset)
|
||||||
|
|
||||||
// FrozenOfAncientFreezer is the progress of the last prune-freezer freeze.
|
// FrozenOfAncientFreezer is the progress of the last prune-freezer freeze.
|
||||||
frozenInDB := ReadFrozenOfAncientFreezer(f.db)
|
frozenInDB := ReadFrozenOfAncientFreezer(f.db)
|
||||||
maxOffset := max(offset, frozenInDB)
|
maxOffset := max(offset, frozenInDB)
|
||||||
log.Info("Read ancient db item counts", "items", minItems, "frozen", maxOffset)
|
|
||||||
|
|
||||||
atomic.StoreUint64(&f.frozen, maxOffset)
|
atomic.StoreUint64(&f.frozen, maxOffset)
|
||||||
if err := f.Sync(); err != nil {
|
if err := f.Sync(); err != nil {
|
||||||
@@ -157,12 +161,12 @@ func (f *prunedfreezer) AncientOffSet() uint64 {
|
|||||||
|
|
||||||
// MigrateTable processes the entries in a given table in sequence
|
// MigrateTable processes the entries in a given table in sequence
|
||||||
// converting them to a new format if they're of an old format.
|
// converting them to a new format if they're of an old format.
|
||||||
func (f *prunedfreezer) MigrateTable(kind string, convert convertLegacyFn) error {
|
func (db *prunedfreezer) MigrateTable(kind string, convert convertLegacyFn) error {
|
||||||
return errNotSupported
|
return errNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
// AncientDatadir returns an error as we don't have a backing chain freezer.
|
// AncientDatadir returns an error as we don't have a backing chain freezer.
|
||||||
func (f *prunedfreezer) AncientDatadir() (string, error) {
|
func (db *prunedfreezer) AncientDatadir() (string, error) {
|
||||||
return "", errNotSupported
|
return "", errNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,10 @@ package types
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -55,40 +53,3 @@ func (s *BlobSidecar) SanityCheck(blockNumber *big.Int, blockHash common.Hash) e
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *BlobSidecar) MarshalJSON() ([]byte, error) {
|
|
||||||
fields := map[string]interface{}{
|
|
||||||
"blockHash": s.BlockHash,
|
|
||||||
"blockNumber": hexutil.EncodeUint64(s.BlockNumber.Uint64()),
|
|
||||||
"txHash": s.TxHash,
|
|
||||||
"txIndex": hexutil.EncodeUint64(s.TxIndex),
|
|
||||||
}
|
|
||||||
fields["blobSidecar"] = s.BlobTxSidecar
|
|
||||||
return json.Marshal(fields)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *BlobSidecar) UnmarshalJSON(input []byte) error {
|
|
||||||
type blobSidecar struct {
|
|
||||||
BlobSidecar BlobTxSidecar `json:"blobSidecar"`
|
|
||||||
BlockNumber *hexutil.Big `json:"blockNumber"`
|
|
||||||
BlockHash common.Hash `json:"blockHash"`
|
|
||||||
TxIndex *hexutil.Big `json:"txIndex"`
|
|
||||||
TxHash common.Hash `json:"txHash"`
|
|
||||||
}
|
|
||||||
var blob blobSidecar
|
|
||||||
if err := json.Unmarshal(input, &blob); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
s.BlobTxSidecar = blob.BlobSidecar
|
|
||||||
if blob.BlockNumber == nil {
|
|
||||||
return errors.New("missing required field 'blockNumber' for BlobSidecar")
|
|
||||||
}
|
|
||||||
s.BlockNumber = blob.BlockNumber.ToInt()
|
|
||||||
s.BlockHash = blob.BlockHash
|
|
||||||
if blob.TxIndex == nil {
|
|
||||||
return errors.New("missing required field 'txIndex' for BlobSidecar")
|
|
||||||
}
|
|
||||||
s.TxIndex = blob.TxIndex.ToInt().Uint64()
|
|
||||||
s.TxHash = blob.TxHash
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -441,14 +441,14 @@ func (b *EthAPIBackend) Engine() consensus.Engine {
|
|||||||
return b.eth.engine
|
return b.eth.engine
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *EthAPIBackend) CurrentValidators() ([]common.Address, error) {
|
func (b *EthAPIBackend) CurrentTurnLength() (turnLength uint8, err error) {
|
||||||
if p, ok := b.eth.engine.(*parlia.Parlia); ok {
|
if p, ok := b.eth.engine.(*parlia.Parlia); ok {
|
||||||
service := p.APIs(b.Chain())[0].Service
|
service := p.APIs(b.Chain())[0].Service
|
||||||
currentHead := rpc.LatestBlockNumber
|
currentHead := rpc.LatestBlockNumber
|
||||||
return service.(*parlia.API).GetValidators(¤tHead)
|
return service.(*parlia.API).GetTurnLength(¤tHead)
|
||||||
}
|
}
|
||||||
|
|
||||||
return []common.Address{}, errors.New("not supported")
|
return 1, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *EthAPIBackend) CurrentHeader() *types.Header {
|
func (b *EthAPIBackend) CurrentHeader() *types.Header {
|
||||||
|
|||||||
@@ -369,6 +369,7 @@ func newHandler(config *handlerConfig) (*handler, error) {
|
|||||||
}
|
}
|
||||||
h.txFetcher = fetcher.NewTxFetcher(h.txpool.Has, addTxs, fetchTx, h.removePeer)
|
h.txFetcher = fetcher.NewTxFetcher(h.txpool.Has, addTxs, fetchTx, h.removePeer)
|
||||||
h.chainSync = newChainSyncer(h)
|
h.chainSync = newChainSyncer(h)
|
||||||
|
h.printPeerStatus()
|
||||||
return h, nil
|
return h, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1017,3 +1018,67 @@ func (h *handler) enableSyncedFeatures() {
|
|||||||
// h.chain.TrieDB().SetBufferSize(pathdb.DefaultBufferSize)
|
// h.chain.TrieDB().SetBufferSize(pathdb.DefaultBufferSize)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PeerDummy struct {
|
||||||
|
ID string
|
||||||
|
Head common.Hash
|
||||||
|
TD *big.Int
|
||||||
|
TimeStamp time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *handler) printPeerStatus() {
|
||||||
|
go func() {
|
||||||
|
statusMap := make(map[string]PeerDummy)
|
||||||
|
for {
|
||||||
|
// run in timer very 1 minue of time
|
||||||
|
time.Sleep(1 * time.Minute)
|
||||||
|
// Create a set to track current peers
|
||||||
|
currentPeers := make(map[string]struct{})
|
||||||
|
// print peer status
|
||||||
|
h.peers.lock.RLock()
|
||||||
|
for _, peer := range h.peers.peers {
|
||||||
|
currentPeers[peer.Peer.ID()] = struct{}{}
|
||||||
|
head, td := peer.Peer.Head()
|
||||||
|
if p, ok := statusMap[peer.Peer.ID()]; ok {
|
||||||
|
if p.Head == head && p.TD.Cmp(td) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
p.Head = head
|
||||||
|
p.TD = td
|
||||||
|
p.TimeStamp = time.Now()
|
||||||
|
statusMap[peer.Peer.ID()] = p
|
||||||
|
} else {
|
||||||
|
statusMap[peer.Peer.ID()] = PeerDummy{
|
||||||
|
ID: peer.Peer.ID(),
|
||||||
|
Head: head,
|
||||||
|
TD: td,
|
||||||
|
TimeStamp: time.Now(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
h.peers.lock.RUnlock()
|
||||||
|
|
||||||
|
// Remove peers from statusMap that are no longer in h.peers.peers
|
||||||
|
for id := range statusMap {
|
||||||
|
if _, exists := currentPeers[id]; !exists {
|
||||||
|
delete(statusMap, id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var count int
|
||||||
|
for _, peer := range statusMap {
|
||||||
|
if peer.TimeStamp.Before(time.Now().Add(-60 * time.Minute)) {
|
||||||
|
count++
|
||||||
|
if count == 1 {
|
||||||
|
log.Warn("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
|
||||||
|
}
|
||||||
|
log.Warn("peer", peer.ID, "head", peer.Head, "TD", peer.TD, "TimeStamp", peer.TimeStamp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if count > 0 {
|
||||||
|
log.Warn("Total peers: ", len(statusMap), "inactive peers: ", count)
|
||||||
|
log.Warn("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|||||||
@@ -131,8 +131,8 @@ func (ec *Client) BlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumb
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BlobSidecars return the Sidecars of a given block number or hash.
|
// BlobSidecars return the Sidecars of a given block number or hash.
|
||||||
func (ec *Client) BlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]*types.BlobSidecar, error) {
|
func (ec *Client) BlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]*types.BlobTxSidecar, error) {
|
||||||
var r []*types.BlobSidecar
|
var r []*types.BlobTxSidecar
|
||||||
err := ec.c.CallContext(ctx, &r, "eth_getBlobSidecars", blockNrOrHash.String())
|
err := ec.c.CallContext(ctx, &r, "eth_getBlobSidecars", blockNrOrHash.String())
|
||||||
if err == nil && r == nil {
|
if err == nil && r == nil {
|
||||||
return nil, ethereum.NotFound
|
return nil, ethereum.NotFound
|
||||||
@@ -141,8 +141,8 @@ func (ec *Client) BlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumbe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BlobSidecarByTxHash return a sidecar of a given blob transaction
|
// BlobSidecarByTxHash return a sidecar of a given blob transaction
|
||||||
func (ec *Client) BlobSidecarByTxHash(ctx context.Context, hash common.Hash) (*types.BlobSidecar, error) {
|
func (ec *Client) BlobSidecarByTxHash(ctx context.Context, hash common.Hash) (*types.BlobTxSidecar, error) {
|
||||||
var r *types.BlobSidecar
|
var r *types.BlobTxSidecar
|
||||||
err := ec.c.CallContext(ctx, &r, "eth_getBlobSidecarByTxHash", hash)
|
err := ec.c.CallContext(ctx, &r, "eth_getBlobSidecarByTxHash", hash)
|
||||||
if err == nil && r == nil {
|
if err == nil && r == nil {
|
||||||
return nil, ethereum.NotFound
|
return nil, ethereum.NotFound
|
||||||
|
|||||||
1
go.mod
1
go.mod
@@ -27,6 +27,7 @@ require (
|
|||||||
github.com/fatih/color v1.16.0
|
github.com/fatih/color v1.16.0
|
||||||
github.com/fatih/structs v1.1.0
|
github.com/fatih/structs v1.1.0
|
||||||
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e
|
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e
|
||||||
|
github.com/fjl/memsize v0.0.2
|
||||||
github.com/fsnotify/fsnotify v1.6.0
|
github.com/fsnotify/fsnotify v1.6.0
|
||||||
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08
|
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08
|
||||||
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46
|
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -335,6 +335,8 @@ github.com/ferranbt/fastssz v0.0.0-20210905181407-59cf6761a7d5 h1:6dVcS0LktRSyEE
|
|||||||
github.com/ferranbt/fastssz v0.0.0-20210905181407-59cf6761a7d5/go.mod h1:S8yiDeAXy8f88W4Ul+0dBMPx49S05byYbmZD6Uv94K4=
|
github.com/ferranbt/fastssz v0.0.0-20210905181407-59cf6761a7d5/go.mod h1:S8yiDeAXy8f88W4Ul+0dBMPx49S05byYbmZD6Uv94K4=
|
||||||
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e h1:bBLctRc7kr01YGvaDfgLbTwjFNW5jdp5y5rj8XXBHfY=
|
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e h1:bBLctRc7kr01YGvaDfgLbTwjFNW5jdp5y5rj8XXBHfY=
|
||||||
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY=
|
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY=
|
||||||
|
github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA=
|
||||||
|
github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
|
||||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||||
github.com/flynn/noise v1.1.0 h1:KjPQoQCEFdZDiP03phOvGi11+SVVhBG2wOWAorLsstg=
|
github.com/flynn/noise v1.1.0 h1:KjPQoQCEFdZDiP03phOvGi11+SVVhBG2wOWAorLsstg=
|
||||||
github.com/flynn/noise v1.1.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag=
|
github.com/flynn/noise v1.1.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag=
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/metrics"
|
"github.com/ethereum/go-ethereum/metrics"
|
||||||
"github.com/ethereum/go-ethereum/metrics/exp"
|
"github.com/ethereum/go-ethereum/metrics/exp"
|
||||||
|
"github.com/fjl/memsize/memsizeui"
|
||||||
"github.com/mattn/go-colorable"
|
"github.com/mattn/go-colorable"
|
||||||
"github.com/mattn/go-isatty"
|
"github.com/mattn/go-isatty"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
@@ -37,6 +38,8 @@ import (
|
|||||||
"gopkg.in/natefinch/lumberjack.v2"
|
"gopkg.in/natefinch/lumberjack.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var Memsize memsizeui.Handler
|
||||||
|
|
||||||
var (
|
var (
|
||||||
verbosityFlag = &cli.IntFlag{
|
verbosityFlag = &cli.IntFlag{
|
||||||
Name: "verbosity",
|
Name: "verbosity",
|
||||||
@@ -310,6 +313,7 @@ func StartPProf(address string, withMetrics bool) {
|
|||||||
if withMetrics {
|
if withMetrics {
|
||||||
exp.Exp(metrics.DefaultRegistry)
|
exp.Exp(metrics.DefaultRegistry)
|
||||||
}
|
}
|
||||||
|
http.Handle("/memsize/", http.StripPrefix("/memsize", &Memsize))
|
||||||
log.Info("Starting pprof server", "addr", fmt.Sprintf("http://%s/debug/pprof", address))
|
log.Info("Starting pprof server", "addr", fmt.Sprintf("http://%s/debug/pprof", address))
|
||||||
go func() {
|
go func() {
|
||||||
if err := http.ListenAndServe(address, nil); err != nil {
|
if err := http.ListenAndServe(address, nil); err != nil {
|
||||||
|
|||||||
@@ -862,72 +862,54 @@ func (s *BlockChainAPI) Health() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *BlockChainAPI) getFinalizedNumber(ctx context.Context, verifiedValidatorNum int64) (int64, error) {
|
// GetFinalizedHeader returns the requested finalized block header.
|
||||||
parliaConfig := s.b.ChainConfig().Parlia
|
// - probabilisticFinalized should be in range [2,21],
|
||||||
if parliaConfig == nil {
|
// then the block header with number `max(fastFinalized, latest-probabilisticFinalized)` is returned
|
||||||
return 0, fmt.Errorf("only parlia engine supported")
|
func (s *BlockChainAPI) GetFinalizedHeader(ctx context.Context, probabilisticFinalized int64) (map[string]interface{}, error) {
|
||||||
|
if probabilisticFinalized < 2 || probabilisticFinalized > 21 {
|
||||||
|
return nil, fmt.Errorf("%d out of range [2,21]", probabilisticFinalized)
|
||||||
}
|
}
|
||||||
|
|
||||||
curValidators, err := s.b.CurrentValidators()
|
currentTurnLength, err := s.b.CurrentTurnLength()
|
||||||
if err != nil { // impossible
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
valLen := int64(len(curValidators))
|
|
||||||
if verifiedValidatorNum < 1 || verifiedValidatorNum > valLen {
|
|
||||||
return 0, fmt.Errorf("%d out of range [1,%d]", verifiedValidatorNum, valLen)
|
|
||||||
}
|
|
||||||
|
|
||||||
fastFinalizedHeader, err := s.b.HeaderByNumber(ctx, rpc.FinalizedBlockNumber)
|
|
||||||
if err != nil { // impossible
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
latestHeader, err := s.b.HeaderByNumber(ctx, rpc.LatestBlockNumber)
|
|
||||||
if err != nil { // impossible
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
lastHeader := latestHeader
|
|
||||||
confirmedValSet := make(map[common.Address]struct{}, valLen)
|
|
||||||
confirmedValSet[lastHeader.Coinbase] = struct{}{}
|
|
||||||
for count := 1; int64(len(confirmedValSet)) < verifiedValidatorNum && count <= int(parliaConfig.Epoch) && lastHeader.Number.Int64() > max(fastFinalizedHeader.Number.Int64(), 1); count++ {
|
|
||||||
lastHeader, err = s.b.HeaderByHash(ctx, lastHeader.ParentHash)
|
|
||||||
if err != nil { // impossible
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
confirmedValSet[lastHeader.Coinbase] = struct{}{}
|
|
||||||
}
|
|
||||||
|
|
||||||
finalizedBlockNumber := max(fastFinalizedHeader.Number.Int64(), lastHeader.Number.Int64())
|
|
||||||
log.Debug("getFinalizedNumber", "LatestBlockNumber", latestHeader.Number.Int64(), "fastFinalizedHeight", fastFinalizedHeader.Number.Int64(),
|
|
||||||
"lastHeader", lastHeader.Number.Int64(), "finalizedBlockNumber", finalizedBlockNumber, "len(confirmedValSet)", len(confirmedValSet))
|
|
||||||
|
|
||||||
return finalizedBlockNumber, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetFinalizedHeader returns the finalized block header based on the specified parameters.
|
|
||||||
// - `verifiedValidatorNum` must be within the range [1, len(currentValidators)].
|
|
||||||
// - The function calculates `probabilisticFinalizedHeight` as the highest height of the block verified by `verifiedValidatorNum` validators,
|
|
||||||
// it then returns the block header with a height equal to `max(fastFinalizedHeight, probabilisticFinalizedHeight)`.
|
|
||||||
// - The height of the returned block header is guaranteed to be monotonically increasing.
|
|
||||||
func (s *BlockChainAPI) GetFinalizedHeader(ctx context.Context, verifiedValidatorNum int64) (map[string]interface{}, error) {
|
|
||||||
finalizedBlockNumber, err := s.getFinalizedNumber(ctx, verifiedValidatorNum)
|
|
||||||
if err != nil { // impossible
|
if err != nil { // impossible
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
fastFinalizedHeader, err := s.b.HeaderByNumber(ctx, rpc.FinalizedBlockNumber)
|
||||||
|
if err != nil { // impossible
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
latestHeader, err := s.b.HeaderByNumber(ctx, rpc.LatestBlockNumber)
|
||||||
|
if err != nil { // impossible
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
finalizedBlockNumber := max(fastFinalizedHeader.Number.Int64(), latestHeader.Number.Int64()-probabilisticFinalized*int64(currentTurnLength))
|
||||||
|
|
||||||
return s.GetHeaderByNumber(ctx, rpc.BlockNumber(finalizedBlockNumber))
|
return s.GetHeaderByNumber(ctx, rpc.BlockNumber(finalizedBlockNumber))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFinalizedBlock returns the finalized block based on the specified parameters.
|
// GetFinalizedBlock returns the requested finalized block.
|
||||||
// - `verifiedValidatorNum` must be within the range [1, len(currentValidators)].
|
// - probabilisticFinalized should be in range [2,21],
|
||||||
// - The function calculates `probabilisticFinalizedHeight` as the highest height of the block verified by `verifiedValidatorNum` validators,
|
// then the block with number `max(fastFinalized, latest-probabilisticFinalized)` is returned
|
||||||
// it then returns the block with a height equal to `max(fastFinalizedHeight, probabilisticFinalizedHeight)`.
|
// - When fullTx is true all transactions in the block are returned, otherwise
|
||||||
// - If `fullTx` is true, the block includes all transactions; otherwise, only transaction hashes are included.
|
// only the transaction hash is returned.
|
||||||
// - The height of the returned block is guaranteed to be monotonically increasing.
|
func (s *BlockChainAPI) GetFinalizedBlock(ctx context.Context, probabilisticFinalized int64, fullTx bool) (map[string]interface{}, error) {
|
||||||
func (s *BlockChainAPI) GetFinalizedBlock(ctx context.Context, verifiedValidatorNum int64, fullTx bool) (map[string]interface{}, error) {
|
if probabilisticFinalized < 2 || probabilisticFinalized > 21 {
|
||||||
finalizedBlockNumber, err := s.getFinalizedNumber(ctx, verifiedValidatorNum)
|
return nil, fmt.Errorf("%d out of range [2,21]", probabilisticFinalized)
|
||||||
|
}
|
||||||
|
|
||||||
|
currentTurnLength, err := s.b.CurrentTurnLength()
|
||||||
if err != nil { // impossible
|
if err != nil { // impossible
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
fastFinalizedHeader, err := s.b.HeaderByNumber(ctx, rpc.FinalizedBlockNumber)
|
||||||
|
if err != nil { // impossible
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
latestHeader, err := s.b.HeaderByNumber(ctx, rpc.LatestBlockNumber)
|
||||||
|
if err != nil { // impossible
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
finalizedBlockNumber := max(fastFinalizedHeader.Number.Int64(), latestHeader.Number.Int64()-probabilisticFinalized*int64(currentTurnLength))
|
||||||
|
|
||||||
return s.GetBlockByNumber(ctx, rpc.BlockNumber(finalizedBlockNumber), fullTx)
|
return s.GetBlockByNumber(ctx, rpc.BlockNumber(finalizedBlockNumber), fullTx)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -631,9 +631,9 @@ func (b testBackend) TxPoolContentFrom(addr common.Address) ([]*types.Transactio
|
|||||||
func (b testBackend) SubscribeNewTxsEvent(events chan<- core.NewTxsEvent) event.Subscription {
|
func (b testBackend) SubscribeNewTxsEvent(events chan<- core.NewTxsEvent) event.Subscription {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
func (b testBackend) ChainConfig() *params.ChainConfig { return b.chain.Config() }
|
func (b testBackend) ChainConfig() *params.ChainConfig { return b.chain.Config() }
|
||||||
func (b testBackend) Engine() consensus.Engine { return b.chain.Engine() }
|
func (b testBackend) Engine() consensus.Engine { return b.chain.Engine() }
|
||||||
func (b testBackend) CurrentValidators() ([]common.Address, error) { return []common.Address{}, nil }
|
func (b testBackend) CurrentTurnLength() (uint8, error) { return 1, nil }
|
||||||
func (b testBackend) GetLogs(ctx context.Context, blockHash common.Hash, number uint64) ([][]*types.Log, error) {
|
func (b testBackend) GetLogs(ctx context.Context, blockHash common.Hash, number uint64) ([][]*types.Log, error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,8 +89,8 @@ type Backend interface {
|
|||||||
|
|
||||||
ChainConfig() *params.ChainConfig
|
ChainConfig() *params.ChainConfig
|
||||||
Engine() consensus.Engine
|
Engine() consensus.Engine
|
||||||
// CurrentValidators return the list of validator at the latest block
|
// CurrentTurnLength return the turnLength at the latest block
|
||||||
CurrentValidators() ([]common.Address, error)
|
CurrentTurnLength() (uint8, error)
|
||||||
|
|
||||||
// This is copied from filters.Backend
|
// This is copied from filters.Backend
|
||||||
// eth/filters needs to be initialized from this backend type, so methods needed by
|
// eth/filters needs to be initialized from this backend type, so methods needed by
|
||||||
|
|||||||
@@ -416,7 +416,7 @@ func (b *backendMock) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent)
|
|||||||
|
|
||||||
func (b *backendMock) Engine() consensus.Engine { return nil }
|
func (b *backendMock) Engine() consensus.Engine { return nil }
|
||||||
|
|
||||||
func (b *backendMock) CurrentValidators() ([]common.Address, error) { return []common.Address{}, nil }
|
func (b *backendMock) CurrentTurnLength() (uint8, error) { return 1, nil }
|
||||||
|
|
||||||
func (b *backendMock) MevRunning() bool { return false }
|
func (b *backendMock) MevRunning() bool { return false }
|
||||||
func (b *backendMock) HasBuilder(builder common.Address) bool { return false }
|
func (b *backendMock) HasBuilder(builder common.Address) bool { return false }
|
||||||
|
|||||||
@@ -153,8 +153,8 @@ var (
|
|||||||
FeynmanFixTime: newUint64(1713419340), // 2024-04-18 05:49:00 AM UTC
|
FeynmanFixTime: newUint64(1713419340), // 2024-04-18 05:49:00 AM UTC
|
||||||
CancunTime: newUint64(1718863500), // 2024-06-20 06:05:00 AM UTC
|
CancunTime: newUint64(1718863500), // 2024-06-20 06:05:00 AM UTC
|
||||||
HaberTime: newUint64(1718863500), // 2024-06-20 06:05:00 AM UTC
|
HaberTime: newUint64(1718863500), // 2024-06-20 06:05:00 AM UTC
|
||||||
HaberFixTime: newUint64(1727316120), // 2024-09-26 02:02:00 AM UTC
|
HaberFixTime: nil, // TBD
|
||||||
BohrTime: newUint64(1727317200), // 2024-09-26 02:20:00 AM UTC
|
BohrTime: nil,
|
||||||
|
|
||||||
Parlia: &ParliaConfig{
|
Parlia: &ParliaConfig{
|
||||||
Period: 3,
|
Period: 3,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
VersionMajor = 1 // Major version component of the current release
|
VersionMajor = 1 // Major version component of the current release
|
||||||
VersionMinor = 4 // Minor version component of the current release
|
VersionMinor = 4 // Minor version component of the current release
|
||||||
VersionPatch = 14 // Patch version component of the current release
|
VersionPatch = 13 // Patch version component of the current release
|
||||||
VersionMeta = "" // Version metadata to append to the version string
|
VersionMeta = "" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user