Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Document error for non-existing code hash
Browse files Browse the repository at this point in the history
  • Loading branch information
yarikbratashchuk committed Jan 19, 2022
1 parent 0a8b745 commit 49250c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions frame/contracts/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,13 +1029,13 @@ where
fn set_code_hash(&mut self, hash: CodeHash<Self::T>) -> Result<(), DispatchError> {
let top_frame = &mut self.top_frame_mut();
let prev_hash = top_frame.contract_info().code_hash.clone();
top_frame.contract_info().code_hash = hash;
if !Self::code_exists(&hash) {
return Err(DispatchError::CannotLookup)
}
top_frame.contract_info().code_hash = hash;
<ContractInfoOf<T>>::insert(top_frame.account_id.clone(), top_frame.contract_info());
increment_refcount::<Self::T>(hash);
decrement_refcount::<Self::T>(prev_hash);
increment_refcount::<Self::T>(hash)?;
decrement_refcount::<Self::T>(prev_hash)?;
Ok(())
}

Expand Down
1 change: 1 addition & 0 deletions frame/contracts/src/wasm/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ define_env!(Env, <E: Ext>,
//
// - requested buffer is not within the bounds of the sandbox memory.
// - the buffer contents cannot be decoded as the required type.
// - code for specified hash does not exist
[__unstable__] seal_set_code_hash(ctx, code_hash_ptr: u32) -> ReturnCode => {
ctx.charge_gas(RuntimeCosts::SetCodeHash)?;
let code_hash: CodeHash<<E as Ext>::T> = ctx.read_sandbox_memory_as(code_hash_ptr)?;
Expand Down

0 comments on commit 49250c5

Please sign in to comment.