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

Event indexing improvements #698

Merged
merged 4 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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 @@ -112,15 +112,13 @@ interface IValidatorManager {
*/
event ValidationPeriodCreated(
bytes32 indexed validationID,
bytes indexed nodeID,
bytes32 indexed registerValidationMessageID,
uint64 weight,
bytes nodeID,
uint64 registrationExpiry
);

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

/**
* @notice Emitted when the staking manager learns that the validation period has been successfully registered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ abstract contract PoSValidatorManagerTest is ValidatorManagerTest {
disableOwner: DEFAULT_P_CHAIN_OWNER
});

event ValidationUptimeUpdated(bytes32 indexed validationID, uint64 uptime);

event DelegatorAdded(
bytes32 indexed delegationID,
bytes32 indexed validationID,
Expand All @@ -73,13 +71,6 @@ abstract contract PoSValidatorManagerTest is ValidatorManagerTest {

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
);
Expand Down
15 changes: 10 additions & 5 deletions contracts/validator-manager/tests/ValidatorManagerTests.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,13 @@ abstract contract ValidatorManagerTest is Test {

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

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

event ValidationPeriodRegistered(
bytes32 indexed validationID, uint64 weight, uint256 timestamp
Expand All @@ -87,6 +85,13 @@ abstract contract ValidatorManagerTest is Test {

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

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

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

Expand Down Expand Up @@ -446,7 +451,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 @@ -324,11 +324,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 @@ -398,6 +401,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 @@ -442,6 +446,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 @@ -472,6 +477,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
Loading