From 3e037bc7ac9ce5512b315ac4472f359c15894f00 Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Sat, 17 Aug 2024 13:09:12 +0000 Subject: [PATCH 01/14] chore: bump aos to 2.0 --- README.md | 4 +++- package.json | 9 +++++---- process/package.json | 5 +++-- process/process.lua | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 60821cee..69c90278 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,12 @@ Status: Preview rc2 Version: 2.0.0-rc2 -Module: `PSPMkkFrJzYI2bQbkmeEQ5ONmeR-FJZu0fNQoSCU1-I` +Module: `ffvkmPM1jW71hFlBpVbaIapBa_Wl6UIwfdTkDNqsKNw` Sqlite-Module: `C4bxMlK8d_wQ-QpXIIZLU8UWXu6Sd8PDJw7HN3nNE2I` +Llama-Module: `Eb_Ol0yQsmAaM_KUzbTKbrwJ0Pi3zAq2s9WEegqhr6I` + ## Requirements diff --git a/package.json b/package.json index 46231b30..1322417c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "type": "module", "name": "@permaweb/aos", - "version": "2.0.0-rc2", + "version": "2.0.0", "main": "src/index.js", "bin": "./bin/aos.js", "repository": "https://github.com/permaweb/aos.git", @@ -29,9 +29,10 @@ "yargs": "^17.7.2" }, "aos": { - "module": "PSPMkkFrJzYI2bQbkmeEQ5ONmeR-FJZu0fNQoSCU1-I", - "sqlite": "C4bxMlK8d_wQ-QpXIIZLU8UWXu6Sd8PDJw7HN3nNE2I", - "version": "2.0.0.rc2" + "module": "ffvkmPM1jW71hFlBpVbaIapBa_Wl6UIwfdTkDNqsKNw", + "sqlite": "G991Xp6Kh28k8_AZcnwaqJ6LZcHlsZcMkrH1mJoAy84", + "llama": "Eb_Ol0yQsmAaM_KUzbTKbrwJ0Pi3zAq2s9WEegqhr6I", + "version": "2.0.0" }, "devDependencies": { "esbuild": "^0.20.1" diff --git a/process/package.json b/process/package.json index c4e63bbc..d93a04ed 100644 --- a/process/package.json +++ b/process/package.json @@ -10,7 +10,8 @@ "scripts": { "build": "ao build", "test": "node --test --experimental-wasm-memory64", - "deploy": "ao publish -w ~/.wallet.json process.wasm -t Memory-Limit -v 1-gb -t Compute-Limit -v 9000000000000 -t Module-Format -v wasm64-unknown-emscripten-draft_2024_02_15 -t AOS-Version -v 2.0.0.rc2 -t Name -v AOS", - "deploy-sqlite": "ao publish -w ~/.wallet.json process.wasm -t Memory-Limit -v 1-gb -t Compute-Limit -v 9000000000000 -t Module-Format -v wasm64-unknown-emscripten-draft_2024_02_15 -t AOS-Version -v 2.0.0.rc2 -t Name -v AOS-SQLITE" + "deploy": "ao publish -w ~/.wallet.json process.wasm -t Memory-Limit -v 1-gb -t Compute-Limit -v 9000000000000 -t Module-Format -v wasm64-unknown-emscripten-draft_2024_02_15 -t AOS-Version -v 2.0.0 -t Name -v AOS", + "deploy-sqlite": "ao publish -w ~/.wallet.json process.wasm -t Memory-Limit -v 1-gb -t Compute-Limit -v 9000000000000 -t Module-Format -v wasm64-unknown-emscripten-draft_2024_02_15 -t AOS-Version -v 2.0.0 -t Name -v SQLITE", + "deploy-llama": "ao publish -w ~/.wallet.json process.wasm -t Memory-Limit -v 1-gb -t Compute-Limit -v 9000000000000 -t Module-Format -v wasm64-unknown-emscripten-draft_2024_02_15 -t AOS-Version -v 2.0.0 -t Name -v LLAMA" } } \ No newline at end of file diff --git a/process/process.lua b/process/process.lua index 3a142ae0..22ab2b47 100644 --- a/process/process.lua +++ b/process/process.lua @@ -29,7 +29,7 @@ end -- Implement assignable polyfills on _ao assignment.init(ao) -local process = { _version = "2.0.0.rc2" } +local process = { _version = "2.0.0" } local maxInboxCount = 10000 -- wrap ao.send and ao.spawn for magic table From adbadb06cd13a1716556b970dac58b836fd8cd36 Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Wed, 4 Sep 2024 17:37:14 +0000 Subject: [PATCH 02/14] chore: added better support for print --- process/process.lua | 12 ++++++++++++ src/commands/os.js | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/process/process.lua b/process/process.lua index 22ab2b47..f0ea251a 100644 --- a/process/process.lua +++ b/process/process.lua @@ -106,6 +106,18 @@ function print(a) if type(a) == "table" then a = stringify.format(a) end + --[[ +In order to print non string types we need to convert to string + ]] + if type(a) == "boolean" then + a = Colors.blue .. tostring(a) .. Colors.reset + end + if type(a) == "nil" then + a = Colors.red .. tostring(a) .. Colors.reset + end + if type(a) == "number" then + a = Colors.green .. tostring(a) .. Colors.reset + end local data = a if ao.outbox.Output.data then diff --git a/src/commands/os.js b/src/commands/os.js index ae85192b..2662559a 100644 --- a/src/commands/os.js +++ b/src/commands/os.js @@ -38,6 +38,7 @@ export function update() { .join('\n\n') luaFiles = ` + if not Utils.includes('.crypto.init', Utils.keys(_G.package.loaded)) then -- if crypto.init is not installed then return a noop _G.package.loaded['.crypto.init'] = { _version = "0.0.0", status = "Not Implemented" } @@ -55,6 +56,13 @@ end luaFiles = luaFiles + '\n' + luaFiles = luaFiles + ` +-- set ao alias if ao does not exist +if not _G.package.loaded['ao'] then + _G.package.loaded['ao'] = _G.package.loaded['.ao'] +end + \n` + return luaFiles } From 40d2d67c3e1a7abbd1b359d11c2c3842cad45f6f Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Wed, 4 Sep 2024 19:08:17 +0000 Subject: [PATCH 03/14] feat: added dryrun toggle to push aos console in dryrun mode --- blueprints/staking.lua | 24 +++++-- blueprints/token.lua | 141 ++++++++++++++++++++++++++++------------ process/process.lua | 2 +- src/dry-eval.js | 39 +++++++++++ src/index.js | 33 ++++++++-- src/services/connect.js | 11 ++++ src/services/errors.js | 3 +- src/services/help.js | 1 + 8 files changed, 199 insertions(+), 55 deletions(-) create mode 100644 src/dry-eval.js diff --git a/blueprints/staking.lua b/blueprints/staking.lua index ec42c4ce..cefddb09 100644 --- a/blueprints/staking.lua +++ b/blueprints/staking.lua @@ -29,7 +29,11 @@ Handlers.stake = function(msg) Stakers[msg.From].amount = utils.add(Stakers[msg.From].amount, msg.Tags.Quantity) Stakers[msg.From].unstake_at = height + delay print("Successfully Staked " .. msg.Tags.Quantity) - msg.reply({ Data = "Successfully Staked " .. msg.Tags.Quantity}) + if msg.reply then + msg.reply({ Data = "Successfully Staked " .. msg.Tags.Quantity}) + else + Send({Target = msg.From, Data = "Successfully Staked " .. msg.Tags.Quantity }) + end end -- Unstake Action Handler @@ -38,10 +42,14 @@ Handlers.unstake = function(msg) assert(stakerInfo and bint(stakerInfo.amount) >= bint(msg.Tags.Quantity), "Insufficient staked amount") stakerInfo.amount = utils.subtract(stakerInfo.amount, msg.Tags.Quantity) Unstaking[msg.From] = { - amount = msg.Quantity, + amount = msg.Tags.Quantity, release_at = stakerInfo.unstake_at } - msg.reply({ Data = "Successfully unstaked " .. msg.Tags.Quantity}) + if msg.reply then + msg.reply({ Data = "Successfully unstaked " .. msg.Tags.Quantity}) + else + Send({Target = msg.From, Data = "Successfully unstaked " .. msg.Tags.Quantity }) + end end -- Finalization Handler @@ -68,8 +76,14 @@ local function continue(fn) end end -Handlers.add('staking.balances', 'Stakers', - function(msg) msg.reply({ Data = require('json').encode(Stakers) }) end) +Handlers.add('staking.balances', Handlers.utils.hasMatchingTag("Action", 'Stakers'), + function(msg) + if msg.reply then + msg.reply({ Data = require('json').encode(Stakers) }) + else + Send({Target = msg.From, Data = require('json').encode(Stakers) }) + end + end) -- Registering Handlers Handlers.add("staking.stake", continue(Handlers.utils.hasMatchingTag("Action", "Stake")), Handlers.stake) diff --git a/blueprints/token.lua b/blueprints/token.lua index ce3cda1b..ba665781 100644 --- a/blueprints/token.lua +++ b/blueprints/token.lua @@ -71,7 +71,7 @@ Logo = Logo or 'SBCCXwwecBlDqRLUjb8dYABExTJXLieawf7m2aBJ-KY' Info ]] -- -Handlers.add('info', "Info", function(msg) +Handlers.add('info', Handlers.utils.hasMatchingTag("Action", "Info"), function(msg) msg.reply({ Name = Name, Ticker = Ticker, @@ -84,7 +84,7 @@ end) Balance ]] -- -Handlers.add('balance', "Balance", function(msg) +Handlers.add('balance', Handlers.utils.hasMatchingTag("Action", "Balance"), function(msg) local bal = '0' -- If not Recipient is provided, then return the Senders balance @@ -97,27 +97,42 @@ Handlers.add('balance', "Balance", function(msg) elseif Balances[msg.From] then bal = Balances[msg.From] end - - msg.reply({ - Balance = bal, - Ticker = Ticker, - Account = msg.Tags.Recipient or msg.From, - Data = bal - }) + if msg.reply then + msg.reply({ + Balance = bal, + Ticker = Ticker, + Account = msg.Tags.Recipient or msg.From, + Data = bal + }) + else + Send({ + Target = msg.From, + Balance = bal, + Ticker = Ticker, + Account = msg.Tags.Recipient or msg.From, + Data = bal + }) + end end) --[[ Balances ]] -- -Handlers.add('balances', "Balances", - function(msg) msg.reply({ Data = json.encode(Balances) }) end) +Handlers.add('balances', Handlers.utils.hasMatchingTag("Action", "Balances"), + function(msg) + if msg.reply then + msg.reply({ Data = json.encode(Balances) }) + else + Send({Target = msg.From, Data = json.encode(Balances) }) + end + end) --[[ Transfer ]] -- -Handlers.add('transfer', "Transfer", function(msg) +Handlers.add('transfer', Handlers.utils.hasMatchingTag("Action", "Transfer"), function(msg) assert(type(msg.Recipient) == 'string', 'Recipient is required!') assert(type(msg.Quantity) == 'string', 'Quantity is required!') assert(bint.__lt(0, bint(msg.Quantity)), 'Quantity must be greater than 0') @@ -165,15 +180,28 @@ Handlers.add('transfer', "Transfer", function(msg) end -- Send Debit-Notice and Credit-Notice - msg.reply(debitNotice) + if msg.reply then + msg.reply(debitNotice) + else + Send(debitNotice) + end Send(creditNotice) end else - msg.reply({ - Action = 'Transfer-Error', - ['Message-Id'] = msg.Id, - Error = 'Insufficient Balance!' - }) + if msg.reply then + msg.reply({ + Action = 'Transfer-Error', + ['Message-Id'] = msg.Id, + Error = 'Insufficient Balance!' + }) + else + Send({ + Target = msg.From, + Action = 'Transfer-Error', + ['Message-Id'] = msg.Id, + Error = 'Insufficient Balance!' + }) + end end end) @@ -181,7 +209,7 @@ end) Mint ]] -- -Handlers.add('mint', "Mint", function(msg) +Handlers.add('mint', Handlers.utils.hasMatchingTag("Action","Mint"), function(msg) assert(type(msg.Quantity) == 'string', 'Quantity is required!') assert(bint(0) < bint(msg.Quantity), 'Quantity must be greater than zero!') @@ -191,15 +219,31 @@ Handlers.add('mint', "Mint", function(msg) -- Add tokens to the token pool, according to Quantity Balances[msg.From] = utils.add(Balances[msg.From], msg.Quantity) TotalSupply = utils.add(TotalSupply, msg.Quantity) - msg.reply({ - Data = Colors.gray .. "Successfully minted " .. Colors.blue .. msg.Quantity .. Colors.reset - }) + if msg.reply then + msg.reply({ + Data = Colors.gray .. "Successfully minted " .. Colors.blue .. msg.Quantity .. Colors.reset + }) + else + Send({ + Target = msg.From, + Data = Colors.gray .. "Successfully minted " .. Colors.blue .. msg.Quantity .. Colors.reset + }) + end else - msg.reply({ - Action = 'Mint-Error', - ['Message-Id'] = msg.Id, - Error = 'Only the Process Id can mint new ' .. Ticker .. ' tokens!' - }) + if msg.reply then + msg.reply({ + Action = 'Mint-Error', + ['Message-Id'] = msg.Id, + Error = 'Only the Process Id can mint new ' .. Ticker .. ' tokens!' + }) + else + Send({ + Target = msg.From, + Action = 'Mint-Error', + ['Message-Id'] = msg.Id, + Error = 'Only the Process Id can mint new ' .. Ticker .. ' tokens!' + }) + end end end) @@ -207,27 +251,38 @@ end) Total Supply ]] -- -Handlers.add('totalSupply', "Total-Supply", function(msg) +Handlers.add('totalSupply', Handlers.utils.hasMatchingTag("Action","Total-Supply"), function(msg) assert(msg.From ~= ao.id, 'Cannot call Total-Supply from the same process!') - - msg.reply({ - Action = 'Total-Supply', - Data = TotalSupply, - Ticker = Ticker - }) + if msg.reply then + msg.reply({ + Action = 'Total-Supply', + Data = TotalSupply, + Ticker = Ticker + }) + else + Send({ + Target = msg.From, + Action = 'Total-Supply', + Data = TotalSupply, + Ticker = Ticker + }) + end end) --[[ Burn ]] -- -Handlers.add('burn', 'Burn', function(msg) - assert(type(msg.Quantity) == 'string', 'Quantity is required!') - assert(bint(msg.Quantity) <= bint(Balances[msg.From]), 'Quantity must be less than or equal to the current balance!') - - Balances[msg.From] = utils.subtract(Balances[msg.From], msg.Quantity) - TotalSupply = utils.subtract(TotalSupply, msg.Quantity) +Handlers.add('burn', Handlers.utils.hasMatchingTag("Action",'Burn'), function(msg) + assert(type(msg.Tags.Quantity) == 'string', 'Quantity is required!') + assert(bint(msg.Tags.Quantity) <= bint(Balances[msg.From]), 'Quantity must be less than or equal to the current balance!') - msg.reply({ - Data = Colors.gray .. "Successfully burned " .. Colors.blue .. msg.Quantity .. Colors.reset - }) + Balances[msg.From] = utils.subtract(Balances[msg.From], msg.Tags.Quantity) + TotalSupply = utils.subtract(TotalSupply, msg.Tags.Quantity) + if msg.reply then + msg.reply({ + Data = Colors.gray .. "Successfully burned " .. Colors.blue .. msg.Tags.Quantity .. Colors.reset + }) + else + Send({Target = msg.From, Data = Colors.gray .. "Successfully burned " .. Colors.blue .. msg.Tags.Quantity .. Colors.reset }) + end end) diff --git a/process/process.lua b/process/process.lua index d6fdea4d..c6bee51a 100644 --- a/process/process.lua +++ b/process/process.lua @@ -349,7 +349,7 @@ function process.handle(msg, _) if (msg.Action == "Eval") then table.insert(Errors, result) local printData = table.concat(HANDLER_PRINT_LOGS, "\n") - return { Error = printData .. '\n\n' .. result } + return { Error = printData .. '\n\n' .. Colors.red .. 'error:\n' .. Colors.reset .. result } end --table.insert(Errors, result) --ao.outbox.Output.data = "" diff --git a/src/dry-eval.js b/src/dry-eval.js new file mode 100644 index 00000000..7648cb65 --- /dev/null +++ b/src/dry-eval.js @@ -0,0 +1,39 @@ +// like evaluate but it does not save memory +import { of } from 'hyper-async' + +export async function dryEval(line, processId, wallet, services, spinner) { + return of() + .map(_ => { + if (process.env.DEBUG) console.time('Send') + return _ + }) + .chain(() => services.dryrun({ + processId: processId, + wallet: wallet, tags: [ + { name: 'Action', value: 'Eval' } + ], + data: line + }, spinner)) + + // .map(x => { + // //console.log(x) + // if (process.env.DEBUG) { + // console.log("") + // console.timeEnd('Send') + // } + // spinner.suffixText = `${chalk.gray("[Computing")} ${chalk.green(x)}${chalk.gray("...]")}` + // if (process.env.DEBUG) console.time('Read') + // return x + // }) + + + .map(x => { + if (process.env.DEBUG) { + console.log("") + console.timeEnd('Read') + } + return x + }) + .toPromise() + //return { output: 'echo: ' + line, prompt: null } +} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 9373c2b5..8058c411 100644 --- a/src/index.js +++ b/src/index.js @@ -14,12 +14,13 @@ import { of, fromPromise, Rejected, Resolved } from 'hyper-async' // actions import { evaluate } from './evaluate.js' import { register } from './register.js' +import { dryEval } from './dry-eval.js' // services import { getWallet, getWalletFromArgs } from './services/wallets.js' import { address, isAddress } from './services/address.js' import { - spawnProcess, sendMessage, readResult, monitorProcess, unmonitorProcess, live, printLive + spawnProcess, sendMessage, readResult, monitorProcess, unmonitorProcess, live, printLive, dryrun } from './services/connect.js' import { blueprints } from './services/blueprints.js' import { gql } from './services/gql.js' @@ -42,6 +43,7 @@ import { readHistory, writeHistory } from './services/history-service.js' const argv = minimist(process.argv.slice(2)) +let dryRunMode = false let luaData = "" if (!process.stdin.isTTY) { @@ -140,6 +142,7 @@ if (!argv['watch']) { spinner.start(); spinner.suffixText = chalk.gray("[Connecting to process...]") const result = await evaluate(luaData, id, jwk, { sendMessage, readResult }, spinner) + spinner.stop() if (result.Output?.data) { @@ -244,6 +247,19 @@ if (!argv['watch']) { return } + if (!editorMode && line == ".dryrun") { + dryRunMode = !dryRunMode + if (dryRunMode) { + console.log(chalk.green('dryrun mode engaged')) + rl.setPrompt(chalk.red('*') + globalThis.prompt) + } else { + console.log(chalk.red('dryrun mode disengaged')) + rl.setPrompt(globalThis.prompt.replace('*', '')) + } + rl.prompt(true) + return; + } + if (!editorMode && line == ".monitor") { const result = await monitor(jwk, id, { monitorProcess }).catch(err => chalk.gray('⚡️ could not monitor process!')) console.log(chalk.green(result)) @@ -374,8 +390,15 @@ if (!argv['watch']) { // create message and publish to ao - const result = await evaluate(line, id, jwk, { sendMessage, readResult }, spinner) - .catch(err => ({ Output: JSON.stringify({ data: { output: err.message } }) })) + let result = null + if (dryRunMode) { + result = await dryEval(line, id, jwk, { dryrun }, spinner) + .catch(err => ({ Output: JSON.stringify({ data: { output: err.message } }) })) + } else { + result = await evaluate(line, id, jwk, { sendMessage, readResult }, spinner) + .catch(err => ({ Output: JSON.stringify({ data: { output: err.message } }) })) + } + const output = result.Output //JSON.parse(result.Output ? result.Output : '{"data": { "output": "error: could not parse result."}}') // log output // console.log(output) @@ -409,7 +432,7 @@ if (!argv['watch']) { } else { globalThis.prompt = output.prompt ? output.prompt : globalThis.prompt } - rl.setPrompt(globalThis.prompt) + rl.setPrompt((dryRunMode ? chalk.red('*') : '') + globalThis.prompt) } else { if (!output) { console.log(chalk.red('An unknown error occurred.')) @@ -438,7 +461,7 @@ if (!argv['watch']) { } process.exit(0) }) - + //} //repl() diff --git a/src/services/connect.js b/src/services/connect.js index 53a5319e..ed0b2571 100644 --- a/src/services/connect.js +++ b/src/services/connect.js @@ -7,6 +7,9 @@ import fs from 'fs' import path from 'path' import os from 'os' import { uniqBy, prop, keys } from 'ramda' +import Arweave from 'arweave' + +const arweave = Arweave.init({}) const pkg = getPkg() @@ -30,6 +33,14 @@ export function readResult(params) { ) } +export function dryrun({ processId, wallet, tags, data }, spinnner) { + return fromPromise(() => + arweave.wallets.jwkToAddress(wallet).then(Owner => + connect(getInfo()).dryrun({ process: processId, Owner, tags, data }) + ) + )() +} + export function sendMessage({ processId, wallet, tags, data }, spinner) { let retries = "." const signer = createDataItemSigner(wallet) diff --git a/src/services/errors.js b/src/services/errors.js index 6908707c..469a5516 100644 --- a/src/services/errors.js +++ b/src/services/errors.js @@ -96,7 +96,8 @@ export function outputError(line, error, origin) { const lineNumberPlaceholder = ' '.repeat(lineNumber.toString().length) console.log( - chalk.bold(chalk.red('error') + ':\n' + error.errorMessage) + + '\n' + + chalk.bold(error.errorMessage) + '\n' + (origin ? chalk.dim(` in ${origin.file}\n`) : "") + chalk.blue(` ${lineNumberPlaceholder} |\n ${lineNumber} | `) + diff --git a/src/services/help.js b/src/services/help.js index 7fcf81d0..6e8d4b83 100644 --- a/src/services/help.js +++ b/src/services/help.js @@ -13,6 +13,7 @@ ${chalk.green('Client commands:')} ${chalk.green('.monitor')} Starts monitoring cron messages for this process ${chalk.green('.unmonitor')} Stops monitoring cron messages for this process ${chalk.green('.editor')} Simple code editor for writing multi-line Lua expressions + ${chalk.green('.dryrun')} Toggle dryrun mode that sends every command as a dryrun and never saves memory ${chalk.green('.exit')} Close the client ${chalk.green('.help')} Print this help screen `) From f9cb49c46216746353f625784c5cad99d48f5c30 Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Wed, 4 Sep 2024 19:34:31 +0000 Subject: [PATCH 04/14] chore: rebuild modules and update package json --- README.md | 10 +++++----- package.json | 6 +++--- process/package.json | 6 +++--- process/test/handlers.test.js | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 69c90278..f2dd9a52 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ logo -Status: Preview rc2 -Version: 2.0.0-rc2 -Module: `ffvkmPM1jW71hFlBpVbaIapBa_Wl6UIwfdTkDNqsKNw` -Sqlite-Module: `C4bxMlK8d_wQ-QpXIIZLU8UWXu6Sd8PDJw7HN3nNE2I` +Version: 2.0.0 +Module: `GHfE2KUbj0nyh6Wdz2Z6tnn4Iid0elkWzATApO_hJ68` -Llama-Module: `Eb_Ol0yQsmAaM_KUzbTKbrwJ0Pi3zAq2s9WEegqhr6I` +Sqlite-Module: `nV8MCmdMbPWXd7pKMP-a5Zr9eqkzZOrqecQTCT0KvHg` + +Llama-Module: `1HhovIWiPIyhVaYKSVoHtwyT_k15I7KKqdNFqYQvfW4` ## Requirements diff --git a/package.json b/package.json index 1322417c..dacc988a 100644 --- a/package.json +++ b/package.json @@ -29,9 +29,9 @@ "yargs": "^17.7.2" }, "aos": { - "module": "ffvkmPM1jW71hFlBpVbaIapBa_Wl6UIwfdTkDNqsKNw", - "sqlite": "G991Xp6Kh28k8_AZcnwaqJ6LZcHlsZcMkrH1mJoAy84", - "llama": "Eb_Ol0yQsmAaM_KUzbTKbrwJ0Pi3zAq2s9WEegqhr6I", + "module": "GHfE2KUbj0nyh6Wdz2Z6tnn4Iid0elkWzATApO_hJ68", + "sqlite": "nV8MCmdMbPWXd7pKMP-a5Zr9eqkzZOrqecQTCT0KvHg", + "llama": "1HhovIWiPIyhVaYKSVoHtwyT_k15I7KKqdNFqYQvfW4", "version": "2.0.0" }, "devDependencies": { diff --git a/process/package.json b/process/package.json index d93a04ed..fd96125b 100644 --- a/process/package.json +++ b/process/package.json @@ -10,8 +10,8 @@ "scripts": { "build": "ao build", "test": "node --test --experimental-wasm-memory64", - "deploy": "ao publish -w ~/.wallet.json process.wasm -t Memory-Limit -v 1-gb -t Compute-Limit -v 9000000000000 -t Module-Format -v wasm64-unknown-emscripten-draft_2024_02_15 -t AOS-Version -v 2.0.0 -t Name -v AOS", - "deploy-sqlite": "ao publish -w ~/.wallet.json process.wasm -t Memory-Limit -v 1-gb -t Compute-Limit -v 9000000000000 -t Module-Format -v wasm64-unknown-emscripten-draft_2024_02_15 -t AOS-Version -v 2.0.0 -t Name -v SQLITE", - "deploy-llama": "ao publish -w ~/.wallet.json process.wasm -t Memory-Limit -v 1-gb -t Compute-Limit -v 9000000000000 -t Module-Format -v wasm64-unknown-emscripten-draft_2024_02_15 -t AOS-Version -v 2.0.0 -t Name -v LLAMA" + "deploy": "ao publish -w ~/.wallet.json process.wasm -t Memory-Limit -v 1-gb -t Compute-Limit -v 9000000000000 -t Module-Format -v wasm64-unknown-emscripten-draft_2024_02_15 -t AOS-Version -v 2.0.0 -t Name -v xl", + "deploy-sqlite": "ao publish -w ~/.wallet.json process.wasm -t Memory-Limit -v 1-gb -t Compute-Limit -v 9000000000000 -t Module-Format -v wasm64-unknown-emscripten-draft_2024_02_15 -t AOS-Version -v 2.0.0 -t Name -v sqlite-xl", + "deploy-llama": "ao publish -w ~/.wallet.json process.wasm -t Memory-Limit -v 16-gb -t Compute-Limit -v 9000000000000 -t Module-Format -v wasm64-unknown-emscripten-draft_2024_02_15 -t AOS-Version -v 2.0.0 -t Name -v llama-xxl -t Extension -v WeaveDrive" } } \ No newline at end of file diff --git a/process/test/handlers.test.js b/process/test/handlers.test.js index d20afa21..b7fcddb8 100644 --- a/process/test/handlers.test.js +++ b/process/test/handlers.test.js @@ -305,7 +305,7 @@ Handlers.add("timestamp", Timestamp: currentTimestamp } const result = await handle(Memory, timestamp, env) - assert.equal(result.Output.data, currentTimestamp) + assert.equal(result.Output.data, "\x1B[32m" + currentTimestamp + "\x1B[0m") assert.ok(true) }) From 6a70faadf78c6f77dfa353a3059f8653595b74a4 Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Fri, 6 Sep 2024 15:57:25 +0000 Subject: [PATCH 05/14] fix: bug with print and cicular references --- README.md | 4 ++-- package.json | 4 ++-- process/stringify.lua | 10 ++++++++-- src/commands/os.js | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f2dd9a52..f4567dcd 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ Version: 2.0.0 -Module: `GHfE2KUbj0nyh6Wdz2Z6tnn4Iid0elkWzATApO_hJ68` +Module: `pvXvNCa-svBhc1ovojvqFn3YlWiP2fZiWR7gKvEGOPQ` -Sqlite-Module: `nV8MCmdMbPWXd7pKMP-a5Zr9eqkzZOrqecQTCT0KvHg` +Sqlite-Module: `wnpdcrIi1bJ9IV7sOAgjqaRVXRZx42pSQ3aDJKhcQQs` Llama-Module: `1HhovIWiPIyhVaYKSVoHtwyT_k15I7KKqdNFqYQvfW4` diff --git a/package.json b/package.json index dacc988a..60931923 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,8 @@ "yargs": "^17.7.2" }, "aos": { - "module": "GHfE2KUbj0nyh6Wdz2Z6tnn4Iid0elkWzATApO_hJ68", - "sqlite": "nV8MCmdMbPWXd7pKMP-a5Zr9eqkzZOrqecQTCT0KvHg", + "module": "pvXvNCa-svBhc1ovojvqFn3YlWiP2fZiWR7gKvEGOPQ", + "sqlite": "wnpdcrIi1bJ9IV7sOAgjqaRVXRZx42pSQ3aDJKhcQQs", "llama": "1HhovIWiPIyhVaYKSVoHtwyT_k15I7KKqdNFqYQvfW4", "version": "2.0.0" }, diff --git a/process/stringify.lua b/process/stringify.lua index 32880304..a828e3ac 100644 --- a/process/stringify.lua +++ b/process/stringify.lua @@ -19,7 +19,7 @@ function stringify.isSimpleArray(tbl) return true end -function stringify.format(tbl, indent) +function stringify.format(tbl, indent, visited) indent = indent or 0 local toIndent = string.rep(" ", indent) local toIndentChild = string.rep(" ", indent + 2) @@ -59,7 +59,13 @@ function stringify.format(tbl, indent) end if not isArray then if type(v) == "table" then - v = stringify.format(v, indent + 2) + visited = visited or {} + if visited[v] then + return "" + end + visited[v] = true + + v = stringify.format(v, indent + 2, visited) elseif type(v) == "string" then v = colors.green .. '"' .. v .. '"' .. colors.reset else diff --git a/src/commands/os.js b/src/commands/os.js index 2662559a..b6f79620 100644 --- a/src/commands/os.js +++ b/src/commands/os.js @@ -26,7 +26,7 @@ export function dry() { export function update() { // let luaFiles = fs.readdirSync(__dirname + "../../process") // .filter(n => /\.lua$/.test(n)) - let luaFiles = ['ao.lua', 'utils.lua', 'assignment.lua', 'handlers-utils.lua', 'handlers.lua', 'eval.lua', 'process.lua'] + let luaFiles = ['stringify.lua', 'ao.lua', 'utils.lua', 'assignment.lua', 'handlers-utils.lua', 'handlers.lua', 'eval.lua', 'process.lua'] .map(name => { const code = fs.readFileSync(__dirname + "../../process/" + name, 'utf-8') const mod = name.replace(/\.lua$/, "") From ef1f8503cf5da4b418a0f02374ffd32f0fed5655 Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Tue, 10 Sep 2024 12:32:04 +0000 Subject: [PATCH 06/14] fix: add check to not reply to self when sending un trusted message --- README.md | 7 ++----- package.json | 4 ++-- process/process.lua | 8 ++++++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f4567dcd..85af0f7f 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,9 @@ Version: 2.0.0 -Module: `pvXvNCa-svBhc1ovojvqFn3YlWiP2fZiWR7gKvEGOPQ` - -Sqlite-Module: `wnpdcrIi1bJ9IV7sOAgjqaRVXRZx42pSQ3aDJKhcQQs` - -Llama-Module: `1HhovIWiPIyhVaYKSVoHtwyT_k15I7KKqdNFqYQvfW4` +Module: `C61NgrJDuhwGUsFca1rgfE7ehAKSdgOqPj6aYYy5u4s` +Sqlite-Module: `02BiXxlw3okihf8o-Rep2z32EDjgj1uAsOB9tMEcyAs` ## Requirements diff --git a/package.json b/package.json index 60931923..aecaada4 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,8 @@ "yargs": "^17.7.2" }, "aos": { - "module": "pvXvNCa-svBhc1ovojvqFn3YlWiP2fZiWR7gKvEGOPQ", - "sqlite": "wnpdcrIi1bJ9IV7sOAgjqaRVXRZx42pSQ3aDJKhcQQs", + "module": "C61NgrJDuhwGUsFca1rgfE7ehAKSdgOqPj6aYYy5u4s", + "sqlite": "02BiXxlw3okihf8o-Rep2z32EDjgj1uAsOB9tMEcyAs", "llama": "1HhovIWiPIyhVaYKSVoHtwyT_k15I7KKqdNFqYQvfW4", "version": "2.0.0" }, diff --git a/process/process.lua b/process/process.lua index c6bee51a..d3358656 100644 --- a/process/process.lua +++ b/process/process.lua @@ -278,13 +278,17 @@ function process.handle(msg, _) -- Only trust messages from a signed owner or an Authority if msg.From ~= msg.Owner and not ao.isTrusted(msg) then - Send({Target = msg.From, Data = "Message is not trusted by this process!"}) + if msg.From ~= ao.id then + Send({Target = msg.From, Data = "Message is not trusted by this process!"}) + end print('Message is not trusted! From: ' .. msg.From .. ' - Owner: ' .. msg.Owner) return ao.result({ }) end if ao.isAssignment(msg) and not ao.isAssignable(msg) then - Send({Target = msg.From, Data = "Assignment is not trusted by this process!"}) + if msg.From ~= ao.id then + Send({Target = msg.From, Data = "Assignment is not trusted by this process!"}) + end print('Assignment is not trusted! From: ' .. msg.From .. ' - Owner: ' .. msg.Owner) return ao.result({ }) end From 13c763b995a015f9d31048182fa53f93c9f6745f Mon Sep 17 00:00:00 2001 From: rakis Date: Sat, 14 Sep 2024 10:31:34 -0700 Subject: [PATCH 07/14] feat: create scratchpad for aos --- src/commands/pad.js | 21 ++++++++ src/index.js | 113 +++++++++++++++++++++++++------------------- 2 files changed, 86 insertions(+), 48 deletions(-) create mode 100644 src/commands/pad.js diff --git a/src/commands/pad.js b/src/commands/pad.js new file mode 100644 index 00000000..f7387a04 --- /dev/null +++ b/src/commands/pad.js @@ -0,0 +1,21 @@ +import os from 'node:os' +import path from 'node:path' +import { spawn } from 'node:child_process' +import fs from 'node:fs' + +export function pad(pid, callback) { + const tempFilePath = path.join(os.homedir(), `.pad-${pid}.lua`); + + const editor = process.env.EDITOR || (process.platform === 'win32' ? 'notepad' : 'vi'); + const child = spawn(editor, [tempFilePath], { + stdio: 'inherit', // This ensures the editor uses the same terminal + shell: true, // For Windows compatibility + }); + + child.on('exit', (exitCode) => { + console.log('Exit Code', exitCode) + const editedContent = fs.readFileSync(tempFilePath, 'utf8'); + callback(null, editedContent); + }); +} + diff --git a/src/index.js b/src/index.js index 9373c2b5..6c38225d 100644 --- a/src/index.js +++ b/src/index.js @@ -39,6 +39,7 @@ import { list } from './services/list.js' import { patch } from './commands/patch.js' import * as os from './commands/os.js' import { readHistory, writeHistory } from './services/history-service.js' +import { pad } from './commands/pad.js' const argv = minimist(process.argv.slice(2)) @@ -355,6 +356,19 @@ if (!argv['watch']) { return; } + if (line === ".pad") { + rl.pause() + pad(id, async (err, content) => { + if (!err) { + // console.log(content) + await doEvaluate(content, id, jwk, spinner, rl) + } + rl.resume(); + rl.prompt(true); + }) + return; + } + if (line === ".exit") { cron.stop(); console.log("Exiting..."); @@ -369,53 +383,7 @@ if (!argv['watch']) { if (process.env.DEBUG) console.time(chalk.gray('Elapsed')) printLive() - spinner.start(); - spinner.suffixText = chalk.gray("[Dispatching message...]") - - - // create message and publish to ao - const result = await evaluate(line, id, jwk, { sendMessage, readResult }, spinner) - .catch(err => ({ Output: JSON.stringify({ data: { output: err.message } }) })) - const output = result.Output //JSON.parse(result.Output ? result.Output : '{"data": { "output": "error: could not parse result."}}') - // log output - // console.log(output) - spinner.stop() - - if (result?.Error || result?.error) { - const error = parseError(result.Error || result.error) - - if (error) { - // get what file the error comes from, - // if the line was loaded - const errorOrigin = getErrorOrigin(loadedModules, error.lineNumber) - - // print error - outputError(line, error, errorOrigin) - } else { - console.log(chalk.red(result.Error || result.error)); - } - } else { - - if (output?.data) { - if (output.data.hasOwnProperty('output')) { - console.log(output.data.output) - } else if (output.data.hasOwnProperty('prompt')) { - console.log('') - } else { - console.log(output.data) - } - if (output.data.hasOwnProperty('prompt')) { - globalThis.prompt = output.data.prompt ? output.data.prompt : globalThis.prompt - } else { - globalThis.prompt = output.prompt ? output.prompt : globalThis.prompt - } - rl.setPrompt(globalThis.prompt) - } else { - if (!output) { - console.log(chalk.red('An unknown error occurred.')) - } - } - } + await doEvaluate(line, id, jwk, spinner, rl) if (process.env.DEBUG) { console.timeEnd(chalk.gray('Elapsed')) @@ -512,4 +480,53 @@ async function handleLoadArgs(jwk, id) { spinner.stop() } -} \ No newline at end of file +} + +async function doEvaluate(line, id, jwk, spinner, rl) { + spinner.start(); + spinner.suffixText = chalk.gray("[Dispatching message...]") + + + // create message and publish to ao + const result = await evaluate(line, id, jwk, { sendMessage, readResult }, spinner) + .catch(err => ({ Output: JSON.stringify({ data: { output: err.message } }) })) + const output = result.Output //JSON.parse(result.Output ? result.Output : '{"data": { "output": "error: could not parse result."}}') + // log output + // console.log(output) + spinner.stop() + + if (result?.Error || result?.error) { + const error = parseError(result.Error || result.error) + if (error) { + // get what file the error comes from, + // if the line was loaded + const errorOrigin = getErrorOrigin(loadedModules, error.lineNumber) + + // print error + outputError(line, error, errorOrigin) + } else { + console.log(chalk.red(result.Error || result.error)); + } + } else { + if (output?.data) { + if (output.data.hasOwnProperty('output')) { + console.log(output.data.output) + } else if (output.data.hasOwnProperty('prompt')) { + console.log('') + } else { + console.log(output.data) + } + if (output.data.hasOwnProperty('prompt')) { + globalThis.prompt = output.data.prompt ? output.data.prompt : globalThis.prompt + } else { + globalThis.prompt = output.prompt ? output.prompt : globalThis.prompt + } + rl.setPrompt(globalThis.prompt) + } else { + if (!output) { + console.log(chalk.red('An unknown error occurred.')) + } + } + } + return; +} From 4205fe27fff9ce0986bf84029565f05108f4f8ca Mon Sep 17 00:00:00 2001 From: rakis Date: Sun, 15 Sep 2024 21:00:50 +0800 Subject: [PATCH 08/14] feat: external editor with aos --- src/commands/pad.js | 29 ++++++++++++++++++++++++++--- src/index.js | 6 +++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/commands/pad.js b/src/commands/pad.js index f7387a04..bdbd3037 100644 --- a/src/commands/pad.js +++ b/src/commands/pad.js @@ -2,9 +2,16 @@ import os from 'node:os' import path from 'node:path' import { spawn } from 'node:child_process' import fs from 'node:fs' +import crypto from 'node:crypto' export function pad(pid, callback) { const tempFilePath = path.join(os.homedir(), `.pad-${pid}.lua`); + let hash = null + try { + hash = getFileHash(tempFilePath) + } catch (e) { + hash = "" + } const editor = process.env.EDITOR || (process.platform === 'win32' ? 'notepad' : 'vi'); const child = spawn(editor, [tempFilePath], { @@ -13,9 +20,25 @@ export function pad(pid, callback) { }); child.on('exit', (exitCode) => { - console.log('Exit Code', exitCode) - const editedContent = fs.readFileSync(tempFilePath, 'utf8'); - callback(null, editedContent); + //console.log('Exit Code: ', exitCode) + if (exitCode == 0) { + const editedContent = fs.readFileSync(tempFilePath, 'utf8'); + if (getFileHash(tempFilePath) !== hash) { + callback(null, editedContent); + } else { + callback(new Error('no changes')) + } + } else { + callback(new Error('exited')) + } }); } + +function getFileHash(filePath) { + const fileBuffer = fs.readFileSync(filePath); + const hashSum = crypto.createHash('sha256'); + hashSum.update(fileBuffer); + return hashSum.digest('hex'); +} + diff --git a/src/index.js b/src/index.js index 6c38225d..87c736d0 100644 --- a/src/index.js +++ b/src/index.js @@ -361,7 +361,7 @@ if (!argv['watch']) { pad(id, async (err, content) => { if (!err) { // console.log(content) - await doEvaluate(content, id, jwk, spinner, rl) + await doEvaluate(content, id, jwk, spinner, rl, loadedModules) } rl.resume(); rl.prompt(true); @@ -383,7 +383,7 @@ if (!argv['watch']) { if (process.env.DEBUG) console.time(chalk.gray('Elapsed')) printLive() - await doEvaluate(line, id, jwk, spinner, rl) + await doEvaluate(line, id, jwk, spinner, rl, loadedModules) if (process.env.DEBUG) { console.timeEnd(chalk.gray('Elapsed')) @@ -482,7 +482,7 @@ async function handleLoadArgs(jwk, id) { } } -async function doEvaluate(line, id, jwk, spinner, rl) { +async function doEvaluate(line, id, jwk, spinner, rl, loadedModules) { spinner.start(); spinner.suffixText = chalk.gray("[Dispatching message...]") From 68b89adf270a08c02a6aff35bdfa53e51571cd0e Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Sun, 15 Sep 2024 13:15:47 +0000 Subject: [PATCH 09/14] fix: merging scratchpad --- src/index.js | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/index.js b/src/index.js index 6e30f30b..fcdccf89 100644 --- a/src/index.js +++ b/src/index.js @@ -377,7 +377,7 @@ if (!argv['watch']) { pad(id, async (err, content) => { if (!err) { // console.log(content) - await doEvaluate(content, id, jwk, spinner, rl, loadedModules) + await doEvaluate(content, id, jwk, spinner, rl, loadedModules, dryRunMode) } rl.resume(); rl.prompt(true); @@ -399,7 +399,7 @@ if (!argv['watch']) { if (process.env.DEBUG) console.time(chalk.gray('Elapsed')) printLive() - await doEvaluate(line, id, jwk, spinner, rl, loadedModules) + await doEvaluate(line, id, jwk, spinner, rl, loadedModules, dryRunMode) if (process.env.DEBUG) { console.timeEnd(chalk.gray('Elapsed')) @@ -490,30 +490,27 @@ async function handleLoadArgs(jwk, id) { }) spinner.start() spinner.suffixText = chalk.gray("[Signing message and sequencing...]") - - // create message and publish to ao - let result = null - if (dryRunMode) { - result = await dryEval(line, id, jwk, { dryrun }, spinner) - .catch(err => ({ Output: JSON.stringify({ data: { output: err.message } }) })) - } else { - result = await evaluate(line, id, jwk, { sendMessage, readResult }, spinner) - .catch(err => ({ Output: JSON.stringify({ data: { output: err.message } }) })) - } + await evaluate(loadCode, id, jwk, { sendMessage, readResult }, spinner) + .catch(err => ({ Output: JSON.stringify({ data: { output: err.message } }) })) + spinner.stop() } } -async function doEvaluate(line, id, jwk, spinner, rl, loadedModules) { +async function doEvaluate(line, id, jwk, spinner, rl, loadedModules, dryRunMode) { spinner.start(); spinner.suffixText = chalk.gray("[Dispatching message...]") - // create message and publish to ao - const result = await evaluate(line, id, jwk, { sendMessage, readResult }, spinner) - .catch(err => ({ Output: JSON.stringify({ data: { output: err.message } }) })) - + let result = null + if (dryRunMode) { + result = await dryEval(line, id, jwk, { dryrun }, spinner) + .catch(err => ({ Output: JSON.stringify({ data: { output: err.message } }) })) + } else { + result = await evaluate(line, id, jwk, { sendMessage, readResult }, spinner) + .catch(err => ({ Output: JSON.stringify({ data: { output: err.message } }) })) + } const output = result.Output //JSON.parse(result.Output ? result.Output : '{"data": { "output": "error: could not parse result."}}') // log output // console.log(output) From 9feae986e141f306c501ffd55f14a99bd4d8152d Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Sun, 15 Sep 2024 13:37:40 +0000 Subject: [PATCH 10/14] fix: integrate pad with 2 --- src/index.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index fcdccf89..3f02e870 100644 --- a/src/index.js +++ b/src/index.js @@ -252,7 +252,7 @@ if (!argv['watch']) { dryRunMode = !dryRunMode if (dryRunMode) { console.log(chalk.green('dryrun mode engaged')) - rl.setPrompt(chalk.red('*') + globalThis.prompt) + rl.setPrompt((dryRunMode ? chalk.red('*') : '') + globalThis.prompt) } else { console.log(chalk.red('dryrun mode disengaged')) rl.setPrompt(globalThis.prompt.replace('*', '')) @@ -321,7 +321,7 @@ if (!argv['watch']) { line = editorData editorData = "" editorMode = false; - rl.setPrompt(globalThis.prompt) + rl.setPrompt((dryRunMode ? chalk.red('*') : '') + globalThis.prompt) } if (editorMode && line === ".delete") { @@ -344,7 +344,8 @@ if (!argv['watch']) { console.log(editorData) editorData = "" editorMode = false - rl.setPrompt(globalThis.prompt) + //rl.setPrompt(globalThis.prompt) + rl.setPrompt((dryRunMode ? chalk.red('*') : '') + globalThis.prompt) rl.prompt(true) return } @@ -352,7 +353,8 @@ if (!argv['watch']) { if (editorMode && line === ".cancel") { editorData = "" editorMode = false; - rl.setPrompt(globalThis.prompt) + //rl.setPrompt(globalThis.prompt) + rl.setPrompt(dryRunMode ? chalk.red('*') : '' + globalThis.prompt) // rl.close() @@ -542,7 +544,8 @@ async function doEvaluate(line, id, jwk, spinner, rl, loadedModules, dryRunMode) } else { globalThis.prompt = output.prompt ? output.prompt : globalThis.prompt } - rl.setPrompt(globalThis.prompt) + rl.setPrompt((dryRunMode ? chalk.red('*') : '') + globalThis.prompt) + // rl.setPrompt(globalThis.prompt) } else { if (!output) { console.log(chalk.red('An unknown error occurred.')) From a237b333675057728218f4fecb65ebfc155ee49c Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Sun, 15 Sep 2024 13:40:06 +0000 Subject: [PATCH 11/14] fix: resolved review items --- src/dry-eval.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dry-eval.js b/src/dry-eval.js index 7648cb65..18935289 100644 --- a/src/dry-eval.js +++ b/src/dry-eval.js @@ -9,7 +9,8 @@ export async function dryEval(line, processId, wallet, services, spinner) { }) .chain(() => services.dryrun({ processId: processId, - wallet: wallet, tags: [ + wallet: wallet, + tags: [ { name: 'Action', value: 'Eval' } ], data: line @@ -30,7 +31,7 @@ export async function dryEval(line, processId, wallet, services, spinner) { .map(x => { if (process.env.DEBUG) { console.log("") - console.timeEnd('Read') + console.timeEnd('Send') } return x }) From 744871cbbceddb8c8205617081e93324b6d1cb20 Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Wed, 18 Sep 2024 06:09:59 +0000 Subject: [PATCH 12/14] chore: updated apm blueprint --- README.md | 4 ++-- package.json | 6 +++--- process/package.json | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 85af0f7f..c7fed3f9 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ Version: 2.0.0 -Module: `C61NgrJDuhwGUsFca1rgfE7ehAKSdgOqPj6aYYy5u4s` +Module: `wAn9sElcBV6IfcxyySc6QnYGQCrlFnps88Y5zMxLsYY` -Sqlite-Module: `02BiXxlw3okihf8o-Rep2z32EDjgj1uAsOB9tMEcyAs` +Sqlite-Module: `A1lO7VyrR2Jh4mcQ_EzKQWGUfN118oFHT5fvf4wyU_8` ## Requirements diff --git a/package.json b/package.json index aecaada4..71011a6d 100644 --- a/package.json +++ b/package.json @@ -29,9 +29,9 @@ "yargs": "^17.7.2" }, "aos": { - "module": "C61NgrJDuhwGUsFca1rgfE7ehAKSdgOqPj6aYYy5u4s", - "sqlite": "02BiXxlw3okihf8o-Rep2z32EDjgj1uAsOB9tMEcyAs", - "llama": "1HhovIWiPIyhVaYKSVoHtwyT_k15I7KKqdNFqYQvfW4", + "module": "wAn9sElcBV6IfcxyySc6QnYGQCrlFnps88Y5zMxLsYY", + "sqlite": "A1lO7VyrR2Jh4mcQ_EzKQWGUfN118oFHT5fvf4wyU_8", + "llama": "QuxilALgsYUwM4lkr7XD9cL9nrzo6lr8mOFmQUix9z4", "version": "2.0.0" }, "devDependencies": { diff --git a/process/package.json b/process/package.json index fd96125b..3b028b14 100644 --- a/process/package.json +++ b/process/package.json @@ -5,7 +5,7 @@ "main": "index.js", "license": "MIT", "dependencies": { - "@permaweb/ao-loader": "^0.0.35" + "@permaweb/ao-loader": "^0.0.36" }, "scripts": { "build": "ao build", @@ -14,4 +14,4 @@ "deploy-sqlite": "ao publish -w ~/.wallet.json process.wasm -t Memory-Limit -v 1-gb -t Compute-Limit -v 9000000000000 -t Module-Format -v wasm64-unknown-emscripten-draft_2024_02_15 -t AOS-Version -v 2.0.0 -t Name -v sqlite-xl", "deploy-llama": "ao publish -w ~/.wallet.json process.wasm -t Memory-Limit -v 16-gb -t Compute-Limit -v 9000000000000 -t Module-Format -v wasm64-unknown-emscripten-draft_2024_02_15 -t AOS-Version -v 2.0.0 -t Name -v llama-xxl -t Extension -v WeaveDrive" } -} \ No newline at end of file +} From bf88451268a96daa8c7149d1857a16658c327327 Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Wed, 18 Sep 2024 23:31:17 +0000 Subject: [PATCH 13/14] fix: handle regression to prevent bricking of processes with errors in handlers --- process/process.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/process/process.lua b/process/process.lua index d3358656..a3c99a8e 100644 --- a/process/process.lua +++ b/process/process.lua @@ -364,9 +364,10 @@ function process.handle(msg, _) end print(Colors.green .. result .. Colors.reset) print("\n" .. Colors.gray .. removeLastThreeLines(debug.traceback()) .. Colors.reset) - return ao.result({ Messages = {}, Spawns = {}, Assignments = {} }) + local printData = table.concat(HANDLER_PRINT_LOGS, "\n") + return ao.result({Error = printData .. '\n\n' .. Colors.red .. 'error:\n' .. Colors.reset .. result, Messages = {}, Spawns = {}, Assignments = {} }) end - + if msg.Action == "Eval" then local response = ao.result({ Output = { From 36f652cee672ba404d11c50dfbfc4ae9756cac6d Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Wed, 18 Sep 2024 23:54:03 +0000 Subject: [PATCH 14/14] chore: updating v2 --- README.md | 4 ++-- package.json | 6 +++--- process/test/print.test.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c7fed3f9..cb1415e5 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ Version: 2.0.0 -Module: `wAn9sElcBV6IfcxyySc6QnYGQCrlFnps88Y5zMxLsYY` +Module: `bkjb55i07GUCUSWROtKK4HU1mBS_X0TyH3M5jMV6aPg` -Sqlite-Module: `A1lO7VyrR2Jh4mcQ_EzKQWGUfN118oFHT5fvf4wyU_8` +Sqlite-Module: `aGVVWHldKA7GBlI_w7Qp_agO6aKjCoOTPA1G2OlluXE` ## Requirements diff --git a/package.json b/package.json index 71011a6d..6a7c035b 100644 --- a/package.json +++ b/package.json @@ -29,9 +29,9 @@ "yargs": "^17.7.2" }, "aos": { - "module": "wAn9sElcBV6IfcxyySc6QnYGQCrlFnps88Y5zMxLsYY", - "sqlite": "A1lO7VyrR2Jh4mcQ_EzKQWGUfN118oFHT5fvf4wyU_8", - "llama": "QuxilALgsYUwM4lkr7XD9cL9nrzo6lr8mOFmQUix9z4", + "module": "bkjb55i07GUCUSWROtKK4HU1mBS_X0TyH3M5jMV6aPg", + "sqlite": "aGVVWHldKA7GBlI_w7Qp_agO6aKjCoOTPA1G2OlluXE", + "llama": "oamLI-KZ1Q9MxNxWwLcqXYavpwKYf1EX1BpEofb6418", "version": "2.0.0" }, "devDependencies": { diff --git a/process/test/print.test.js b/process/test/print.test.js index a70f61e6..183ccc42 100644 --- a/process/test/print.test.js +++ b/process/test/print.test.js @@ -131,6 +131,6 @@ test('Print Errors in Handlers', async () => { msg2.Data = "ping" const result = await handle(Memory, msg2, env) - assert.ok(result.Output.data.includes('handling message')) + assert.ok(result.Error.includes('handling message')) assert.ok(true) })