evm: make setGuardianSetHash public
This commit is contained in:
parent
7b90ea119b
commit
ed86ea95f7
|
@ -108,7 +108,7 @@ abstract contract Governance is GovernanceStructs, Messages, Setters, ERC1967Upg
|
|||
storeGuardianSet(upgrade.newGuardianSet, upgrade.newGuardianSetIndex);
|
||||
|
||||
// Store the guardian set hash
|
||||
setGuardianSetHash(upgrade.newGuardianSetIndex, upgrade.newGuardianSetHash);
|
||||
setGuardianSetHash(upgrade.newGuardianSetIndex);
|
||||
|
||||
// Makes the new guardianSet effective
|
||||
updateGuardianSetIndex(upgrade.newGuardianSetIndex);
|
||||
|
|
|
@ -31,7 +31,6 @@ contract GovernanceStructs {
|
|||
uint8 action;
|
||||
uint16 chain;
|
||||
|
||||
bytes32 newGuardianSetHash;
|
||||
Structs.GuardianSet newGuardianSet;
|
||||
uint32 newGuardianSetIndex;
|
||||
}
|
||||
|
@ -103,9 +102,6 @@ contract GovernanceStructs {
|
|||
uint8 guardianLength = encodedUpgrade.toUint8(index);
|
||||
index += 1;
|
||||
|
||||
// Guardian set hash.
|
||||
gsu.newGuardianSetHash = keccak256(encodedUpgrade.slice(index, guardianLength * 20 + 4));
|
||||
|
||||
gsu.newGuardianSet = Structs.GuardianSet({
|
||||
keys : new address[](guardianLength),
|
||||
expirationTime : 0
|
||||
|
|
|
@ -56,7 +56,20 @@ contract Setters is State {
|
|||
_state.evmChainId = evmChainId;
|
||||
}
|
||||
|
||||
function setGuardianSetHash(uint32 index, bytes32 hash) internal {
|
||||
_state.guardianSetHashes[index] = hash;
|
||||
function setGuardianSetHash(uint32 index) public {
|
||||
// Fetch the guardian set at the specified index.
|
||||
Structs.GuardianSet memory guardianSet = _state.guardianSets[index];
|
||||
|
||||
uint256 guardianCount = guardianSet.keys.length;
|
||||
bytes memory encodedGuardianSet;
|
||||
for (uint256 i = 0; i < guardianCount;) {
|
||||
encodedGuardianSet = abi.encodePacked(encodedGuardianSet, guardianSet.keys[i]);
|
||||
unchecked { i += 1; }
|
||||
}
|
||||
|
||||
// Store the hash.
|
||||
_state.guardianSetHashes[index] = keccak256(
|
||||
abi.encodePacked(encodedGuardianSet, guardianSet.expirationTime)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue