Commit de7d5f6e authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge branch 'develop' into ctb/optimize-spacer-check

parents 54a3e562 1c00dcbc
......@@ -871,10 +871,6 @@ jobs:
name: Deposit ETH through the bridge
command: timeout 8m npx hardhat deposit-eth --network devnetL1 --l1-contracts-json-path ../../.devnet/sdk-addresses.json
working_directory: packages/sdk
- run:
name: Check the status
command: npx hardhat check-op-node
working_directory: packages/contracts-bedrock
- run:
name: Dump op-node logs
command: |
......@@ -926,10 +922,6 @@ jobs:
name: Deposit ETH through the bridge
command: timeout 10m npx hardhat deposit-eth --network devnetL1
working_directory: packages/sdk
- run:
name: Check the status
command: npx hardhat check-op-node
working_directory: packages/contracts-bedrock
- run:
name: Dump op-node logs
command: |
......
......@@ -5,45 +5,34 @@ import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuar
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
/**
* @title TransferOnion
* @notice TransferOnion is a hash onion for distributing tokens. The shell commits
* to an ordered list of the token transfers and can be permissionlessly
* unwrapped in order. The SENDER must `approve` this contract as
* `transferFrom` is used to move the token balances.
*/
/// @title TransferOnion
/// @notice TransferOnion is a hash onion for distributing tokens. The shell commits
/// to an ordered list of the token transfers and can be permissionlessly
/// unwrapped in order. The SENDER must `approve` this contract as
/// `transferFrom` is used to move the token balances.
contract TransferOnion is ReentrancyGuard {
using SafeERC20 for ERC20;
/**
* @notice Struct representing a layer of the onion.
*/
/// @notice Struct representing a layer of the onion.
struct Layer {
address recipient;
uint256 amount;
bytes32 shell;
}
/**
* @notice Address of the token to distribute.
*/
/// @notice Address of the token to distribute.
ERC20 public immutable TOKEN;
/**
* @notice Address of the account to distribute tokens from.
*/
/// @notice Address of the account to distribute tokens from.
address public immutable SENDER;
/**
* @notice Current shell hash.
*/
/// @notice Current shell hash.
bytes32 public shell;
/**
* @param _token Address of the token to distribute.
* @param _sender Address of the sender to distribute from.
* @param _shell Initial shell of the onion.
*/
/// @notice Constructs a new TransferOnion.
/// @param _token Address of the token to distribute.
/// @param _sender Address of the sender to distribute from.
/// @param _shell Initial shell of the onion.
constructor(
ERC20 _token,
address _sender,
......@@ -54,11 +43,8 @@ contract TransferOnion is ReentrancyGuard {
shell = _shell;
}
/**
* @notice Peels layers from the onion and distributes tokens.
*
* @param _layers Array of onion layers to peel.
*/
/// @notice Peels layers from the onion and distributes tokens.
/// @param _layers Array of onion layers to peel.
function peel(Layer[] memory _layers) public nonReentrant {
bytes32 tempShell = shell;
uint256 length = _layers.length;
......@@ -75,6 +61,7 @@ contract TransferOnion is ReentrancyGuard {
tempShell = layer.shell;
// Transfer the tokens.
// slither-disable-next-line arbitrary-send-erc20
TOKEN.safeTransferFrom(SENDER, layer.recipient, layer.amount);
// Unchecked increment to save some gas.
......
......@@ -20,7 +20,7 @@ import { OptimismPortal } from "../L1/OptimismPortal.sol";
contract L1StandardBridge_Getter_Test is Bridge_Initializer {
/// @dev Test that the accessors return the correct initialized values.
function test_getters_succeeds() external {
function test_getters_succeeds() external view {
assert(L1Bridge.l2TokenBridge() == address(L2Bridge));
assert(L1Bridge.OTHER_BRIDGE() == L2Bridge);
assert(L1Bridge.messenger() == L1Messenger);
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
// Testing utilities
import { Test } from "forge-std/Test.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
// Target contract
import { TransferOnion } from "../periphery/TransferOnion.sol";
/**
* @title TransferOnionTest
* @notice Test coverage of TransferOnion
*/
/// @title TransferOnionTest
/// @notice Test coverage of TransferOnion
contract TransferOnionTest is Test {
/**
* @notice TransferOnion
*/
/// @notice TransferOnion
TransferOnion internal onion;
/**
* @notice token constructor arg
*/
/// @notice Token constructor argument
address internal _token;
/**
* @notice sender constructor arg
*/
/// @notice Sender constructor argument
address internal _sender;
/**
* @notice Sets up addresses, deploys contracts and funds the owner.
*/
/// @notice Sets up addresses, deploys contracts and funds the owner.
function setUp() public {
ERC20 token = new ERC20("Token", "TKN");
_token = address(token);
_sender = makeAddr("sender");
}
/**
* @notice Deploy the TransferOnion with a dummy shell
*/
/// @notice Deploy the TransferOnion with a dummy shell.
function _deploy() public {
_deploy(bytes32(0));
}
/**
* @notice Deploy the TransferOnion with a specific shell
*/
/// @notice Deploy the TransferOnion with a specific shell.
function _deploy(bytes32 _shell) public {
onion = new TransferOnion({ _token: ERC20(_token), _sender: _sender, _shell: _shell });
}
/**
* @notice Build the onion data
*/
/// @notice Build the onion data.
function _onionize(TransferOnion.Layer[] memory _layers)
public
pure
......@@ -66,9 +53,7 @@ contract TransferOnionTest is Test {
return (hash, _layers);
}
/**
* @notice The constructor sets the variables as expected
*/
/// @notice The constructor sets the variables as expected.
function test_constructor_succeeds() external {
_deploy();
......@@ -77,9 +62,7 @@ contract TransferOnionTest is Test {
assertEq(onion.shell(), bytes32(0));
}
/**
* @notice unwrap
*/
/// @notice Tests unwrapping the onion.
function test_unwrap_succeeds() external {
// Commit to transferring tiny amounts of tokens
TransferOnion.Layer[] memory _layers = new TransferOnion.Layer[](2);
......
import { task, types } from 'hardhat/config'
import { OpNodeProvider } from '@eth-optimism/core-utils'
// TODO(tynes): add in config validation
task('check-op-node', 'Validate the config of the op-node')
.addParam(
'opNodeUrl',
'URL of the OP Node.',
'http://localhost:7545',
types.string
)
.setAction(async (args) => {
const provider = new OpNodeProvider(args.opNodeUrl)
const syncStatus = await provider.syncStatus()
console.log(JSON.stringify(syncStatus, null, 2))
const config = await provider.rollupConfig()
console.log(JSON.stringify(config, null, 2))
})
import './check-op-node'
import './solidity'
import './check-l2'
import './generate-deploy-config'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment