Skip to content

Commit

Permalink
Rename contract to HACKATOM
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Feb 5, 2024
1 parent 24bd400 commit 1478603
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions packages/vm/benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const INSTANTIATION_THREADS: usize = 128;
const CONTRACTS: u64 = 10;

const DEFAULT_CAPABILITIES: &str = "cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3,iterator,staking";
static CONTRACT: &[u8] = include_bytes!("../testdata/hackatom.wasm");
static HACKATOM: &[u8] = include_bytes!("../testdata/hackatom.wasm");
static CYBERPUNK: &[u8] = include_bytes!("../testdata/cyberpunk.wasm");

fn bench_instance(c: &mut Criterion) {
Expand All @@ -42,7 +42,7 @@ fn bench_instance(c: &mut Criterion) {
let backend = mock_backend(&[]);
let (instance_options, memory_limit) = mock_instance_options();
let _instance =
Instance::from_code(CONTRACT, backend, instance_options, memory_limit).unwrap();
Instance::from_code(HACKATOM, backend, instance_options, memory_limit).unwrap();
});
});

Expand All @@ -52,7 +52,7 @@ fn bench_instance(c: &mut Criterion) {
gas_limit: HIGH_GAS_LIMIT,
};
let mut instance =
Instance::from_code(CONTRACT, backend, much_gas, Some(DEFAULT_MEMORY_LIMIT)).unwrap();
Instance::from_code(HACKATOM, backend, much_gas, Some(DEFAULT_MEMORY_LIMIT)).unwrap();

b.iter(|| {
let info = mock_info(&instance.api().addr_make("creator"), &coins(1000, "earth"));
Expand All @@ -76,7 +76,7 @@ fn bench_instance(c: &mut Criterion) {
gas_limit: HIGH_GAS_LIMIT,
};
let mut instance =
Instance::from_code(CONTRACT, backend, much_gas, Some(DEFAULT_MEMORY_LIMIT)).unwrap();
Instance::from_code(HACKATOM, backend, much_gas, Some(DEFAULT_MEMORY_LIMIT)).unwrap();

let info = mock_info(&instance.api().addr_make("creator"), &coins(1000, "earth"));
let verifier = instance.api().addr_make("verifies");
Expand Down Expand Up @@ -140,15 +140,15 @@ fn bench_cache(c: &mut Criterion) {
unsafe { Cache::new(options.clone()).unwrap() };

b.iter(|| {
let result = cache.save_wasm(CONTRACT);
let result = cache.save_wasm(HACKATOM);
assert!(result.is_ok());
});
});

group.bench_function("load wasm", |b| {
let cache: Cache<MockApi, MockStorage, MockQuerier> =
unsafe { Cache::new(options.clone()).unwrap() };
let checksum = cache.save_wasm(CONTRACT).unwrap();
let checksum = cache.save_wasm(HACKATOM).unwrap();

b.iter(|| {
let result = cache.load_wasm(&checksum);
Expand All @@ -161,7 +161,7 @@ fn bench_cache(c: &mut Criterion) {
let mut cache: Cache<MockApi, MockStorage, MockQuerier> =
unsafe { Cache::new(options).unwrap() };
cache.set_module_unchecked(true);
let checksum = cache.save_wasm(CONTRACT).unwrap();
let checksum = cache.save_wasm(HACKATOM).unwrap();

b.iter(|| {
let result = cache.load_wasm(&checksum);
Expand All @@ -172,7 +172,7 @@ fn bench_cache(c: &mut Criterion) {
group.bench_function("analyze", |b| {
let cache: Cache<MockApi, MockStorage, MockQuerier> =
unsafe { Cache::new(options.clone()).unwrap() };
let checksum = cache.save_wasm(CONTRACT).unwrap();
let checksum = cache.save_wasm(HACKATOM).unwrap();

b.iter(|| {
let result = cache.analyze(&checksum);
Expand All @@ -189,7 +189,7 @@ fn bench_cache(c: &mut Criterion) {
);
let cache: Cache<MockApi, MockStorage, MockQuerier> =
unsafe { Cache::new(non_memcache).unwrap() };
let checksum = cache.save_wasm(CONTRACT).unwrap();
let checksum = cache.save_wasm(HACKATOM).unwrap();

b.iter(|| {
let _ = cache
Expand All @@ -212,7 +212,7 @@ fn bench_cache(c: &mut Criterion) {
let mut cache: Cache<MockApi, MockStorage, MockQuerier> =
unsafe { Cache::new(non_memcache).unwrap() };
cache.set_module_unchecked(true);
let checksum = cache.save_wasm(CONTRACT).unwrap();
let checksum = cache.save_wasm(HACKATOM).unwrap();

b.iter(|| {
let _ = cache
Expand All @@ -226,7 +226,7 @@ fn bench_cache(c: &mut Criterion) {
});

group.bench_function("instantiate from memory", |b| {
let checksum = Checksum::generate(CONTRACT);
let checksum = Checksum::generate(HACKATOM);
let cache: Cache<MockApi, MockStorage, MockQuerier> =
unsafe { Cache::new(options.clone()).unwrap() };
// Load into memory
Expand All @@ -247,7 +247,7 @@ fn bench_cache(c: &mut Criterion) {
});

group.bench_function("instantiate from pinned memory", |b| {
let checksum = Checksum::generate(CONTRACT);
let checksum = Checksum::generate(HACKATOM);
let cache: Cache<MockApi, MockStorage, MockQuerier> =
unsafe { Cache::new(options.clone()).unwrap() };
// Load into pinned memory
Expand Down Expand Up @@ -291,10 +291,10 @@ fn bench_instance_threads(c: &mut Criterion) {
// Offset to the i32.const (0x41) 15731626 (0xf00baa) (unsigned leb128 encoded) instruction
// data we want to replace
let query_int_data = b"\x41\xaa\x97\xc0\x07";
let offset = find_subsequence(CONTRACT, query_int_data).unwrap() + 1;
let offset = find_subsequence(HACKATOM, query_int_data).unwrap() + 1;

let mut leb128_buf = [0; 4];
let mut contract = CONTRACT.to_vec();
let mut contract = HACKATOM.to_vec();

let mut random_checksum = || {
let mut writable = &mut leb128_buf[..];
Expand Down

0 comments on commit 1478603

Please sign in to comment.