-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
rpc: change BlockNumber constant values to match ethclient #27219
Conversation
Isn't that a big breaking change?
Anyone who was using it as above will be broken. |
Meh, maybe..? Although, anyone depending on 'pending' to be meaningfully different from 'latest' is already working under flawed premises.
Pending is a very vague concept.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. We should add a backwards incompatibility note in the release
Using negative numbers for this is so so so bad. Still, shouldn't the negative numbers only be some internal implementation detail? They should not be exposed to the outside world afaik. cc @fjl? |
I agree we shouldn't expose internal implementation specific detail to users. We need to change the block parameter type to a compound one which can be either a valid block number or a default block params( But it requires a breaking change. |
I hate that we have support for these special negative numbers in the first place. The only reason we have them is because I gave in on some PR years ago. In the original ethclient API, we had support for "latest" by passing a ethclient does have an explicit way of accessing pending state, with special methods. We added support for Later, we added support for "safe" and "finalized" in the same way, in #25580. These do make sense for BlockByNumber, etc. It was obvious to add them using the same numbering system used by |
The problem is, If we have to make a change at all, I would suggest we change the definition of |
I don't see the point of that. If we do like in this PR, then:
With your proposed change,
I think we should move towards minimizing the use of
Are you sure? |
I meant, we could swap the values of the constants instead of applying changes in this PR. Then ethclient's definition of There is no other code in go-ethereum that relies on the numeric value of these constants. |
@fjl PTAL |
Interesting, a filters-related test failed. Need to investigate this. |
- avoid creating big.Int just to compare with BlockNumber - use String method of BlockNumber
eth/filters/api_test.go
Outdated
@@ -56,7 +56,8 @@ func TestUnmarshalJSONNewFilterArgs(t *testing.T) { | |||
|
|||
// from, to block number | |||
var test1 FilterCriteria | |||
vector := fmt.Sprintf(`{"fromBlock":"%#x","toBlock":"%#x"}`, fromBlock, toBlock) | |||
vector := fmt.Sprintf(`{"fromBlock":"%v","toBlock":"%v"}`, fromBlock, toBlock) | |||
t.Logf("vector: %s", vector) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like debugging debris
…27219) ethclient accepts certain negative block number values as specifiers for the "pending", "safe" and "finalized" block. In case of "pending", the value accepted by ethclient (-1) did not match rpc.PendingBlockNumber (-2). This wasn't really a problem, but other values accepted by ethclient did match the definitions in package rpc, and it's weird to have this one special case where they don't. To fix it, we decided to change the values of the constants rather than changing ethclient. The constant values are not otherwise significant. This is a breaking API change, but we believe not a dangerous one. --------- Co-authored-by: Felix Lange <[email protected]>
…thereum#27219)" This reverts commit c27eb12.
…thereum#27219)" This reverts commit c27eb12.
An off-comment here https://github.com/ethereum/go-ethereum/pull/21177/files/07d5cfbf0a5e92a51459a43fe4021ceccae428b3#diff-1053ae80885a491cefa0ab360c605e7abbcec41fbb620c070a132c58a3bd6cac , caused an error: #27205 .
This PR fixes that error