Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
po-bera committed Jan 19, 2024
1 parent 2ffa242 commit 2797a6f
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 163 deletions.
6 changes: 3 additions & 3 deletions cosmos/runtime/txpool/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ import (
func (m *Mempool) AnteHandle(
ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler,
) (sdk.Context, error) {
// The transaction puts into this function is a remote transaction,
// received by CheckTx.
telemetry.IncrCounter(float32(1), MetricKeyCometRemoteTxs)
// The transaction put into this function by CheckTx
// is a transaction from CometBFT mempool.
telemetry.IncrCounter(float32(1), MetricKeyCometPoolTxs)
msgs := tx.GetMsgs()

// TODO: Record the time it takes to build a payload.
Expand Down
4 changes: 4 additions & 0 deletions cosmos/runtime/txpool/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type SdkTx interface {
// TxSubProvider.
type TxSubProvider interface {
SubscribeTransactions(ch chan<- core.NewTxsEvent, reorgs bool) event.Subscription
Stats() (int, int)
}

// TxSerializer provides an interface to Serialize Geth Transactions to Bytes (via sdk.Tx).
Expand Down Expand Up @@ -152,6 +153,9 @@ func (h *handler) mainLoop() {
case err = <-h.txsSub.Err():
h.stopCh <- struct{}{}
case event := <-h.txsCh:
pending, queue := h.txPool.Stats()
telemetry.SetGauge(float32(pending), MetricKeyTxPoolPending)
telemetry.SetGauge(float32(queue), MetricKeyTxPoolQueue)
telemetry.IncrCounter(float32(len(event.Txs)), MetricKeyCometLocalTxs)
h.broadcastTransactions(event.Txs)
}
Expand Down
34 changes: 3 additions & 31 deletions cosmos/runtime/txpool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ package txpool
import (
"context"
"errors"
"fmt"
"math/big"
"sync"
"time"

"cosmossdk.io/log"

Expand Down Expand Up @@ -72,7 +70,6 @@ type Mempool struct {
crc CometRemoteCache
blockBuilderMu *sync.RWMutex
priceLimit *big.Int
txPoolMetrics *eth.Metrics
}

// New creates a new Mempool.
Expand All @@ -87,7 +84,6 @@ func New(
crc: newCometRemoteCache(),
blockBuilderMu: blockBuilderMu,
priceLimit: priceLimit,
txPoolMetrics: eth.NewMetrics(),
}
}

Expand All @@ -98,14 +94,10 @@ func (m *Mempool) Init(
txSerializer TxSerializer,
) {
m.handler = newHandler(txBroadcaster, m.TxPool, txSerializer, m.crc, logger)
for _, metric := range eth.TxPoolMetrics {
m.txPoolMetrics.Register(metric)
}
}

// Start starts the Mempool TxHandler.
func (m *Mempool) Start() error {
go m.loop()
return m.handler.Start()
}

Expand All @@ -114,26 +106,11 @@ func (m *Mempool) Stop() error {
return m.handler.Stop()
}

func (m *Mempool) loop() {
report := time.NewTicker(1 * time.Second)
defer report.Stop()
for {
select {
case <-report.C:
m.txPoolMetrics.Report()
}
}
}

func (m *Mempool) EthMetrics() *eth.Metrics {
return m.txPoolMetrics
}

// Insert attempts to insert a Tx into the app-side mempool returning an error upon failure.
func (m *Mempool) Insert(ctx context.Context, sdkTx sdk.Tx) error {
txPoolPending, txPoolQueued := m.TxPool.Stats()
txPoolPending, txPoolQueue := m.TxPool.Stats()
telemetry.SetGauge(float32(txPoolPending), MetricKeyTxPoolPending)
telemetry.SetGauge(float32(txPoolQueued), MetricKeyTxPoolQueued)
telemetry.SetGauge(float32(txPoolQueue), MetricKeyTxPoolQueue)

sCtx := sdk.UnwrapSDKContext(ctx)
msgs := sdkTx.GetMsgs()
Expand Down Expand Up @@ -165,11 +142,7 @@ func (m *Mempool) Insert(ctx context.Context, sdkTx sdk.Tx) error {
return errs[0]
}

h := ethTx.Hash()
if !m.crc.IsRemoteTx(h) {
// Add the eth tx to the remote cache for the first time.
m.crc.MarkRemoteSeen(h)
}
m.crc.MarkRemoteSeen(ethTx.Hash())

return nil
}
Expand All @@ -187,7 +160,6 @@ func (m *Mempool) Select(context.Context, [][]byte) mempool.Iterator {

// Remove is an intentional no-op as the eth txpool handles removals.
func (m *Mempool) Remove(tx sdk.Tx) error {
fmt.Println("REMOVE")
// Get the Eth payload envelope from the Cosmos transaction.
msgs := tx.GetMsgs()
if len(msgs) == 1 {
Expand Down
4 changes: 4 additions & 0 deletions cosmos/runtime/txpool/mocks/tx_sub_provider.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions cosmos/runtime/txpool/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ package txpool
const (
MetricKeyCometPrefix = "polaris_cometbft_"

MetricKeyCometRemoteTxs = "polaris_cometbft_remote_txs"
MetricKeyCometLocalTxs = "polaris_cometbft_local_txs"
MetricKeyCometPoolTxs = "polaris_cometbft_comet_pool_txs"
MetricKeyCometLocalTxs = "polaris_cometbft_local_txs"

MetricKeyTimeShouldEject = "polaris_cometbft_time_should_eject"
MetricKeyAnteEjectedTxs = "polaris_cometbft_ante_ejected_txs"
MetricKeyAnteShouldEjectInclusion = "polaris_cometbft_ante_should_eject_included"
MetricKeyAnteShouldEjectExpiredTx = "polaris_cometbft_should_eject_expired"
MetricKeyAnteShouldEjectPriceLimit = "polaris_cometbft_should_eject_price_limit"
MetricKeyAnteShouldEjectExpiredTx = "polaris_cometbft_ante_should_eject_expired"
MetricKeyAnteShouldEjectPriceLimit = "polaris_cometbft_ante_should_eject_price_limit"

MetricKeyTxPoolPending = "polaris_cometbft_txpool_pending"
MetricKeyTxPoolQueued = "polaris_cometbft_txpool_queued"
MetricKeyTxPoolQueue = "polaris_cometbft_txpool_queue"

MetricKeyMempoolFull = "polaris_cometbft_mempool_full"
MetricKeyMempoolSize = "polaris_cometbft_mempool_size"
Expand Down
12 changes: 0 additions & 12 deletions eth/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ replace github.com/ethereum/go-ethereum => github.com/berachain/polaris-geth v1.
require (
github.com/berachain/polaris/contracts v0.1.5-alpha
github.com/berachain/polaris/lib v0.0.4-alpha
github.com/cosmos/cosmos-sdk v0.50.3
github.com/ethereum/go-ethereum v1.13.10
github.com/holiman/uint256 v1.2.4
github.com/onsi/ginkgo/v2 v2.14.0
Expand All @@ -18,12 +17,10 @@ require (
)

require (
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
github.com/allegro/bigcache v1.2.1 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.11.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/bytedance/sonic v1.10.0 // indirect
Expand Down Expand Up @@ -66,10 +63,6 @@ require (
github.com/gorilla/websocket v1.5.1 // indirect
github.com/graph-gophers/graphql-go v1.5.0 // indirect
github.com/hashicorp/go-bexpr v0.1.12 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-metrics v0.5.1 // indirect
github.com/hashicorp/go-uuid v1.0.2 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/huin/goupnp v1.3.0 // indirect
Expand All @@ -85,7 +78,6 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/pointerstructure v1.2.1 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
Expand All @@ -96,10 +88,6 @@ require (
github.com/peterh/liner v1.2.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rs/cors v1.10.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand Down
13 changes: 0 additions & 13 deletions eth/go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk=
Expand All @@ -9,7 +8,6 @@ github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKS
github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/berachain/polaris-geth v1.13.10-2-polar h1:W1dahX0MvEzRv5kRww0FpN0j8M9qhSiftUaWFsUSGi8=
github.com/berachain/polaris-geth v1.13.10-2-polar/go.mod h1:sc48XYQxCzH3fG9BcrXCOOgQk2JfZzNAmIKnceogzsA=
github.com/berachain/polaris/contracts v0.1.5-alpha h1:XA3yBKH4uwR3p6AuurmECGzfeLIWrCE+tqm3qUNZnVM=
Expand Down Expand Up @@ -47,7 +45,6 @@ github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/Yj
github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M=
github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY=
github.com/cosmos/cosmos-sdk v0.50.3 h1:zP0AXm54ws2t2qVWvcQhEYVafhOAREU2QL0gnbwjvXw=
github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 h1:d28BXYi+wUpz1KBmiF9bWrjEMacUEREV6MBi2ODnrfQ=
Expand Down Expand Up @@ -157,10 +154,6 @@ github.com/graph-gophers/graphql-go v1.5.0 h1:fDqblo50TEpD0LY7RXk/LFVYEVqo3+tXMN
github.com/graph-gophers/graphql-go v1.5.0/go.mod h1:YtmJZDLbF1YYNrlNAuiO5zAStUWc3XZT07iGsVqe1Os=
github.com/hashicorp/go-bexpr v0.1.12 h1:XrdVhmwu+9iYxIUWxsGVG7NQwrhzJZ0vR6nbN5bLgrA=
github.com/hashicorp/go-bexpr v0.1.12/go.mod h1:ACktpcSySkFNpcxWSClFrut7wicd9WzisnvHuw+g9K8=
github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=
github.com/hashicorp/go-metrics v0.5.1 h1:rfPwUqFU6uZXNvGl4hzjY8LEBsqFVU4si1H9/Hqck/U=
github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE=
github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c=
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 h1:3JQNjnMRil1yD0IfZKHF9GxxWKDJGj8I0IqOUol//sw=
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc=
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
Expand Down Expand Up @@ -217,7 +210,6 @@ github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzp
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg=
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
Expand Down Expand Up @@ -251,7 +243,6 @@ github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=
github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/peterh/liner v1.2.2 h1:aJ4AOodmL+JxOZZEL2u9iJf8omNRpqHc/EbrK+3mAXw=
Expand All @@ -260,10 +251,6 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q=
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
Expand Down
99 changes: 0 additions & 99 deletions eth/metrics.go

This file was deleted.

0 comments on commit 2797a6f

Please sign in to comment.