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: ...@@ -871,10 +871,6 @@ jobs:
name: Deposit ETH through the bridge name: Deposit ETH through the bridge
command: timeout 8m npx hardhat deposit-eth --network devnetL1 --l1-contracts-json-path ../../.devnet/sdk-addresses.json command: timeout 8m npx hardhat deposit-eth --network devnetL1 --l1-contracts-json-path ../../.devnet/sdk-addresses.json
working_directory: packages/sdk working_directory: packages/sdk
- run:
name: Check the status
command: npx hardhat check-op-node
working_directory: packages/contracts-bedrock
- run: - run:
name: Dump op-node logs name: Dump op-node logs
command: | command: |
...@@ -926,10 +922,6 @@ jobs: ...@@ -926,10 +922,6 @@ jobs:
name: Deposit ETH through the bridge name: Deposit ETH through the bridge
command: timeout 10m npx hardhat deposit-eth --network devnetL1 command: timeout 10m npx hardhat deposit-eth --network devnetL1
working_directory: packages/sdk working_directory: packages/sdk
- run:
name: Check the status
command: npx hardhat check-op-node
working_directory: packages/contracts-bedrock
- run: - run:
name: Dump op-node logs name: Dump op-node logs
command: | command: |
......
...@@ -5,45 +5,34 @@ import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuar ...@@ -5,45 +5,34 @@ import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuar
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
/** /// @title TransferOnion
* @title TransferOnion /// @notice TransferOnion is a hash onion for distributing tokens. The shell commits
* @notice TransferOnion is a hash onion for distributing tokens. The shell commits /// to an ordered list of the token transfers and can be permissionlessly
* to an ordered list of the token transfers and can be permissionlessly /// unwrapped in order. The SENDER must `approve` this contract as
* unwrapped in order. The SENDER must `approve` this contract as /// `transferFrom` is used to move the token balances.
* `transferFrom` is used to move the token balances.
*/
contract TransferOnion is ReentrancyGuard { contract TransferOnion is ReentrancyGuard {
using SafeERC20 for ERC20; using SafeERC20 for ERC20;
/** /// @notice Struct representing a layer of the onion.
* @notice Struct representing a layer of the onion.
*/
struct Layer { struct Layer {
address recipient; address recipient;
uint256 amount; uint256 amount;
bytes32 shell; bytes32 shell;
} }
/** /// @notice Address of the token to distribute.
* @notice Address of the token to distribute.
*/
ERC20 public immutable TOKEN; 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; address public immutable SENDER;
/** /// @notice Current shell hash.
* @notice Current shell hash.
*/
bytes32 public shell; bytes32 public shell;
/** /// @notice Constructs a new TransferOnion.
* @param _token Address of the token to distribute. /// @param _token Address of the token to distribute.
* @param _sender Address of the sender to distribute from. /// @param _sender Address of the sender to distribute from.
* @param _shell Initial shell of the onion. /// @param _shell Initial shell of the onion.
*/
constructor( constructor(
ERC20 _token, ERC20 _token,
address _sender, address _sender,
...@@ -54,11 +43,8 @@ contract TransferOnion is ReentrancyGuard { ...@@ -54,11 +43,8 @@ contract TransferOnion is ReentrancyGuard {
shell = _shell; shell = _shell;
} }
/** /// @notice Peels layers from the onion and distributes tokens.
* @notice Peels layers from the onion and distributes tokens. /// @param _layers Array of onion layers to peel.
*
* @param _layers Array of onion layers to peel.
*/
function peel(Layer[] memory _layers) public nonReentrant { function peel(Layer[] memory _layers) public nonReentrant {
bytes32 tempShell = shell; bytes32 tempShell = shell;
uint256 length = _layers.length; uint256 length = _layers.length;
...@@ -75,6 +61,7 @@ contract TransferOnion is ReentrancyGuard { ...@@ -75,6 +61,7 @@ contract TransferOnion is ReentrancyGuard {
tempShell = layer.shell; tempShell = layer.shell;
// Transfer the tokens. // Transfer the tokens.
// slither-disable-next-line arbitrary-send-erc20
TOKEN.safeTransferFrom(SENDER, layer.recipient, layer.amount); TOKEN.safeTransferFrom(SENDER, layer.recipient, layer.amount);
// Unchecked increment to save some gas. // Unchecked increment to save some gas.
......
...@@ -20,7 +20,7 @@ import { OptimismPortal } from "../L1/OptimismPortal.sol"; ...@@ -20,7 +20,7 @@ import { OptimismPortal } from "../L1/OptimismPortal.sol";
contract L1StandardBridge_Getter_Test is Bridge_Initializer { contract L1StandardBridge_Getter_Test is Bridge_Initializer {
/// @dev Test that the accessors return the correct initialized values. /// @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.l2TokenBridge() == address(L2Bridge));
assert(L1Bridge.OTHER_BRIDGE() == L2Bridge); assert(L1Bridge.OTHER_BRIDGE() == L2Bridge);
assert(L1Bridge.messenger() == L1Messenger); assert(L1Bridge.messenger() == L1Messenger);
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.15; pragma solidity 0.8.15;
// Testing utilities
import { Test } from "forge-std/Test.sol"; import { Test } from "forge-std/Test.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
// Target contract
import { TransferOnion } from "../periphery/TransferOnion.sol"; import { TransferOnion } from "../periphery/TransferOnion.sol";
/** /// @title TransferOnionTest
* @title TransferOnionTest /// @notice Test coverage of TransferOnion
* @notice Test coverage of TransferOnion
*/
contract TransferOnionTest is Test { contract TransferOnionTest is Test {
/** /// @notice TransferOnion
* @notice TransferOnion
*/
TransferOnion internal onion; TransferOnion internal onion;
/** /// @notice Token constructor argument
* @notice token constructor arg
*/
address internal _token; address internal _token;
/** /// @notice Sender constructor argument
* @notice sender constructor arg
*/
address internal _sender; 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 { function setUp() public {
ERC20 token = new ERC20("Token", "TKN"); ERC20 token = new ERC20("Token", "TKN");
_token = address(token); _token = address(token);
_sender = makeAddr("sender"); _sender = makeAddr("sender");
} }
/** /// @notice Deploy the TransferOnion with a dummy shell.
* @notice Deploy the TransferOnion with a dummy shell
*/
function _deploy() public { function _deploy() public {
_deploy(bytes32(0)); _deploy(bytes32(0));
} }
/** /// @notice Deploy the TransferOnion with a specific shell.
* @notice Deploy the TransferOnion with a specific shell
*/
function _deploy(bytes32 _shell) public { function _deploy(bytes32 _shell) public {
onion = new TransferOnion({ _token: ERC20(_token), _sender: _sender, _shell: _shell }); 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) function _onionize(TransferOnion.Layer[] memory _layers)
public public
pure pure
...@@ -66,9 +53,7 @@ contract TransferOnionTest is Test { ...@@ -66,9 +53,7 @@ contract TransferOnionTest is Test {
return (hash, _layers); return (hash, _layers);
} }
/** /// @notice The constructor sets the variables as expected.
* @notice The constructor sets the variables as expected
*/
function test_constructor_succeeds() external { function test_constructor_succeeds() external {
_deploy(); _deploy();
...@@ -77,9 +62,7 @@ contract TransferOnionTest is Test { ...@@ -77,9 +62,7 @@ contract TransferOnionTest is Test {
assertEq(onion.shell(), bytes32(0)); assertEq(onion.shell(), bytes32(0));
} }
/** /// @notice Tests unwrapping the onion.
* @notice unwrap
*/
function test_unwrap_succeeds() external { function test_unwrap_succeeds() external {
// Commit to transferring tiny amounts of tokens // Commit to transferring tiny amounts of tokens
TransferOnion.Layer[] memory _layers = new TransferOnion.Layer[](2); 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 './solidity'
import './check-l2' import './check-l2'
import './generate-deploy-config' 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