Skip to content

Instantly share code, notes, and snippets.

View webmaster128's full-sized avatar

Simon Warta webmaster128

View GitHub Profile
diff --git a/packages/vm/src/wasm_backend/engine.rs b/packages/vm/src/wasm_backend/engine.rs
index 7b2f6190a9..a6bdb62e09 100644
--- a/packages/vm/src/wasm_backend/engine.rs
+++ b/packages/vm/src/wasm_backend/engine.rs
@@ -16,14 +16,27 @@ use super::limiting_tunables::LimitingTunables;
/// https://github.com/WebAssembly/memory64/blob/master/proposals/memory64/Overview.md
const MAX_WASM_PAGES: u32 = 65536;
-fn cost(_operator: &Operator) -> u64 {
+fn cost(operator: &Operator) -> u64 {
@webmaster128
webmaster128 / length_prefixed_v2.md
Last active November 5, 2023 21:35
Reducing size of CosmWasm storage key encoding

Length prefixes key namespacing, version 2

In https://github.com/CosmWasm/cosmwasm/blob/main/docs/STORAGE_KEYS.md you can see the standard storage key encoding used in CosmWasm from 2020-2023. In the meantime we figured out that using short keys is important for the performance of the underlying database. How much it affects performance, I don't know. But the more I learn about how those databases and their caching works, the more I'm convinced this is the right direction.

CosmWasm developers love performance. It allows them to build things that are hard or impossible to build in other systems. We want to make it easy for our developers to reach peak performance.

@webmaster128
webmaster128 / coins_iteration.rs
Last active September 5, 2023 07:14
Example for iterating Coins
#[test]
fn can_loop_through_coins() -> StdResult<()> {
let mut coins = Coins::default();
coins.add(Coin::new(123, "uwasm"))?;
coins.add(Coin::new(7, "uwasm"))?;
coins.add(Coin::new(65, "uatom"))?;
for borrowed_coin in coins.iter() {
println!("Element: {borrowed_coin}");
}
@webmaster128
webmaster128 / pubkey.json
Created June 27, 2023 20:05
Drand bls-unchained-g1-rfc9380 tests for domain fix by Yolan (Protocol Labs). See https://github.com/drand/drand/pull/1249
{"public_key": "a1ee12542360bf75742bcade13d6134e7d5283d9eb782887c47d3d9725f05805d37b0106b7f744395bf82c175dd7434a169e998f188a657a030d588892c0cd2c01f996aaf331c4d8bc5b9734bbe261d09e7d2d39ef88b635077f262bd7bbb30f"}
@webmaster128
webmaster128 / doc.json
Last active June 26, 2023 13:59
New JSON u128/i128 seralization
{
"amount": -170141183460469231731687303715884105728
}
diff --git a/packages/std/src/memory.rs b/packages/std/src/memory.rs
index c331a53c..09462d25 100644
--- a/packages/std/src/memory.rs
+++ b/packages/std/src/memory.rs
@@ -15,9 +15,21 @@ pub struct Region {
pub length: u32,
}
+
+extern "C" {
@webmaster128
webmaster128 / stores.diff
Created May 4, 2023 11:36
Use new runtime stores in Wasmer 3 examples
diff --git a/examples/compiler_singlepass.rs b/examples/compiler_singlepass.rs
index 01fb181b12..5d6d90152f 100644
--- a/examples/compiler_singlepass.rs
+++ b/examples/compiler_singlepass.rs
@@ -41,6 +41,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create an empty import object.
let import_object = imports! {};
+ // Create a new store for this instance
+ let compiler = Singlepass::default();
@webmaster128
webmaster128 / nois_example_addresses.md
Created February 7, 2023 19:20
Nois example addresses for testing

This file contains 100 Nois addresses and public keys randomly generated using a CosmJS script. The private key is not persisted.

  1. nois1ffy2rz96sjxzm2ezwkmvyeupktp7elt6w3xckt (secp256k1 A13gZDsrmBTAFxcwtTTpBiYR7S0iD2o73r4FGmHnVQ1n)
  2. nois1uw8c69maprjq5ure7x80x9nauasrn7why5dfwd (secp256k1 A2SpNQkf6qCAq7/xjm5gGVLrn2VU4Z9VPWiSXdrykmYx)
  3. nois1zh77twxfc47eu59q7mc7027jvvcnrpte3sr922 (secp256k1 AxhQFLFRR0Dd7NH2DaEc58FuwNfufsJ3bzK6W2R70kwH)
  4. nois1wpy3gwlw4tt3uy0u5jrspfz0w9azztvlr0d04s (secp256k1 A7TAYBnzPnww1W2EbfDsA3Wk5DWhZnIrq6HQztX2Q8RA)
  5. nois1rw47dxvhw3ahdlcznvwpcz43cdq8l0832eg6re (secp256k1 As3jzZ22pKFx59VXh7zk9OkQJHgQIugJvPg7wNsGb4qU)
  6. nois12a8yv4ndgnkygujj7cmmkfz2j9wjanezldwye0 (secp256k1 A4KD4pHEXEFv6XB+Sbe0+bccx7uGRNwtnuBTC/hC/kil)
  7. nois1vupa7ftemarqqmq0c7a60f2je4adt3h6r39hzf (secp256k1 A2nsC3rcN1u7RCUXX8oJMO4ULGepu1Wo99GQKYqMUsXU)
@webmaster128
webmaster128 / build_wasm.sh
Created December 7, 2022 10:38
Optimized CosmWasm builds THAT ARE NOT REPRODUCIBLE since they use whatever toolchain you have installed locally
#!/bin/bash
set -o errexit -o nounset -o pipefail
command -v shellcheck >/dev/null && shellcheck "$0"
# This script lives in a ./devtools sub directory.
# Navigate to the repo root first.
SCRIPT_DIR="$(realpath "$(dirname "$0")")"
cd "${SCRIPT_DIR}/.."
# compile all contracts
{
"jsonrpc": "2.0",
"id": -1,
"result": {
"hash": "F64B8C6A320A9C25FD1EA60B00194817B069C9CBEF19B736117D9339F33F2E51",
"height": "389794",
"index": 1,
"tx_result": {
"code": 0,
"data": "CiYKJC9jb3Ntd2FzbS53YXNtLnYxLk1zZ0V4ZWN1dGVDb250cmFjdA==",