Skip to content

Commit

Permalink
emit full data in indexed events
Browse files Browse the repository at this point in the history
  • Loading branch information
cam-schultz committed Jan 8, 2025
1 parent 9d3a3d9 commit f4cfd3d
Show file tree
Hide file tree
Showing 11 changed files with 630 additions and 386 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions contracts/validator-manager/ValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ abstract contract ValidatorManager is Initializable, ContextUpgradeable, IValida
totalWeight += initialValidator.weight;

emit InitialValidatorCreated(
validationID, initialValidator.nodeID, initialValidator.weight
validationID, initialValidator.weight, initialValidator.nodeID
);
}
$._churnTracker.totalWeight = totalWeight;
Expand Down Expand Up @@ -300,7 +300,7 @@ abstract contract ValidatorManager is Initializable, ContextUpgradeable, IValida
$._validationPeriods[validationID].endedAt = 0;

emit ValidationPeriodCreated(
validationID, input.nodeID, messageID, weight, input.registrationExpiry
validationID, messageID, weight, input.nodeID, input.registrationExpiry
);

return validationID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ interface IPoSValidatorManager is IValidatorManager {
* @param startTime The time at which the registration was completed
*/
event DelegatorRegistered(
bytes32 indexed delegationID, bytes32 indexed validationID, uint256 startTime
bytes32 indexed delegationID, bytes32 indexed validationID, uint256 indexed startTime
);

/**
Expand All @@ -116,15 +116,18 @@ interface IPoSValidatorManager is IValidatorManager {
* @param fees The portion of the delegator's rewards paid to the validator
*/
event DelegationEnded(
bytes32 indexed delegationID, bytes32 indexed validationID, uint256 rewards, uint256 fees
bytes32 indexed delegationID,
bytes32 indexed validationID,
uint256 indexed rewards,
uint256 fees
);

/**
* @notice Event emitted when the uptime of a validator is updated. Only emitted when the uptime is greater than the stored uptime.
* @param validationID The ID of the validation period
* @param uptime The updated uptime of the validator
*/
event UptimeUpdated(bytes32 indexed validationID, uint64 uptime);
event UptimeUpdated(bytes32 indexed validationID, uint64 indexed uptime);

/**
* @notice Updates the uptime of the validationID if the submitted proof is greated than the stored uptime.
Expand Down
12 changes: 6 additions & 6 deletions contracts/validator-manager/interfaces/IValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ interface IValidatorManager {
*/
event ValidationPeriodCreated(
bytes32 indexed validationID,
bytes indexed nodeID,
bytes32 indexed registerValidationMessageID,
uint64 weight,
uint64 indexed weight,
bytes nodeID,
uint64 registrationExpiry
);

event InitialValidatorCreated(
bytes32 indexed validationID, bytes indexed nodeID, uint64 weight
bytes32 indexed validationID, uint64 indexed weight, bytes nodeID
);

/**
Expand All @@ -130,7 +130,7 @@ interface IValidatorManager {
* @param timestamp The time at which the validation period was registered with the contract.
*/
event ValidationPeriodRegistered(
bytes32 indexed validationID, uint64 weight, uint256 timestamp
bytes32 indexed validationID, uint64 indexed weight, uint256 indexed timestamp
);

/**
Expand All @@ -145,7 +145,7 @@ interface IValidatorManager {
event ValidatorRemovalInitialized(
bytes32 indexed validationID,
bytes32 indexed setWeightMessageID,
uint64 weight,
uint64 indexed weight,
uint256 endTime
);

Expand All @@ -167,7 +167,7 @@ interface IValidatorManager {
event ValidatorWeightUpdate(
bytes32 indexed validationID,
uint64 indexed nonce,
uint64 weight,
uint64 indexed weight,
bytes32 setWeightMessageID
);

Expand Down
16 changes: 6 additions & 10 deletions contracts/validator-manager/tests/PoSValidatorManagerTests.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,19 @@ abstract contract PoSValidatorManagerTest is ValidatorManagerTest {
);

event DelegatorRegistered(
bytes32 indexed delegationID, bytes32 indexed validationID, uint256 startTime
bytes32 indexed delegationID, bytes32 indexed validationID, uint256 indexed startTime
);

event DelegatorRemovalInitialized(bytes32 indexed delegationID, bytes32 indexed validationID);

event ValidatorWeightUpdate(
bytes32 indexed validationID,
uint64 indexed nonce,
uint64 weight,
bytes32 setWeightMessageID
);

event DelegationEnded(
bytes32 indexed delegationID, bytes32 indexed validationID, uint256 rewards, uint256 fees
bytes32 indexed delegationID,
bytes32 indexed validationID,
uint256 indexed rewards,
uint256 fees
);

event UptimeUpdated(bytes32 indexed validationID, uint64 uptime);
event UptimeUpdated(bytes32 indexed validationID, uint64 indexed uptime);

function testDelegationFeeBipsTooLow() public {
vm.expectRevert(
Expand Down
19 changes: 13 additions & 6 deletions contracts/validator-manager/tests/ValidatorManagerTests.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,36 @@ abstract contract ValidatorManagerTest is Test {

event ValidationPeriodCreated(
bytes32 indexed validationID,
bytes indexed nodeID,
bytes32 indexed registerValidationMessageID,
uint64 weight,
uint64 indexed weight,
bytes nodeID,
uint64 registrationExpiry
);

event InitialValidatorCreated(
bytes32 indexed validationID, bytes indexed nodeID, uint64 weight
bytes32 indexed validationID, uint64 indexed weight, bytes nodeID
);

event ValidationPeriodRegistered(
bytes32 indexed validationID, uint64 weight, uint256 timestamp
bytes32 indexed validationID, uint64 indexed weight, uint256 indexed timestamp
);

event ValidatorRemovalInitialized(
bytes32 indexed validationID,
bytes32 indexed setWeightMessageID,
uint64 weight,
uint64 indexed weight,
uint256 endTime
);

event ValidationPeriodEnded(bytes32 indexed validationID, ValidatorStatus indexed status);

event ValidatorWeightUpdate(
bytes32 indexed validationID,
uint64 indexed nonce,
uint64 indexed weight,
bytes32 setWeightMessageID
);

receive() external payable {}
fallback() external payable {}

Expand Down Expand Up @@ -446,7 +453,7 @@ abstract contract ValidatorManagerTest is Test {

_beforeSend(_weightToValue(weight), address(this));
vm.expectEmit(true, true, true, true, address(validatorManager));
emit ValidationPeriodCreated(validationID, nodeID, bytes32(0), weight, registrationExpiry);
emit ValidationPeriodCreated(validationID, bytes32(0), weight, nodeID, registrationExpiry);

_initializeValidatorRegistration(
ValidatorRegistrationInput({
Expand Down
6 changes: 6 additions & 0 deletions tests/utils/validator_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,14 @@ func InitializeValidatorSet(
)
manager, err := ivalidatormanager.NewIValidatorManager(validatorManagerAddress, l1Info.RPCClient)
Expect(err).Should(BeNil())

// Check that the first initial validator was registered successfully
initialValidatorCreatedEvent, err := GetEventFromLogs(
receipt.Logs,
manager.ParseInitialValidatorCreated,
)
Expect(err).Should(BeNil())
Expect(initialValidatorCreatedEvent.NodeID).Should(Equal(nodes[0].NodeID.Bytes()))
var validationIDs []ids.ID
for i := range nodes {
validationIDs = append(validationIDs, l1Info.SubnetID.Append(uint32(i)))
Expand Down Expand Up @@ -399,6 +402,7 @@ func InitializeNativeValidatorRegistration(
stakingManager.ParseValidationPeriodCreated,
)
Expect(err).Should(BeNil())
Expect(registrationInitiatedEvent.NodeID).Should(Equal(node.NodeID.Bytes()))
return receipt, ids.ID(registrationInitiatedEvent.ValidationID)
}

Expand Down Expand Up @@ -443,6 +447,7 @@ func InitializeERC20ValidatorRegistration(
stakingManager.ParseValidationPeriodCreated,
)
Expect(err).Should(BeNil())
Expect(registrationInitiatedEvent.NodeID).Should(Equal(node.NodeID.Bytes()))
return receipt, ids.ID(registrationInitiatedEvent.ValidationID)
}

Expand Down Expand Up @@ -473,6 +478,7 @@ func InitializePoAValidatorRegistration(
validatorManager.ParseValidationPeriodCreated,
)
Expect(err).Should(BeNil())
Expect(registrationInitiatedEvent.NodeID).Should(Equal(node.NodeID.Bytes()))
return receipt, ids.ID(registrationInitiatedEvent.ValidationID)
}

Expand Down

0 comments on commit f4cfd3d

Please sign in to comment.