Skip to content

Commit a14355b

Browse files
committed
Merge remote-tracking branch 'origin/develop' into bold-merge
2 parents a9a222f + b140ed6 commit a14355b

File tree

9 files changed

+291
-12
lines changed

9 files changed

+291
-12
lines changed

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Additional Use Grant: You may use the Licensed Work in a production environment
2222
Expansion Program Term of Use](https://docs.arbitrum.foundation/assets/files/Arbitrum%20Expansion%20Program%20Jan182024-4f08b0c2cb476a55dc153380fa3e64b0.pdf). For purposes of this
2323
Additional Use Grant, the "Covered Arbitrum Chains" are
2424
(a) Arbitrum One (chainid:42161), Arbitrum Nova (chainid:42170),
25-
rbitrum Rinkeby testnet/Rinkarby (chainid:421611),Arbitrum Nitro
25+
Arbitrum Rinkeby testnet/Rinkarby (chainid:421611),Arbitrum Nitro
2626
Goerli testnet (chainid:421613), and Arbitrum Sepolia Testnet
2727
(chainid:421614); (b) any future blockchains authorized to be
2828
designated as Covered Arbitrum Chains by the decentralized autonomous

foundry.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ cache_path = 'forge-cache/sol'
66
optimizer = true
77
optimizer_runs = 2000
88
via_ir = false
9-
solc_version = '0.8.17'
10-
remappings = ['@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/',
9+
evm_version = 'cancun'
10+
remappings = ['ds-test/=lib/forge-std/lib/ds-test/src/',
11+
'forge-std/=lib/forge-std/src/',
12+
'@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/',
1113
'@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/',
1214
'@offchainlabs/upgrade-executor/=node_modules/@offchainlabs/upgrade-executor/']
1315
fs_permissions = [{ access = "read", path = "./"}]

hardhat.config.ts

+20
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ const solidity = {
4343
},
4444
},
4545
},
46+
'src/mocks/HostioTest.sol': {
47+
version: '0.8.24',
48+
settings: {
49+
optimizer: {
50+
enabled: true,
51+
runs: 100,
52+
},
53+
evmVersion: 'cancun',
54+
},
55+
},
4656
},
4757
}
4858

@@ -69,6 +79,16 @@ if (process.env['INTERFACE_TESTER_SOLC_VERSION']) {
6979
},
7080
},
7181
},
82+
'src/mocks/HostioTest.sol': {
83+
version: '0.8.24',
84+
settings: {
85+
optimizer: {
86+
enabled: true,
87+
runs: 100,
88+
},
89+
evmVersion: 'cancun',
90+
},
91+
},
7292
}
7393
}
7494

scripts/deploymentUtils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ export async function deployAllContracts(
242242
)
243243
const rollupUser = await deployContract('RollupUserLogic', signer, [], verify)
244244
const upgradeExecutor = await deployUpgradeExecutor(signer)
245+
await upgradeExecutor.deployTransaction.wait()
245246
const validatorWalletCreator = await deployContract(
246247
'ValidatorWalletCreator',
247248
signer,

src/mocks/CreateTest.sol

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright 2024, Offchain Labs, Inc.
2+
// For license information, see https://github.com/nitro/blob/master/LICENSE
3+
// SPDX-License-Identifier: BUSL-1.1
4+
5+
pragma solidity ^0.8.0;
6+
7+
/*
8+
* This contract is the solidity equivalent of the stylus create test contract.
9+
*/
10+
contract CreateTest {
11+
// solhint-disable no-complex-fallback
12+
// solhint-disable reason-string
13+
// solhint-disable avoid-low-level-calls
14+
// solhint-disable-next-line prettier/prettier
15+
fallback(bytes calldata input) external returns (bytes memory) {
16+
uint8 kind = uint8(input[0]);
17+
input = input[1:];
18+
19+
bytes32 endowment = bytes32(input[:32]);
20+
input = input[32:];
21+
22+
address addr;
23+
24+
if (kind == 2) {
25+
bytes32 salt = bytes32(input[:32]);
26+
input = input[32:];
27+
bytes memory code = input;
28+
assembly {
29+
addr := create2(endowment, add(code, 32), mload(code), salt)
30+
}
31+
} else {
32+
bytes memory code = input;
33+
assembly {
34+
addr := create(endowment, add(code, 32), mload(code))
35+
}
36+
}
37+
if (addr == address(0)) {
38+
revert("failed to create");
39+
}
40+
return addr.code;
41+
}
42+
}

src/mocks/HostioTest.sol

+196
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
// Copyright 2024, Offchain Labs, Inc.
2+
// For license information, see https://github.com/nitro/blob/master/LICENSE
3+
// SPDX-License-Identifier: BUSL-1.1
4+
5+
pragma solidity ^0.8.24;
6+
7+
/*
8+
* HostioTest is a test contract used to compare EVM with Stylus.
9+
*/
10+
contract HostioTest {
11+
function exitEarly() external pure {
12+
assembly {
13+
stop()
14+
}
15+
}
16+
17+
function transientLoadBytes32(bytes32 key) external view returns (bytes32) {
18+
bytes32 data;
19+
assembly {
20+
data := tload(key)
21+
}
22+
return data;
23+
}
24+
25+
function transientStoreBytes32(bytes32 key, bytes32 value) external {
26+
assembly {
27+
// solc-ignore-next-line transient-storage
28+
tstore(key, value)
29+
}
30+
}
31+
32+
function returnDataSize() external pure returns (uint256) {
33+
uint256 size;
34+
assembly {
35+
size := returndatasize()
36+
}
37+
return size;
38+
}
39+
40+
function emitLog(
41+
bytes calldata _data,
42+
int8 n,
43+
bytes32 t1,
44+
bytes32 t2,
45+
bytes32 t3,
46+
bytes32 t4
47+
) external {
48+
bytes memory data = _data;
49+
if (n == 0) {
50+
assembly {
51+
log0(add(data, 32), mload(data))
52+
}
53+
} else if (n == 1) {
54+
assembly {
55+
log1(add(data, 32), mload(data), t1)
56+
}
57+
} else if (n == 2) {
58+
assembly {
59+
log2(add(data, 32), mload(data), t1, t2)
60+
}
61+
} else if (n == 3) {
62+
assembly {
63+
log3(add(data, 32), mload(data), t1, t2, t3)
64+
}
65+
} else if (n == 4) {
66+
assembly {
67+
log4(add(data, 32), mload(data), t1, t2, t3, t4)
68+
}
69+
} else {
70+
revert("invalid n for emit log");
71+
}
72+
}
73+
74+
function accountBalance(address account) external view returns (uint256) {
75+
return account.balance;
76+
}
77+
78+
function accountCode(address account) external view returns (bytes memory) {
79+
uint256 size = 10000;
80+
bytes memory code = new bytes(size);
81+
assembly {
82+
extcodecopy(account, add(code, 32), 0, size)
83+
size := extcodesize(account)
84+
mstore(code, size)
85+
}
86+
return code;
87+
}
88+
89+
function accountCodeSize(address account) external view returns (uint256) {
90+
uint256 size;
91+
assembly {
92+
size := extcodesize(account)
93+
}
94+
return size;
95+
}
96+
97+
function accountCodehash(address account) external view returns (bytes32) {
98+
bytes32 hash;
99+
assembly {
100+
hash := extcodehash(account)
101+
}
102+
return hash;
103+
}
104+
105+
function evmGasLeft() external view returns (uint256) {
106+
return gasleft();
107+
}
108+
109+
function evmInkLeft() external view returns (uint256) {
110+
return gasleft();
111+
}
112+
113+
function blockBasefee() external view returns (uint256) {
114+
return block.basefee;
115+
}
116+
117+
function chainid() external view returns (uint256) {
118+
return block.chainid;
119+
}
120+
121+
function blockCoinbase() external view returns (address) {
122+
return block.coinbase;
123+
}
124+
125+
function blockGasLimit() external view returns (uint256) {
126+
return block.gaslimit;
127+
}
128+
129+
function blockNumber() external view returns (uint256) {
130+
return block.number;
131+
}
132+
133+
function blockTimestamp() external view returns (uint256) {
134+
return block.timestamp;
135+
}
136+
137+
function contractAddress() external view returns (address) {
138+
return address(this);
139+
}
140+
141+
function mathDiv(uint256 a, uint256 b) external pure returns (uint256) {
142+
return a / b;
143+
}
144+
145+
function mathMod(uint256 a, uint256 b) external pure returns (uint256) {
146+
return a % b;
147+
}
148+
149+
function mathPow(uint256 a, uint256 b) external pure returns (uint256) {
150+
uint256 result;
151+
assembly {
152+
result := exp(a, b)
153+
}
154+
return result;
155+
}
156+
157+
function mathAddMod(
158+
uint256 a,
159+
uint256 b,
160+
uint256 c
161+
) external pure returns (uint256) {
162+
return addmod(a, b, c);
163+
}
164+
165+
function mathMulMod(
166+
uint256 a,
167+
uint256 b,
168+
uint256 c
169+
) external pure returns (uint256) {
170+
return mulmod(a, b, c);
171+
}
172+
173+
function msgSender() external view returns (address) {
174+
return msg.sender;
175+
}
176+
177+
function msgValue() external payable returns (uint256) {
178+
return msg.value;
179+
}
180+
181+
function keccak(bytes calldata preimage) external pure returns (bytes32) {
182+
return keccak256(preimage);
183+
}
184+
185+
function txGasPrice() external view returns (uint256) {
186+
return tx.gasprice;
187+
}
188+
189+
function txInkPrice() external view returns (uint256) {
190+
return tx.gasprice;
191+
}
192+
193+
function txOrigin() external view returns (address) {
194+
return tx.origin;
195+
}
196+
}

src/precompiles/ArbSys.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ interface ArbSys {
3131
function arbChainID() external view returns (uint256);
3232

3333
/**
34-
* @notice Get internal version number identifying an ArbOS build
34+
* @notice Get internal version number identifying an ArbOS build, this is `55 + nitroArbOS version number`
35+
* e.g. on ArbOS 31 this would return 86. This is the only function that have the 55 offset.
3536
* @return version number as int
3637
*/
3738
function arbOSVersion() external view returns (uint256);

src/precompiles/ArbWasm.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ interface ArbWasm {
9292
/// @notice Gets the minimum costs to invoke a program
9393
/// @return gas amount of gas in increments of 256 when not cached
9494
/// @return cached amount of gas in increments of 64 when cached
95-
function minInitGas() external view returns (uint8 gas, uint8 cached);
95+
function minInitGas() external view returns (uint64 gas, uint64 cached);
9696

9797
/// @notice Gets the linear adjustment made to program init costs.
9898
/// @return percent the adjustment (100% = no adjustment).

test/e2e/orbitChain.ts

+24-7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ import { AssertionStateStruct } from '../../build/types/src/challengeV2/IAsserti
2626
import { getLocalNetworks } from '../../scripts/testSetup'
2727
import { applyAlias } from '../contract/utils'
2828
import { BigNumber, ContractTransaction, Wallet, ethers } from 'ethers'
29+
import {
30+
l1Networks,
31+
l2Networks,
32+
} from '@arbitrum/sdk/dist/lib/dataEntities/networks'
2933

3034
const LOCALHOST_L2_RPC = 'http://127.0.0.1:8547'
3135
const LOCALHOST_L3_RPC = 'http://127.0.0.1:3347'
@@ -70,10 +74,18 @@ describe('Orbit Chain', () => {
7074
l2WethGateway: '',
7175
},
7276
}
73-
addCustomNetwork({
74-
customL1Network: l1Network,
75-
customL2Network: l2Network,
76-
})
77+
if (!l2Networks[l2Network.chainID.toString()]) {
78+
if (!l1Networks[l2Network.chainID.toString()]) {
79+
addCustomNetwork({
80+
customL1Network: l1Network,
81+
customL2Network: l2Network,
82+
})
83+
} else {
84+
addCustomNetwork({
85+
customL2Network: l2Network,
86+
})
87+
}
88+
}
7789

7890
l1Provider = new JsonRpcProvider(LOCALHOST_L2_RPC)
7991
l2Provider = new JsonRpcProvider(LOCALHOST_L3_RPC)
@@ -644,7 +656,10 @@ describe('Orbit Chain', () => {
644656

645657
const inbox = l2Network.ethBridge.inbox
646658
const maxFeePerGas = BigNumber.from('100000000') // 0.1 gwei
647-
let fee = await deployHelper.getDeploymentTotalCost(inbox, maxFeePerGas)
659+
let fee = await deployHelper.getDeploymentTotalCost(inbox, maxFeePerGas, {
660+
from: userL1Wallet.address,
661+
gasPrice: maxFeePerGas,
662+
})
648663

649664
if (nativeToken) {
650665
const decimals = await nativeToken.decimals()
@@ -689,7 +704,6 @@ describe('Orbit Chain', () => {
689704
).wait()
690705
}
691706

692-
// deploy factories
693707
const receipt = await (
694708
await deployHelper
695709
.connect(userL1Wallet)
@@ -738,7 +752,10 @@ describe('Orbit Chain', () => {
738752

739753
const inbox = l2Network.ethBridge.inbox
740754
const maxFeePerGas = BigNumber.from('100000000') // 0.1 gwei
741-
let fee = await deployHelper.getDeploymentTotalCost(inbox, maxFeePerGas)
755+
let fee = await deployHelper.getDeploymentTotalCost(inbox, maxFeePerGas, {
756+
from: userL1Wallet.address,
757+
gasPrice: maxFeePerGas,
758+
})
742759
if (nativeToken) {
743760
const decimals = await nativeToken.decimals()
744761
if (decimals < 18) {

0 commit comments

Comments
 (0)