Skip to content

Commit

Permalink
fix(vars): clean up old vars utils, and clarify comments
Browse files Browse the repository at this point in the history
  • Loading branch information
atticusofsparta committed Jan 13, 2025
1 parent b35bafd commit 091b4fc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 43 deletions.
6 changes: 3 additions & 3 deletions ao-build-config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ao-dev-cli options
stack_size: 65536 # 64kb
initial_memory: 1048576 # 1mb stack size is included in initial memory, along with heap
maximum_memory: 1073741824 # 1gb
stack_size: 65536 # 64KiB
initial_memory: 1048576 # 1MiB stack size is included in initial memory, along with heap
maximum_memory: 1073741824 # 1GiB
target: 32 # wasm32 or wasm 64
# extra info
aos_git_hash: '15dd81ee596518e2f44521e973b8ad1ce3ee9945' # used to pull in the 'process' folder at a specific git hash
Expand Down
20 changes: 0 additions & 20 deletions test/utils.mjs
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
import AoLoader from '@permaweb/ao-loader';
import {
AOS_WASM,
AO_LOADER_HANDLER_ENV,
AO_LOADER_OPTIONS,
DEFAULT_HANDLE_OPTIONS,
ANT_EVAL_OPTIONS,
AOS_ANT_WASM,
} from '../tools/constants.mjs';

/**
* Loads the aos wasm binary and returns the handle function with program memory
* @returns {Promise<{handle: Function, memory: WebAssembly.Memory}>}
*/
export async function createAosLoader(params) {
const handle = await AoLoader(AOS_WASM, AO_LOADER_OPTIONS);
const evalRes = await handle(
null,
{ ...DEFAULT_HANDLE_OPTIONS, ...params },
AO_LOADER_HANDLER_ENV,
);

return {
handle,
memory: evalRes.Memory,
};
}

export async function createAntAosLoader() {
const handle = await AoLoader(AOS_ANT_WASM, AO_LOADER_OPTIONS);
// just to get the mem buffer originally
Expand Down
20 changes: 2 additions & 18 deletions tools/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,13 @@ export const AO_LOADER_OPTIONS = {
format: 'wasm32-unknown-emscripten-metering',
inputEncoding: 'JSON-1',
outputEncoding: 'JSON-1',
memoryLimit: '1073741824', // in bytes
memoryLimit: '1073741824', // 1 GiB in bytes
computeLimit: (9e12).toString(),
extensions: [],
};

export const AOS_WASM = fs.readFileSync(
path.join(
__dirname,
'fixtures/aos-cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk.wasm',
),
);

export const AOS_ANT_WASM = fs.readFileSync(
path.join(__dirname, '../dist/aos-ant.wasm'),
path.join(__dirname, '../dist/aos-ant.wasm'), // MUST load as binary (note no utf-8 flag)
);

export const BUNDLED_AOS_ANT_LUA = fs.readFileSync(
Expand Down Expand Up @@ -76,12 +69,3 @@ export const DEFAULT_HANDLE_OPTIONS = {
From: STUB_ADDRESS,
Timestamp: Date.now(),
};

export const ANT_EVAL_OPTIONS = {
...DEFAULT_HANDLE_OPTIONS,
Tags: [
{ name: 'Action', value: 'Eval' },
{ name: 'Module', value: ''.padEnd(43, '1') },
],
Data: BUNDLED_AOS_ANT_LUA,
};
4 changes: 2 additions & 2 deletions tools/load-aos.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AoLoader } from '@permaweb/ao-loader';
import { AOS_ANT_WASM } from './constants.mjs';

const {
BUNDLED_AOS_ANT_LUA,
DEFAULT_ANT_STATE,
AOS_WASM,
AO_LOADER_OPTIONS,
AO_LOADER_HANDLER_ENV,
DEFAULT_HANDLE_OPTIONS,
Expand All @@ -18,7 +18,7 @@ async function main() {
['Transfer', { Recipient: 'iKryOeZQMONi2965nKz528htMMN_sBcjlhc-VncoRjA' }],
];

const handle = await AoLoader(AOS_WASM, AO_LOADER_OPTIONS);
const handle = await AoLoader(AOS_ANT_WASM, AO_LOADER_OPTIONS);
// memory dump of the evaluated program
let programState = undefined;

Expand Down

0 comments on commit 091b4fc

Please sign in to comment.