Skip to content

Commit

Permalink
Merge branch 'develop' into wsdt/bnb-deployment-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wsdt authored Jul 20, 2023
2 parents 425c312 + 613200a commit 56cc91f
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 165 deletions.
7 changes: 3 additions & 4 deletions integration-tests/test/alt-l2/teleportation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
historyDataRepository,
} from '@boba/teleportation/src/data-source'
import { OptimismEnv } from './shared/env'
import { getContractFactory, predeploys } from '@eth-optimism/contracts'

describe('teleportation', () => {
let env: OptimismEnv
Expand Down Expand Up @@ -704,7 +703,7 @@ describe('teleportation', () => {

let disbursement = []
for (const event of events) {
const sourceChainId = chainIdBnb // event.args.sourceChainId.toNumber() -> (is correct, but we were mocking a fake chainId for testing)
const sourceChainId = chainIdBnb // event.args.sourceChainId -> (is correct, but we were mocking a fake chainId for testing)
const depositId = event.args.depositId
const amount = event.args.amount
const token = event.args.token
Expand Down Expand Up @@ -784,7 +783,7 @@ describe('teleportation', () => {

let disbursement = []
for (const event of events) {
const sourceChainId = chainIdBnb // event.args.sourceChainId.toNumber() -> (is correct, but we were mocking a fake chainId for testing)
const sourceChainId = chainIdBnb // event.args.sourceChainId -> (is correct, but we were mocking a fake chainId for testing)
const depositId = event.args.depositId
const amount = event.args.amount
const token = event.args.token
Expand Down Expand Up @@ -866,7 +865,7 @@ describe('teleportation', () => {

let disbursement = []
for (const event of events) {
const sourceChainId = event.args.sourceChainId.toNumber()
const sourceChainId = event.args.sourceChainId
const depositId = await TeleportationBNB.totalDisbursements(chainId) // event.args.depositId --> correct, but we used a fake chainId to simulate Bnb so we need to correct depositId here
const amount = event.args.amount
const token = event.args.token
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/test/eth-l2/teleportation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ describe('teleportation', () => {

let disbursement = []
for (const event of events) {
const sourceChainId = chainIdBnb // event.args.sourceChainId.toNumber() -> (is correct, but we were mocking a fake chainId for testing)
const sourceChainId = chainIdBnb // event.args.sourceChainId -> (is correct, but we were mocking a fake chainId for testing)
const depositId = event.args.depositId
const amount = event.args.amount
const token = event.args.token
Expand Down Expand Up @@ -783,7 +783,7 @@ describe('teleportation', () => {

let disbursement = []
for (const event of events) {
const sourceChainId = chainIdBnb // event.args.sourceChainId.toNumber() -> (is correct, but we were mocking a fake chainId for testing)
const sourceChainId = chainIdBnb // event.args.sourceChainId -> (is correct, but we were mocking a fake chainId for testing)
const depositId = event.args.depositId
const amount = event.args.amount
const token = event.args.token
Expand Down Expand Up @@ -865,7 +865,7 @@ describe('teleportation', () => {

let disbursement = []
for (const event of events) {
const sourceChainId = event.args.sourceChainId.toNumber()
const sourceChainId = event.args.sourceChainId
const depositId = await TeleportationBNB.totalDisbursements(chainId) // event.args.depositId --> correct, but we used a fake chainId to simulate Bnb so we need to correct depositId here
const amount = event.args.amount
const token = event.args.token
Expand Down
8 changes: 5 additions & 3 deletions l2geth/core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ The state transitioning model does all the necessary work to work out a valid ne
3) Create a new state object if the recipient is \0*32
4) Value transfer
== If contract creation ==
4a) Attempt to run transaction data
4b) If valid, use result as code for the new state object
4a) Attempt to run transaction data
4b) If valid, use result as code for the new state object
== end ==
5) Run Script section
6) Derive new state root
Expand Down Expand Up @@ -277,7 +279,7 @@ func (st *StateTransition) buyGas() error {
if !st.isEthereumL2 {
bobaval = new(big.Int).Div(bobaval, st.bobaPriceRatioDivisor)
}
if st.state.GetBobaBalance(st.msg.From()).Cmp(bobaval) < 0 {
if st.state.GetBobaBalance(st.msg.From()).Cmp(bobaval) <= 0 {
if !st.isEthereumL2 {
return errInsufficientL1NativeTokenBalanceForGas
}
Expand Down
2 changes: 1 addition & 1 deletion packages/boba/bobalink/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"@eth-optimism/common-ts": "0.2.2",
"bcfg": "^0.1.6",
"bcfg": "^0.2.1",
"dotenv": "^8.2.0",
"ethers": "^5.5.4"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/boba/bundler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"hardhat": "^2.12.5",
"hardhat-deploy": "^0.11.12",
"ow": "^0.28.1",
"sinon": "^14.0.0",
"sinon": "^15.2.0",
"solidity-coverage": "^0.7.21",
"solidity-string-utils": "^0.0.8-0",
"ts-node": ">=8.0.0",
Expand Down
42 changes: 20 additions & 22 deletions packages/boba/contracts/contracts/Teleportation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity 0.8.9;

/* External Imports */
import '@openzeppelin/contracts/utils/math/SafeMath.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol";
Expand All @@ -18,7 +17,6 @@ import '@openzeppelin/contracts/utils/Address.sol';
*/
contract Teleportation is PausableUpgradeable, MulticallUpgradeable {
using Address for address;
using SafeMath for uint256;
using SafeERC20 for IERC20;

/**************
Expand All @@ -28,7 +26,7 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {
address token;
uint256 amount;
address addr;
uint256 sourceChainId;
uint32 sourceChainId;
uint256 depositId;
}

Expand Down Expand Up @@ -63,7 +61,7 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {

/// @dev Assets and networks to be supported. ZeroAddress for native asset
/// {assetAddress} => {targetChainId} => {tokenConfig}
mapping(address => mapping(uint256 => SupportedToken)) public supportedTokens;
mapping(address => mapping(uint32 => SupportedToken)) public supportedTokens;

/// @dev The total number of successful deposits received.
mapping(uint256 => uint256) public totalDeposits;
Expand All @@ -81,22 +79,22 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {
event MinDepositAmountSet(
/* @dev Zero Address = native asset **/
address token,
uint256 toChainId,
uint32 toChainId,
uint256 previousAmount,
uint256 newAmount
);

event MaxDepositAmountSet(
/* @dev Zero Address = native asset **/
address token,
uint256 toChainId,
uint32 toChainId,
uint256 previousAmount,
uint256 newAmount
);

event MaxTransferAmountPerDaySet(
address token,
uint256 toChainId,
uint32 toChainId,
uint256 previousAmount,
uint256 newAmount
);
Expand All @@ -110,8 +108,8 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {
event AssetReceived(
/** @dev Must be ZeroAddress for nativeAsset */
address token,
uint256 sourceChainId,
uint256 indexed toChainId,
uint32 sourceChainId,
uint32 indexed toChainId,
uint256 indexed depositId,
address indexed emitter,
uint256 amount
Expand All @@ -122,23 +120,23 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {
address indexed to,
address indexed token,
uint256 amount,
uint256 sourceChainId
uint32 sourceChainId
);

/** @dev only for native assets */
event DisbursementFailed(
uint256 indexed depositId,
address indexed to,
uint256 amount,
uint256 sourceChainId
uint32 sourceChainId
);

/** @dev Only for native assets */
event DisbursementRetrySuccess(
uint256 indexed depositId,
address indexed to,
uint256 amount,
uint256 sourceChainId
uint32 sourceChainId
);

event DisburserTransferred(
Expand All @@ -151,7 +149,7 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {

event TokenSupported(
address indexed token,
uint256 indexed toChainId,
uint32 indexed toChainId,
bool supported
);

Expand Down Expand Up @@ -201,7 +199,7 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {
*
* @param _token Token address to support or ZeroAddress for native
*/
function addSupportedToken(address _token, uint256 _toChainId, uint256 _minDepositAmount, uint256 _maxDepositAmount, uint256 _maxTransferAmountPerDay) public onlyOwner() onlyInitialized() {
function addSupportedToken(address _token, uint32 _toChainId, uint256 _minDepositAmount, uint256 _maxDepositAmount, uint256 _maxTransferAmountPerDay) public onlyOwner() onlyInitialized() {
require(supportedTokens[_token][_toChainId].supported == false, "Already supported");
// Not added ERC165 as implemented for L1 ERC20
require(address(0) == _token || Address.isContract(_token), "Not contract or native");
Expand All @@ -224,7 +222,7 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {
*
* @param _token The token not to support.
*/
function removeSupportedToken(address _token, uint256 _toChainId) external onlyOwner() onlyInitialized() {
function removeSupportedToken(address _token, uint32 _toChainId) external onlyOwner() onlyInitialized() {
require(supportedTokens[_token][_toChainId].supported == true, "Already not supported");
delete supportedTokens[_token][_toChainId].supported;
delete supportedTokens[_token][_toChainId].minDepositAmount;
Expand All @@ -245,7 +243,7 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {
* @param _amount The amount of token or native asset to deposit (must be the same as msg.value if native asset)
* @param _toChainId The destination chain ID.
*/
function teleportAsset(address _token, uint256 _amount, uint256 _toChainId)
function teleportAsset(address _token, uint256 _amount, uint32 _toChainId)
external
payable
whenNotPaused()
Expand Down Expand Up @@ -273,7 +271,7 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {
IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);
}

emit AssetReceived(_token, block.chainid, _toChainId, totalDeposits[_toChainId], msg.sender, _amount);
emit AssetReceived(_token, uint32(block.chainid), _toChainId, totalDeposits[_toChainId], msg.sender, _amount);
totalDeposits[_toChainId] += 1;
}

Expand Down Expand Up @@ -303,7 +301,7 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {

uint256 _amount = _disbursements[i].amount;
address _addr = _disbursements[i].addr;
uint256 _sourceChainId = _disbursements[i].sourceChainId;
uint32 _sourceChainId = _disbursements[i].sourceChainId;
uint256 _depositId = _disbursements[i].depositId;
address _token = _disbursements[i].token;

Expand Down Expand Up @@ -366,7 +364,7 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {
require(failedDisbursement.failed, "DepositId not failed disbursement");
uint256 _amount = failedDisbursement.disbursement.amount;
address _addr = failedDisbursement.disbursement.addr;
uint256 _sourceChainId = failedDisbursement.disbursement.sourceChainId;
uint32 _sourceChainId = failedDisbursement.disbursement.sourceChainId;

// slither-disable-next-line calls-loop,reentrancy-events
(bool success,) = _addr.call{gas: 3000, value: _amount}("");
Expand Down Expand Up @@ -454,7 +452,7 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {
* @param _token configure for which token or ZeroAddress for native
* @param _minDepositAmount The new minimum deposit amount.
*/
function setMinAmount(address _token, uint256 _toChainId, uint256 _minDepositAmount) external onlyOwner() {
function setMinAmount(address _token, uint32 _toChainId, uint256 _minDepositAmount) external onlyOwner() {
SupportedToken memory supToken = supportedTokens[_token][_toChainId];
require(supToken.supported, "Token or chain not supported");
require(_minDepositAmount > 0 && _minDepositAmount <= supToken.maxDepositAmount, "incorrect min deposit amount");
Expand All @@ -472,7 +470,7 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {
* @param _toChainId target chain id to set configuration for
* @param _maxDepositAmount The new maximum deposit amount.
*/
function setMaxAmount(address _token, uint256 _toChainId, uint256 _maxDepositAmount) external onlyOwner() {
function setMaxAmount(address _token, uint32 _toChainId, uint256 _maxDepositAmount) external onlyOwner() {
SupportedToken memory supToken = supportedTokens[_token][_toChainId];
require(supToken.supported, "Token or chain not supported");
require(_maxDepositAmount <= supToken.maxTransferAmountPerDay, "max deposit amount more than daily limit");
Expand All @@ -489,7 +487,7 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {
* @param _token Token or native asset (ZeroAddr) to set value for
* @param _maxTransferAmountPerDay The new maximum daily transfer amount.
*/
function setMaxTransferAmountPerDay(address _token, uint256 _toChainId, uint256 _maxTransferAmountPerDay) external onlyOwner() {
function setMaxTransferAmountPerDay(address _token, uint32 _toChainId, uint256 _maxTransferAmountPerDay) external onlyOwner() {

SupportedToken memory supToken = supportedTokens[_token][_toChainId];
require(supToken.supported, "Token or chain not supported");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ let signer2: Signer
let signerAddress: string
let signer2Address: string

const chainId31337 = '31337'
const chainId4 = '4'
const chainId31337 = 31337
const chainId4 = 4
const initialSupply = utils.parseEther('10000000000')
const tokenName = 'BOBA'
const tokenSymbol = 'BOBA'
Expand Down
2 changes: 1 addition & 1 deletion packages/boba/gas-price-oracle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"dependencies": {
"@eth-optimism/common-ts": "0.2.2",
"bcfg": "^0.1.6",
"bcfg": "^0.2.1",
"dotenv": "^8.2.0",
"ethers": "^5.5.4",
"lodash": "^4.17.21"
Expand Down
2 changes: 1 addition & 1 deletion packages/boba/teleportation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@eth-optimism/contracts": "0.5.11",
"@ethersproject/keccak256": "^5.7.0",
"asn1.js": "^5.4.1",
"bcfg": "^0.1.6",
"bcfg": "^0.2.1",
"bn.js": "^5.2.1",
"dotenv": "^8.6.0",
"ethereumjs-tx": "^2.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/common-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@eth-optimism/core-utils": "0.8.1",
"@sentry/node": "^7.30.0",
"@types/pino-std-serializers": "^4.0.0",
"bcfg": "^0.1.7",
"bcfg": "^0.2.1",
"body-parser": "^1.20.0",
"commander": "^9.0.0",
"dotenv": "^16.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/data-transport-layer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@sentry/tracing": "^7.30.0",
"@types/express": "^4.17.12",
"axios": "^0.21.1",
"bcfg": "^0.1.6",
"bcfg": "^0.2.1",
"bfj": "^7.0.2",
"browser-or-node": "^1.3.0",
"cors": "^2.8.5",
Expand Down Expand Up @@ -86,7 +86,7 @@
"hardhat": "^2.12.5",
"lint-staged": "11.0.0",
"mocha": "^8.4.0",
"pino-pretty": "^5.0.0",
"pino-pretty": "^10.0.1",
"prettier": "^2.3.1",
"prom-client": "^14.2.0",
"rimraf": "^3.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/message-relayer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@eth-optimism/ynatm": "^0.2.2",
"@eth-optimism/sdk": "1.0.1",
"@sentry/node": "^7.30.0",
"bcfg": "^0.1.6",
"bcfg": "^0.2.1",
"dotenv": "^10.0.0",
"ethers": "^5.5.4",
"node-fetch": "^2.6.1"
Expand Down
Loading

0 comments on commit 56cc91f

Please sign in to comment.