Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-vball committed Nov 28, 2024
1 parent 9ed8d9d commit 3661a57
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 45 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest {

function testSuccess() public {
// This test contract must be an allowed relayer since it is what
// will call receiveCrossSubnetMessage.
// will call receiveCrossChainMessage.
address[] memory allowedRelayers = new address[](2);
allowedRelayers[0] = address(this);
allowedRelayers[1] = DEFAULT_RELAYER_REWARD_ADDRESS;
Expand Down
6 changes: 3 additions & 3 deletions contracts/validator-manager/ValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ abstract contract ValidatorManager is Initializable, ContextUpgradeable, IValida
// Check that adding this validator would not exceed the maximum churn rate.
_checkAndUpdateChurnTracker(weight, 0);

(bytes32 validationID, bytes memory registerSubnetValidatorMessage) = ValidatorMessages
(bytes32 validationID, bytes memory registerL1ValidatorMessage) = ValidatorMessages
.packRegisterL1ValidatorMessage(
ValidatorMessages.ValidationPeriod({
l1ID: $._l1ID,
Expand All @@ -281,11 +281,11 @@ abstract contract ValidatorManager is Initializable, ContextUpgradeable, IValida
weight: weight
})
);
$._pendingRegisterValidationMessages[validationID] = registerSubnetValidatorMessage;
$._pendingRegisterValidationMessages[validationID] = registerL1ValidatorMessage;
$._registeredValidators[input.nodeID] = validationID;

// Submit the message to the Warp precompile.
bytes32 messageID = WARP_MESSENGER.sendWarpMessage(registerSubnetValidatorMessage);
bytes32 messageID = WARP_MESSENGER.sendWarpMessage(registerL1ValidatorMessage);
$._validationPeriods[validationID].status = ValidatorStatus.PendingAdded;
$._validationPeriods[validationID].nodeID = input.nodeID;
$._validationPeriods[validationID].startingWeight = weight;
Expand Down
2 changes: 1 addition & 1 deletion contracts/validator-manager/ValidatorMessages.sol
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ library ValidatorMessages {
}

/**
* @notice Unpacks a byte array as a SubnetValidatorWeightMessage.
* @notice Unpacks a byte array as an L1ValidatorWeightMessage.
* The message format specification is the same as the one used in above for packing.
*
* @param input The byte array to unpack.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct ValidatorChurnPeriod {

/**
* @notice Validator Manager settings, used to initialize the Validator Manager
* @notice The l1ID is the ID of the subnet that the Validator Manager is managing
* @notice The l1ID is the ID of the L1 that the Validator Manager is managing
* @notice The churnPeriodSeconds is the duration of the churn period in seconds
* @notice The maximumChurnPercentage is the maximum percentage of the total weight that can be added or removed in a single churn period
*/
Expand Down
12 changes: 6 additions & 6 deletions contracts/validator-manager/tests/PoSValidatorManagerTests.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1629,9 +1629,9 @@ abstract contract PoSValidatorManagerTest is ValidatorManagerTest {

uint256 balanceBefore = _getStakeAssetBalance(address(this));

bytes memory subnetValidatorRegistrationMessage =
bytes memory l1ValidatorRegistrationMessage =
ValidatorMessages.packL1ValidatorRegistrationMessage(validationID, false);
_mockGetPChainWarpMessage(subnetValidatorRegistrationMessage, true);
_mockGetPChainWarpMessage(l1ValidatorRegistrationMessage, true);

posValidatorManager.completeEndValidation(0);

Expand Down Expand Up @@ -2301,7 +2301,7 @@ abstract contract PoSValidatorManagerTest is ValidatorManagerTest {
uint64 validatorWeight,
address rewardRecipient
) internal {
bytes memory subnetValidatorRegistrationMessage =
bytes memory l1ValidatorRegistrationMessage =
ValidatorMessages.packL1ValidatorRegistrationMessage(validationID, false);

vm.expectEmit(true, true, true, true, address(posValidatorManager));
Expand All @@ -2312,7 +2312,7 @@ abstract contract PoSValidatorManagerTest is ValidatorManagerTest {
_expectStakeUnlock(validatorOwner, _weightToValue(validatorWeight));
_expectRewardIssuance(rewardRecipient, expectedReward);

_completeEndValidation(subnetValidatorRegistrationMessage);
_completeEndValidation(l1ValidatorRegistrationMessage);

if (rewardRecipient == validatorOwner) {
assertEq(
Expand All @@ -2332,8 +2332,8 @@ abstract contract PoSValidatorManagerTest is ValidatorManagerTest {
}
}

function _completeEndValidation(bytes memory subnetValidatorRegistrationMessage) internal {
_mockGetPChainWarpMessage(subnetValidatorRegistrationMessage, true);
function _completeEndValidation(bytes memory l1ValidatorRegistrationMessage) internal {
_mockGetPChainWarpMessage(l1ValidatorRegistrationMessage, true);
posValidatorManager.completeEndValidation(0);
}

Expand Down
20 changes: 10 additions & 10 deletions contracts/validator-manager/tests/ValidatorManagerTests.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ abstract contract ValidatorManagerTest is Test {
bytes32 validationID = _setUpInitializeValidatorRegistration(
DEFAULT_NODE_ID, DEFAULT_L1_ID, DEFAULT_WEIGHT, DEFAULT_EXPIRY, DEFAULT_BLS_PUBLIC_KEY
);
(, bytes memory registerSubnetValidatorMessage) = ValidatorMessages
(, bytes memory registerL1ValidatorMessage) = ValidatorMessages
.packRegisterL1ValidatorMessage(
ValidatorMessages.ValidationPeriod({
l1ID: DEFAULT_L1_ID,
Expand All @@ -202,7 +202,7 @@ abstract contract ValidatorManagerTest is Test {
weight: DEFAULT_WEIGHT
})
);
_mockSendWarpMessage(registerSubnetValidatorMessage, bytes32(0));
_mockSendWarpMessage(registerL1ValidatorMessage, bytes32(0));
validatorManager.resendRegisterValidatorMessage(validationID);
}

Expand Down Expand Up @@ -259,10 +259,10 @@ abstract contract ValidatorManagerTest is Test {
force: false
});

bytes memory subnetValidatorRegistrationMessage =
bytes memory l1ValidatorRegistrationMessage =
ValidatorMessages.packL1ValidatorRegistrationMessage(validationID, false);

_mockGetPChainWarpMessage(subnetValidatorRegistrationMessage, true);
_mockGetPChainWarpMessage(l1ValidatorRegistrationMessage, true);

vm.expectEmit(true, true, true, true, address(validatorManager));
emit ValidationPeriodEnded(validationID, ValidatorStatus.Completed);
Expand All @@ -274,10 +274,10 @@ abstract contract ValidatorManagerTest is Test {
bytes32 validationID = _setUpInitializeValidatorRegistration(
DEFAULT_NODE_ID, DEFAULT_L1_ID, DEFAULT_WEIGHT, DEFAULT_EXPIRY, DEFAULT_BLS_PUBLIC_KEY
);
bytes memory subnetValidatorRegistrationMessage =
bytes memory l1ValidatorRegistrationMessage =
ValidatorMessages.packL1ValidatorRegistrationMessage(validationID, false);

_mockGetPChainWarpMessage(subnetValidatorRegistrationMessage, true);
_mockGetPChainWarpMessage(l1ValidatorRegistrationMessage, true);

vm.expectEmit(true, true, true, true, address(validatorManager));
emit ValidationPeriodEnded(validationID, ValidatorStatus.Invalidated);
Expand Down Expand Up @@ -417,7 +417,7 @@ abstract contract ValidatorManagerTest is Test {
weight: weight
})
);
(, bytes memory registerSubnetValidatorMessage) = ValidatorMessages
(, bytes memory registerL1ValidatorMessage) = ValidatorMessages
.packRegisterL1ValidatorMessage(
ValidatorMessages.ValidationPeriod({
l1ID: l1ID,
Expand All @@ -430,7 +430,7 @@ abstract contract ValidatorManagerTest is Test {
})
);
vm.warp(registrationExpiry - 1);
_mockSendWarpMessage(registerSubnetValidatorMessage, bytes32(0));
_mockSendWarpMessage(registerL1ValidatorMessage, bytes32(0));

_beforeSend(_weightToValue(weight), address(this));
vm.expectEmit(true, true, true, true, address(validatorManager));
Expand Down Expand Up @@ -459,10 +459,10 @@ abstract contract ValidatorManagerTest is Test {
validationID = _setUpInitializeValidatorRegistration(
nodeID, l1ID, weight, registrationExpiry, blsPublicKey
);
bytes memory subnetValidatorRegistrationMessage =
bytes memory l1ValidatorRegistrationMessage =
ValidatorMessages.packL1ValidatorRegistrationMessage(validationID, true);

_mockGetPChainWarpMessage(subnetValidatorRegistrationMessage, true);
_mockGetPChainWarpMessage(l1ValidatorRegistrationMessage, true);

vm.warp(registrationTimestamp);
vm.expectEmit(true, true, true, true, address(validatorManager));
Expand Down
2 changes: 1 addition & 1 deletion tests/flows/teleporter/add_fee_amount.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func AddFeeAmount(network *localnetwork.LocalNetwork, teleporter utils.Teleporte
fundedKey,
)

// Relay message containing the specific receipt from Subnet B to Subnet A
// Relay message containing the specific receipt from L1 B to L1 A
teleporter.RelayTeleporterMessage(
ctx,
sendSpecificReceiptsReceipt,
Expand Down
6 changes: 4 additions & 2 deletions tests/flows/teleporter/insufficient_gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ func InsufficientGas(network *localnetwork.LocalNetwork, teleporter utils.Telepo
// Send message from L1A to L1B with 0 execution gas, which should fail to execute
message := "Hello, world!"
optsA, err := bind.NewKeyedTransactorWithChainID(
fundedKey, l1AInfo.EVMChainID)
fundedKey,
l1AInfo.EVMChainID,
)
Expect(err).Should(BeNil())
tx, err := l1ATestMessenger.SendMessage(
optsA, l1BInfo.BlockchainID, testMessengerContractB, fundedAddress, big.NewInt(0), big.NewInt(0), message,
Expand All @@ -58,7 +60,7 @@ func InsufficientGas(network *localnetwork.LocalNetwork, teleporter utils.Telepo
aggregator := network.GetSignatureAggregator()
defer aggregator.Shutdown()

// Relay message from SubnetA to SubnetB
// Relay message from L1 A to L1 B
receipt = teleporter.RelayTeleporterMessage(
ctx,
receipt,
Expand Down
4 changes: 2 additions & 2 deletions tests/flows/teleporter/registry/pause_teleporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func PauseTeleporter(network *localnetwork.LocalNetwork, teleporter utils.Telepo
aggregator := network.GetSignatureAggregator()
defer aggregator.Shutdown()

// Send a message from subnet A to subnet B, which should fail
// Send a message from L1 A to L1 B, which should fail
teleporter.SendExampleCrossChainMessageAndVerify(
ctx,
l1AInfo,
Expand All @@ -82,7 +82,7 @@ func PauseTeleporter(network *localnetwork.LocalNetwork, teleporter utils.Telepo
Expect(err).Should(BeNil())
Expect(isPaused).Should(BeFalse())

// Send a message from subnet A to subnet B again, which should now succeed
// Send a message from L1 A to L1 B again, which should now succeed
teleporter.SendExampleCrossChainMessageAndVerify(
ctx,
l1AInfo,
Expand Down
2 changes: 1 addition & 1 deletion tests/flows/teleporter/registry/teleporter_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TeleporterRegistry(network *localnetwork.LocalNetwork, teleporter utils.Tel
aggregator := network.GetSignatureAggregator()
defer aggregator.Shutdown()

// Call addProtocolVersion on subnetB to register the new Teleporter version
// Call addProtocolVersion on L1 B to register the new Teleporter version
teleporter.AddProtocolVersionAndWaitForAcceptance(
ctx,
l1BInfo,
Expand Down
12 changes: 6 additions & 6 deletions tests/flows/teleporter/send_specific_receipts.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func SendSpecificReceipts(network *localnetwork.LocalNetwork, teleporter utils.T
aggregator := network.GetSignatureAggregator()
defer aggregator.Shutdown()

// Clear the receipt queue from Subnet B -> Subnet A to have a clean slate for the test flow.
// Clear the receipt queue from L1 B -> L1 A to have a clean slate for the test flow.
teleporter.ClearReceiptQueue(ctx, fundedKey, l1BInfo, l1AInfo, aggregator)

// Use mock token as the fee token
Expand Down Expand Up @@ -120,7 +120,7 @@ func SendSpecificReceipts(network *localnetwork.LocalNetwork, teleporter utils.T
Expect(delivered).Should(BeTrue())

// Call send specific receipts to get reward of relaying two messages
goLog.Println("Sending specific receipts from Subnet B to Subnet A")
goLog.Println("Sending specific receipts from L1 B to L1 A")
receipt, messageID := utils.SendSpecifiedReceiptsAndWaitForAcceptance(
ctx,
l1BTeleporterMessenger,
Expand All @@ -135,8 +135,8 @@ func SendSpecificReceipts(network *localnetwork.LocalNetwork, teleporter utils.T
fundedKey,
)

// Relay message from Subnet B to Subnet A
goLog.Println("Relaying the specific receipts from Subnet B to Subnet A")
// Relay message from L1 B to L1 A
goLog.Println("Relaying the specific receipts from L1 B to L1 A")
receipt = teleporter.RelayTeleporterMessage(
ctx,
receipt,
Expand Down Expand Up @@ -184,13 +184,13 @@ func SendSpecificReceipts(network *localnetwork.LocalNetwork, teleporter utils.T
Message: []byte{1, 2, 3, 4},
}

goLog.Println("Sending a message from Subnet B to Subnet A to trigger receipts")
goLog.Println("Sending a message from L1 B to L1 A to trigger receipts")
// This message will also have the same receipts as the previous message
receipt, messageID = utils.SendCrossChainMessageAndWaitForAcceptance(
ctx, l1BTeleporterMessenger, l1BInfo, l1AInfo, sendCrossChainMessageInput, fundedKey)

goLog.Println("Relaying the message from L1 B to L1 A")
// Relay message from Subnet B to Subnet A
// Relay message from L1 B to L1 A
receipt = teleporter.RelayTeleporterMessage(
ctx,
receipt,
Expand Down
2 changes: 1 addition & 1 deletion tests/interfaces/subnet_test_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/ava-labs/subnet-evm/ethclient"
)

// Tracks information about a test subnet used for executing tests against.
// Tracks information about a test L1 used for executing tests against.
type L1TestInfo struct {
L1ID ids.ID
BlockchainID ids.ID
Expand Down
3 changes: 2 additions & 1 deletion tests/suites/teleporter/teleporter_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ var _ = ginkgo.BeforeSuite(func() {
utils.PoAValidatorManager,
[]uint64{units.Schmeckle, units.Schmeckle, units.Schmeckle, units.Schmeckle, units.Schmeckle},
fundedKey,
false)
false,
)
}

log.Info("Set up ginkgo before suite")
Expand Down
6 changes: 3 additions & 3 deletions tests/utils/teleporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (t TeleporterTestInfo) SendExampleCrossChainMessageAndVerify(
signatureAggregator *aggregator.SignatureAggregator,
expectSuccess bool,
) {
// Call the example messenger contract on Subnet A
// Call the example messenger contract on L1 A
optsA, err := bind.NewKeyedTransactorWithChainID(senderKey, source.EVMChainID)
Expect(err).Should(BeNil())
tx, err := sourceExampleMessenger.SendMessage(
Expand Down Expand Up @@ -337,9 +337,9 @@ func (t TeleporterTestInfo) ClearReceiptQueue(
)
for outstandReceiptCount.Cmp(big.NewInt(0)) != 0 {
log.Info("Emptying receipt queue", "remainingReceipts", outstandReceiptCount.String())
// Send message from Subnet B to Subnet A to trigger the "regular" method of delivering receipts.
// Send message from L1 B to L1 A to trigger the "regular" method of delivering receipts.
// The next message from B->A will contain the same receipts that were manually sent in the above steps,
// but they should not be processed again on Subnet A.
// but they should not be processed again on L1 A.
sendCrossChainMessageInput := teleportermessenger.TeleporterMessageInput{
DestinationBlockchainID: destination.BlockchainID,
DestinationAddress: common.HexToAddress("0x1111111111111111111111111111111111111111"),
Expand Down

0 comments on commit 3661a57

Please sign in to comment.