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

Implementation of anchoring via KAS API #591

Merged
merged 4 commits into from Aug 11, 2020

Conversation

KimKyungup
Copy link
Contributor

Proposed changes

This PR complete kas package.

  • AnchorPeriodicBlock will be called by all chain event with a block to anchor periocially.
  • AnchorByBlockNum will be called by API to anchor specific block.
  • Add test codes to convert a block to a payload of KAS anchor API.

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...

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.

Please, consider re-locate kas package.
This package is only for the service chain.

kas/anchor.go Outdated
return
}

anchor.anchorBlock(block)
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't it need to handle error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is. If there is an error, anchorBlock will log.
In next stage, I will add more feature to retry anchoring in anchorBlcok.

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But for API, the function should return an error.
API will be added in next PR.

kas/anchor.go Outdated Show resolved Hide resolved
jeongkyun-oh
jeongkyun-oh previously approved these changes Aug 7, 2020
kas/anchor.go Show resolved Hide resolved
kas/anchor.go Outdated Show resolved Hide resolved
kas/anchor.go Outdated
return
}

anchor.anchorBlock(block)

This comment was marked as resolved.

kas/anchor.go Outdated Show resolved Hide resolved
kas/anchor.go Outdated
return
}

anchor.AnchorBlock(block)
Copy link
Contributor

Choose a reason for hiding this comment

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

If the returned error won't be handled, AnchorBlock should not return an error.

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 case doesn't not need to handle. But anchor API will handle the error.

Copy link
Contributor

Choose a reason for hiding this comment

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

If the error from AnchorPeriodicBlock does not need to be handled, it is not natural that an error is logged inside AnchorBlock. How about moving out log outside AnchorBlock and leave the log KASAnchor in the API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think they are different between not need to be handled and need to be logged.
Both AnchorPeriodicBlock and API need to log the error.
But for now AnchorPeriodicBlock doesn't need to be handled.

Copy link
Contributor

Choose a reason for hiding this comment

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

The point I want to emphasize is that if you don't need to handle the error, that is not an error.
As you don't handle the error from AnchorPeriodicBlock, for me, it should be a warning, not an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. I will change the caller chose log or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ehnuje PTAL. I reflected. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@KimKyungup
Copy link
Contributor Author

Please, consider re-locate kas package.
This package is only for the service chain.

@aidan-kwon Thanks. After all implementation PR, I will move this package into the service chain package.

@KimKyungup
Copy link
Contributor Author

@jeongkyun-oh @aidan-kwon PTAL :)

@KimKyungup KimKyungup merged commit 2eb90d1 into klaytn:dev Aug 11, 2020
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

4 participants