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

WIP fix eth_getRewardByHash by enabling storereward #745

Closed
wants to merge 2 commits into from

Conversation

wanwiset25
Copy link
Collaborator

@wanwiset25 wanwiset25 commented Nov 25, 2024

Proposed changes

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Regular KTLO or any of the maintaince work. e.g code style
  • CICD Improvement

Impacted Components

Which part of the codebase this PR will touch base on,

Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)
    API

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

if err == nil {
rewards := make(map[string]map[string]map[string]*big.Int)
err = json.Unmarshal(data, &rewards)
if err == nil {
log.Error("[GetRewardByHash] file found and returning rewards", "blocknum", header.Number.String())
Copy link
Collaborator

Choose a reason for hiding this comment

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

why log an error when err == nil ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed, thanks!

@gzliudan
Copy link
Collaborator

The function GetRewardByHash is also exist in the file les/api_backend.go

@@ -408,25 +408,19 @@ func (b *EthApiBackend) StateAtBlock(ctx context.Context, block *types.Block, re

func (s *EthApiBackend) GetRewardByHash(hash common.Hash) map[string]map[string]map[string]*big.Int {
header := s.eth.blockchain.GetHeaderByHash(hash)
err := errors.New("header hash not found")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line is useless sometimes, such as when return rewards.

Copy link

@liam-icheng-lai liam-icheng-lai Nov 25, 2024

Choose a reason for hiding this comment

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

relocate this error declaration and put a missing hash into the message, so that whenever it logs, we know which hash is missing

}
}
log.Error("[GetRewardByHash]", "err", err)
return make(map[string]map[string]map[string]*big.Int)
Copy link
Collaborator

@gzliudan gzliudan Nov 25, 2024

Choose a reason for hiding this comment

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

Can we return nil and err if err != nil ? So API caller know the fail reason.

@wanwiset25 wanwiset25 changed the title fix eth_getRewardByHash by enabling storereward WIP fix eth_getRewardByHash by enabling storereward Nov 25, 2024
@wanwiset25
Copy link
Collaborator Author

this change is not required anymore
I checked with Subnet but now have confirmed the behavior in XDPoS is different and already correct

@wanwiset25 wanwiset25 closed this Nov 26, 2024
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