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

[api] historical eth_getbalance & eth_call #4339

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

envestcc
Copy link
Member

Description

as title

Fixes #(issue)

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

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

  • [] make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

@envestcc envestcc requested review from CoderZhi, dustinxie, Liuhaai and a team as code owners July 19, 2024 00:49
@envestcc envestcc marked this pull request as draft July 19, 2024 01:18
@envestcc envestcc marked this pull request as ready for review July 22, 2024 00:45
case rpc.SafeBlockNumber, rpc.FinalizedBlockNumber, rpc.LatestBlockNumber:
stateHeight = core.bc.TipHeight()
case rpc.EarliestBlockNumber:
stateHeight = core.bc.Genesis().EasterBlockHeight
Copy link
Member

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

Copy link
Member Author

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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

same as above

Copy link
Member Author

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

Copy link

sonarcloud bot commented Aug 1, 2024

Comment on lines +111 to +112
func AccountStateAtHeight(ctx context.Context, height uint64, sr protocol.HistroicalStateReader,
addr address.Address) (*state.Account, error) {
Copy link
Collaborator

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()
Copy link
Collaborator

Choose a reason for hiding this comment

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

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