diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 78e3d8ffa2..8182282ae7 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -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, diff --git a/core/txpool/txpool.go b/core/txpool/txpool.go index 9da20cd763..82ee2fafa8 100644 --- a/core/txpool/txpool.go +++ b/core/txpool/txpool.go @@ -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) diff --git a/internal/cli/bootnode.go b/internal/cli/bootnode.go index 8051046a09..756956daa9 100644 --- a/internal/cli/bootnode.go +++ b/internal/cli/bootnode.go @@ -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" @@ -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 @@ -60,6 +66,18 @@ func (b *BootnodeCommand) Flags() *flagset.Flagset { Usage: "listening address of bootnode (:)", 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 (:)", + Value: &b.prometheusAddr, + }) flags.BoolFlag(&flagset.BoolFlag{ Name: "v5", Default: false, @@ -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) diff --git a/packaging/templates/package_scripts/control b/packaging/templates/package_scripts/control index 679699c18a..67080212e6 100644 --- a/packaging/templates/package_scripts/control +++ b/packaging/templates/package_scripts/control @@ -1,5 +1,5 @@ Source: bor -Version: 1.0.0-beta +Version: 1.0.4 Section: develop Priority: standard Maintainer: Polygon diff --git a/packaging/templates/package_scripts/control.arm64 b/packaging/templates/package_scripts/control.arm64 index 2f8c3bd8a1..a98715a6d8 100644 --- a/packaging/templates/package_scripts/control.arm64 +++ b/packaging/templates/package_scripts/control.arm64 @@ -1,5 +1,5 @@ Source: bor -Version: 1.0.0-beta +Version: 1.0.4 Section: develop Priority: standard Maintainer: Polygon diff --git a/packaging/templates/package_scripts/control.profile.amd64 b/packaging/templates/package_scripts/control.profile.amd64 index 3692578885..76875d1940 100644 --- a/packaging/templates/package_scripts/control.profile.amd64 +++ b/packaging/templates/package_scripts/control.profile.amd64 @@ -1,5 +1,5 @@ Source: bor-profile -Version: 1.0.0-beta +Version: 1.0.4 Section: develop Priority: standard Maintainer: Polygon diff --git a/packaging/templates/package_scripts/control.profile.arm64 b/packaging/templates/package_scripts/control.profile.arm64 index 347129e197..d455176ada 100644 --- a/packaging/templates/package_scripts/control.profile.arm64 +++ b/packaging/templates/package_scripts/control.profile.arm64 @@ -1,5 +1,5 @@ Source: bor-profile -Version: 1.0.0-beta +Version: 1.0.4 Section: develop Priority: standard Maintainer: Polygon diff --git a/packaging/templates/package_scripts/control.validator b/packaging/templates/package_scripts/control.validator index e1bd6e1673..44abd64e08 100644 --- a/packaging/templates/package_scripts/control.validator +++ b/packaging/templates/package_scripts/control.validator @@ -1,5 +1,5 @@ Source: bor-profile -Version: 1.0.0-beta +Version: 1.0.4 Section: develop Priority: standard Maintainer: Polygon diff --git a/packaging/templates/package_scripts/control.validator.arm64 b/packaging/templates/package_scripts/control.validator.arm64 index 97b287371f..944771ed76 100644 --- a/packaging/templates/package_scripts/control.validator.arm64 +++ b/packaging/templates/package_scripts/control.validator.arm64 @@ -1,5 +1,5 @@ Source: bor-profile -Version: 1.0.0-beta +Version: 1.0.4 Section: develop Priority: standard Maintainer: Polygon diff --git a/params/version.go b/params/version.go index 82097fbcde..bfdb438b06 100644 --- a/params/version.go +++ b/params/version.go @@ -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 diff --git a/rpc/execution_pool.go b/rpc/execution_pool.go index daa431e9bc..378ed55fa2 100644 --- a/rpc/execution_pool.go +++ b/rpc/execution_pool.go @@ -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 @@ -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() diff --git a/rpc/handler.go b/rpc/handler.go index a056176b8b..6a75e67502 100644 --- a/rpc/handler.go +++ b/rpc/handler.go @@ -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. diff --git a/trie/trie.go b/trie/trie.go index 33b14bfd55..726308ff80 100644 --- a/trie/trie.go +++ b/trie/trie.go @@ -21,6 +21,7 @@ import ( "bytes" "errors" "fmt" + "sync" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -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. @@ -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 }