Skip to content

Commit

Permalink
eth,monitor: min/max gas price logs
Browse files Browse the repository at this point in the history
  • Loading branch information
kyriediculous committed Jul 1, 2021
1 parent f4cbf47 commit 49a63bf
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- \#1911 [Experimental] Enable scene classification for Adult/Soccer (@jailuthra, @yondonfu)
- \#1915 Use gas price monitor for gas price suggestions for all Ethereum transactions (@kyriediculous)
- \#1930 Support custom minimum gas price (@yondonfu)
- \#1942 Log min and max gas price when monitoring is enabled (@kyriediculous)

#### Broadcaster

Expand Down
5 changes: 5 additions & 0 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/ethereum/go-ethereum/params"
"github.com/golang/glog"
"github.com/livepeer/go-livepeer/eth/contracts"
"github.com/livepeer/go-livepeer/monitor"
)

var abis = []string{
Expand Down Expand Up @@ -129,6 +130,10 @@ func (b *backend) SetMaxGasPrice(gp *big.Int) {
b.Lock()
defer b.Unlock()
b.maxGasPrice = gp

if monitor.Enabled {
monitor.MaxGasPrice(gp)
}
}

func (b *backend) MaxGasPrice() *big.Int {
Expand Down
4 changes: 4 additions & 0 deletions eth/gaspricemonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ func (gpm *GasPriceMonitor) SetMinGasPrice(minGasPrice *big.Int) {
gpm.gasPriceMu.Lock()
defer gpm.gasPriceMu.Unlock()
gpm.minGasPrice = minGasPrice

if monitor.Enabled {
monitor.MinGasPrice(minGasPrice)
}
}

func (gpm *GasPriceMonitor) MinGasPrice() *big.Int {
Expand Down
33 changes: 33 additions & 0 deletions monitor/census.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ type (
mValueRedeemed *stats.Float64Measure
mTicketRedemptionError *stats.Int64Measure
mSuggestedGasPrice *stats.Float64Measure
mMinGasPrice *stats.Float64Measure
mMaxGasPrice *stats.Float64Measure
mTranscodingPrice *stats.Float64Measure

// Metrics for pixel accounting
Expand Down Expand Up @@ -276,6 +278,8 @@ func InitCensus(nodeType NodeType, version string) {
census.mValueRedeemed = stats.Float64("value_redeemed", "ValueRedeemed", "gwei")
census.mTicketRedemptionError = stats.Int64("ticket_redemption_errors", "TicketRedemptionError", "tot")
census.mSuggestedGasPrice = stats.Float64("suggested_gas_price", "SuggestedGasPrice", "gwei")
census.mMinGasPrice = stats.Float64("min_gas_price", "MinGasPrice", "gwei")
census.mMaxGasPrice = stats.Float64("max_gas_price", "MaxGasPrice", "gwei")
census.mTranscodingPrice = stats.Float64("transcoding_price", "TranscodingPrice", "wei")

// Metrics for pixel accounting
Expand Down Expand Up @@ -687,6 +691,21 @@ func InitCensus(nodeType NodeType, version string) {
TagKeys: baseTags,
Aggregation: view.Sum(),
},
{
Name: "min_gas_price",
Measure: census.mMinGasPrice,
Description: "Minimum gas price to use for gas price suggestions",
TagKeys: baseTags,
Aggregation: view.LastValue(),
},
{
Name: "max_gas_price",
Measure: census.mMaxGasPrice,
Description: "Maximum gas price to use for gas price suggestions",
TagKeys: baseTags,
Aggregation: view.LastValue(),
},

// Metrics for pixel accounting
{
Name: "mil_pixels_processed",
Expand Down Expand Up @@ -1436,6 +1455,20 @@ func SuggestedGasPrice(gasPrice *big.Int) {
stats.Record(census.ctx, census.mSuggestedGasPrice.M(wei2gwei(gasPrice)))
}

func MinGasPrice(minGasPrice *big.Int) {
census.lock.Lock()
defer census.lock.Unlock()

stats.Record(census.ctx, census.mMinGasPrice.M(wei2gwei(minGasPrice)))
}

func MaxGasPrice(maxGasPrice *big.Int) {
census.lock.Lock()
defer census.lock.Unlock()

stats.Record(census.ctx, census.mMaxGasPrice.M(wei2gwei(maxGasPrice)))
}

// TranscodingPrice records the last transcoding price
func TranscodingPrice(sender string, price *big.Rat) {
census.lock.Lock()
Expand Down

0 comments on commit 49a63bf

Please sign in to comment.