-
Notifications
You must be signed in to change notification settings - Fork 39
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
fix: include genesis validators in gateway parent validators tracker #1166
base: main
Are you sure you want to change the base?
fix: include genesis validators in gateway parent validators tracker #1166
Conversation
Signed-off-by: Sander Pick <[email protected]>
@@ -203,6 +203,11 @@ library LibValidatorSet { | |||
validators.validators[validator].metadata = metadata; | |||
} | |||
|
|||
/// @notice Set validator data using metadata from memory bytes | |||
function setMetadataFromConstructor(ValidatorSet storage validators, address validator, bytes memory metadata) internal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugly... we can only have bytes memory
in the constructor.
Hunch: This issue is also the reason that in federated mode, you have to always include all validators, instead of being able to add them one-by-one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanderpick The fix is correct for staking, but need to call record federated for permission mode. But adding permission mode into the constructor is actually quite a big change propagating to fendermint too. Check out #1150 as well, some ideas are documented there too.
uint256 amount = params.genesisValidators[i].weight; | ||
bytes memory metadata = params.genesisValidators[i].metadata; | ||
LibValidatorSet.setMetadataFromConstructor(s.validatorsTracker.validators, addr, metadata); | ||
LibValidatorSet.recordDeposit(s.validatorsTracker.validators, addr, amount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this technically works for Staking
backed power, but will not work for federated. Ideally it would call record federated based on the permission mode.
Ah, makes sense. Somehow I missed #1150. I'm happy to take a stab at passing the mode in the constructor here, but sounds like from slack convo you're picking this up. If so, do you want access to this branch or will you just recreate it? Nbd either way. |
@sanderpick yeah, it's quite tedious to fix the constructor, quite some code needs to be updated in fendermint. @raulk mentioned yesterday that he will check this out to see if there are easier fixes. But I think for collateral based subnets, this is the fix. |
This PR is the result of trying to track down the cause of the following behavior:
listActiveValidators()
will be zero when applying this first change here.WeightsSumLessThanThreshold
http://localhost:<comet_rpc_port>/status
). Power is zero for the first two nodes.I'm not sure if this fix is ideal, but it works. It just adds the genesis validators to the parent validator tracker before setting the initial membership in the gateway constructor.