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

add feeHistory spec #212

Merged
merged 1 commit into from
Jun 16, 2021
Merged

add feeHistory spec #212

merged 1 commit into from
Jun 16, 2021

Conversation

zsfelfoldi
Copy link
Contributor

This PR adds the feeHistory API function spec.
See also:

"params": [
{
"name": "blockCount",
"description": "Number of blocks in the requested range.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider mentioning what a value of 0 does/means. Also, are there any constraints on this (limit to number one can request)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 213 to 214
"name": "lastBlock",
"description": "Last block number of the requested range.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider renaming this to "newest" instead of "last". Depending on your frame of reference, "last" may be closer to genesis than head, or it may be closer to head than genesis.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 218 to 223
{
"$ref": "#/components/schemas/BlockNumber"
},
{
"$ref": "#/components/schemas/BlockNumberTag"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should create a new type for BlockNumberOrTag since it comes up a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 253 to 254
"title": "firstBlock",
"description": "First block number of the returned range.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider "newest" here if you decide to change the above to "newest" so naming is consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean oldest I guess :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, all the more reason to change this wording! I thought by "first" you meant "latest" (most recent, first block counting down from now, etc.). 😁

},
"baseFee": {
"title": "baseFeeArray",
"description": "An array of block base fees (including the next block after the returned range).",
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems odd to me that this would return more blocks than requested. If the user wants +1, they can just ask for +1.

Copy link
Contributor Author

@zsfelfoldi zsfelfoldi Jun 13, 2021

Choose a reason for hiding this comment

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

This info is derived from the requested blocks (the next base fee always follows from the last block). It makes sense to specify it like this because the pending base fee is basically the most important and it has nothing to do with the pending state that is not supported at all by some backends (so it either couldn't be queried or would be an ugly corner case with only the baseFee returned for the pending block). On the other hand if pending state is supported and the pending block is queried then we can even predict even the after-pending block's base fee because it follows from the pending state and it is a good indicator of congestion in the mempool. There isn't even a way to specify the after-pending block as lastBlock. So I'd strongly like to keep it this way and specify that the function returns info derivable from the requested blocks (hence the extra baseFee value).

},
"gasUsedRatio": {
"title": "gasUsedArray",
"description": "An array of block gas used ratios.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a decimal number between 0 and 1? Might be good to provide a bit more description here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@timbeiko
Copy link
Collaborator

@MicahZoltu @lightclient does this seem ready to merge to you?

},
"baseFee": {
"title": "baseFeeArray",
"description": "An array of block base fees (including the next block after the newest of the returned range because this value can be derived from the newest block).",

Choose a reason for hiding this comment

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

Is this null if the block has no base fee?

@alcuadrado
Copy link
Member

@MicahZoltu @lightclient does this seem ready to merge to you?

I'm curious about this. What will be the criteria to accept modifications to this spec? Will accepting a new method imply that all the clients and developer networks (e.g. ganache, hardhat, remix) need to implement it?

Copy link
Member

@lightclient lightclient left a comment

Choose a reason for hiding this comment

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

Thanks for making this PR! In general, it would be good to avoid discussing things in parentheses. It would be better to state things explicitly. I'd also like the actual type information to be encoded in the schema.

{
"name": "eth_feeHistory",
"summary": "Transaction fee history",
"description": "Returns transaction base fee and effective priority fee history for the requested/supported block range.",
Copy link
Member

Choose a reason for hiding this comment

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

What would the behaviour be before EIP-1559 blocks? I think it would be good to mention that upfront in the description.

Copy link
Member

Choose a reason for hiding this comment

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

Also, these should be listed "base fee per gas" and "effective priority fee per gas".

"params": [
{
"name": "blockCount",
"description": "Number of blocks in the requested range (positive integer; less may be returned if requesting the entire specified range is not supported).",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "Number of blocks in the requested range (positive integer; less may be returned if requesting the entire specified range is not supported).",
"description": "Number of blocks in the requested range (less may be returned if requesting the entire specified range is not supported).",

The schema should denote the type.

It's also not clear to me what "not supported" means?

},
{
"name": "newestBlock",
"description": "Newest (highest number) block of the requested range (the range between headBlock-4 and headBlock are guaranteed to be supported while the pending block and older history are optional to support).",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "Newest (highest number) block of the requested range (the range between headBlock-4 and headBlock are guaranteed to be supported while the pending block and older history are optional to support).",
"description": "Highest number block of the requested range. The range between headBlock-4 and headBlock are guaranteed to be supported while the pending block and older history are optional to support.",

},
{
"name": "rewardPercentiles",
"description": "A list of percentile values (0..100 floating point) to sample from each block's miner rewards in ascending order, weighted by gas used.",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "A list of percentile values (0..100 floating point) to sample from each block's miner rewards in ascending order, weighted by gas used.",
"description": "A list of percentile values to sample from each block's miner rewards in ascending order, weighted by gas used.",

Please use the schema field to communicate the type information.

"properties": {
"oldestBlock": {
"title": "oldestBlock",
"description": "Oldest (lowest number) block of the returned range.",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "Oldest (lowest number) block of the returned range.",
"description": "Lowest number block of the returned range.",

},
"baseFee": {
"title": "baseFeeArray",
"description": "An array of block base fees (including the next block after the newest of the returned range because this value can be derived from the newest block).",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "An array of block base fees (including the next block after the newest of the returned range because this value can be derived from the newest block).",
"description": "An array of block base fees per gas. This includes the next block after the newest of the returned range, because this value can be derived from the newest block.",

},
"gasUsedRatio": {
"title": "gasUsedArray",
"description": "An array of block gas used ratios (gasUsed/gasLimit; 0..1 floating point).",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "An array of block gas used ratios (gasUsed/gasLimit; 0..1 floating point).",
"description": "An array of block gas used ratios. This is calculated by dividing the gasUsed by the gasLimit.",

Copy link
Member

Choose a reason for hiding this comment

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

Please use the schema to denote the type.

"type": "array",
"items": {
"title": "gasUsedRatio",
"description": "The ratio of gas used and gas limit (0..1 floating point).",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "The ratio of gas used and gas limit (0..1 floating point).",
"description": "The ratio of gas used and gas limit.",

Copy link
Member

Choose a reason for hiding this comment

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

Please use the schema to denote the type.

},
"reward": {
"title": "rewardArray",
"description": "A two-dimensional array of block miner rewards (effective priority fees) at the requested block percentiles.",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "A two-dimensional array of block miner rewards (effective priority fees) at the requested block percentiles.",
"description": "A two-dimensional array of effective priority fees per gas at the requested block percentiles.",

@@ -1135,6 +1223,17 @@
"pending"
]
},
"BlockNumberOrTag": {
Copy link
Member

Choose a reason for hiding this comment

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

Did you just pull this out to be more explicit?

@lightclient
Copy link
Member

@MicahZoltu @lightclient does this seem ready to merge to you?

I'm curious about this. What will be the criteria to accept modifications to this spec? Will accepting a new method imply that all the clients and developer networks (e.g. ganache, hardhat, remix) need to implement it?

This is a great question. I think the best way to go about it is have endpoints be discussed and proposed as PRs and then merge those changes into the spec repo as "pre-releases". Every month or so, we would need to have a synchronous call with the stakeholders (like the teams you've mentioned) and client devs to get a thumbs up on the release candidate, then we can release a new version of the spec. It may also be useful to target a date where all major tooling has adapted to support the latest json-rpc spec. If this is the desired path, I would like to see the spec broken out into its own repository. Curious to know what people think of this.

@MicahZoltu
Copy link
Contributor

I have a mild preference for having a branch that we merge PRs like this into that is named something like spec-alpha or spec-beta. The reason for this is because in association with the call you mentioned, we can create a Pull Request of spec-alpha into spec-beta or spec-beta into main so that the changeset being discussed on that particular call is very clear and people can leave comments directly on the changeset under discussion.

We could also have a branch for release-candidate that we can merge into while we wait for client implementations, then once we are comfortable asserting "this is the spec" (and we have some implementations) we can merge release-candidate into main. This would make the workflow something like personal_fork -> alpha -> beta -> release-candidate -> main (exact names TBD).

A workflow like this makes it very easy to find out what is the current specification (broadly speaking, implemented by one or more clients) as well as making it easy to see what is currently up for "official" proposal and easy to generate a diff or a PR for discussing current proposals.

@timbeiko
Copy link
Collaborator

@alcuadrado good question! As @lightclient and @MicahZoltu have pointed out, this process is still new and we haven't figured out the kinks yet. I'm in favor of the general approach of having multiple branch and review periods. I'll try and draft up a proposal today/tomorrow.

As for this specific PR, I'm inclined to merge it for a couple reasons:

  1. We've already merged other London/1559-related endpoints (e.g. Add effectiveGasPrice to eth_getTransactionReceipt #206, Correct baseFee to baseFeePerGas #192) and have pointed people here as the canonical place to follow these changes;
  2. We've discussed adding this API first on the Gas API call a few weeks ago and confirmed it on AllCoreDevs last Friday (London JSON RPC Specification pm#334 (comment))
  3. Geth and Besu already have WIP PRs to support this, see eth/gasprice: implement feeHistory API go-ethereum#23033 & eth_feeHistory hyperledger/besu#2432

Ideally, tooling/infrastructure should support this, but having full 1559 support on Day 1 of the London fork isn't a strict requirement as legacy txns will still be allowed.

Copy link
Member

@lightclient lightclient left a comment

Choose a reason for hiding this comment

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

Looks good, I think just a couple missed per gases and then good to go.

{
"name": "eth_feeHistory",
"summary": "Transaction fee history",
"description": "Returns base fee and transaction effective priority fee history for the requested block range if available. The range between headBlock-4 and headBlock is guaranteed to be available while retrieving data from the pending block and older history are optional to support. For pre-EIP-1559 blocks the gas prices are returned as rewards and zeroes are returned for the base fee.",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "Returns base fee and transaction effective priority fee history for the requested block range if available. The range between headBlock-4 and headBlock is guaranteed to be available while retrieving data from the pending block and older history are optional to support. For pre-EIP-1559 blocks the gas prices are returned as rewards and zeroes are returned for the base fee.",
"description": "Returns base fee per as and transaction effective priority fee per gas history for the requested block range if available. The range between headBlock-4 and headBlock is guaranteed to be available while retrieving data from the pending block and older history are optional to support. For pre-EIP-1559 blocks the gas prices are returned as rewards and zeroes are returned for the base fee per gas.",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

"description": "Number of blocks in the requested range. Between 1 and 1024 blocks can be requested in a single query. Less than requested may be returned if not all blocks are available.",
"required": true,
"schema": {
"$ref": "#/components/schemas/Integer"
Copy link
Member

Choose a reason for hiding this comment

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

This should be an integer between 1 and 1024. IMO anything we can encode in the schema, we should.

Copy link
Member

Choose a reason for hiding this comment

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

On second thought, I suppose the description is good enough for now. Eventually we'll should encode in the schema though.

@zsfelfoldi
Copy link
Contributor Author

I added the missing "per gas" where requested and squashed my commits. I think it's mergeable now unless there is a further issue :)

@fvictorio
Copy link

@zsfelfoldi is the gist of the original proposal correct? Shouldn't be this one instead?

@timbeiko
Copy link
Collaborator

+1. The HackMD link seems wrong.

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.

7 participants