Skip to content

Commit

Permalink
Merge branch 'svm-dev' into mrice32/l02
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspai committed Feb 5, 2025
2 parents eabf245 + cf0b6b8 commit c63b6e3
Show file tree
Hide file tree
Showing 19 changed files with 681 additions and 416 deletions.
216 changes: 92 additions & 124 deletions contracts/SpokePool.sol

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions contracts/SpokePoolVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract SpokePoolVerifier {
error InvalidSpokePool();

/**
* @notice Passthrough function to `depositV3()` on the SpokePool contract.
* @notice Passthrough function to `deposit()` on the SpokePool contract.
* @dev Protects the caller from losing their ETH (or other native token) by reverting if the SpokePool address
* they intended to call does not exist on this chain. Because this contract can be deployed at the same address
* everywhere callers should be protected even if the transaction is submitted to an unintended network.
Expand Down Expand Up @@ -58,7 +58,7 @@ contract SpokePoolVerifier {
if (msg.value != inputAmount) revert InvalidMsgValue();
if (!address(spokePool).isContract()) revert InvalidSpokePool();
// Set msg.sender as the depositor so that msg.sender can speed up the deposit.
spokePool.depositV3{ value: msg.value }(
spokePool.deposit{ value: msg.value }(
msg.sender.toBytes32(),
recipient,
inputToken,
Expand Down
2 changes: 1 addition & 1 deletion contracts/SwapAndBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ abstract contract SwapAndBridgeBase is Lockable, MultiCaller {
DepositData calldata depositData
) internal {
_acrossInputToken.safeIncreaseAllowance(address(spokePool), _acrossInputAmount);
spokePool.depositV3(
spokePool.deposit(
depositData.depositor.toBytes32(),
depositData.recipient.toBytes32(),
address(_acrossInputToken).toBytes32(), // input token
Expand Down
12 changes: 6 additions & 6 deletions contracts/erc7683/ERC7683OrderDepositorExternal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ contract ERC7683OrderDepositorExternal is ERC7683OrderDepositor, Ownable, MultiC
message
);
} else {
SPOKE_POOL.unsafeDepositV3(
depositor,
recipient,
inputToken,
outputToken,
SPOKE_POOL.unsafeDeposit(
depositor.toBytes32(),
recipient.toBytes32(),
inputToken.toBytes32(),
outputToken.toBytes32(),
inputAmount,
outputAmount,
destinationChainId,
exclusiveRelayer,
exclusiveRelayer.toBytes32(),
depositNonce,
quoteTimestamp,
fillDeadline,
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/SpokePoolInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ interface SpokePoolInterface {

function emergencyDeleteRootBundle(uint256 rootBundleId) external;

function deposit(
function depositDeprecated_5947912356(
address recipient,
address originToken,
uint256 amount,
Expand Down
153 changes: 141 additions & 12 deletions contracts/interfaces/V3SpokePoolInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ interface V3SpokePoolInterface {
bytes message;
}

// Same as V3RelayData but using addresses instead of bytes32 & depositId is uint32.
// Will be deprecated in favor of V3RelayData in the future.
struct V3RelayDataLegacy {
address depositor;
address recipient;
address exclusiveRelayer;
address inputToken;
address outputToken;
uint256 inputAmount;
uint256 outputAmount;
uint256 originChainId;
uint32 depositId;
uint32 fillDeadline;
uint32 exclusivityDeadline;
bytes message;
}

// Contains parameters passed in by someone who wants to execute a slow relay leaf.
struct V3SlowFill {
V3RelayData relayData;
Expand All @@ -82,7 +99,7 @@ interface V3SpokePoolInterface {
uint256 repaymentChainId;
}

// Packs together parameters emitted in FilledV3Relay because there are too many emitted otherwise.
// Packs together parameters emitted in FilledRelay because there are too many emitted otherwise.
// Similar to V3RelayExecutionParams, these parameters are not used to uniquely identify the deposit being
// filled so they don't have to be unpacked by all clients.
struct V3RelayExecutionEventInfo {
Expand Down Expand Up @@ -113,7 +130,7 @@ interface V3SpokePoolInterface {
* EVENTS *
**************************************/

event V3FundsDeposited(
event FundsDeposited(
bytes32 inputToken,
bytes32 outputToken,
uint256 inputAmount,
Expand All @@ -129,7 +146,7 @@ interface V3SpokePoolInterface {
bytes message
);

event RequestedSpeedUpV3Deposit(
event RequestedSpeedUpDeposit(
uint256 updatedOutputAmount,
uint256 indexed depositId,
bytes32 indexed depositor,
Expand All @@ -138,7 +155,7 @@ interface V3SpokePoolInterface {
bytes depositorSignature
);

event FilledV3Relay(
event FilledRelay(
bytes32 inputToken,
bytes32 outputToken,
uint256 inputAmount,
Expand All @@ -156,7 +173,7 @@ interface V3SpokePoolInterface {
V3RelayExecutionEventInfo relayExecutionInfo
);

event RequestedV3SlowFill(
event RequestedSlowFill(
bytes32 inputToken,
bytes32 outputToken,
uint256 inputAmount,
Expand All @@ -182,7 +199,7 @@ interface V3SpokePoolInterface {
* FUNCTIONS *
**************************************/

function depositV3(
function deposit(
bytes32 depositor,
bytes32 recipient,
bytes32 inputToken,
Expand Down Expand Up @@ -212,7 +229,7 @@ interface V3SpokePoolInterface {
bytes calldata message
) external payable;

function depositV3Now(
function depositNow(
bytes32 depositor,
bytes32 recipient,
bytes32 inputToken,
Expand All @@ -226,7 +243,37 @@ interface V3SpokePoolInterface {
bytes calldata message
) external payable;

function speedUpV3Deposit(
function depositV3Now(
address depositor,
address recipient,
address inputToken,
address outputToken,
uint256 inputAmount,
uint256 outputAmount,
uint256 destinationChainId,
address exclusiveRelayer,
uint32 fillDeadlineOffset,
uint32 exclusivityDeadline,
bytes calldata message
) external payable;

function unsafeDeposit(
bytes32 depositor,
bytes32 recipient,
bytes32 inputToken,
bytes32 outputToken,
uint256 inputAmount,
uint256 outputAmount,
uint256 destinationChainId,
bytes32 exclusiveRelayer,
uint256 depositNonce,
uint32 quoteTimestamp,
uint32 fillDeadline,
uint32 exclusivityParameter,
bytes calldata message
) external payable;

function speedUpDeposit(
bytes32 depositor,
uint256 depositId,
uint256 updatedOutputAmount,
Expand All @@ -235,13 +282,24 @@ interface V3SpokePoolInterface {
bytes calldata depositorSignature
) external;

function fillV3Relay(
function speedUpV3Deposit(
address depositor,
uint256 depositId,
uint256 updatedOutputAmount,
address updatedRecipient,
bytes calldata updatedMessage,
bytes calldata depositorSignature
) external;

function fillRelay(
V3RelayData calldata relayData,
uint256 repaymentChainId,
bytes32 repaymentAddress
) external;

function fillV3RelayWithUpdatedDeposit(
function fillV3Relay(V3RelayDataLegacy calldata relayData, uint256 repaymentChainId) external;

function fillRelayWithUpdatedDeposit(
V3RelayData calldata relayData,
uint256 repaymentChainId,
bytes32 repaymentAddress,
Expand All @@ -251,9 +309,9 @@ interface V3SpokePoolInterface {
bytes calldata depositorSignature
) external;

function requestV3SlowFill(V3RelayData calldata relayData) external;
function requestSlowFill(V3RelayData calldata relayData) external;

function executeV3SlowRelayLeaf(
function executeSlowRelayLeaf(
V3SlowFill calldata slowFillLeaf,
uint32 rootBundleId,
bytes32[] calldata proof
Expand Down Expand Up @@ -284,4 +342,75 @@ interface V3SpokePoolInterface {
error LowLevelCallFailed(bytes data);
error InsufficientSpokePoolBalanceToExecuteLeaf();
error NoRelayerRefundToClaim();

/**************************************
* LEGACY EVENTS *
**************************************/

// Note: these events are unused, but included in the ABI for ease of migration.
event V3FundsDeposited(
address inputToken,
address outputToken,
uint256 inputAmount,
uint256 outputAmount,
uint256 indexed destinationChainId,
uint32 indexed depositId,
uint32 quoteTimestamp,
uint32 fillDeadline,
uint32 exclusivityDeadline,
address indexed depositor,
address recipient,
address exclusiveRelayer,
bytes message
);

event RequestedSpeedUpV3Deposit(
uint256 updatedOutputAmount,
uint32 indexed depositId,
address indexed depositor,
address updatedRecipient,
bytes updatedMessage,
bytes depositorSignature
);

// Legacy struct only used to preserve the FilledV3Relay event definition.
struct LegacyV3RelayExecutionEventInfo {
address updatedRecipient;
bytes updatedMessage;
uint256 updatedOutputAmount;
FillType fillType;
}

event FilledV3Relay(
address inputToken,
address outputToken,
uint256 inputAmount,
uint256 outputAmount,
uint256 repaymentChainId,
uint256 indexed originChainId,
uint32 indexed depositId,
uint32 fillDeadline,
uint32 exclusivityDeadline,
address exclusiveRelayer,
address indexed relayer,
address depositor,
address recipient,
bytes message,
LegacyV3RelayExecutionEventInfo relayExecutionInfo
);

event RequestedV3SlowFill(
address inputToken,
address outputToken,
uint256 inputAmount,
uint256 outputAmount,
uint256 indexed originChainId,
uint32 indexed depositId,
uint32 fillDeadline,
uint32 exclusivityDeadline,
address exclusiveRelayer,
address depositor,
address recipient,
bytes message
);
}
10 changes: 7 additions & 3 deletions contracts/libraries/AddressConverters.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ library Bytes32ToAddress {
error InvalidBytes32();

function toAddress(bytes32 _bytes32) internal pure returns (address) {
if (uint256(_bytes32) >> 160 != 0) {
revert InvalidBytes32();
}
checkAddress(_bytes32);
return address(uint160(uint256(_bytes32)));
}

function toAddressUnchecked(bytes32 _bytes32) internal pure returns (address) {
return address(uint160(uint256(_bytes32)));
}

function checkAddress(bytes32 _bytes32) internal pure {
if (uint256(_bytes32) >> 160 != 0) {
revert InvalidBytes32();
}
}
}

library AddressToBytes32 {
Expand Down
2 changes: 1 addition & 1 deletion contracts/permit2-order/Permit2Depositor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ contract Permit2Depositor {
uint256 amountToDeposit = order.input.amount + order.fillerCollateral.amount;

IERC20(order.input.token).safeIncreaseAllowance(address(SPOKE_POOL), amountToDeposit);
SPOKE_POOL.depositV3(
SPOKE_POOL.deposit(
order.info.offerer.toBytes32(),
// Note: Permit2OrderLib checks that order only has a single output.
order.outputs[0].recipient.toBytes32(),
Expand Down
6 changes: 3 additions & 3 deletions contracts/test/MockSpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ contract MockSpokePool is SpokePool, MockV2SpokePoolInterface, OwnableUpgradeabl
_verifyDepositorSignature(depositor, expectedTypedDataV4Hash, depositorSignature);
}

function verifyUpdateV3DepositMessage(
function verifyUpdateV3DepositMessageBytes32(
bytes32 depositor,
uint256 depositId,
uint256 originChainId,
Expand All @@ -103,7 +103,7 @@ contract MockSpokePool is SpokePool, MockV2SpokePoolInterface, OwnableUpgradeabl
updatedRecipient,
updatedMessage,
depositorSignature,
UPDATE_V3_DEPOSIT_DETAILS_HASH
UPDATE_BYTES32_DEPOSIT_DETAILS_HASH
);
}

Expand All @@ -125,7 +125,7 @@ contract MockSpokePool is SpokePool, MockV2SpokePoolInterface, OwnableUpgradeabl
updatedRecipient.toBytes32(),
updatedMessage,
depositorSignature,
UPDATE_V3_DEPOSIT_ADDRESS_OVERLOAD_DETAILS_HASH
UPDATE_ADDRESS_DEPOSIT_DETAILS_HASH
);
}

Expand Down
6 changes: 3 additions & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ remappings = [
"hardhat/=node_modules/hardhat/",
]
via_ir = true
optimizer_runs = 1_000_000
solc_version = "0.8.25"
optimizer_runs = 800
solc_version = "0.8.23"
revert_strings = "strip"

solc = "0.8.25"
solc = "0.8.23"
evm_version = "shanghai"

[rpc_endpoints]
Expand Down
4 changes: 2 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const mnemonic = getMnemonic();
const LARGE_CONTRACT_COMPILER_SETTINGS = {
version: solcVersion,
settings: {
optimizer: { enabled: true, runs: 1000 },
optimizer: { enabled: true, runs: 800 },
viaIR: true,
debug: { revertStrings: isTest ? "debug" : "strip" },
},
Expand All @@ -68,7 +68,7 @@ const config: HardhatUserConfig = {
overrides: {
"contracts/HubPool.sol": LARGE_CONTRACT_COMPILER_SETTINGS,
"contracts/Linea_SpokePool.sol": {
...DEFAULT_CONTRACT_COMPILER_SETTINGS,
...LARGE_CONTRACT_COMPILER_SETTINGS,
// NOTE: Linea only supports 0.8.19.
// See https://docs.linea.build/build-on-linea/ethereum-differences#evm-opcodes
version: "0.8.19",
Expand Down
Loading

0 comments on commit c63b6e3

Please sign in to comment.