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

Added eth namespace Block Header apis #1088

Merged
merged 21 commits into from
Jan 14, 2022

Conversation

aeharvlee
Copy link
Contributor

@aeharvlee aeharvlee commented Dec 15, 2021

Proposed changes

Added Engine() to backend interface and CNAPIBackend also.

  • We need it when calculating proposer of the block. This proposer will be used by (&EthereumAPI{}).Miner method.
  • Regenerated backend_mock.go also because new method Engine is added.

Added rpcMarshalHeader function.

  • This is for supporting Etheruem compatible format.

Added Methods for BlockNonce

  • Added implementations from Ethereum.
  • You can check the Ethereum implementations here.

Made BaseFee as protocol params for eth namespace.

  • Value of BaseFee and Extradata are considered by klaytn developers.
  • While defining BaseFee as protocol params, the parts that previously defined baseFee were also modified.

Types of changes

Please put an x in the boxes related to your change.

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes ($ make test)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Related issues

  • Please leave the issue numbers or links related to this PR here.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

Added Engine() to backend
* We need it when calculating proposer of the block.
* Regenerated backend_mock.go also.

Add rpcMarshalHeader
* This is for supporting Etheruem compatible format.

Add Methods for BlockNonce
* Added implementations from Ethereum.

Make BaseFee as protocol params and make extradata for eth namespace.
* Value of BaseFee and Extradata are considered by klaytn developers.
* While defining BaseFee as protocol params, the parts that previously defined baseFee were also modified.
Added Engine() to backend
* We need it when calculating proposer of the block.
@aeharvlee aeharvlee added this to the v1.8.0 milestone Dec 16, 2021
ExtraData should be empty which is discussed by Klaytn devs.
GasLimit: current ethereum gas limit x 30
api/api_ethereum.go Outdated Show resolved Hide resolved
GetHeaderByNumber in Ethereum always return nil
because the backend returns nil at error position.
Comment on lines 373 to 375
klaytnHeader, err := api.publicBlockChainAPI.GetHeaderByNumber(ctx, number)
// In Ethereum, err is always nil because the backend of Ethereum always return nil.
err = nil
Copy link
Contributor Author

@aeharvlee aeharvlee Jan 3, 2022

Choose a reason for hiding this comment

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

It can be looked weird, but currently Ethereum backend always return nil at error position.

Ethereum source code link.

Klaytn devs decided to serve this field as empty when serving
eth namespace api.
api/api_ethereum.go Outdated Show resolved Hide resolved
blockchain/vm/runtime/runtime.go Show resolved Hide resolved
api/api_ethereum.go Outdated Show resolved Hide resolved
api/api_ethereum.go Outdated Show resolved Hide resolved
api/api_ethereum_test.go Outdated Show resolved Hide resolved
aeharvlee and others added 4 commits January 4, 2022 13:06
Co-authored-by: yumiel yoomee1313 <yumiel.ko@krustuniverse.com>
Co-authored-by: yumiel yoomee1313 <yumiel.ko@krustuniverse.com>
yoomee1313
yoomee1313 previously approved these changes Jan 4, 2022
hqjang-pepper
hqjang-pepper previously approved these changes Jan 6, 2022
Comment on lines +64 to +69
results := reflect.ValueOf(&api).MethodByName(testAPIName).Call(
[]reflect.Value{
reflect.ValueOf(context.Background()),
reflect.ValueOf(blockParam),
},
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Reflect package is used due to call multiple api tests at a time

jimni1222
jimni1222 previously approved these changes Jan 6, 2022
api/api_ethereum.go Outdated Show resolved Hide resolved
Inserting error directly is a bad practice.
So use another way to handle it.

Use logger exactly.
Co-authored-by: Donghwan Aidan Kwon <48199072+aidan-kwon@users.noreply.github.com>
jimni1222
jimni1222 previously approved these changes Jan 10, 2022
All block signatures should be recoverable, and miner is the field Klaytn should provide the correct value. It's not the field dummy value is allowed.
Gave values to header so that we can check whether rpcMarshalHeader assigns all fields values properly
Just compare field and values using json marshaling, it is more simpler
@ehnuje ehnuje requested a review from bitaholic January 13, 2022 06:21
Copy link
Member

@aidan-kwon aidan-kwon left a comment

Choose a reason for hiding this comment

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

Thank you!

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.

None yet

6 participants