Skip to content

Commit

Permalink
refactor: use checked bytecode
Browse files Browse the repository at this point in the history
  • Loading branch information
onbjerg committed Aug 1, 2022
1 parent 2c4cffc commit 3526179
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion anvil/src/eth/backend/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub trait Db: DatabaseRef + Database + DatabaseCommit + Send + Sync {
H256::from_slice(&keccak256(code.as_ref())[..])
};
info.code_hash = code_hash;
info.code = Some(Bytecode::new_raw(code.0));
info.code = Some(Bytecode::new_raw(code.0).to_checked());
self.insert_account(address, info);
}

Expand Down
2 changes: 1 addition & 1 deletion anvil/src/eth/backend/mem/in_memory_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Db for MemDb {
code: if account.code.0.is_empty() {
None
} else {
Some(Bytecode::new_raw(account.code.0))
Some(Bytecode::new_raw(account.code.0).to_checked())
},
// use max nonce in case account is imported multiple times with difference
// nonces to prevent collisions
Expand Down
2 changes: 1 addition & 1 deletion evm/src/executor/fork/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ where
let acc = AccountInfo {
nonce: nonce.as_u64(),
balance,
code: code.map(|bytes| Bytecode::new_raw(bytes)),
code: code.map(|bytes| Bytecode::new_raw(bytes).to_checked()),
code_hash,
};
pin.db.accounts().write().insert(addr, acc.clone());
Expand Down
2 changes: 1 addition & 1 deletion evm/src/executor/inspector/cheatcodes/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub fn apply<DB: Database>(

// TODO: Does this increase gas usage?
data.subroutine.load_account(inner.0, data.db);
data.subroutine.set_code(inner.0, Bytecode::new_raw(code.0), hash);
data.subroutine.set_code(inner.0, Bytecode::new_raw(code.0).to_checked(), hash);
Ok(Bytes::new())
}
HEVMCalls::Deal(inner) => {
Expand Down
2 changes: 1 addition & 1 deletion evm/src/executor/inspector/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ where
if let Some(context) = self.context.last() {
self.ic_map.insert(
*context,
build_ic_map(data.env.cfg.spec_id, &interp.contract().bytecode.bytecode()),
build_ic_map(data.env.cfg.spec_id, interp.contract().bytecode.bytecode()),
);
}
Return::Continue
Expand Down
2 changes: 1 addition & 1 deletion evm/src/executor/inspector/debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ where
// code given by the interpreter may either be the contract init code, or the runtime code.
self.ic_map.insert(
self.context,
build_ic_map(data.env.cfg.spec_id, &interp.contract().bytecode.bytecode()),
build_ic_map(data.env.cfg.spec_id, interp.contract().bytecode.bytecode()),
);
self.previous_gas_block = interp.contract.first_gas_block();
Return::Continue
Expand Down

0 comments on commit 3526179

Please sign in to comment.