diff --git a/src/IncentivizedMessageEscrow.sol b/src/IncentivizedMessageEscrow.sol index 8024a6d..119ff2a 100644 --- a/src/IncentivizedMessageEscrow.sol +++ b/src/IncentivizedMessageEscrow.sol @@ -21,14 +21,14 @@ import "./MessagePayload.sol"; * and verify messages. There are 4 functions that an integration has to implement. * Any implementation of this contract, allows applications to deliver a message to ::submitMessage * along with the respective incentives. - * The integration (this contract) will handle transfering the message to the destination and + * The integration (this contract) will handle transferring the message to the destination and * returning an ack from the destination to the integrating application. * * The incentive is released when an ack from the destination chain is delivered to this contract. * * Beyond making relayer incentives stronger, this contract also implements several quality of life features: * - Refund unused gas. - * - Seperate gas payments for call and ack. + * - Separate gas payments for call and ack. * - Simple implementation of new messaging protocols. * * Applications integration with Generalised Incentives have to be aware that Acks are replayable. @@ -94,7 +94,7 @@ abstract contract IncentivizedMessageEscrow is IIncentivizedMessageEscrow, Bytes * @notice Verifies the authenticity of a message. * @dev Should be overwritten by the specific messaging protocol verification structure. * onRecv. implementations should collect acks so _verifyPacket returns true after acks have been executed once. - * @param messagingProtocolContext Some context that is useful for verifing the message. + * @param messagingProtocolContext Some context that is useful for verifying the message. * It should not contain the message but instead verification context like signatures, header, etc. * Context may not be needed for verifying the message and can be prepended to rawMessage. * @param rawMessage Some kind of package, initially untrusted. Should contain the message as a slice @@ -123,7 +123,7 @@ abstract contract IncentivizedMessageEscrow is IIncentivizedMessageEscrow, Bytes * @param destinationIdentifier The destination chain for the message. * @param destinationImplementation The destination escrow contract. * @param message The message. Contains relevant escrow context. - * @param deadline A timestamp that the message should be delivered before. If the AMB does not nativly + * @param deadline A timestamp that the message should be delivered before. If the AMB does not natively * support a timeout on their messages this parameter should be ignored. If 0 is provided, parse it as MAX. * @return costOfsendPacketInNativeToken An additional cost to emitting messages in NATIVE tokens. */ @@ -334,8 +334,8 @@ abstract contract IncentivizedMessageEscrow is IIncentivizedMessageEscrow, Bytes * @param destinationIdentifier 32 bytes that identifies the destination chain. * @param destinationAddress The destination application encoded in 65 bytes: First byte is the length and last 64 is the destination application. * @param message The message to be sent to the destination. Please ensure the message is block-unique. - * This means that you don't send the same message twice in a single block. If you need to do that, add a nonce or noice. - * @param incentive The incentive to attatch to the bounty. The price of this incentive has to be paid, + * This means that you don't send the same message twice in a single block. If you need to do that, add a nonce or noise. + * @param incentive The incentive to attach to the bounty. The price of this incentive has to be paid, * any excess is refunded to refundGasTo. (not msg.sender) * @param deadline After this date, do not allow relayers to execute the message on the destination chain. If set to 0, disable timeouts. * Not all AMBs may support disabling the deadline. If acks are required it is recommended to set the deadline sometime in the future. @@ -477,7 +477,7 @@ abstract contract IncentivizedMessageEscrow is IIncentivizedMessageEscrow, Bytes revert NotImplementedError(); } - // Check if there is a mis-match between the cost and the value of the message. + // Check if there is a mismatch between the cost and the value of the message. if (uint128(msg.value) != cost) { if (uint128(msg.value) > cost) { // Send the unused gas back to the the user. @@ -670,7 +670,7 @@ abstract contract IncentivizedMessageEscrow is IIncentivizedMessageEscrow, Bytes // First check if the application trusts the implementation on the destination chain. bytes32 expectedDestinationImplementationHash = implementationAddressHash[fromApplication][destinationIdentifier]; // Check that the application approves the source implementation - // For acks, this should always be the case except when a fradulent applications sends a message to this contract. + // For acks, this should always be the case except when a fraudulent applications sends a message to this contract. if (expectedDestinationImplementationHash != keccak256(destinationImplementationIdentifier)) revert InvalidImplementationAddress(); // Deliver the ack to the application. @@ -825,7 +825,7 @@ abstract contract IncentivizedMessageEscrow is IIncentivizedMessageEscrow, Bytes } /** - * @notice Verifies the input parameters are contained messageIdentfier and that the other arguments are valid. + * @notice Verifies the input parameters are contained messageIdentifier and that the other arguments are valid. * The usage of this function is intended when no parameters of a message can be trusted and we have to verify them. * This is the case when we receive a timeout, as the timeout had to be emitted without any verification * on the remote chain, for us to then verify since we know when a message identifier is good AND how to compute it. @@ -851,7 +851,7 @@ abstract contract IncentivizedMessageEscrow is IIncentivizedMessageEscrow, Bytes fromApplication = address(uint160(bytes20(message[FROM_APPLICATION_START_EVM:FROM_APPLICATION_END]))); bytes32 expectedDestinationImplementationHash = implementationAddressHash[fromApplication][destinationIdentifier]; // Check that the application approves of the remote implementation. - // For timeouts, this could fail because of fradulent sender or bad data. + // For timeouts, this could fail because of fraudulent sender or bad data. if (expectedDestinationImplementationHash != keccak256(implementationIdentifier)) revert InvalidImplementationAddress(); // Do we need to check deadline again? @@ -926,7 +926,7 @@ abstract contract IncentivizedMessageEscrow is IIncentivizedMessageEscrow, Bytes ackFee = gasSpentOnSource * priceOfAckGas; // deliveryFee + ackFee < 2**144 + 2**144 = 2**145 actualFee = deliveryFee + ackFee; - // (priceOfDeliveryGas * maxGasDelivery + priceOfDeliveryGas * maxGasAck) has been caculated before (escrowBounty) < (2**48 * 2**96) + (2**48 * 2**96) = 2**144 + 2**144 = 2**145 + // (priceOfDeliveryGas * maxGasDelivery + priceOfDeliveryGas * maxGasAck) has been calculated before (escrowBounty) < (2**48 * 2**96) + (2**48 * 2**96) = 2**144 + 2**144 = 2**145 uint256 maxDeliveryFee = maxGasDelivery * priceOfDeliveryGas; uint256 maxAckFee = maxGasAck * priceOfAckGas; uint256 maxFee = maxDeliveryFee + maxAckFee; @@ -1018,7 +1018,7 @@ abstract contract IncentivizedMessageEscrow is IIncentivizedMessageEscrow, Bytes /** * @notice Sets a bounty for a message - * @dev Does not check if enough incentives have been provided, this is delegated as responsiblity + * @dev Does not check if enough incentives have been provided, this is delegated as responsibility * of the caller of this function. * @param fromApplication The application that called the contract. Should generally be msg.sender. Is used to separate storage between applications. * @param destinationIdentifier The destination chain. Combined with fromApplication, this specifics a unique remote escrow implementation. @@ -1044,7 +1044,7 @@ abstract contract IncentivizedMessageEscrow is IIncentivizedMessageEscrow, Bytes /** * @notice Allows anyone to re-execute an ack which didn't properly execute. - * @dev No applciation should rely on this function. It should only be used incase an application has faulty logic. + * @dev No application should rely on this function. It should only be used incase an application has faulty logic. * Example: Faulty logic results in wrong enforcement on gas limit => out of gas? * * This function allows replaying acks. @@ -1094,21 +1094,21 @@ abstract contract IncentivizedMessageEscrow is IIncentivizedMessageEscrow, Bytes bytes calldata implementationIdentifier, bytes calldata receiveAckWithContext ) external payable virtual { - // Has the package previously been executed? (otherwise timeout might be more appropiate) + // Has the package previously been executed? (otherwise timeout might be more appropriate) // Load the messageIdentifier from receiveAckWithContext. - // This makes it slighly easier to retry messages. + // This makes it slightly easier to retry messages. bytes32 messageIdentifier = bytes32(receiveAckWithContext[MESSAGE_IDENTIFIER_START:MESSAGE_IDENTIFIER_END]); bytes32 storedAckHash = _messageDelivered[sourceIdentifier][implementationIdentifier][messageIdentifier]; - // First, check if there is actually an appropiate hash at the message identifier. + // First, check if there is actually an appropriate hash at the message identifier. // Then, check if the storedAckHash & the source target (sourceIdentifier & implementationIdentifier) matches the executed one. if (storedAckHash == bytes32(0) || storedAckHash != keccak256(receiveAckWithContext)) revert CannotRetryWrongMessage(storedAckHash, keccak256(receiveAckWithContext)); // Send the package again. uint128 cost = _sendPacket(sourceIdentifier, implementationIdentifier, receiveAckWithContext, 0); - // Check if there is a mis-match between the cost and the value of the message. + // Check if there is a mismatch between the cost and the value of the message. if (uint128(msg.value) != cost) { if (uint128(msg.value) > cost) { // Send the unused gas back to the the user. @@ -1166,7 +1166,7 @@ abstract contract IncentivizedMessageEscrow is IIncentivizedMessageEscrow, Bytes // When the message arrives, the usual incentive check ensures only 1 message can arrive. Since the incentive check is based on // messageIdentifier, we need to verify it. // Remember, the messageIdentifier is actually untrusted. So it is trivial to pass the above check. However, any way to pass - // the above check fradulently would result in messageIdentifier being wrong and unable to be reproduced on the source chain. + // the above check fraudulently would result in messageIdentifier being wrong and unable to be reproduced on the source chain. // Load the deadline from the message. uint64 deadline = uint64(bytes8(message[CTX0_DEADLINE_START:CTX0_DEADLINE_END])); @@ -1197,7 +1197,7 @@ abstract contract IncentivizedMessageEscrow is IIncentivizedMessageEscrow, Bytes 0 ); - // Check if there is a mis-match between the cost and the value of the message. + // Check if there is a mismatch between the cost and the value of the message. if (uint128(msg.value) != cost) { if (uint128(msg.value) > cost) { // Send the unused gas back to the the user. diff --git a/src/apps/layerzero/IncentivizedLayerZeroEscrow.sol b/src/apps/layerzero/IncentivizedLayerZeroEscrow.sol index 7000c4d..5ad1249 100644 --- a/src/apps/layerzero/IncentivizedLayerZeroEscrow.sol +++ b/src/apps/layerzero/IncentivizedLayerZeroEscrow.sol @@ -58,14 +58,14 @@ contract ExecutorZero is ILayerZeroExecutor { * the executor. This has to be done for every remote chain & ULN. * * This implementation works by breaking the LZ endpoint flow. It relies on the - * `.verfiyable` check on the ULN. When a cross-chain message is verified (step 2) + * `.verifiable` check on the ULN. When a cross-chain message is verified (step 2) * `commitVerification` is called and it deletes the storage for the verification: https://github.com/LayerZero-Labs/LayerZero-v2/blob/1fde89479fdc68b1a54cda7f19efa84483fcacc4/messagelib/contracts/uln/uln302/ReceiveUln302.sol#L56 - * this exactly `verfiyable: true -> false`. + * this exactly `verifiable: true -> false`. * We break this making the subcall `EndpointV2::verify` revert on _initializable: * https://github.com/LayerZero-Labs/LayerZero-v2/blob/1fde89479fdc68b1a54cda7f19efa84483fcacc4/protocol/contracts/EndpointV2.sol#L340 * That is the purpose of `allowInitializePath`. * - * Then we can use `verfiyable` to check if a message has been verified by DVNs. + * Then we can use `verifiable` to check if a message has been verified by DVNs. */ contract IncentivizedLayerZeroEscrow is IncentivizedMessageEscrow, ExecutorZero { using PacketV1Codec for bytes; @@ -239,13 +239,13 @@ contract IncentivizedLayerZeroEscrow is IncentivizedMessageEscrow, ExecutorZero // Verify the message on the LZ ultra light node. // Without any protection, this is a DoS vector. It is protected by setting allowInitializePath to return false // As a result, once this returns true it should return true perpetually. - bool verifyable = ULN.verifiable(_config, _headerHash, _payloadHash); - if (!verifyable) { + bool verifiable = ULN.verifiable(_config, _headerHash, _payloadHash); + if (!verifiable) { // LayerZero may have migrated to a new receive library. Check the timeout receive library. (address timeoutULN, uint256 expiry) = ENDPOINT.defaultReceiveLibraryTimeout(srcEid); if (timeoutULN == address(0) || expiry < block.timestamp) revert LZ_ULN_Verifying(); - verifyable = IReceiveUlnBase(timeoutULN).verifiable(_config, _headerHash, _payloadHash); - if (!verifyable) revert LZ_ULN_Verifying(); + verifiable = IReceiveUlnBase(timeoutULN).verifiable(_config, _headerHash, _payloadHash); + if (!verifiable) revert LZ_ULN_Verifying(); } // Get the source chain diff --git a/src/apps/mock/OnRecvIncentivizedMockEscrow.sol b/src/apps/mock/OnRecvIncentivizedMockEscrow.sol index 4489555..587e23c 100644 --- a/src/apps/mock/OnRecvIncentivizedMockEscrow.sol +++ b/src/apps/mock/OnRecvIncentivizedMockEscrow.sol @@ -116,9 +116,9 @@ contract OnRecvIncentivizedMockEscrow is IncentivizedMessageEscrow { bytes32 feeRecipient ) onlyMessagingProtocol external { uint256 gasLimit = gasleft(); - VerifiedMessageHashContext storage _verfiedMessageHashContext = isVerifiedMessageHash[keccak256(rawMessage)]; - _verfiedMessageHashContext.chainIdentifier = chainIdentifier; - _verfiedMessageHashContext.implementationIdentifier = destinationImplementationIdentifier; + VerifiedMessageHashContext storage _verifiedMessageHashContext = isVerifiedMessageHash[keccak256(rawMessage)]; + _verifiedMessageHashContext.chainIdentifier = chainIdentifier; + _verifiedMessageHashContext.implementationIdentifier = destinationImplementationIdentifier; _handleAck(chainIdentifier, destinationImplementationIdentifier, rawMessage, feeRecipient, gasLimit); } diff --git a/src/apps/polymer/vIBCEscrow.sol b/src/apps/polymer/vIBCEscrow.sol index ffaee8b..590570e 100644 --- a/src/apps/polymer/vIBCEscrow.sol +++ b/src/apps/polymer/vIBCEscrow.sol @@ -104,7 +104,7 @@ contract IncentivizedPolymerEscrow is APolymerEscrow, IbcReceiverBase, IbcReceiv } function onCloseIbcChannel(bytes32 channelId, string calldata, bytes32) external virtual onlyIbcDispatcher { - // logic to determin if the channel should be closed + // logic to determine if the channel should be closed bool channelFound = false; for (uint256 i = 0; i < connectedChannels.length; i++) { if (connectedChannels[i] == channelId) { @@ -158,7 +158,7 @@ contract IncentivizedPolymerEscrow is APolymerEscrow, IbcReceiverBase, IbcReceiv // Get the payload by removing the implementation identifier. bytes calldata rawMessage = ack.data[POLYMER_PACKAGE_PAYLOAD_START:]; - // Set a verificaiton context so we can recover the ack. + // Set a verification context so we can recover the ack. isVerifiedMessageHash[keccak256(rawMessage)] = VerifiedMessageHashContext({ chainIdentifier: packet.src.channelId, implementationIdentifier: destinationImplementationIdentifier diff --git a/src/apps/wormhole/IncentivizedWormholeEscrow.sol b/src/apps/wormhole/IncentivizedWormholeEscrow.sol index 50038ac..62ef596 100644 --- a/src/apps/wormhole/IncentivizedWormholeEscrow.sol +++ b/src/apps/wormhole/IncentivizedWormholeEscrow.sol @@ -10,7 +10,7 @@ import { IWormhole } from "./interfaces/IWormhole.sol"; /** * @title Incentivized Wormhole Message Escrow * @notice Incentivizes Wormhole messages through Generalised Incentives. - * Wormhole does not have any native way of relaying messages, this implemention adds one. + * Wormhole does not have any native way of relaying messages, this implementation adds one. * * When using Wormhole with Generalised Incentives and you don't want to lose message, be very careful regarding * emitting messages to destinationChainIdentifiers that does not exist. Wormhole has no way to verify if a @@ -50,7 +50,7 @@ contract IncentivizedWormholeEscrow is IncentivizedMessageEscrow, WormholeVerifi amount = WORMHOLE.messageFee(); } - /** @notice Wormhole proofs are valid until the guardian set is changed. The new guradian set may sign a new VAA */ + /** @notice Wormhole proofs are valid until the guardian set is changed. The new guardian set may sign a new VAA */ function _proofValidPeriod(bytes32 /* destinationIdentifier */) override internal pure returns(uint64) { return 0; } diff --git a/src/apps/wormhole/external/callworm/WormholeVerifier.sol b/src/apps/wormhole/external/callworm/WormholeVerifier.sol index b06d1b4..339aa62 100644 --- a/src/apps/wormhole/external/callworm/WormholeVerifier.sol +++ b/src/apps/wormhole/external/callworm/WormholeVerifier.sol @@ -23,7 +23,7 @@ contract WormholeVerifier is GettersGetter { constructor(address wormholeState) payable GettersGetter(wormholeState) {} - /// @dev parseAndVerifyVM serves to parse an encodedVM and wholy validate it for consumption + /// @dev parseAndVerifyVM serves to parse an encodedVM and wholly validate it for consumption function parseAndVerifyVM(bytes calldata encodedVM) public view returns ( SmallStructs.SmallVM memory vm, bytes calldata payload, @@ -91,7 +91,7 @@ contract WormholeVerifier is GettersGetter { /** - * @dev verifySignatures serves to validate arbitrary sigatures against an arbitrary guardianSet + * @dev verifySignatures serves to validate arbitrary signatures against an arbitrary guardianSet * - it intentionally does not solve for expectations within guardianSet (you should use verifyVM if you need these protections) * - it intentioanlly does not solve for quorum (you should use verifyVM if you need these protections) * - it intentionally returns true when signatures is an empty set (you should use verifyVM if you need these protections) @@ -215,7 +215,7 @@ contract WormholeVerifier is GettersGetter { } /** - * @dev quorum serves solely to determine the number of signatures required to acheive quorum + * @dev quorum serves solely to determine the number of signatures required to achieve quorum */ function quorum(uint numGuardians) public pure virtual returns (uint numSignaturesRequiredForQuorum) { unchecked { diff --git a/src/apps/wormhole/external/wormhole/Messages.sol b/src/apps/wormhole/external/wormhole/Messages.sol index e702caf..07ccb1d 100644 --- a/src/apps/wormhole/external/wormhole/Messages.sol +++ b/src/apps/wormhole/external/wormhole/Messages.sol @@ -12,7 +12,7 @@ import "./libraries/external/BytesLib.sol"; contract Messages is Getters { using BytesLib for bytes; - /// @dev parseAndVerifyVM serves to parse an encodedVM and wholy validate it for consumption + /// @dev parseAndVerifyVM serves to parse an encodedVM and wholly validate it for consumption function parseAndVerifyVM(bytes calldata encodedVM) public view returns (Structs.VM memory vm, bool valid, string memory reason) { vm = parseVM(encodedVM); /// setting checkHash to false as we can trust the hash field in this case given that parseVM computes and then sets the hash field above @@ -103,7 +103,7 @@ contract Messages is Getters { /** - * @dev verifySignatures serves to validate arbitrary sigatures against an arbitrary guardianSet + * @dev verifySignatures serves to validate arbitrary signatures against an arbitrary guardianSet * - it intentionally does not solve for expectations within guardianSet (you should use verifyVM if you need these protections) * - it intentioanlly does not solve for quorum (you should use verifyVM if you need these protections) * - it intentionally returns true when signatures is an empty set (you should use verifyVM if you need these protections) @@ -208,7 +208,7 @@ contract Messages is Getters { } /** - * @dev quorum serves solely to determine the number of signatures required to acheive quorum + * @dev quorum serves solely to determine the number of signatures required to achieve quorum */ function quorum(uint numGuardians) public pure virtual returns (uint numSignaturesRequiredForQuorum) { // The max number of guardians is 255 diff --git a/src/apps/wormhole/external/wormhole/libraries/external/BytesLib.sol b/src/apps/wormhole/external/wormhole/libraries/external/BytesLib.sol index 58b8f51..6ff3eef 100644 --- a/src/apps/wormhole/external/wormhole/libraries/external/BytesLib.sol +++ b/src/apps/wormhole/external/wormhole/libraries/external/BytesLib.sol @@ -421,14 +421,14 @@ library BytesLib { } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { - // unsuccess: + // unsuccessful: success := 0 cb := 0 } } } default { - // unsuccess: + // unsuccessful: success := 0 } } @@ -466,7 +466,7 @@ library BytesLib { fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { - // unsuccess: + // unsuccessful: success := 0 } } @@ -491,7 +491,7 @@ library BytesLib { mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { - // unsuccess: + // unsuccessful: success := 0 cb := 0 } @@ -500,7 +500,7 @@ library BytesLib { } } default { - // unsuccess: + // unsuccessful: success := 0 } } diff --git a/src/interfaces/IMessageEscrowEvents.sol b/src/interfaces/IMessageEscrowEvents.sol index bd7a5fa..f1e8484 100644 --- a/src/interfaces/IMessageEscrowEvents.sol +++ b/src/interfaces/IMessageEscrowEvents.sol @@ -28,7 +28,7 @@ interface IMessageEscrowEvents { // To save gas, this event does not emit the full incentive scheme. // Instead, the new gas prices are emitted. As a result, the relayer can collect all bountyIncreased - // and then use the maximum. (since the maxmimum is enforced in the smart contract) + // and then use the maximum. (since the maximum is enforced in the smart contract) event BountyIncreased( bytes32 indexed messageIdentifier, uint96 newDeliveryGasPrice,