Skip to content

Commit 7790645

Browse files
committed
chore: Use v1.7.7 Optimism contracts
1 parent dad68e7 commit 7790645

File tree

9 files changed

+34
-53
lines changed

9 files changed

+34
-53
lines changed

Diff for: crates/fpvm/bindings/bindings.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ MIPS_ARTIFACT="$CTB/forge-artifacts/MIPS.sol/MIPS.json"
3030
PREIMAGE_ARTIFACT="$CTB/forge-artifacts/PreimageOracle.sol/PreimageOracle.json"
3131

3232
MIPS_BIN=$(cat $MIPS_ARTIFACT | jq -r '.bytecode.object')
33-
PREIMAGE_DEPLOYED_BIN=$(cat $PREIMAGE_ARTIFACT | jq -r '.deployedBytecode.object')
33+
PREIMAGE_BIN=$(cat $PREIMAGE_ARTIFACT | jq -r '.bytecode.object')
3434

3535
echo "Removing old bindings..."
3636
rm $DIR/*.bin
3737
echo "Old bindings removed."
3838

3939
echo -n "${MIPS_BIN:2}" > $DIR/mips_creation.bin
40-
echo -n "${PREIMAGE_DEPLOYED_BIN:2}" >> $DIR/preimage_oracle_deployed.bin
40+
echo -n "${PREIMAGE_BIN:2}" >> $DIR/preimage_creation.bin
4141

4242
echo "Bindings generated successfully."

Diff for: crates/fpvm/bindings/mips_creation.bin

+1-1
Large diffs are not rendered by default.

Diff for: crates/fpvm/bindings/preimage_creation.bin

+1
Large diffs are not rendered by default.

Diff for: crates/fpvm/bindings/preimage_oracle_deployed.bin

-1
This file was deleted.

Diff for: crates/fpvm/open_mips_tests/test/bin/oracle.bin

-16 Bytes
Binary file not shown.

Diff for: crates/fpvm/open_mips_tests/test/oracle.asm

-4
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ $readloop:
6969
addiu $t0, $t0, -1
7070
bnez $t0, $readloop
7171
nop
72-
# reading the pre-image stream at EOF should have no effect
73-
li $a1, 0x31000008
74-
li $v0, 4003
75-
syscall
7672

7773
# length at 0x31000000. We also check that the lower 32 bits are zero
7874
lui $s1, 0x3100

Diff for: crates/fpvm/src/patch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn load_elf(raw: &[u8]) -> Result<State> {
3737
let mut state = State {
3838
pc: elf.ehdr.e_entry as u32,
3939
next_pc: elf.ehdr.e_entry as u32 + 4,
40-
heap: 0x20000000,
40+
heap: 0x05000000,
4141
..Default::default()
4242
};
4343

Diff for: crates/fpvm/src/test_utils/evm.rs

+22-39
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub const PREIMAGE_ORACLE_ADDR: [u8; 20] = hex!("0000000000000000000000000000000
2121
pub const MIPS_CREATION_CODE: &str = include_str!("../../bindings/mips_creation.bin");
2222
/// The deployed EVM bytecode of the PreimageOracle contract.
2323
pub const PREIMAGE_ORACLE_DEPLOYED_CODE: &str =
24-
include_str!("../../bindings/preimage_oracle_deployed.bin");
24+
include_str!("../../bindings/preimage_creation.bin");
2525

2626
/// A wrapper around a [revm] interpreter with an in-memory backend that has the MIPS & PreimageOracle
2727
/// smart contracts deployed at deterministic addresses. This is used for differential testing the
@@ -62,10 +62,27 @@ impl<'a> MipsEVM<'a, CacheDB<EmptyDB>> {
6262
);
6363

6464
// Deploy the PreimageOracle contract.
65-
self.deploy_contract(
66-
Address::from_slice(PREIMAGE_ORACLE_ADDR.as_slice()),
67-
Bytes::from(hex::decode(PREIMAGE_ORACLE_DEPLOYED_CODE)?),
68-
)?;
65+
let preimage_creation_heap = hex::decode(PREIMAGE_ORACLE_DEPLOYED_CODE)?
66+
.into_iter()
67+
.chain([0u8; 64])
68+
.collect::<Vec<_>>();
69+
self.fill_tx_env(TransactTo::Create, preimage_creation_heap.into());
70+
if let Ok(ResultAndState {
71+
result:
72+
revm::primitives::ExecutionResult::Success {
73+
reason: _,
74+
gas_used: _,
75+
gas_refunded: _,
76+
logs: _,
77+
output: Output::Create(code, _),
78+
},
79+
state: _,
80+
}) = self.inner.transact()
81+
{
82+
self.deploy_contract(Address::from_slice(PREIMAGE_ORACLE_ADDR.as_slice()), code)?;
83+
} else {
84+
anyhow::bail!("Failed to deploy PreimageOracle contract");
85+
};
6986

7087
// Deploy the MIPS contract prior to deploying it manually. This contract has an immutable
7188
// variable, so we let the creation code fill this in for us, and then deploy it to the
@@ -229,40 +246,6 @@ mod test {
229246
path::PathBuf,
230247
};
231248

232-
#[test]
233-
fn sanity_evm_execution() {
234-
const SAMPLE: [u8; 2180] = hex!("f8e0cb960000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000e22306a30adb7e99858491484b0d6627fe00efea43ec78488033a797a499e22ad6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007000e000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5b4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d3021ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba85e58769b32a1beaf1ea27375a44095a0d1fb664ce2dd358e7fcbfb78c26a193440eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968ffd70157e48063fc33c97a050f7f640233bf646cc98d9524c6b92bcf3ab56f839867cc5f7f196b93bae1e27e6320742445d290f2263827498b54fec539f756afcefad4e508c098b9a7e1d8feb19955fb02ba9675585078710969d3440f5054e0f9dc3e7fe016e050eff260334f18a5d4fe391d82092319f5964f2e2eb7c1c3a5f8b13a49e282f609c317a833fb8d976d11517c571d1221a265d25af778ecf8923490c6ceeb450aecdc82e28293031d10c7d73bf85e57bf041a97360aa2c5d99cc1df82d9c4b87413eae2ef048f94b4d3554cea73d92b0f7af96e0271c691e2bb5c67add7c6caf302256adedf7ab114da0acfe870d449a3a489f781d659e8beccda7bce9f4e8618b6bd2f4132ce798cdc7a60e7e1460a7299e3c6342a579626d22733e50f526ec2fa19a22b31e8ed50f23cd1fdf94c9154ed3a7609a2f1ff981fe1d3b5c807b281e4683cc6d6315cf95b9ade8641defcb32372f1c126e398ef7a5a2dce0a8a7f68bb74560f8f71837c2c2ebbcbf7fffb42ae1896f13f7c7479a0b46a28b6f55540f89444f63de0378e3d121be09e06cc9ded1c20e65876d36aa0c65e9645644786b620e2dd2ad648ddfcbf4a7e5b1a3a4ecfe7f64667a3f0b7e2f4418588ed35a2458cffeb39b93d26f18d2ab13bdce6aee58e7b99359ec2dfd95a9c16dc00d6ef18b7933a6f8dc65ccb55667138776f7dea101070dc8796e3774df84f40ae0c8229d0d6069e5c8f39a7c299677a09d367fc7b05e3bc380ee652cdc72595f74c7b1043d0e1ffbab734648c838dfb0527d971b602bc216c9619ef0abf5ac974a1ed57f4050aa510dd9c74f508277b39d7973bb2dfccc5eeb0618db8cd74046ff337f0a7bf2c8e03e10f642c1886798d71806ab1e888d9e5ee87d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
235-
236-
let mut mips_evm = MipsEVM::new();
237-
mips_evm.try_init().unwrap();
238-
239-
mips_evm.fill_tx_env(
240-
TransactTo::Call(MIPS_ADDR.into()),
241-
Bytes::from(SAMPLE.to_vec()),
242-
);
243-
244-
let ResultAndState { result, state: _ } = mips_evm.inner.transact().unwrap();
245-
246-
assert!(result.is_success());
247-
let ExecutionResult::Success {
248-
reason: _,
249-
gas_used: _,
250-
gas_refunded: _,
251-
logs: _,
252-
output: Output::Call(output),
253-
} = result
254-
else {
255-
panic!("Expected success, got {:?}", result);
256-
};
257-
258-
assert_eq!(
259-
output,
260-
Bytes::from_static(&hex!(
261-
"03720be420feea4ae4f803f0f630004f8bd2b0256171dd26043e48bf524da332"
262-
))
263-
);
264-
}
265-
266249
#[test]
267250
fn evm() {
268251
let mut mips_evm = MipsEVM::new();

Diff for: crates/fpvm/src/witness.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ impl Default for StepWitness {
5050

5151
sol! {
5252
/// `PreimageOracle` loadLocalData function.
53-
function loadLocalData(uint256,bytes32,uint256,uint256) external returns (bytes32);
53+
function loadLocalData(uint256,bytes32,bytes32,uint256,uint256) external returns (bytes32);
5454

5555
/// `PreimageOracle` loadKeccak256PreimagePart function.
5656
function loadKeccak256PreimagePart(uint256,bytes) external;
5757

5858
/// `MIPS` step function.
59-
function step(bytes,bytes) external returns (bytes32);
59+
function step(bytes,bytes,bytes32) external returns (bytes32);
6060
}
6161

6262
impl StepWitness {
@@ -92,9 +92,10 @@ impl StepWitness {
9292

9393
let call = loadLocalDataCall {
9494
_0: B256::from(preimage_key).into(),
95-
_1: B256::from(tmp),
96-
_2: U256::from(preimage_value.len() - 8),
97-
_3: U256::from(self.preimage_offset?),
95+
_1: B256::ZERO, // constant local context
96+
_2: B256::from(tmp),
97+
_3: U256::from(preimage_value.len() - 8),
98+
_4: U256::from(self.preimage_offset?),
9899
};
99100

100101
Some(call.abi_encode().into())
@@ -118,6 +119,7 @@ impl StepWitness {
118119
let call = stepCall {
119120
_0: self.state.to_vec().into(),
120121
_1: self.mem_proof.to_vec().into(),
122+
_2: B256::ZERO // constant local context
121123
};
122124

123125
call.abi_encode().into()

0 commit comments

Comments
 (0)