Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport master to develop after v1.0.4 #1013

Merged
merged 19 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2195,7 +2195,7 @@ func RegisterFilterAPI(stack *node.Node, backend ethapi.Backend, ethcfg *ethconf
LogCacheSize: ethcfg.FilterLogCacheSize,
})

filterAPI := filters.NewFilterAPI(filterSystem, isLightClient, ethconfig.Defaults.BorLogs)
filterAPI := filters.NewFilterAPI(filterSystem, isLightClient, ethcfg.BorLogs)
stack.RegisterAPIs([]rpc.API{{
Namespace: "eth",
Service: filterAPI,
Expand Down
3 changes: 3 additions & 0 deletions core/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,9 @@ func (pool *TxPool) validateTxBasics(tx *types.Transaction, local bool) error {
// return core.ErrInsufficientFunds
// }
// Verify that replacing transactions will not result in overdraft
pool.pendingMu.RLock()
defer pool.pendingMu.RUnlock()

list := pool.pending[from]
if list != nil { // Sender already has pending txs
sum := new(big.Int).Add(tx.Cost(), list.totalcost)
Expand Down
54 changes: 46 additions & 8 deletions internal/cli/bootnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ import (
"errors"
"fmt"
"net"
"net/http"
"os"
"os/signal"
"path/filepath"
"strings"
"syscall"
"time"

"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/internal/cli/flagset"
"github.com/ethereum/go-ethereum/internal/cli/server"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/metrics/prometheus"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/p2p/nat"
Expand All @@ -26,14 +30,16 @@ import (
type BootnodeCommand struct {
UI cli.Ui

listenAddr string
v5 bool
verbosity int
logLevel string
nat string
nodeKey string
saveKey string
dryRun bool
listenAddr string
enableMetrics bool
prometheusAddr string
v5 bool
verbosity int
logLevel string
nat string
nodeKey string
saveKey string
dryRun bool
}

// Help implements the cli.Command interface
Expand All @@ -60,6 +66,18 @@ func (b *BootnodeCommand) Flags() *flagset.Flagset {
Usage: "listening address of bootnode (<ip>:<port>)",
Value: &b.listenAddr,
})
flags.BoolFlag(&flagset.BoolFlag{
Name: "metrics",
Usage: "Enable metrics collection and reporting",
Value: &b.enableMetrics,
Default: true,
})
flags.StringFlag(&flagset.StringFlag{
Name: "prometheus-addr",
Default: "127.0.0.1:7071",
Usage: "listening address of bootnode (<ip>:<port>)",
Value: &b.prometheusAddr,
})
flags.BoolFlag(&flagset.BoolFlag{
Name: "v5",
Default: false,
Expand Down Expand Up @@ -237,6 +255,26 @@ func (b *BootnodeCommand) Run(args []string) int {
}
}

if b.enableMetrics {
prometheusMux := http.NewServeMux()

prometheusMux.Handle("/debug/metrics/prometheus", prometheus.Handler(metrics.DefaultRegistry))

promServer := &http.Server{
Addr: b.prometheusAddr,
Handler: prometheusMux,
ReadHeaderTimeout: 30 * time.Second,
}

go func() {
if err := promServer.ListenAndServe(); err != nil {
log.Error("Failure in running Prometheus server", "err", err)
}
}()

log.Info("Enabling metrics export to prometheus", "path", fmt.Sprintf("http://%s/debug/metrics/prometheus", b.prometheusAddr))
}

signalCh := make(chan os.Signal, 4)
signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)

Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor
Version: 1.0.0-beta
Version: 1.0.4
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.arm64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor
Version: 1.0.0-beta
Version: 1.0.4
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.profile.amd64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.0.0-beta
Version: 1.0.4
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.profile.arm64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.0.0-beta
Version: 1.0.4
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.validator
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.0.0-beta
Version: 1.0.4
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.0.0-beta
Version: 1.0.4
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
8 changes: 4 additions & 4 deletions params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
)

const (
VersionMajor = 1 // Major version component of the current release
VersionMinor = 0 // Minor version component of the current release
VersionPatch = 0 // Patch version component of the current release
VersionMeta = "beta" // Version metadata to append to the version string
VersionMajor = 1 // Major version component of the current release
VersionMinor = 0 // Minor version component of the current release
VersionPatch = 4 // Patch version component of the current release
VersionMeta = "" // Version metadata to append to the version string
)

var GitCommit string
Expand Down
7 changes: 5 additions & 2 deletions rpc/execution_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ type SafePool struct {
service string // the service using ep
processed atomic.Int64 // keeps count of total processed requests

close chan struct{}
close chan struct{}
closeOnce sync.Once

// Skip sending task to execution pool
fastPath bool
Expand Down Expand Up @@ -103,7 +104,9 @@ func (s *SafePool) Size() int {
}

func (s *SafePool) Stop() {
close(s.close)
s.closeOnce.Do(func() {
close(s.close)
})

if s.executionPool.Load() != nil {
s.executionPool.Load().Stop()
Expand Down
1 change: 1 addition & 0 deletions rpc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ func (h *handler) close(err error, inflightReq *requestOp) {
h.callWG.Wait()
h.cancelRoot()
h.cancelServerSubscriptions(err)
h.executionPool.Stop()
}

// addRequestOp registers a request operation.
Expand Down
6 changes: 5 additions & 1 deletion trie/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"bytes"
"errors"
"fmt"
"sync"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -48,7 +49,8 @@ type Trie struct {

// tracer is the tool to track the trie changes.
// It will be reset after each commit operation.
tracer *tracer
tracer *tracer
tracerMutex sync.Mutex
}

// newFlag returns the cache flag value for a newly created node.
Expand Down Expand Up @@ -605,7 +607,9 @@ func (t *Trie) resolveAndTrack(n hashNode, prefix []byte) (node, error) {
return nil, err
}

t.tracerMutex.Lock()
t.tracer.onRead(prefix, blob)
t.tracerMutex.Unlock()

return mustDecodeNode(n, blob), nil
}
Expand Down
Loading