Skip to content

Commit

Permalink
Add High Gas Contract
Browse files Browse the repository at this point in the history
  • Loading branch information
joelsmith-2019 committed Dec 5, 2023
1 parent 4e6ded1 commit 070c102
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c840df15067463fafaf2dd62705123b504a75d95742abac7b82a0952cf3bbcda clock_example.wasm
ff68899d7ba95c9865a4bbdbfe4654f7fceae703375ec451ebc46dd95b0861f3 clock_example.wasm
1 change: 0 additions & 1 deletion artifacts/checksums_intermediate.txt

This file was deleted.

Binary file modified artifacts/clock_example.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ optimize:
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
--platform linux/arm64 \
cosmwasm/rust-optimizer-arm64:0.12.12; else \
cosmwasm/rust-optimizer-arm64:0.15.0; else \
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
--platform linux/amd64 \
cosmwasm/rust-optimizer:0.12.12; fi
cosmwasm/rust-optimizer:0.15.0; fi
18 changes: 17 additions & 1 deletion src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ pub fn instantiate(
fn increment(deps: DepsMut) -> Result<(), ContractError> {
let mut config = CONFIG.load(deps.storage)?;
config.val += 1;
CONFIG.save(deps.storage, &config)?;

// Save 1 million times to test gas usage
for _ in 0..1_000 {
CONFIG.save(deps.storage, &config)?;
}

Ok(())
}

Expand All @@ -46,6 +51,17 @@ pub fn execute(
}
}

// sudo msg
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn sudo(deps: DepsMut, _env: Env, msg: SudoMsg) -> Result<Response, ContractError> {
match msg {
SudoMsg::ClockEndBlock {} => {
increment(deps)?;
Ok(Response::new())
}
}
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
Expand Down

0 comments on commit 070c102

Please # to comment.