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

[ethapi] Expose overrides to eth client as well #21738

Closed
wants to merge 1 commit into from

Conversation

fxfactorial
Copy link
Contributor

after seeing it mentioned in a tweet - checked and saw ethclient doesn't expose overrides of contract calls (eth_call)

also changed the extra pointer - maps are already pointers

// a message call.
// Note, state and stateDiff can't be specified at the same time. If state is
// set, message execution will only use the data in the given state. Otherwise
// if statDiff is set, all diff will be applied first and then execute the call
// message.
type account struct {
type Account struct {
Copy link
Member

Choose a reason for hiding this comment

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

This is an internal packag,e you can't use it as an API surface, Go won't allow outside callers to access it. All in all internal is meant to be used internally by Geth.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahh - that's right - okay so I either move it out or make a same type in ethclient.go - i wonder if a type alias would do the trick 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.

just tried - a type alias worked great - I make an account in outside go-ethereum code just fine

var accounts map[common.Address]account
func (s *PublicBlockChainAPI) Call(
ctx context.Context, args CallArgs,
blockNrOrHash rpc.BlockNumberOrHash, overrides map[common.Address]Account,
Copy link
Member

Choose a reason for hiding this comment

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

The point of *map[common.Address]account is to differentiate between mandatory an optional arguments in the RPC layer. Please revert.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but if caller doesn't provide the map - anyway it will be nil, no?

@fxfactorial
Copy link
Contributor Author

ah - seems like i need to also change up abigen because my bindings now not compiling

Copy link
Contributor

@fjl fjl left a comment

Choose a reason for hiding this comment

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

We cannot change CallContract because it is part of the stable API, and many other projects use this API.

The state overrides are not supported everywhere, and I would strongly prefer to not add this functionality to ethclient. But I also understand it's annoying having to wrap the geth-specific APIs yourself.

I think what we could do is to add a new package "ethclient/gethclient" that contains an RPC wrapper for all the Geth-specific functionality.

@fxfactorial
Copy link
Contributor Author

@fjl okay that's a good point - I agree. Is there an enumeration of the specific geth functionalities ?

@fjl
Copy link
Contributor

fjl commented Oct 25, 2020

Not really, but you can check the https://geth.ethereum.org/docs/rpc/server site for info about the geth-specific RPC methods (see sidebar).

@fxfactorial
Copy link
Contributor Author

@fjl woof - that looks like quite a bit of refactoring to get that out the door - maybe if there is a design desired - i can impl that - otherwise i might go in a direction ya'll don't agree with

@fjl
Copy link
Contributor

fjl commented Nov 2, 2020

You don't need to add all the methods, just add the package and the method you want.
We can expand the method set later when more people want other methods.

If you need some design help, what I want is something that's basically like ethclient:

package gethclient

type Client struct{
     c *rpc.Client
}

type AccountOverrides struct{
	Nonce     *hexutil.Uint64              `json:"nonce"`
	Code      *hexutil.Bytes               `json:"code"`
	Balance   **hexutil.Big                `json:"balance"`
	State     *map[common.Hash]common.Hash `json:"state"`
	StateDiff *map[common.Hash]common.Hash `json:"stateDiff"`
}

func (ec *Client) Call(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int, overrides map[common.Address]AccountOverrides) ([]byte, error) {
    ...
}

@fjl
Copy link
Contributor

fjl commented May 27, 2021

I'm still interested to add this 'gethclient' package, but don't have time to work on it right now.
@fxfactorial If you have time, we would absolutely accept a PR to add a basic version of it, even if it only contains one method.

Closing this because we won't make the change in ethclient itself.

@fjl fjl closed this May 27, 2021
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.

3 participants