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

Commit

Permalink
revert tele
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdevbear committed Jan 18, 2024
1 parent 2472a4a commit 25fbe13
Show file tree
Hide file tree
Showing 6 changed files with 347 additions and 43 deletions.
10 changes: 0 additions & 10 deletions cosmos/runtime/txpool/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func (m *Mempool) AnteHandle(
ctx.BlockTime().Unix(), ethTx,
); shouldEject {
m.crc.DropRemoteTx(ethTx.Hash())
telemetry.IncrCounter(float32(1), MetricKeyMempoolAnteEvictedTxs)
return ctx, errors.New("eject from comet mempool")
}
}
Expand All @@ -77,15 +76,6 @@ func (m *Mempool) shouldEjectFromCometMempool(
expired := currentTime-m.crc.TimeFirstSeen(txHash) > m.lifetime
priceOverLimit := tx.GasPrice().Cmp(m.priceLimit) <= 0

if includedInBlock {
telemetry.IncrCounter(float32(1), MetricKeyTimeShouldEjectInclusion)
}
if expired {
telemetry.IncrCounter(float32(1), MetricKeyTimeShouldEjectExpiredTx)
}
if priceOverLimit {
telemetry.IncrCounter(float32(1), MetricKeyTimeShouldEjectPriceLimit)
}
return includedInBlock || expired || priceOverLimit
}

Expand Down
2 changes: 1 addition & 1 deletion cosmos/runtime/txpool/comet.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

const (
defaultCacheSize = txChanSize
defaultCacheSize = 4096
)

// CometRemoteCache is used to mark which txs are added to our Polaris node remotely from
Expand Down
6 changes: 1 addition & 5 deletions cosmos/runtime/txpool/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ func (h *handler) mainLoop() {
case err = <-h.txsSub.Err():
h.stopCh <- struct{}{}
case event := <-h.txsCh:
telemetry.IncrCounter(float32(len(event.Txs)), MetricKeyBroadcastLocalTxs)
h.broadcastTransactions(event.Txs)
}
}
Expand All @@ -169,7 +168,6 @@ func (h *handler) failedLoop() {
h.logger.Error("failed to broadcast transaction after max retries", "tx", maxRetries)
continue
}
telemetry.IncrCounter(float32(1), MetricKeyBroadcastFailedTxs)
h.broadcastTransaction(failed.tx, failed.retries-1)
}

Expand Down Expand Up @@ -202,8 +200,7 @@ func (h *handler) stop(err error) {
close(h.failedTxs)
}

// broadcastTransactions will propagate a batch of local transactions to the CometBFT mempool
// before broadcasting them to the network.
// broadcastTransactions will propagate a batch of transactions to the CometBFT mempool.
func (h *handler) broadcastTransactions(txs ethtypes.Transactions) {
numBroadcasted := 0
for _, signedEthTx := range txs {
Expand All @@ -219,7 +216,6 @@ func (h *handler) broadcastTransactions(txs ethtypes.Transactions) {

// broadcastTransaction will propagate a transaction to the CometBFT mempool.
func (h *handler) broadcastTransaction(tx *ethtypes.Transaction, retries int) {
telemetry.IncrCounter(float32(1), MetricKeyBroadcastTxs)
txBytes, err := h.serializer.ToSdkTxBytes(tx, tx.Gas())
if err != nil {
h.logger.Error("failed to serialize transaction", "err", err)
Expand Down
16 changes: 3 additions & 13 deletions cosmos/runtime/txpool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"github.com/berachain/polaris/eth/core"
"github.com/berachain/polaris/lib/utils"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/mempool"

Expand Down Expand Up @@ -136,15 +135,8 @@ func (m *Mempool) Insert(ctx context.Context, sdkTx sdk.Tx) error {
return errs[0]
}

h := ethTx.Hash()
if m.crc.IsRemoteTx(h) {
telemetry.IncrCounter(float32(1), MetricKeyMempoolSeenBeforeTxs)
} else {
// Add the eth tx to the remote cache for the first time.
m.crc.MarkRemoteSeen(h)
}
telemetry.IncrCounter(float32(1), MetricKeyMempoolRemoteTxs)
telemetry.IncrCounter(float32(1), MetricKeyMempoolSize)
// Add the eth tx to the remote cache.
m.crc.MarkRemoteSeen(ethTx.Hash())

return nil
}
Expand All @@ -170,9 +162,8 @@ func (m *Mempool) Remove(tx sdk.Tx) error {
return nil
}

txs := env.UnwrapPayload().ExecutionPayload.Transactions
// Unwrap the payload to unpack the individual eth transactions to remove from the txpool.
for _, txBz := range txs {
for _, txBz := range env.UnwrapPayload().ExecutionPayload.Transactions {
ethTx := new(ethtypes.Transaction)
if err := ethTx.UnmarshalBinary(txBz); err != nil {
continue
Expand All @@ -182,7 +173,6 @@ func (m *Mempool) Remove(tx sdk.Tx) error {
// Remove the eth tx from comet seen tx cache.
m.crc.DropRemoteTx(txHash)
}
telemetry.IncrCounter(float32(-1*len(txs)), MetricKeyMempoolSize)
}
return nil
}
17 changes: 3 additions & 14 deletions cosmos/runtime/txpool/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,7 @@
package txpool

const (
MetricKeyMempoolFull = "polaris_cometbft_mempool_full"
MetricKeyMempoolSize = "polaris_cometbft_mempool_size"
MetricKeyMempoolRemoteTxs = "polaris_cometbft_mempool_remote_txs"
MetricKeyMempoolForcelyRemovedTxs = "polaris_cometbft_mempool_forcely_removed_txs"
MetricKeyMempoolAnteEvictedTxs = "polaris_cometbft_mempool_ante_evicted_txs"
MetricKeyBroadcastTxs = "polaris_cometbft_broadcast_txs"
MetricKeyBroadcastLocalTxs = "polaris_cometbft_broadcast_local_txs"
MetricKeyBroadcastFailedTxs = "polaris_cometbft_broadcast_failed_txs"
MetricKeyBroadcastFailure = "polaris_cometbft_broadcast_failure"
MetricKeyMempoolSeenBeforeTxs = "polaris_cometbft_broadcast_seen_before_txs"
MetricKeyTimeShouldEject = "polaris_cometbft_time_should_eject"
MetricKeyTimeShouldEjectInclusion = "polaris_cometbft_should_eject_due_to_included_in_block"
MetricKeyTimeShouldEjectExpiredTx = "polaris_cometbft_should_eject_due_to_expired_tx"
MetricKeyTimeShouldEjectPriceLimit = "polaris_cometbft_should_eject_due_to_price_limit"
MetricKeyMempoolFull = "polaris_cometbft_mempool_full"
MetricKeyBroadcastFailure = "polaris_cometbft_broadcast_failure"
MetricKeyTimeShouldEject = "polaris_cometbft_time_should_eject"
)
Loading

0 comments on commit 25fbe13

Please sign in to comment.