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

Allow 0 premined reward wallet #1776

Merged
merged 4 commits into from
Aug 4, 2023

Conversation

sergerad
Copy link
Contributor

@sergerad sergerad commented Aug 3, 2023

Description

Update logic that prevents 0 premine for reward wallet. Allow 0 premine if epoch rewards are also 0.

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have updated the official documentation
  • I have added sufficient documentation in code

Testing

  • I have tested this code with the official test suite
  • I have tested this code manually

Manual tests

Ran local cluster against Sepolia rootchain. Verified that bridging works. Verified that legacy and EIP1559 L2 functionality works.

Copy link
Collaborator

@goran-ethernal goran-ethernal left a comment

Choose a reason for hiding this comment

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

I added a comment that needs to be fixed.

Also, one more thing that should be fixed, while I was looking at this PR, which is not directly affected by this PR, but it should be fixed since it is in regards to the reward wallet. It is the validateRewardWallet function in command/genesis/params.go. It doesn't validate the reward wallet flag correctly. It should do parsePremineInfo before checking if reward wallet address is zero address.

The function should look like this:

// validateRewardWallet validates reward wallet flag
func (p *genesisParams) validateRewardWallet() error {
	if p.rewardWallet == "" {
		return errors.New("reward wallet address must be defined")
	}

	premineInfo, err := parsePremineInfo(p.rewardWallet)
	if err != nil {
		return err
	}

	if premineInfo.address == types.ZeroAddress {
		return errors.New("reward wallet address must not be zero address")
	}

	if premineInfo.amount.Cmp(big.NewInt(0)) < 1 {
		return errRewardWalletAmountZero
	}

	return nil
}

Or check if the epochReward is 0 and rewardTokenCode is an empty string, then just don't validate the reward wallet at all.

@sergerad
Copy link
Contributor Author

sergerad commented Aug 3, 2023

@goran-ethernal Thanks - for the latter comment I went with leaving the epoch reward check after zero addr check to be safe

@goran-ethernal goran-ethernal merged commit d5be69a into 0xPolygon:develop Aug 4, 2023
6 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Aug 4, 2023
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.

None yet

3 participants