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

[Enhancement] Add Gas Price Oracle User Configuration #4362

Closed
wants to merge 146 commits into from

Conversation

Aishlia
Copy link

@Aishlia Aishlia commented Feb 10, 2023

Issue

#4357 Add feature to enable users to specify gas price parameters (blocks, percentile, defaultPriceGwei, maxPriceGwei, and numberTxsnSampled) in config and as flags.

Test

Unit Test Coverage

Before:

ok      github.com/harmony-one/harmony/cmd/harmony    0.756s    coverage: 44.8% of statements

After:

PASS
ok  	github.com/harmony-one/harmony/cmd/harmony	0.568s

Test/Run Logs

julianai@Harmonys-MacBook-Air harmony % go test ./cmd/harmony
# gopkg.in/olebedev/go-duktape.v3
In file included from _cgo_export.c:4:
debugger.go:23:13: warning: unused function '_duk_debugger_attach' [-Wunused-function]
ok  	github.com/harmony-one/harmony/cmd/harmony	0.495s
julianai@Harmonys-MacBook-Air harmony % go test -run TestHarmonyFlags
# gopkg.in/olebedev/go-duktape.v3
In file included from _cgo_export.c:4:
debugger.go:23:13: warning: unused function '_duk_debugger_attach' [-Wunused-function]
PASS
ok  	github.com/harmony-one/harmony/cmd/harmony	0.497s

Operational Checklist

  1. Does this PR introduce backward-incompatible changes to the on-disk data structure and/or the over-the-wire protocol?. (If no, skip to question 8.)

    NO

  2. Describe the migration plan.. For each flag epoch, describe what changes take place at the flag epoch, the anticipated interactions between upgraded/non-upgraded nodes, and any special operational considerations for the migration.

  3. Describe how the plan was tested.

  4. How much minimum baking period after the last flag epoch should we allow on Pangaea before promotion onto mainnet?

  5. What are the planned flag epoch numbers and their ETAs on Pangaea?

  6. What are the planned flag epoch numbers and their ETAs on mainnet?

    Note that this must be enough to cover baking period on Pangaea.

  7. What should node operators know about this planned change?

  8. Does this PR introduce backward-incompatible changes NOT related to on-disk data structure and/or over-the-wire protocol? (If no, continue to question 11.)

    NO

  9. Does the existing node.sh continue to work with this change?

  10. What should node operators know about this change?

  11. Does this PR introduce significant changes to the operational requirements of the node software, such as >20% increase in CPU, memory, and/or disk usage?

    NO

TODO

@Aishlia Aishlia self-assigned this Feb 10, 2023
@Aishlia Aishlia closed this Feb 10, 2023
@Aishlia Aishlia reopened this Feb 10, 2023
@Aishlia Aishlia closed this Feb 11, 2023
@Aishlia Aishlia reopened this Feb 11, 2023
Copy link
Contributor

@MaxMustermann2 MaxMustermann2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update test TestHarmonyFlags as well.

rosetta/infra/harmony-pstn.conf Show resolved Hide resolved
cmd/harmony/main.go Outdated Show resolved Hide resolved
cmd/harmony/flags.go Outdated Show resolved Hide resolved
}
gasPriceOracleMaxPriceGweiFlag = cli.IntFlag{
Name: "gpo.maxprice",
Usage: "Maximum possible gas price in gwei returned by eth_gasPrice (default: 12)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is max gas price (12) < default gas price (100) ?

Percentile: 80,
DefaultPriceGwei: 100,
MaxPriceGwei: 12,
NumberTxsSampled: 3,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refer to the values here instead of hard coding them.

@@ -803,6 +803,9 @@ func setupConsensusAndNode(hc harmonyconfig.HarmonyConfig, nodeConfig *nodeconfi
Uint64("viewID", viewID).
Msg("Init Blockchain")

// Assign GasPriceOracle parameters to the current node
currentNode.HarmonyConfig.GasPriceOracle = hc.GasPriceOracle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't see why this is needed. The currentNode stores within itself the entire config (including the GasPriceOracle) per below.

node.HarmonyConfig = harmonyconfig

@@ -71,6 +71,7 @@ require (
github.com/c2h5oh/datasize v0.0.0-20220606134207-859f65c6625b
github.com/ledgerwatch/erigon-lib v0.0.0-20221218022306-0f8fdd40c2db
github.com/ledgerwatch/log/v3 v3.6.0
github.com/libp2p/go-libp2p-core v0.20.1
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's preferred not to commit go.mod and go.sum for minor changes.

"updated",
DefaultGasPriceOracleConfig.NumberTxsSampled,
),
)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a sanity check for maxPrice < defaultPrice

@@ -387,7 +387,7 @@ func (hmy *Harmony) GetValidatorInformation(
// b.apiCache.Forget(prevKey)

// calculate last APRHistoryLength epochs for averaging APR
// epochFrom := bc.GasPriceConfig().StakingEpoch
// epochFrom := bc.GasPriceOracleConfig().StakingEpoch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo this change.

hmy/hmy.go Outdated
Default: big.NewInt(100e9), // minimum of 100 gwei
}
gpoParams := nodeAPI.GetHarmonyConfig().GasPriceOracle

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Remove this blank line.

@ONECasey
Copy link
Contributor

A few merge conflicts after a rebase.

@ONECasey
Copy link
Contributor

Fixed the merge conflicts for you.

@ONECasey
Copy link
Contributor

New dev. Needs mentorship. Closed

@ONECasey ONECasey closed this Mar 14, 2023
MaxMustermann2 added a commit to MaxMustermann2/harmony that referenced this pull request May 22, 2023
This change makes the gas price oracle options available as options in
the configuration file / command line. In addition, the gas price
oracle's suggestion mechanism has been modified to return the default
gas price when block utilization is low. In other words, the oracle can
be configured to return the 60th percentile gas price from the last 5
blocks with 3 transactions each, or return the default gas price if
those 5 blocks were utilized less than 50% of their capacity

Fixes harmony-one#4357 and supersedes harmony-one#4362
ONECasey pushed a commit that referenced this pull request May 25, 2023
This change makes the gas price oracle options available as options in
the configuration file / command line. In addition, the gas price
oracle's suggestion mechanism has been modified to return the default
gas price when block utilization is low. In other words, the oracle can
be configured to return the 60th percentile gas price from the last 5
blocks with 3 transactions each, or return the default gas price if
those 5 blocks were utilized less than 50% of their capacity

Fixes #4357 and supersedes #4362
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants