-
Notifications
You must be signed in to change notification settings - Fork 20.1k
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
internal/ethapi: fix eth_chainId method #22243
Conversation
Although the ChainID is represented as a *big.Int in the ChainConfig, it was being marshaled as a uint64 by the PublicEthereumAPI. This leads to discrepancies between the config and calls to the API when the ChainID is bigger than math.MaxUint64.
Thanks for catching it. Apparently, we define two Here: https://github.com/ethereum/go-ethereum/blob/master/internal/ethapi/api.go#L533 I think we can just remove the API in |
I would prefer to keep the one in internal/ethapi and delete the implementation in package eth. |
Yeah, this did confuse me |
@Fjf @rjl493456442 Just checking in to see if you were expecting any action on my part? I was thinking I'd wait for agreement between you two before taking any further action. |
Ok, I agree with @fjl. The one in internal is neeed because it's used by both Could you move the code from |
@karalabe do we want to add something like this? diff --git a/rpc/service.go b/rpc/service.go
index bef891ea11..e30f8d7382 100644
--- a/rpc/service.go
+++ b/rpc/service.go
@@ -26,6 +26,7 @@ import (
"sync"
"unicode"
+ "github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/log"
)
@@ -82,11 +83,17 @@ func (r *serviceRegistry) registerName(name string, rcvr interface{}) error {
}
r.services[name] = svc
}
- for name, cb := range callbacks {
+ for methodName, cb := range callbacks {
if cb.isSubscribe {
- svc.subscriptions[name] = cb
+ if _, exist := svc.subscriptions[methodName]; exist {
+ utils.Fatalf("API double-register of %v.%v\n", name, methodName)
+ }
+ svc.subscriptions[methodName] = cb
} else {
- svc.callbacks[name] = cb
+ if _, exist := svc.callbacks[methodName]; exist {
+ utils.Fatalf("Double-register of %v.%v\n", name, methodName)
+ }
+ svc.callbacks[methodName] = cb
}
}
return nil
|
Use the implementation of ChainId from eth/api.go in internal/ethapi/api.go and removed ChainId from eth/api.go.
Hi @karalabe I've made this change |
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.
SGTM
This removes the duplicated definition of eth_chainID in package eth and updates the definition in internal/ethapi to treat chain ID as a bigint. Co-authored-by: Felix Lange <fjl@twurst.com>
Although the ChainID is represented as a
*big.Int
in theChainConfig
, itwas being marshaled as a
uint64
by thePublicEthereumAPI
. This leads todiscrepancies between the config and calls to the API when the
ChainID
is bigger than
math.MaxUint64
.