fix: include genesis validators in gateway parent validators tracker#1166
fix: include genesis validators in gateway parent validators tracker#1166sanderpick wants to merge 1 commit intoconsensus-shipyard:mainfrom
Conversation
Signed-off-by: Sander Pick <sanderpick@gmail.com>
| } | ||
|
|
||
| /// @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.
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.
@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.
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. |
|
closes this PR as it's fixed in #1302 |
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.WeightsSumLessThanThresholdhttp://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.
This change is