Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve(SpokePool): Remove Testable/Timer base contract #237

Merged
merged 4 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions contracts/Arbitrum_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,15 @@ contract Arbitrum_SpokePool is SpokePool {
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _wethAddress Weth address for this network to set.
* @param _timerAddress Timer address to set.
*/
function initialize(
uint32 _initialDepositId,
address _l2GatewayRouter,
address _crossDomainAdmin,
address _hubPool,
address _wethAddress,
address _timerAddress
address _wethAddress
) public initializer {
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, _wethAddress, _timerAddress);
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, _wethAddress);
_setL2GatewayRouter(_l2GatewayRouter);
}

Expand Down
7 changes: 2 additions & 5 deletions contracts/Boba_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,18 @@ contract Boba_SpokePool is Ovm_SpokePool {
* relay hash collisions.
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _timerAddress Timer address to set.
*/
function initialize(
uint32 _initialDepositId,
address _crossDomainAdmin,
address _hubPool,
address _timerAddress
address _hubPool
) public initializer {
__OvmSpokePool_init(
_initialDepositId,
_crossDomainAdmin,
_hubPool,
0x4200000000000000000000000000000000000006,
0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000,
_timerAddress
0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000
);
}
}
6 changes: 2 additions & 4 deletions contracts/Ethereum_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ contract Ethereum_SpokePool is SpokePool, OwnableUpgradeable {
* relay hash collisions.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _wethAddress Weth address for this network to set.
* @param _timerAddress Timer address to set.
*/
function initialize(
uint32 _initialDepositId,
address _hubPool,
address _wethAddress,
address _timerAddress
address _wethAddress
) public initializer {
__Ownable_init();
__SpokePool_init(_initialDepositId, _hubPool, _hubPool, _wethAddress, _timerAddress);
__SpokePool_init(_initialDepositId, _hubPool, _hubPool, _wethAddress);
}

/**************************************
Expand Down
7 changes: 2 additions & 5 deletions contracts/Optimism_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@ contract Optimism_SpokePool is Ovm_SpokePool {
* relay hash collisions.
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _timerAddress Timer address to set.
*/
function initialize(
uint32 _initialDepositId,
address _crossDomainAdmin,
address _hubPool,
address _timerAddress
address _hubPool
) public initializer {
__OvmSpokePool_init(
_initialDepositId,
_crossDomainAdmin,
_hubPool,
Lib_PredeployAddresses.OVM_ETH,
0x4200000000000000000000000000000000000006,
_timerAddress
0x4200000000000000000000000000000000000006
);
}
}
6 changes: 2 additions & 4 deletions contracts/Ovm_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,16 @@ contract Ovm_SpokePool is SpokePool {
* relay hash collisions.
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _timerAddress Timer address to set.
*/
function __OvmSpokePool_init(
uint32 _initialDepositId,
address _crossDomainAdmin,
address _hubPool,
address _l2Eth,
address _wrappedNativeToken,
address _timerAddress
address _wrappedNativeToken
) public onlyInitializing {
l1Gas = 5_000_000;
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, _wrappedNativeToken, _timerAddress);
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, _wrappedNativeToken);
messenger = Lib_PredeployAddresses.L2_CROSS_DOMAIN_MESSENGER;
//slither-disable-next-line missing-zero-check
l2Eth = _l2Eth;
Expand Down
6 changes: 2 additions & 4 deletions contracts/Polygon_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,17 @@ contract Polygon_SpokePool is IFxMessageProcessor, SpokePool {
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _wmaticAddress Replaces wrappedNativeToken for this network since MATIC is the native currency on polygon.
* @param _fxChild FxChild contract, changeable by Admin.
* @param _timerAddress Timer address to set.
*/
function initialize(
uint32 _initialDepositId,
PolygonTokenBridger _polygonTokenBridger,
address _crossDomainAdmin,
address _hubPool,
address _wmaticAddress, // Note: wmatic is used here since it is the token sent via msg.value on polygon.
address _fxChild,
address _timerAddress
address _fxChild
) public initializer {
callValidated = false;
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, _wmaticAddress, _timerAddress);
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, _wmaticAddress);
polygonTokenBridger = _polygonTokenBridger;
//slither-disable-next-line missing-zero-check
fxChild = _fxChild;
Expand Down
15 changes: 9 additions & 6 deletions contracts/SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity ^0.8.0;
import "./MerkleLib.sol";
import "./interfaces/WETH9Interface.sol";
import "./SpokePoolInterface.sol";
import "./upgradeable/TestableUpgradeable.sol";
import "./upgradeable/MultiCallerUpgradeable.sol";
import "./upgradeable/EIP712CrossChainUpgradeable.sol";

Expand All @@ -29,7 +28,6 @@ import "@openzeppelin/contracts/utils/math/SignedMath.sol";
abstract contract SpokePool is
SpokePoolInterface,
UUPSUpgradeable,
TestableUpgradeable,
ReentrancyGuardUpgradeable,
MultiCallerUpgradeable,
EIP712CrossChainUpgradeable
Expand Down Expand Up @@ -168,21 +166,18 @@ abstract contract SpokePool is
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _wrappedNativeTokenAddress wrappedNativeToken address for this network to set.
* @param _timerAddress Timer address to set.
*/
function __SpokePool_init(
uint32 _initialDepositId,
address _crossDomainAdmin,
address _hubPool,
address _wrappedNativeTokenAddress,
address _timerAddress
address _wrappedNativeTokenAddress
) public onlyInitializing {
numberOfDeposits = _initialDepositId;
__EIP712_init("ACROSS-V2", "1.0.0");
__UUPSUpgradeable_init();
__ReentrancyGuard_init();
depositQuoteTimeBuffer = 3600;
__Testable_init(_timerAddress);
_setCrossDomainAdmin(_crossDomainAdmin);
_setHubPool(_hubPool);
wrappedNativeToken = WETH9Interface(_wrappedNativeTokenAddress);
Expand Down Expand Up @@ -639,6 +634,14 @@ abstract contract SpokePool is
return block.chainid;
}

/**
* @notice Gets the current time.
* @return uint for the current timestamp.
*/
function getCurrentTime() public view virtual returns (uint256) {
return block.timestamp; // solhint-disable-line not-rely-on-time
}

/**************************************
* INTERNAL FUNCTIONS *
**************************************/
Expand Down
5 changes: 2 additions & 3 deletions contracts/Succinct_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ contract Succinct_SpokePool is SpokePool, ITelepathyHandler {
uint32 _initialDepositId,
address _crossDomainAdmin,
address _hubPool,
address _wrappedNativeToken,
address timerAddress
address _wrappedNativeToken
) public initializer {
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, _wrappedNativeToken, timerAddress);
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, _wrappedNativeToken);
succinctTargetAmb = _succinctTargetAmb;
hubChainId = _hubChainId;
}
Expand Down
6 changes: 2 additions & 4 deletions contracts/ZkSync_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,16 @@ contract ZkSync_SpokePool is SpokePool {
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _wethAddress Weth address for this network to set.
* @param _timerAddress Timer address to set.
*/
function initialize(
uint32 _initialDepositId,
ZkBridgeLike _zkErc20Bridge,
ZkBridgeLike _zkEthBridge,
address _crossDomainAdmin,
address _hubPool,
address _wethAddress,
address _timerAddress
address _wethAddress
) public initializer {
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, _wethAddress, _timerAddress);
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, _wethAddress);
_setZkBridges(_zkErc20Bridge, _zkEthBridge);
}

Expand Down
15 changes: 12 additions & 3 deletions contracts/test/MockSpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,25 @@ import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
*/
contract MockSpokePool is SpokePool, OwnableUpgradeable {
uint256 private chainId_;
uint256 private currentTime;

function initialize(
uint32 _initialDepositId,
address _crossDomainAdmin,
address _hubPool,
address _wethAddress,
address _timerAddress
address _wethAddress
) public initializer {
__Ownable_init();
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, _wethAddress, _timerAddress);
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, _wethAddress);
currentTime = block.timestamp; // solhint-disable-line not-rely-on-time
}

function setCurrentTime(uint256 time) external {
currentTime = time;
}

function getCurrentTime() public view override returns (uint256) {
return currentTime;
}

// solhint-disable-next-line no-empty-blocks
Expand Down
8 changes: 4 additions & 4 deletions contracts/test/SuccinctMocks.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ pragma solidity ^0.8.0;

contract TelepathyBroadcasterMock {
function send(
uint16 _recipientChainId,
address _recipientAddress,
bytes calldata _data
) external returns (bytes32) {
uint16,
address,
bytes calldata
) external pure returns (bytes32) {
return bytes32(0);
}
}
60 changes: 0 additions & 60 deletions contracts/upgradeable/TestableUpgradeable.sol

This file was deleted.

2 changes: 1 addition & 1 deletion test/SpokePool.Admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("SpokePool Admin Functions", async function () {
it("Can set initial deposit ID", async function () {
const spokePool = await hre.upgrades.deployProxy(
await getContractFactory("MockSpokePool", owner),
[1, owner.address, owner.address, owner.address, owner.address],
[1, owner.address, owner.address, owner.address],
{ kind: "uups" }
);
expect(await spokePool.numberOfDeposits()).to.equal(1);
Expand Down
8 changes: 1 addition & 7 deletions test/SpokePool.SlowRelay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ import {
randomBigNumber,
BigNumber,
} from "./utils";
import {
spokePoolFixture,
enableRoutes,
RelayData,
getExecuteSlowRelayParams,
SlowFill,
} from "./fixtures/SpokePool.Fixture";
import { spokePoolFixture, enableRoutes, getExecuteSlowRelayParams, SlowFill } from "./fixtures/SpokePool.Fixture";
import { getFillRelayParams, getRelayHash } from "./fixtures/SpokePool.Fixture";
import { MerkleTree } from "../utils/MerkleTree";
import { buildSlowRelayTree } from "./MerkleLib.utils";
Expand Down
2 changes: 1 addition & 1 deletion test/chain-specific-spokepools/Arbitrum_SpokePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("Arbitrum Spoke Pool", function () {

arbitrumSpokePool = await hre.upgrades.deployProxy(
await getContractFactory("Arbitrum_SpokePool", owner),
[0, l2GatewayRouter.address, owner.address, hubPool.address, l2Weth, timer.address],
[0, l2GatewayRouter.address, owner.address, hubPool.address, l2Weth],
{ kind: "uups" }
);

Expand Down
2 changes: 1 addition & 1 deletion test/chain-specific-spokepools/Ethereum_SpokePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("Ethereum Spoke Pool", function () {

spokePool = await hre.upgrades.deployProxy(
await getContractFactory("Ethereum_SpokePool", owner),
[0, hubPool.address, weth.address, timer.address],
[0, hubPool.address, weth.address],
{ kind: "uups" }
);

Expand Down
2 changes: 1 addition & 1 deletion test/chain-specific-spokepools/Optimism_SpokePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("Optimism Spoke Pool", function () {

optimismSpokePool = await hre.upgrades.deployProxy(
await getContractFactory("Optimism_SpokePool", owner),
[0, owner.address, hubPool.address, timer.address],
[0, owner.address, hubPool.address],
{ kind: "uups" }
);

Expand Down
2 changes: 1 addition & 1 deletion test/chain-specific-spokepools/Polygon_SpokePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("Polygon Spoke Pool", function () {

polygonSpokePool = await hre.upgrades.deployProxy(
await getContractFactory("Polygon_SpokePool", owner),
[0, polygonTokenBridger.address, owner.address, hubPool.address, weth.address, fxChild.address, timer.address],
[0, polygonTokenBridger.address, owner.address, hubPool.address, weth.address, fxChild.address],
{ kind: "uups" }
);

Expand Down
2 changes: 1 addition & 1 deletion test/chain-specific-spokepools/Succinct_SpokePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("Succinct Spoke Pool", function () {

succinctSpokePool = await hre.upgrades.deployProxy(
await getContractFactory("Succinct_SpokePool", owner),
[l1ChainId, succinctTargetAmb.address, 0, hubPool.address, hubPool.address, weth.address, timer.address],
[l1ChainId, succinctTargetAmb.address, 0, hubPool.address, hubPool.address, weth.address],
{ kind: "uups" }
);
});
Expand Down
Loading