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

blockchain: make a genesis block according to forks #246

Merged
merged 8 commits into from
Feb 6, 2025

Conversation

ulbqb
Copy link
Contributor

@ulbqb ulbqb commented Feb 3, 2025

Proposed changes

This PR enables to make genesis blocks according to forks. This may have braking change in the case where the fork of genesis is Istanbul fork and after because this changes the state root of genesis by changing codeinfo of SCA (version 0 into version 1). But there is no effect against mainnet and testnet because the genesis doesn't have any forks. You can see the state roof of genesis doesn't change in this test.

This stores genesis accounts like bellow:

  • account with delegation code and fork is prague → CreateEOA and SetCodeToEOA
  • account with empty code but non-empty storage and fork is prague → CreateEOA
  • account with non-empty code except for delegation code → CreateSmartContractAccount and SetCode
  • otherwise → as is

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 read the CLA and signed by comment I have read the CLA Document and I hereby sign the CLA in first time contribute
  • 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

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

@ulbqb ulbqb mentioned this pull request Feb 3, 2025
9 tasks
@ulbqb ulbqb self-assigned this Feb 3, 2025
@ulbqb ulbqb marked this pull request as draft February 3, 2025 08:05
@ulbqb ulbqb force-pushed the fix/genesis_toblock branch from ec909e9 to 8c57216 Compare February 4, 2025 07:01
@ulbqb ulbqb changed the title blockchain: make a genesis block with reference to rules blockchain: make a genesis block with reference to forks Feb 4, 2025
@ulbqb ulbqb changed the title blockchain: make a genesis block with reference to forks blockchain: make a genesis block according to forks Feb 4, 2025
@ulbqb ulbqb marked this pull request as ready for review February 4, 2025 07:23
@shiki-tak
Copy link
Contributor

How about clearly indicating in the code that the code diff from this PR does not affect the production (test) environment and is for testing purposes? Or adding a link to this PR in the code?

@ulbqb
Copy link
Contributor Author

ulbqb commented Feb 6, 2025

@shiki-tak
This change is needed for not only test but also main env. But this just doesn't affect live mainnet and testnet.

Copy link
Contributor

@hyunsooda hyunsooda left a comment

Choose a reason for hiding this comment

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

If I'm not mistaken, I don't see negative impact to other area by genesis block state changing. Also, this may be treated as correct modification

Comment on lines +325 to +329
// If account.Code is nil and originalCode is not nil,
// just update the code and don't change the other states
if len(account.Code) != 0 && originalCode != nil {
logger.Warn("this address already has a not nil code, now the code of this address has been changed", "addr", addr.String())
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this can be checked first before L316-322.

Copy link
Contributor Author

@ulbqb ulbqb Feb 6, 2025

Choose a reason for hiding this comment

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

I can't do that. I want to do continue after setting code if an original code exists.

ulbqb and others added 2 commits February 6, 2025 16:32
@ulbqb ulbqb requested a review from Mdaiki0730 February 6, 2025 09:24
Copy link
Contributor

@Mdaiki0730 Mdaiki0730 left a comment

Choose a reason for hiding this comment

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

LGTM

@ulbqb ulbqb merged commit e9c79b1 into kaiachain:dev Feb 6, 2025
11 checks passed
@ulbqb ulbqb deleted the fix/genesis_toblock branch February 6, 2025 12:24
@github-actions github-actions bot locked and limited conversation to collaborators Feb 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants