Skip to content

Commit 666bccb

Browse files
pxrlnicholaspai
andauthored
feat: Remove SpokePool v2 functionality (#456)
* feat: Remove non-USS functionality from SpokePool This PR showcases how we will remove all non-USS functionality in the spoke pools once all non-USS deposits are fills, fills are refunded, and roots are executed. This PR reduces the bytecode significantly and means we can use the full optimizer runs setting for compiling these new contracts * Remove Deposit and SlowRelay tests Signed-off-by: nicholaspai <[email protected]> * WIP * WIP * Update utils.ts * Add back Deposit functions * add back legacy deposit unit tests * Update hardhat.config.ts * fix tests * Update package.json * fix Signed-off-by: nicholaspai <[email protected]> * Add depositUSSNow, replace error strings with custom error types, fix tests * Fix * Fix tests * Update SpokePool.Deposit.ts * feat: Remove all "USS" references in contracts This PR implements a simple find-and-replace of "USS" with "V3" to make it more clear that this is a new version of the Across protocol that supports new features such as cross-chain token-swaps. USS is an internal code name for "Universal Settlement Service" but this is not neccessariy the language that will be used to market this product. So, renaming to V3 makes these contract changes more of a blank slate. * Replace USS with V3 * Remove UBA references * fix tests * merge master * fix tests * change depositV3Now to take in exclusivity deadline * Fix * Update Ovm_SpokePool.sol * Update Ovm_SpokePool.sol * add back depositfor, remove special polygon spoke pool compiler rules * update hardhat-zksolc * Update test/SpokePool.Deposit.ts Co-authored-by: Paul <[email protected]> * Update hardhat.config.ts --------- Signed-off-by: nicholaspai <[email protected]> Co-authored-by: nicholaspai <[email protected]> Co-authored-by: nicholaspai <[email protected]>
1 parent a4d2e20 commit 666bccb

31 files changed

+475
-3852
lines changed

contracts/MerkleLib.sol

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,6 @@ library MerkleLib {
4141
return MerkleProof.verify(proof, root, keccak256(abi.encode(refund)));
4242
}
4343

44-
/**
45-
* @notice Verifies that a distribution is contained within a merkle root.
46-
* @param root the merkle root.
47-
* @param slowRelayFulfillment the relayData fulfillment struct.
48-
* @param proof the merkle proof.
49-
* @return bool to signal if the slow relay's proof correctly shows inclusion of the slow relay within the tree.
50-
*/
51-
/// @custom:audit FOLLOWING FUNCTION TO BE DEPRECATED
52-
function verifySlowRelayFulfillment(
53-
bytes32 root,
54-
SpokePoolInterface.SlowFill memory slowRelayFulfillment,
55-
bytes32[] memory proof
56-
) internal pure returns (bool) {
57-
return MerkleProof.verify(proof, root, keccak256(abi.encode(slowRelayFulfillment)));
58-
}
59-
6044
function verifyV3SlowRelayFulfillment(
6145
bytes32 root,
6246
V3SpokePoolInterface.V3SlowFill memory slowRelayFulfillment,

contracts/Ovm_SpokePool.sol

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ contract Ovm_SpokePool is SpokePool, CircleCCTPAdapter {
3636
address public l2Eth;
3737

3838
// Address of the Optimism L2 messenger.
39-
address public messenger;
39+
address public constant MESSENGER = Lib_PredeployAddresses.L2_CROSS_DOMAIN_MESSENGER;
40+
// @dev This storage slot is reserved to replace the old messenger public variable that has now been
41+
// replaced by the above constant.
42+
address private __deprecated_messenger;
4043

4144
// Address of custom bridge used to bridge Synthetix-related assets like SNX.
4245
address private constant SYNTHETIX_BRIDGE = 0x136b1EC699c62b0606854056f02dC7Bb80482d63;
@@ -51,6 +54,8 @@ contract Ovm_SpokePool is SpokePool, CircleCCTPAdapter {
5154
event SetL1Gas(uint32 indexed newL1Gas);
5255
event SetL2TokenBridge(address indexed l2Token, address indexed tokenBridge);
5356

57+
error NotCrossDomainAdmin();
58+
5459
/// @custom:oz-upgrades-unsafe-allow constructor
5560
constructor(
5661
address _wrappedNativeTokenAddress,
@@ -80,7 +85,6 @@ contract Ovm_SpokePool is SpokePool, CircleCCTPAdapter {
8085
) public onlyInitializing {
8186
l1Gas = 5_000_000;
8287
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool);
83-
messenger = Lib_PredeployAddresses.L2_CROSS_DOMAIN_MESSENGER;
8488
//slither-disable-next-line missing-zero-check
8589
l2Eth = _l2Eth;
8690
}
@@ -169,10 +173,7 @@ contract Ovm_SpokePool is SpokePool, CircleCCTPAdapter {
169173

170174
// Apply OVM-specific transformation to cross domain admin address on L1.
171175
function _requireAdminSender() internal view override {
172-
require(
173-
LibOptimismUpgradeable.crossChainSender(messenger) == crossDomainAdmin,
174-
"OVM_XCHAIN: wrong sender of cross-domain message"
175-
);
176+
if (LibOptimismUpgradeable.crossChainSender(MESSENGER) != crossDomainAdmin) revert NotCrossDomainAdmin();
176177
}
177178

178179
// Reserve storage slots for future versions of this base contract to add state variables without

contracts/Polygon_SpokePool.sol

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ contract Polygon_SpokePool is IFxMessageProcessor, SpokePool, CircleCCTPAdapter
5151
event SetPolygonTokenBridger(address indexed polygonTokenBridger);
5252
event ReceivedMessageFromL1(address indexed caller, address indexed rootMessageSender);
5353

54+
error CallValidatedAlreadySet();
55+
error CallValidatedNotSet();
56+
error DelegateCallFailed();
57+
error NotHubPool();
58+
error NotFxChild();
59+
5460
// Note: validating calls this way ensures that strange calls coming from the fxChild won't be misinterpreted.
5561
// Put differently, just checking that msg.sender == fxChild is not sufficient.
5662
// All calls that have admin privileges must be fired from within the processMessageFromRoot method that's gone
@@ -59,7 +65,7 @@ contract Polygon_SpokePool is IFxMessageProcessor, SpokePool, CircleCCTPAdapter
5965
modifier validateInternalCalls() {
6066
// Make sure callValidated is set to True only once at beginning of processMessageFromRoot, which prevents
6167
// processMessageFromRoot from being re-entered.
62-
require(!callValidated, "callValidated already set");
68+
if (callValidated) revert CallValidatedAlreadySet();
6369

6470
// This sets a variable indicating that we're now inside a validated call.
6571
// Note: this is used by other methods to ensure that this call has been validated by this method and is not
@@ -143,8 +149,8 @@ contract Polygon_SpokePool is IFxMessageProcessor, SpokePool, CircleCCTPAdapter
143149
bytes calldata data
144150
) public validateInternalCalls {
145151
// Validation logic.
146-
require(msg.sender == fxChild, "Not from fxChild");
147-
require(rootMessageSender == crossDomainAdmin, "Not from mainnet admin");
152+
if (msg.sender != fxChild) revert NotFxChild();
153+
if (rootMessageSender != crossDomainAdmin) revert NotHubPool();
148154

149155
// This uses delegatecall to take the information in the message and process it as a function call on this contract.
150156
/// This is a safe delegatecall because its made to address(this) so there is no risk of delegating to a
@@ -153,7 +159,7 @@ contract Polygon_SpokePool is IFxMessageProcessor, SpokePool, CircleCCTPAdapter
153159
/// @custom:oz-upgrades-unsafe-allow delegatecall
154160
(bool success, ) = address(this).delegatecall(data);
155161
//slither-disable-end low-level-calls
156-
require(success, "delegatecall failed");
162+
if (!success) revert DelegateCallFailed();
157163

158164
emit ReceivedMessageFromL1(msg.sender, rootMessageSender);
159165
}
@@ -254,6 +260,6 @@ contract Polygon_SpokePool is IFxMessageProcessor, SpokePool, CircleCCTPAdapter
254260
// `processMessageFromRoot`. This prevents calling the admin functions from any other method besides
255261
// `processMessageFromRoot`.
256262
function _requireAdminSender() internal view override {
257-
require(callValidated, "Must call processMessageFromRoot");
263+
if (!callValidated) revert CallValidatedNotSet();
258264
}
259265
}

0 commit comments

Comments
 (0)