mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-05 07:13:08 +00:00
Implement codesize/codecopy for interpreter
This commit is contained in:
parent
0f3285c33b
commit
6946eacaca
@ -340,8 +340,8 @@ impl<'a> Interpreter<'a> {
|
||||
0x35 => self.run_calldataload(), // "CALLDATALOAD",
|
||||
0x36 => self.run_calldatasize(), // "CALLDATASIZE",
|
||||
0x37 => self.run_calldatacopy(), // "CALLDATACOPY",
|
||||
0x38 => todo!(), // "CODESIZE",
|
||||
0x39 => todo!(), // "CODECOPY",
|
||||
0x38 => self.run_codesize(), // "CODESIZE",
|
||||
0x39 => self.run_codecopy(), // "CODECOPY",
|
||||
0x3a => self.run_gasprice(), // "GASPRICE",
|
||||
0x3b => todo!(), // "EXTCODESIZE",
|
||||
0x3c => todo!(), // "EXTCODECOPY",
|
||||
@ -804,6 +804,32 @@ impl<'a> Interpreter<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn run_codesize(&mut self) {
|
||||
self.push(
|
||||
self.generation_state.memory.contexts[self.context].segments
|
||||
[Segment::ContextMetadata as usize]
|
||||
.get(ContextMetadata::CodeSize as usize),
|
||||
)
|
||||
}
|
||||
|
||||
fn run_codecopy(&mut self) {
|
||||
let dest_offset = self.pop().as_usize();
|
||||
let offset = self.pop().as_usize();
|
||||
let size = self.pop().as_usize();
|
||||
for i in 0..size {
|
||||
let code_byte =
|
||||
self.generation_state
|
||||
.memory
|
||||
.mload_general(self.context, Segment::Code, offset + i);
|
||||
self.generation_state.memory.mstore_general(
|
||||
self.context,
|
||||
Segment::MainMemory,
|
||||
dest_offset + i,
|
||||
code_byte,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn run_gasprice(&mut self) {
|
||||
self.push(self.get_txn_field(NormalizedTxnField::ComputedFeePerGas))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user