Skip to content

Commit

Permalink
Merge branch 'svm-dev' into chrismaree/c-01-fix-non-claim-relaier-ref…
Browse files Browse the repository at this point in the history
…und-address
  • Loading branch information
chrismaree committed Jan 3, 2025
2 parents f32fdfb + f890911 commit 2c7eae0
Show file tree
Hide file tree
Showing 81 changed files with 8,108 additions and 1,299 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ module.exports = {
"node/no-unsupported-features/es-syntax": ["error", { ignores: ["modules"] }],
"mocha/no-exclusive-tests": "error",
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/naming-convention": "none",
},
};
9 changes: 9 additions & 0 deletions Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ wallet = "test/svm/keys/localnet-wallet.json"

[scripts]
test = "anchor run generateExternalTypes && yarn run ts-mocha -p ./tsconfig.json -t 1000000 test/svm/**/*.ts"
queryEvents = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/queryEvents.ts"
initialize = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/initialize.ts"
queryState = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/queryState.ts"
enableRoute = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/enableRoute.ts"
Expand All @@ -33,10 +34,18 @@ simpleFill = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/simpleFill.ts"
simpleFakeRelayerRepayment = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/simpleFakeRelayerRepayment.ts"
closeRelayerPdas = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/closeRelayerPdas.ts"
closeDataWorkerLookUpTables = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/closeDataWorkerLookUpTables.ts"
proposeRebalanceToSpokePool = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/proposeRebalanceToSpokePool.ts"
executeRebalanceToSpokePool = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/executeRebalanceToSpokePool.ts"
remotePauseDeposits = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/remotePauseDeposits.ts"
remoteHubPoolSetDepositRoute = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/remoteHubPoolSetDepositRoute.ts"
proposeRebalanceToHubPool = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/proposeRebalanceToHubPool.ts"
executeRebalanceToHubPool = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/executeRebalanceToHubPool.ts"
bridgeLiabilityToHubPool = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/bridgeLiabilityToHubPool.ts"
remoteHubPoolPauseDeposits = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/remoteHubPoolPauseDeposits.ts"
generateExternalTypes = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/generateExternalTypes.ts"
fakeFillWithRandomDistribution = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/fakeFillWithRandomDistribution.ts"
addressToPublicKey = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/addressToPublicKey.ts"
publicKeyToAddress = "NODE_NO_WARNINGS=1 yarn run ts-node ./scripts/svm/publicKeyToAddress.ts"

[test.validator]
url = "https://api.mainnet-beta.solana.com"
Expand Down
17 changes: 17 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

# This is a comment.
# Each line is a file pattern followed by one or more owners.
# Note: CODEOWNERS are automatically requested for review on relevant PRs.
# Order is important; the last matching pattern takes the most
# precedence.

# These owners will be the default owners for everything in
# the repo unless a later match takes precedence.
* @mrice32 @nicholaspai @pxrl @bmzig

# Solana
/programs/ @mrice32 @nicholaspai @chrismaree @Reinis-FRP @md0x
/scripts/svm/ @mrice32 @nicholaspai @chrismaree @Reinis-FRP @md0x
/src/svm/ @mrice32 @nicholaspai @chrismaree @Reinis-FRP @md0x
/test/svm/ @mrice32 @nicholaspai @chrismaree @Reinis-FRP @md0x

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ The latest contract deployments on Production will always be under the `deployed

This repository assumes you have [Node](https://nodejs.org/en/download/package-manager) installed, with a minimum version of 16.18.0. Depending on what you want to do with the repo you might also need [foundry](https://book.getfoundry.sh/getting-started/installation) and [anchor](https://www.anchor-lang.com/docs/installation) to also be installed. If you have build issues please insure these are both installed first.

Note if you get build issues on the initial `yarn` command try downgrading to node 20.17 (`nvm use 20.17`). If you've never used anchor before you might need to run `avm use latest` as well.

## Build

```shell
Expand Down
72 changes: 72 additions & 0 deletions contracts/Ink_SpokePool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "@eth-optimism/contracts/libraries/constants/Lib_PredeployAddresses.sol";

import "./Ovm_SpokePool.sol";
import "./external/interfaces/CCTPInterfaces.sol";
import { IOpUSDCBridgeAdapter } from "./external/interfaces/IOpUSDCBridgeAdapter.sol";

/**
* @notice Ink Spoke pool.
* @custom:security-contact [email protected]
*/
contract Ink_SpokePool is Ovm_SpokePool {
using SafeERC20 for IERC20;

// Address of the custom L2 USDC bridge.
address private constant USDC_BRIDGE = address(0);

/// @custom:oz-upgrades-unsafe-allow constructor
constructor(
address _wrappedNativeTokenAddress,
uint32 _depositQuoteTimeBuffer,
uint32 _fillDeadlineBuffer,
IERC20 _l2Usdc,
ITokenMessenger _cctpTokenMessenger
)
Ovm_SpokePool(
_wrappedNativeTokenAddress,
_depositQuoteTimeBuffer,
_fillDeadlineBuffer,
_l2Usdc,
_cctpTokenMessenger
)
{} // solhint-disable-line no-empty-blocks

/**
* @notice Construct the OVM World Chain SpokePool.
* @param _initialDepositId Starting deposit ID. Set to 0 unless this is a re-deployment in order to mitigate
* relay hash collisions.
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _withdrawalRecipient Address which receives token withdrawals. Can be changed by admin. For Spoke Pools on L2, this will
*/
function initialize(
uint32 _initialDepositId,
address _crossDomainAdmin,
address _withdrawalRecipient
) public initializer {
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _withdrawalRecipient, Lib_PredeployAddresses.OVM_ETH);
}

/**
* @notice Ink-specific logic to bridge tokens back to the hub pool contract on L1.
* @param amountToReturn Amount of the token to bridge back.
* @param l2TokenAddress Address of the l2 Token to bridge back. This token will either be bridged back to the token defined in the mapping `remoteL1Tokens`,
* or via the canonical mapping defined in the bridge contract retrieved from `tokenBridges`.
* @dev This implementation deviates slightly from `_bridgeTokensToHubPool` in the `Ovm_SpokePool` contract since World Chain has a USDC bridge which uses
* a custom interface. This is because the USDC token on World Chain is meant to be upgraded to a native, CCTP supported version in the future.
*/
function _bridgeTokensToHubPool(uint256 amountToReturn, address l2TokenAddress) internal virtual override {
// Handle custom USDC bridge which doesn't conform to the standard bridge interface. In the future, CCTP may be used to bridge USDC to mainnet, in which
// case bridging logic is handled by the Ovm_SpokePool code. In the meantime, if CCTP is not enabled, then use the USDC bridge. Once CCTP is activated on
// WorldChain, this block of code will be unused.
if (l2TokenAddress == address(usdcToken) && !_isCCTPEnabled()) {
usdcToken.safeIncreaseAllowance(USDC_BRIDGE, amountToReturn);
IOpUSDCBridgeAdapter(USDC_BRIDGE).sendMessage(
withdrawalRecipient, // _to. Withdraw, over the bridge, to the l1 hub pool contract.
amountToReturn, // _amount.
l1Gas // _minGasLimit. Same value used in other OpStack bridges.
);
} else super._bridgeTokensToHubPool(amountToReturn, l2TokenAddress);
}
}
2 changes: 1 addition & 1 deletion deploy/056_deploy_op_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
from: deployer,
log: true,
skipIfAlreadyDeployed: true,
constructorArguments,
args: constructorArguments,
});

await hre.run("verify:verify", { address: deployment, constructorArguments });
Expand Down
28 changes: 28 additions & 0 deletions deploy/057_deploy_ink_spokepool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
import { FILL_DEADLINE_BUFFER, WETH, QUOTE_TIME_BUFFER, ZERO_ADDRESS } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre);

const initArgs = [
1,
// Set hub pool as cross domain admin since it delegatecalls the Adapter logic.
hubPool.address,
hubPool.address,
];
const constructorArgs = [
WETH[spokeChainId],
QUOTE_TIME_BUFFER,
FILL_DEADLINE_BUFFER,
ZERO_ADDRESS,
// L2_ADDRESS_MAP[spokeChainId].cctpTokenMessenger,
// For now, we are not using the CCTP bridge and can disable by setting
// the cctpTokenMessenger to the zero address.
ZERO_ADDRESS,
];
await deployNewProxy("Ink_SpokePool", constructorArgs, initArgs);
};
module.exports = func;
func.tags = ["InkSpokePool", "ink"];
10 changes: 8 additions & 2 deletions deploy/consts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export { ZERO_ADDRESS } from "@uma/common";

import { ZERO_ADDRESS } from "@uma/common";
import { CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "../utils";

export { ZERO_ADDRESS } from "@uma/common";

export const USDC = TOKEN_SYMBOLS_MAP.USDC.addresses;
export const USDCe = TOKEN_SYMBOLS_MAP["USDC.e"].addresses;
export const WETH = TOKEN_SYMBOLS_MAP.WETH.addresses;
Expand Down Expand Up @@ -80,6 +81,11 @@ export const OP_STACK_ADDRESS_MAP: {
L1CrossDomainMessenger: "0x5D4472f31Bd9385709ec61305AFc749F0fA8e9d0",
L1StandardBridge: "0x697402166Fbf2F22E970df8a6486Ef171dbfc524",
},
[CHAIN_IDs.INK]: {
L1CrossDomainMessenger: "0x69d3cf86b2bf1a9e99875b7e2d9b6a84426c171f",
L1StandardBridge: "0x88ff1e5b602916615391f55854588efcbb7663f0",
L1OpUSDCBridgeAdapter: ZERO_ADDRESS,
},
[CHAIN_IDs.LISK]: {
L1CrossDomainMessenger: "0x31B72D76FB666844C41EdF08dF0254875Dbb7edB",
L1StandardBridge: "0x2658723Bf70c7667De6B25F99fcce13A16D25d08",
Expand Down
7 changes: 7 additions & 0 deletions deployments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,10 @@ This is because this `deployments.json` file is used by bots in [`@across-protoc
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| AlephZero_SpokePool | [0x13fDac9F9b4777705db45291bbFF3c972c6d1d97](https://evm-explorer.alephzero.org/address/0x13fDac9F9b4777705db45291bbFF3c972c6d1d97) |
| MulticallHandler | [0x924a9f036260DdD5808007E1AA95f08eD08aA569](https://evm-explorer.alephzero.org/address/0x924a9f036260DdD5808007E1AA95f08eD08aA569) |

## Ink mainnet (57073)

| Contract Name | Address |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| Ink_SpokePool | [0xeF684C38F94F48775959ECf2012D7E864ffb9dd4](https://explorer.inkonchain.com/address/0xeF684C38F94F48775959ECf2012D7E864ffb9dd4) |
| MulticallHandler | [0x924a9f036260DdD5808007E1AA95f08eD08aA569](https://explorer.inkonchain.com/address/0x924a9f036260DdD5808007E1AA95f08eD08aA569) |
8 changes: 7 additions & 1 deletion deployments/deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"Redstone_Adapter": { "address": "0x188F8C95B7cfB7993B53a4F643efa687916f73fA", "blockNumber": 20432774 },
"Zora_Adapter": { "address": "0x024f2fc31cbdd8de17194b1892c834f98ef5169b", "blockNumber": 20512287 },
"WorldChain_Adapter": { "address": "0xA8399e221a583A57F54Abb5bA22f31b5D6C09f32", "blockNumber": 20963234 },
"AlephZero_Adapter": { "address": "0x6F4083304C2cA99B077ACE06a5DcF670615915Af", "blockNumber": 21131132 }
"AlephZero_Adapter": { "address": "0x6F4083304C2cA99B077ACE06a5DcF670615915Af", "blockNumber": 21131132 },
"Ink_Adapter": { "address": "0x7e90a40c7519b041a7df6498fbf5662e8cfc61d2", "blockNumber": 21438590 }
},
"10": {
"SpokePool": { "address": "0x6f26Bf09B1C792e3228e5467807a900A503c0281", "blockNumber": 93903076 },
Expand Down Expand Up @@ -157,5 +158,10 @@
"41455": {
"SpokePool": { "address": "0x13fDac9F9b4777705db45291bbFF3c972c6d1d97", "blockNumber": 4240318 },
"MulticallHandler": { "address": "0x924a9f036260DdD5808007E1AA95f08eD08aA569", "blockNumber": 4112529 }
},
"57073": {
"SpokePool": { "address": "0xeF684C38F94F48775959ECf2012D7E864ffb9dd4", "blockNumber": 1139240 },
"SpokePoolVerifier": { "address": "0xB4A8d45647445EA9FC3E1058096142390683dBC2", "blockNumber": 1152853 },
"MulticallHandler": { "address": "0x924a9f036260DdD5808007E1AA95f08eD08aA569", "blockNumber": 1145284 }
}
}
1 change: 1 addition & 0 deletions deployments/ink/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
57073
Loading

0 comments on commit 2c7eae0

Please sign in to comment.