diff --git a/cmd/geth/consolecmd.go b/cmd/geth/consolecmd.go index 4364d1af3b..eb0878775c 100644 --- a/cmd/geth/consolecmd.go +++ b/cmd/geth/consolecmd.go @@ -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 { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index fc5c300ab4..e2bbdb17f8 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -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{ diff --git a/consensus/bor/rest.go b/consensus/bor/rest.go index f9ed4c489b..6460b75a3c 100644 --- a/consensus/bor/rest.go +++ b/consensus/bor/rest.go @@ -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) } } } diff --git a/core/blockchain.go b/core/blockchain.go index a57a2f7f78..1b11c781c5 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -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 { diff --git a/core/blockchain_bor_test.go b/core/blockchain_bor_test.go index 52f4f7cd83..1b0373c41a 100644 --- a/core/blockchain_bor_test.go +++ b/core/blockchain_bor_test.go @@ -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(), }}) + } diff --git a/docs/cli/server.md b/docs/cli/server.md index 14e645907b..5a3e7e1052 100644 --- a/docs/cli/server.md +++ b/docs/cli/server.md @@ -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 diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 82fc8d5681..6e8915358b 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -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") } diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go index e699846b76..b837e7669b 100644 --- a/ethstats/ethstats.go +++ b/ethstats/ethstats.go @@ -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, } diff --git a/internal/cli/server/flags.go b/internal/cli/server/flags.go index 925c4b397e..b8f6003420 100644 --- a/internal/cli/server/flags.go +++ b/internal/cli/server/flags.go @@ -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, })