Merge 'master' into 'v0.2.16-candidate'

This commit is contained in:
Manav Darji 2022-04-26 17:21:51 +05:30
commit 0525715949
9 changed files with 65 additions and 30 deletions

View file

@ -146,7 +146,7 @@ func remoteConsole(ctx *cli.Context) error {
path = filepath.Join(path, "sepolia")
}
}
endpoint = fmt.Sprintf("%s/geth.ipc", path)
endpoint = fmt.Sprintf("%s/bor.ipc", path)
}
client, err := dialRPC(endpoint)
if err != nil {

View file

@ -242,7 +242,7 @@ var (
}
TxLookupLimitFlag = cli.Uint64Flag{
Name: "txlookuplimit",
Usage: "Number of recent blocks to maintain transactions index for (default = about one year, 0 = entire chain)",
Usage: "Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain)",
Value: ethconfig.Defaults.TxLookupLimit,
}
LightKDFFlag = cli.BoolFlag{

View file

@ -113,7 +113,7 @@ func (h *HeimdallClient) FetchWithRetry(rawPath string, rawQuery string) (*Respo
if err == nil && res != nil {
return res, nil
}
log.Info("Retrying again in 5 seconds for next Heimdall data", "path", u.Path)
log.Info("Retrying again in 5 seconds to fetch data from Heimdall", "path", u.Path)
}
}
}

View file

@ -1381,12 +1381,6 @@ func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types
for _, data := range bc.stateSyncData {
bc.stateSyncFeed.Send(StateSyncEvent{Data: data})
}
bc.chain2HeadFeed.Send(Chain2HeadEvent{
Type: Chain2HeadCanonicalEvent,
NewChain: []*types.Block{block},
})
// BOR
}
} else {
@ -1479,11 +1473,6 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool)
defer func() {
if lastCanon != nil && bc.CurrentBlock().Hash() == lastCanon.Hash() {
bc.chainHeadFeed.Send(ChainHeadEvent{lastCanon})
bc.chain2HeadFeed.Send(Chain2HeadEvent{
Type: Chain2HeadCanonicalEvent,
NewChain: []*types.Block{lastCanon},
})
}
}()
// Start the parallel header verifier
@ -1599,6 +1588,22 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool)
}
}()
// accumulator for canonical blocks
var canonAccum []*types.Block
emitAccum := func() {
size := len(canonAccum)
if size == 0 || size > 5 {
// avoid reporting events for large sync events
return
}
bc.chain2HeadFeed.Send(Chain2HeadEvent{
Type: Chain2HeadCanonicalEvent,
NewChain: canonAccum,
})
canonAccum = canonAccum[:0]
}
for ; block != nil && err == nil || errors.Is(err, ErrKnownBlock); block, err = it.next() {
// If the chain is terminating, stop processing blocks
if bc.insertStopped() {
@ -1755,6 +1760,15 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool)
if !setHead {
return it.index, nil // Direct block insertion of a single block
}
// BOR
if status == CanonStatTy {
canonAccum = append(canonAccum, block)
} else {
emitAccum()
}
// BOR
switch status {
case CanonStatTy:
log.Debug("Inserted new block", "number", block.Number(), "hash", block.Hash(),
@ -1783,6 +1797,10 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool)
}
}
// BOR
emitAccum()
// BOR
// Any blocks remaining here? The only ones we care about are the future ones
if block != nil && errors.Is(err, consensus.ErrFutureBlock) {
if err := bc.addFutureBlock(block); err != nil {

View file

@ -80,7 +80,7 @@ func TestChain2HeadEvent(t *testing.T) {
}
for j := 0; j < len(ev.NewChain); j++ {
if ev.NewChain[j].Hash() != expect.Added[j] {
t.Fatal("Newchain hashes Do Not Match")
t.Fatalf("Newchain hashes Do Not Match %s %s", ev.NewChain[j].Hash(), expect.Added[j])
}
}
case <-time.After(2 * time.Second):
@ -92,6 +92,8 @@ func TestChain2HeadEvent(t *testing.T) {
readEvent(&eventTest{
Type: Chain2HeadCanonicalEvent,
Added: []common.Hash{
chain[0].Hash(),
chain[1].Hash(),
chain[2].Hash(),
}})
@ -129,6 +131,8 @@ func TestChain2HeadEvent(t *testing.T) {
readEvent(&eventTest{
Type: Chain2HeadCanonicalEvent,
Added: []common.Hash{
replacementBlocks[2].Hash(),
replacementBlocks[3].Hash(),
}})
}

View file

@ -93,7 +93,7 @@ The ```bor server``` command runs the Bor client.
- ```cache.preimages```: Enable recording the SHA3/keccak preimages of trie keys.
- ```txlookuplimit```: Number of recent blocks to maintain transactions index for (default = about one year, 0 = entire chain).
- ```txlookuplimit```: Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain).
### JsonRPC Options

View file

@ -133,9 +133,6 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface
if head.UncleHash != types.EmptyUncleHash && len(body.UncleHashes) == 0 {
return nil, fmt.Errorf("server returned empty uncle list but block header indicates uncles")
}
if head.TxHash == types.EmptyRootHash && len(body.Transactions) > 0 {
return nil, fmt.Errorf("server returned non-empty transaction list but block header indicates no transactions")
}
if head.TxHash != types.EmptyRootHash && len(body.Transactions) == 0 {
return nil, fmt.Errorf("server returned empty transaction list but block header indicates transactions")
}

View file

@ -86,6 +86,20 @@ type fullNodeBackend interface {
SuggestGasTipCap(ctx context.Context) (*big.Int, error)
}
type EthstatsDataType struct {
kv map[string]string
}
// Function to add data to EthstatsData
func (e *EthstatsDataType) AddKV(key, val string) {
e.kv[key] = val
}
// Arbitrary Data that can be included
var EthstatsData = &EthstatsDataType{
kv: make(map[string]string),
}
// Service implements an Ethereum netstats reporting daemon that pushes local
// chain statistics up to a monitoring server.
type Service struct {
@ -466,16 +480,17 @@ func (s *Service) readLoop(conn *connWrapper) {
// nodeInfo is the collection of meta information about a node that is displayed
// on the monitoring page.
type nodeInfo struct {
Name string `json:"name"`
Node string `json:"node"`
Port int `json:"port"`
Network string `json:"net"`
Protocol string `json:"protocol"`
API string `json:"api"`
Os string `json:"os"`
OsVer string `json:"os_v"`
Client string `json:"client"`
History bool `json:"canUpdateHistory"`
Name string `json:"name"`
Node string `json:"node"`
Port int `json:"port"`
Network string `json:"net"`
Protocol string `json:"protocol"`
API string `json:"api"`
Os string `json:"os"`
OsVer string `json:"os_v"`
Client string `json:"client"`
History bool `json:"canUpdateHistory"`
Data map[string]string `json:"data"`
}
// authMsg is the authentication infos needed to login to a monitoring server.
@ -513,6 +528,7 @@ func (s *Service) login(conn *connWrapper) error {
OsVer: runtime.GOARCH,
Client: "0.1.1",
History: true,
Data: EthstatsData.kv,
},
Secret: s.pass,
}

View file

@ -228,7 +228,7 @@ func (c *Command) Flags() *flagset.Flagset {
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "txlookuplimit",
Usage: "Number of recent blocks to maintain transactions index for (default = about one year, 0 = entire chain)",
Usage: "Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain)",
Value: &c.cliConfig.Cache.TxLookupLimit,
})