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

GraphQL master FF for review #18445

Merged
merged 42 commits into from Jan 21, 2019
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
4b53623
Initial work on a graphql API
Arachnid Oct 13, 2018
e0f4d7e
Added receipts, and more transaction fields.
Arachnid Oct 14, 2018
c46a697
Finish receipts, add logs
Arachnid Oct 14, 2018
ed02332
Add transactionCount to block
Arachnid Oct 14, 2018
cd53e60
Add types and .
Arachnid Oct 15, 2018
4e3be4f
Update Block type to be compatible with ethql
Arachnid Oct 15, 2018
9286152
Rename nonce to transactionCount in Account, to be compatible with ethql
Arachnid Oct 15, 2018
4ecd3de
Update transaction, receipt and log to match ethql
Arachnid Oct 15, 2018
76e45cf
Add query operator, for a range of blocks
Arachnid Oct 15, 2018
460d158
Added ommerCount to Block
Arachnid Oct 15, 2018
75aeee1
Add transactionAt and ommerAt to Block
Arachnid Oct 15, 2018
42bbab1
Added sendRawTransaction mutation
Arachnid Oct 16, 2018
c6c6a7a
Add Call and EstimateGas to graphQL API
Arachnid Oct 16, 2018
59e2a7f
Refactored to use hexutil.Bytes instead of HexBytes
Arachnid Oct 16, 2018
8790e18
Replace BigNum with hexutil.Big
Arachnid Oct 16, 2018
ba6f531
Refactor call and estimateGas to use ethapi struct type
Arachnid Oct 16, 2018
268a03b
Replace ethgraphql.Address with common.Address
Arachnid Oct 16, 2018
21cef58
Replace ethgraphql.Hash with common.Hash
Arachnid Oct 16, 2018
d92e373
Converted most quantities to Long instead of Int
Arachnid Oct 16, 2018
b235d18
Add support for logs
Arachnid Oct 16, 2018
549d649
Fix bug in runFilter
Arachnid Oct 16, 2018
19735c1
Restructured Transaction to work primarily with headers, so uncle dat…
Arachnid Oct 16, 2018
135b7d9
Add gasPrice API
Arachnid Oct 16, 2018
0e6fa8e
Add protocolVersion API
Arachnid Oct 16, 2018
32068e0
Add syncing API
Arachnid Oct 16, 2018
c3387f8
Moved schema into its own source file
Arachnid Oct 16, 2018
a79bacd
Move some single use args types into anonymous structs
Arachnid Oct 16, 2018
c5f893d
Add doc-comments
Arachnid Oct 17, 2018
205f82e
Fixed backend fetching to use context
Arachnid Oct 17, 2018
844aa56
Added (very) basic tests
Arachnid Oct 17, 2018
5719808
Add documentation to the graphql schema
Arachnid Oct 17, 2018
532ec8e
Fix reversion for formatting of big numbers
Arachnid Oct 18, 2018
c104779
Correct spelling error
Arachnid Oct 18, 2018
1c5ed0d
s/BigInt/Long/
Arachnid Oct 19, 2018
84874ac
Update common/types.go
holiman Oct 19, 2018
738f505
Merge branch 'master' into graphql
Arachnid Nov 22, 2018
202a100
Fixes in response to review
Arachnid Nov 22, 2018
c780558
Fix lint error
Arachnid Nov 22, 2018
dd46004
Merge branch 'master' into graphql
Dec 27, 2018
81efd4b
Updated calls on private functions
Dec 30, 2018
27e7465
Fix typo in graphql.go
Arachnid Jan 15, 2019
0c70616
Rollback ethapi breaking changes for graphql support
kshinn Jan 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions internal/ethapi/api.go
Expand Up @@ -686,14 +686,14 @@ type CallArgs struct {
func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr rpc.BlockNumber, timeout time.Duration) ([]byte, uint64, bool, error) {
defer func(start time.Time) { log.Debug("Executing EVM call finished", "runtime", time.Since(start)) }(time.Now())

state, header, err := b.StateAndHeaderByNumber(ctx, blockNr)
state, header, err := s.b.StateAndHeaderByNumber(ctx, blockNr)
if state == nil || err != nil {
return nil, 0, false, err
}
// Set sender address or use a default if none specified
var addr common.Address
if args.From == nil {
if wallets := b.AccountManager().Wallets(); len(wallets) > 0 {
if wallets := s.b.AccountManager().Wallets(); len(wallets) > 0 {
if accounts := wallets[0].Accounts(); len(accounts) > 0 {
addr = accounts[0].Address
}
Expand Down Expand Up @@ -765,9 +765,7 @@ func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNr r
return (hexutil.Bytes)(result), err
}

// DoEstimateGas returns an estimate of the amount of gas needed to execute the
// given transaction against the current pending block.
func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNr rpc.BlockNumber) (hexutil.Uint64, error) {
func (s *PublicBlockChainAPI) doEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNr rpc.BlockNumber) (hexutil.Uint64, error) {
// Binary search the gas requirement, as it may be higher than the amount used
var (
lo uint64 = params.TxGas - 1
Expand Down Expand Up @@ -814,8 +812,10 @@ func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNr rpc.Bl
return hexutil.Uint64(hi), nil
}

// EstimateGas returns an estimate of the amount of gas needed to execute the
// given transaction against the current pending block.
func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs) (hexutil.Uint64, error) {
return DoEstimateGas(ctx, s.b, args, rpc.PendingBlockNumber)
return s.doEstimateGas(ctx, s.b, args, rpc.PendingBlockNumber)
Copy link
Member

Choose a reason for hiding this comment

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

@Arachnid I would like you to confirm this change. My understanding reading your PR was that you wanted to make DoCall and DoEstimate independent. And in fact, this is what is currently breaking the build. Could you and @kshinn clarify what you want to do 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.

This was one of the changes I made to bring this inline with the direction of the design of the rest of the calls (delegating to a private method). If the intent was to move away from that direction, then the changes I made in the last commit can be omitted.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kshinn This breaks existing code (per the build):

# github.com/ethereum/go-ethereum/graphql
graphql/grahpql.go:894:30: undefined: ethapi.DoCall
graphql/grahpql.go:915:14: undefined: ethapi.DoEstimateGas

Would you mind either reverting the change or fixing that code? I'm okay with either if @gballet is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't mind at all. I'll play with getting this working and push and update to this branch.

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine either way, as long as it works.

}

// ExecutionResult groups all structured logs emitted by the EVM
Expand All @@ -842,7 +842,7 @@ type StructLogRes struct {
Storage *map[string]string `json:"storage,omitempty"`
}

// formatLogs formats EVM returned structured logs for json output
// FormatLogs formats EVM returned structured logs for json output
func FormatLogs(logs []vm.StructLog) []StructLogRes {
formatted := make([]StructLogRes, len(logs))
for index, trace := range logs {
Expand Down