Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for issues #1000 and #1002 #1005

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
3 changes: 2 additions & 1 deletion dev-cli/container/src/node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions dev-cli/container/src/node/src/bin/ao-spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ const uploadAoProcess = spawnProcessWith({
/**
* implement to create a contract using the ao SDK
*/
create: async ({ module, tags, wallet }) => {
create: async ({ module, scheduler, tags, wallet }) => {
return spawn({
moduleId: module,
module,
scheduler,
tags,
signer: createDataItemSigner(wallet)
}).then((contractId) => ({ contractId }))
}).then((processId) => ({ processId }))
}
})

Expand All @@ -35,6 +36,7 @@ Promise.resolve()
uploadAoProcess({
walletPath: process.env.WALLET_PATH,
module: process.env.MODULE_TX,
scheduler: process.env.SCHEDULER_ADDRESS,
tags: parseTags(process.env.TAGS || JSON.stringify([[], []]))
})
)
Expand Down
4 changes: 4 additions & 0 deletions dev-cli/container/src/node/src/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export const DEFAULT_MODULE_FORMAT_TAG = { name: 'Module-Format', value: 'wasm64
export const DEFAULT_INPUT_ENCODING_TAG = { name: 'Input-Encoding', value: 'JSON-1' }
export const DEFAULT_OUTPUT_ENCODING_TAG = { name: 'Output-Encoding', value: 'JSON-1' }
export const DEFAULT_VARIANT_TAG = { name: 'Variant', value: 'ao.TN.1' }
export const DEFAULT_MEMORY_LIMIT_TAG = {name: 'Memory-Limit', value: '1-gb' }
export const DEFAULT_COMPUTE_LIMIT_TAG = {name: 'Compute-Limit', value: '9000000000000' }

export const DEFAULT_BUNDLER_HOST = 'https://up.arweave.net'

Expand All @@ -12,5 +14,7 @@ export const AoModuleTags = [
DEFAULT_INPUT_ENCODING_TAG,
DEFAULT_OUTPUT_ENCODING_TAG,
DEFAULT_VARIANT_TAG,
DEFAULT_MEMORY_LIMIT_TAG,
DEFAULT_COMPUTE_LIMIT_TAG,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be in this PR. There needs to be internal discussion on if there should even be defaults for this or if it should be derived from the build flags used to produce the wasm binary (see #983)

Let's keep this PR small and focused on only the issues highlighted in the issues it claims to address.

{ name: 'Content-Type', value: 'application/wasm' }
]
3 changes: 2 additions & 1 deletion dev-cli/container/src/node/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,13 @@ export const uploadModuleWith =
*/
export const spawnProcessWith =
({ walletExists, readWallet, create }) =>
async ({ walletPath, module, tags }) => {
async ({ walletPath, module, scheduler, tags }) => {
if (!(await walletExists(walletPath))) throw new WalletNotFoundError()

const wallet = await readWallet(walletPath)
const res = await create({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create in ao-spawn.js needs to be updated to accept scheduler field on the argument.

module,
scheduler,
tags,
wallet
})
Expand Down
4 changes: 4 additions & 0 deletions dev-cli/container/src/node/test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ describe('createContractWith', () => {
const res = await spawnProcess({
walletPath: '/path/to/wallet.json',
module: 'module-tx-123',
scheduler: 'scheduler-tx-123',
tags: [
{ name: 'foo', value: 'bar' }
]
Expand All @@ -275,6 +276,7 @@ describe('createContractWith', () => {
create: (params) => {
assert.deepStrictEqual(params, {
module: 'module-tx-123',
scheduler: 'scheduler-tx-123',
tags: [
{ name: 'foo', value: 'bar' }
],
Expand All @@ -288,6 +290,7 @@ describe('createContractWith', () => {
await spawnProcess({
walletPath: '/path/to/wallet.json',
module: 'module-tx-123',
scheduler: 'scheduler-tx-123',
tags: [
{ name: 'foo', value: 'bar' }
]
Expand All @@ -303,6 +306,7 @@ describe('createContractWith', () => {
await contract({
walletPath: '/path/to/wallet.json',
module: 'module-tx-123',
scheduler: 'scheduler-tx-123',
tags: [
{ name: 'foo', value: 'bar' }
]
Expand Down
4 changes: 2 additions & 2 deletions dev-cli/src/commands/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ function amountArgs (amount) {
]
}

export async function balance ({ wallet, host }) {
export async function balance ({ wallet, bundler }) {
const cmdArgs = [
...walletArgs(wallet),
...bundlerArgs(host)
...bundlerArgs(bundler)
]

const p = Deno.run({
Expand Down
4 changes: 2 additions & 2 deletions dev-cli/src/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export async function init ({ lang = 'lua' }, name) {

export const command = new Command()
.description('Create an ao Process Source Project')
.usage('-l cpp <my-project-name>')
.usage('-l c <my-project-name>')
.option(
'-l, --lang <language:string>',
'The starter to use. Defaults to Lua. Options are "lua" and "cpp"'
'The starter to use. Defaults to Lua. Options are "lua" and "c"'
Comment on lines +22 to +25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be in this PR. If anything, it should be a separate issue and PR, so that our team can look at it, by itself.

)
.arguments('<name:string>')
.action(init)
19 changes: 16 additions & 3 deletions dev-cli/src/commands/spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,30 @@ import { Command } from '../deps.js'
import { tagsArg, walletArgs } from '../utils.js'
import { VERSION } from '../versions.js'

function sourceArgs (src) {
function moduleArgs (src) {
return [
'-e',
`MODULE_TX=${src}`
]
}

function schedulerArgs (src) {
return [
'-e',
`SCHEDULER_ADDRESS=${src}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where this is used in ao-spawn.js. I would suspect that it would be mapped to scheduler when calling uploadAoProcess, similar to WALLET_PATH and MODULE_TX

]
}

/**
* TODO:
* - Validate existence of wallet
* - require confirmation and bypass with --yes
*/
export async function spawn ({ wallet, tag, value, source }) {
export async function spawn ({ wallet, tag, value, module, scheduler }) {
const cmdArgs = [
...walletArgs(wallet),
...sourceArgs(source),
...moduleArgs(module),
...schedulerArgs(scheduler),
...tagsArg({ tags: tag, values: value })
]

Expand Down Expand Up @@ -50,6 +58,11 @@ export const command = new Command()
'the transaction that contains the ao Module',
{ required: true }
)
.option(
'-s, --scheduler <address:string>',
'the ao scheduler address',
{ required: true }
)
Comment on lines +61 to +65
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

.option(
'-t, --tag <tag:string>',
'additional tag to add to the transaction. MUST have a corresponding --value',
Expand Down
Loading