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

eth,monitor: min/max gas price logs #1942

Merged
merged 1 commit into from
Jul 8, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 {
yondonfu marked this conversation as resolved.
Show resolved Hide resolved
monitor.MaxGasPrice(gp)
}
}

func (b *backend) MaxGasPrice() *big.Int {
Expand Down
7 changes: 7 additions & 0 deletions eth/gaspricemonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ func NewGasPriceMonitor(gpo GasPriceOracle, pollingInterval time.Duration, minGa
if minGasPrice != nil {
minGasP = minGasPrice
}
if monitor.Enabled {
monitor.MinGasPrice(minGasP)
}
return &GasPriceMonitor{
gpo: gpo,
pollingInterval: pollingInterval,
Expand All @@ -70,6 +73,10 @@ func (gpm *GasPriceMonitor) SetMinGasPrice(minGasPrice *big.Int) {
gpm.gasPriceMu.Lock()
defer gpm.gasPriceMu.Unlock()
gpm.minGasPrice = minGasPrice

if monitor.Enabled {
yondonfu marked this conversation as resolved.
Show resolved Hide resolved
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