From bb0e439bb615a94cb7d5f92ce570b2b46ff82bdf Mon Sep 17 00:00:00 2001 From: ian Date: Mon, 23 Aug 2021 23:13:08 +0800 Subject: [PATCH 1/6] ethclient: delete check empty tx root hash --- ethclient/ethclient.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index a17696356c..369d098f76 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -124,9 +124,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") } From b86a566f8ecdd7095ade325ce177d470847b0f18 Mon Sep 17 00:00:00 2001 From: chuwt Date: Fri, 29 Oct 2021 22:15:35 +0800 Subject: [PATCH 2/6] Fix default attach endpoint --- cmd/geth/consolecmd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/geth/consolecmd.go b/cmd/geth/consolecmd.go index 75f9a82aa8..3937da3032 100644 --- a/cmd/geth/consolecmd.go +++ b/cmd/geth/consolecmd.go @@ -139,7 +139,7 @@ func remoteConsole(ctx *cli.Context) error { path = filepath.Join(homeDir, "/.bor/data") } } - endpoint = fmt.Sprintf("%s/geth.ipc", path) + endpoint = fmt.Sprintf("%s/bor.ipc", path) } client, err := dialRPC(endpoint) if err != nil { From b02c742268c56cb9cfab82ebf5f16efd48ea0d96 Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Tue, 25 Jan 2022 12:52:25 +0000 Subject: [PATCH 3/6] Added arbitray data Ethstats --- ethstats/ethstats.go | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) 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, } From 44603dbaa9e3585232fb48eeb1cd5ed96c32e853 Mon Sep 17 00:00:00 2001 From: Jaynti Kanani Date: Wed, 20 Apr 2022 14:25:08 +0400 Subject: [PATCH 4/6] Update rest.go (#349) Co-authored-by: Krishna Upadhyaya --- consensus/bor/rest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) } } } From 65f4d27991886095fd171194cb1166d6d9fca0f9 Mon Sep 17 00:00:00 2001 From: SHIVAM SHARMA Date: Wed, 20 Apr 2022 16:15:21 +0530 Subject: [PATCH 5/6] Shivam/ethstats backend fix (#341) * Emit events for all blocks insertChain() * small fix * test-case-fix * Fix tests Co-authored-by: Ferran --- core/blockchain.go | 39 ++++++++++++++++++++++++++----------- core/blockchain_bor_test.go | 6 +++++- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 5bd2f93561..76c4b3cd3c 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1641,12 +1641,6 @@ func (bc *BlockChain) writeBlockWithState(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 { @@ -1749,11 +1743,6 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er 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 @@ -1853,6 +1842,22 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er } }() + // 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 || err == ErrKnownBlock; block, err = it.next() { // If the chain is terminating, stop processing blocks if bc.insertStopped() { @@ -1993,6 +1998,14 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er blockWriteTimer.Update(time.Since(substart) - statedb.AccountCommits - statedb.StorageCommits - statedb.SnapshotCommits) blockInsertTimer.UpdateSince(start) + // 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(), @@ -2026,6 +2039,10 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er stats.report(chain, it.index, dirty) } + // 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(), }}) + } From d561a25739a44e370b34b6a75c458e3d9a8dd42e Mon Sep 17 00:00:00 2001 From: shiziwen Date: Wed, 20 Apr 2022 18:46:11 +0800 Subject: [PATCH 6/6] fix: modify the comment of txlookuplimit (#344) --- cmd/utils/flags.go | 2 +- docs/cli/server.md | 2 +- internal/cli/server/flags.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index c0db932dd7..0c71a157aa 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -227,7 +227,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/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/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, })