-
Notifications
You must be signed in to change notification settings - Fork 328
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
[api] historical eth_getbalance & eth_call #4339
base: master
Are you sure you want to change the base?
Conversation
api/coreservice.go
Outdated
case rpc.SafeBlockNumber, rpc.FinalizedBlockNumber, rpc.LatestBlockNumber: | ||
stateHeight = core.bc.TipHeight() | ||
case rpc.EarliestBlockNumber: | ||
stateHeight = core.bc.Genesis().EasterBlockHeight |
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.
why it is easter height? it should be 1
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.
good catch
@@ -367,8 +368,8 @@ func (svr *gRPCHandler) ReadContract(ctx context.Context, in *iotexapi.ReadContr | |||
return nil, status.Error(codes.InvalidArgument, err.Error()) | |||
} | |||
sc.SetGasLimit(in.GetGasLimit()) | |||
|
|||
data, receipt, err := svr.coreService.ReadContract(ctx, callerAddr, sc) | |||
sc.SetGasPrice(big.NewInt(0)) // ReadContract() is read-only, use 0 to prevent insufficient gas |
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.
can this be omitted? I mean, by default it should be 0?
@@ -399,7 +404,8 @@ func (svr *web3Handler) call(in *gjson.Result) (interface{}, error) { | |||
return "0x" + ret, nil | |||
} | |||
exec, _ := action.NewExecution(to, 0, value, gasLimit, gasPrice, data) | |||
ret, receipt, err := svr.coreService.ReadContract(context.Background(), callerAddr, exec) | |||
exec.SetGasPrice(big.NewInt(0)) // ReadContract() is read-only, use 0 to prevent insufficient gas |
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.
same as above
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.
the gasPrice may not be 0, because it can be set by the action sender
Quality Gate passedIssues Measures |
func AccountStateAtHeight(ctx context.Context, height uint64, sr protocol.HistroicalStateReader, | ||
addr address.Address) (*state.Account, error) { |
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.
format
@@ -350,6 +404,7 @@ func (core *coreService) Account(addr address.Address) (*iotextypes.AccountMeta, | |||
accountMeta.ContractByteCode = code | |||
} | |||
span.AddEvent("bc.BlockHeaderByHeight") | |||
tipHeight := core.bc.TipHeight() |
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.
the tipHeight
may be from a different value from state
read from https://github.com/iotexproject/iotex-core/pull/4339/files#diff-a84e0d7fdb009bebf88eb3c2582dc4c2f5fce09f6d40a3a514b553c198675f42R373
Description
as title
Fixes #(issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: