agoric-labs / gimix

hackathon project to make a market for completing GitHub issues.
5 stars 0 forks source link

feat(oracle): accept invitation (wip) #11

Open 0xpatrickdev opened 10 months ago

0xpatrickdev commented 10 months ago

To Test

0xpatrickdev commented 10 months ago

Stuck here atm, breaking for ⛽️:

{"level":30,"time":1700178427210,"pid":60835,"hostname":"bldbox","msg":"Server listening at http://[::1]:5000"}
{"level":30,"time":1700178427214,"pid":60835,"hostname":"bldbox","msg":"Server listening at http://127.0.0.1:5000"}
Server is now listening on http://[::1]:5000
{"level":30,"time":1700178430185,"pid":60835,"hostname":"bldbox","reqId":"req-1","req":{"method":"GET","url":"/admin/accept","hostname":"localhost:5000","remoteAddress":"::1","remotePort":50340},"msg":"incoming request"}
address agoric1xfa2mphrt6292w5vxvnmjt47tfr7sqp5nd0lcj
instance Alleged: BoardRemoteInstanceHandle <Alleged: BoardRemoteInstanceHandle <[Object: null prototype] {}>> [Alleged: BoardRemoteInstanceHandle] {
  getBoardId: [Function: getBoardId] Function <Function <[Object: null prototype] {}>>
}
[Error <Object <[Object: null prototype] {}>>: unknown id: [object Alleged: BoardRemoteInstanceHandle]
  at file:///Users/0xpatrick/repos/gimix/oracle-server/src/lib/marshal.ts:28:11
  at convertValToSlot (file:///Users/0xpatrick/repos/gimix/oracle-server/src/lib/marshal.ts:8:22)
  at Array.map (<anonymous>)
  at Array.map (<anonymous>)
  at Array.map (<anonymous>)
  at acceptOracleInvitation (file:///Users/0xpatrick/repos/gimix/oracle-server/src/lib/stargate.ts:67:51)
  at async Object.<anonymous> (file:///Users/0xpatrick/repos/gimix/oracle-server/src/routes/admin.ts:18:18)]
{"level":30,"time":1700178430306,"pid":60835,"hostname":"bldbox","reqId":"req-1","res":{"statusCode":500},"responseTime":120.4447078704834,"msg":"request completed"}
0xpatrickdev commented 10 months ago

Server logs

can't find the instance for GiMiX

yarn run v1.22.19
$ yarn workspace oracle-server run dev
$ ts-node-esm src/server.ts
InteractiveSigner Object <[Object: null prototype] {}> {
  signingClient: SigningStargateClient {
    tmClient: Tendermint34Client {
      client: [HttpClient],
      p: [class Params [Function <Complex prototype>]],
      r: [class Responses [Function <Complex prototype>]]
    },
    queryClient: QueryClient {
      tmClient: [Tendermint34Client],
      auth: [Object <Complex prototype>],
      bank: [Object <Complex prototype>],
      staking: [Object <Complex prototype>],
      tx: [Object <Complex prototype>]
    },
    accountParser: [Function: accountFromAny] Function <Function <Complex prototype>>,
    registry: Registry { types: [Map <Complex prototype> [Map]] },
    aminoTypes: AminoTypes { register: [Object <Complex prototype>] },
    signer: DirectSecp256k1HdWallet {
      secret: [EnglishMnemonic],
      seed: [Uint8Array],
      accounts: [Array]
    },
    broadcastTimeoutMs: undefined,
    broadcastPollIntervalMs: undefined,
    gasPrice: undefined
  }
}
{"level":30,"time":1700191629070,"pid":84791,"hostname":"bldbox","msg":"Server listening at http://[::1]:5000"}
wallet update Object <[Object: null prototype] {}> {
  status: Object <[Object: null prototype] {}> {
    error: 'Error: instance: undefined (an undefined) - Must be a remotable (InstanceHandle)',
    id: 1700191030820,
    invitationSpec: Object <[Object: null prototype] {}> {
      description: 'gimix oracle invitation',
      instance: undefined,
      source: 'purse'
    },
    offerArgs: undefined,
    proposal: Object <[Object: null prototype] {}> {}
  },
  updated: 'offerStatus'
}
{"level":30,"time":1700191629074,"pid":84791,"hostname":"bldbox","msg":"Server listening at http://127.0.0.1:5000"}
Server is now listening on http://[::1]:5000
jittering CosmJS follower by 634ms
jittering CosmJS follower by 4194ms
jittering CosmJS follower by 4862ms
jittering CosmJS follower by 2239ms

Chain Logs

2023-11-17T03:17:11.506Z SwingSet: vat: v43: walletFactory.fromBridge: { blockHeight: 67367, blockTime: 1700191030, owner: 'agoric1xfa2mphrt6292w5vxvnmjt47tfr7sqp5nd0lcj', spendAction: '{"body":"#{\\"method\\":\\"executeOffer\\",\\"offer\\":{\\"id\\":1700191030820,\\"invitationSpec\\":{\\"description\\":\\"gimix oracle invitation\\",\\"instance\\":\\"#undefined\\",\\"source\\":\\"purse\\"},\\"offerArgs\\":\\"#undefined\\",\\"proposal\\":{}}}","slots":[]}', type: 'WALLET_SPEND_ACTION' }
2023-11-17T03:17:11.509Z SwingSet: vat: v43: walletFactory: { wallet: Object [Alleged: SmartWallet self] {}, actionCapData: { body: '#{"method":"executeOffer","offer":{"id":1700191030820,"invitationSpec":{"description":"gimix oracle invitation","instance":"#undefined","source":"purse"},"offerArgs":"#undefined","proposal":{}}}', slots: [] } }
2023-11-17T03:17:11.527Z SwingSet: vat: v43: wallet agoric1xfa2mphrt6292w5vxvnmjt47tfr7sqp5nd0lcj starting executeOffer 1700191030820
2023-11-17T03:17:11.529Z SwingSet: ls: v43: Logging sent error stack (Error#60)
2023-11-17T03:17:11.529Z SwingSet: ls: v43: Error#60: instance: undefined (an undefined) - Must be a remotable (InstanceHandle)
2023-11-17T03:17:11.529Z SwingSet: ls: v43: Error: instance: undefined (an undefined) - Must be a remotable (InstanceHandle)
 at construct ()
 at Error (/bundled-source/.../node_modules/ses/src/error/tame-error-constructor.js:56)
 at makeError (/bundled-source/.../node_modules/ses/src/error/assert.js:243)
 at throwLabeled (.../patterns/src/utils.js:132)
 at applyLabelingError (.../patterns/src/utils.js:154)
 at every ()
 at mustMatch (.../patterns/src/patterns/patternMatchers.js:528)
 at purse (.../smart-wallet/src/invitations.js:103)
 at purse (.../smart-wallet/src/invitations.js:102)
 at tryBody (.../smart-wallet/src/offers.js:83)
 at tryBody (.../smart-wallet/src/offers.js:79)
 at executeOffer (.../smart-wallet/src/offers.js:172)
 at executeOffer (.../smart-wallet/src/offers.js:61)
 at executeOffer (.../smart-wallet/src/smartWallet.js:414)
 at apply ()
 at apply ()
 at In "executeOffer" method of (SmartWallet offers) (/bundled-source/.../node_modules/@endo/exo/src/exo-tools.js:42)
 at (.../smart-wallet/src/smartWallet.js:550)
 at ()

2023-11-17T03:17:11.530Z SwingSet: ls: v43: Error#60 ERROR_NOTE: Caused by (Error#61)
2023-11-17T03:17:11.530Z SwingSet: ls: v43: Error#60 ERROR_NOTE: Sent as error:liveSlots:v43#70021
2023-11-17T03:17:11.530Z SwingSet: ls: v43: Error#61: undefined undefined - Must be a remotable (InstanceHandle)
2023-11-17T03:17:11.530Z SwingSet: ls: v43: Error: undefined (an undefined) - Must be a remotable (InstanceHandle)
 at construct ()
 at Error (/bundled-source/.../node_modules/ses/src/error/tame-error-constructor.js:56)
 at makeError (/bundled-source/.../node_modules/ses/src/error/assert.js:243)
 at fail (/bundled-source/.../node_modules/ses/src/error/assert.js:357)
 at baseAssert (/bundled-source/.../node_modules/ses/src/error/assert.js:377)
 at assertChecker (.../pass-style/src/passStyle-helpers.js:75)
 at applyLabelingError (.../patterns/src/utils.js:152)
 at every ()
 at mustMatch (.../patterns/src/patterns/patternMatchers.js:528)
 at purse (.../smart-wallet/src/invitations.js:103)
 at purse (.../smart-wallet/src/invitations.js:102)
 at tryBody (.../smart-wallet/src/offers.js:83)
 at tryBody (.../smart-wallet/src/offers.js:79)
 at executeOffer (.../smart-wallet/src/offers.js:172)
 at executeOffer (.../smart-wallet/src/offers.js:61)
 at executeOffer (.../smart-wallet/src/smartWallet.js:414)
 at apply ()
 at apply ()
 at In "executeOffer" method of (SmartWallet offers) (/bundled-source/.../node_modules/@endo/exo/src/exo-tools.js:42)
 at (.../smart-wallet/src/smartWallet.js:550)
 at ()

2023-11-17T03:17:11.543Z SwingSet: ls: v9: Logging sent error stack (RemoteError(error:liveSlots:v43#70021)#6)
2023-11-17T03:17:11.543Z SwingSet: ls: v9: RemoteError(error:liveSlots:v43#70021)#6: instance: undefined (an undefined) - Must be a remotable (InstanceHandle)
2023-11-17T03:17:11.543Z SwingSet: ls: v9: Error: instance: undefined (an undefined) - Must be a remotable (InstanceHandle)
 at construct ()
 at Error (/bundled-source/.../node_modules/ses/src/error/tame-error-constructor.js:56)
 at makeError (/bundled-source/.../node_modules/ses/src/error/assert.js:243)
 at decodeErrorCommon (/bundled-source/.../node_modules/@endo/marshal/src/marshal.js:281)
 at decodeFromSmallcaps (/bundled-source/.../node_modules/@endo/marshal/src/encodeToSmallcaps.js:434)
 at fromCapData (/bundled-source/.../node_modules/@endo/marshal/src/marshal.js:356)
 at notifyOnePromise (/bundled-source/.../packages/swingset-liveslots/src/liveslots.js:1225)
 at notify (/bundled-source/.../packages/swingset-liveslots/src/liveslots.js:1249)
 at dispatchToUserspace (/bundled-source/.../packages/swingset-liveslots/src/liveslots.js:1514)
 at runWithoutMetering (/bundled-source/.../packages/swingset-xsnap-supervisor/lib/supervisor-subprocess-xsnap.js:60)
 at ()

2023-11-17T03:17:11.543Z SwingSet: ls: v9: RemoteError(error:liveSlots:v43#70021)#6 ERROR_NOTE: Sent as error:liveSlots:v9#70006
2023-11-17T03:17:11.546Z SwingSet: vat: v43: wallet agoric1xfa2mphrt6292w5vxvnmjt47tfr7sqp5nd0lcj OFFER ERROR: (RemoteError(error:liveSlots:v9#70006)#62)
2023-11-17T03:17:11.546Z SwingSet: vat: v43: RemoteError(error:liveSlots:v9#70006)#62: instance: undefined (an undefined) - Must be a remotable (InstanceHandle)
2023-11-17T03:17:11.546Z SwingSet: vat: v43: Error: instance: undefined (an undefined) - Must be a remotable (InstanceHandle)
 at construct ()
 at Error (/bundled-source/.../node_modules/ses/src/error/tame-error-constructor.js:56)
 at makeError (/bundled-source/.../node_modules/ses/src/error/assert.js:243)
 at decodeErrorCommon (/bundled-source/.../node_modules/@endo/marshal/src/marshal.js:281)
 at decodeFromSmallcaps (/bundled-source/.../node_modules/@endo/marshal/src/encodeToSmallcaps.js:434)
 at fromCapData (/bundled-source/.../node_modules/@endo/marshal/src/marshal.js:356)
 at notifyOnePromise (/bundled-source/.../packages/swingset-liveslots/src/liveslots.js:1225)
 at notify (/bundled-source/.../packages/swingset-liveslots/src/liveslots.js:1249)
 at dispatchToUserspace (/bundled-source/.../packages/swingset-liveslots/src/liveslots.js:1514)
 at runWithoutMetering (/bundled-source/.../packages/swingset-xsnap-supervisor/lib/supervisor-subprocess-xsnap.js:60)
 at ()

2023-11-17T03:17:11.547Z SwingSet: vat: v43: wallet agoric1xfa2mphrt6292w5vxvnmjt47tfr7sqp5nd0lcj offerStatus { id: 1700191030820, invitationSpec: { description: 'gimix oracle invitation', instance: undefined, source: 'purse' }, offerArgs: undefined, proposal: {}, error: 'Error: instance: undefined (an undefined) - Must be a remotable (InstanceHandle)' }
2023-11-17T03:17:11.549Z SwingSet: xsnap: v43: RemoteError(error:liveSlots:v9#70006)#62 ERROR_NOTE: Sent as error:liveSlots:v43#70022
2023-11-17T03:17:11.549Z SwingSet: ls: v43: Logging sent error stack (RemoteError(error:liveSlots:v9#70006)#62)
2023-11-17T03:17:11.555Z SwingSet: xsnap: v10: UnhandledPromiseRejectionWarning: (RemoteError(error:liveSlots:v43#70022)#8)
2023-11-17T03:17:11.556Z SwingSet: xsnap: v10: RemoteError(error:liveSlots:v43#70022)#8: instance: undefined (an undefined) - Must be a remotable (InstanceHandle)
2023-11-17T03:17:11.556Z SwingSet: xsnap: v10: Error: instance: undefined (an undefined) - Must be a remotable (InstanceHandle)
 at construct ()
 at Error (/bundled-source/.../node_modules/ses/src/error/tame-error-constructor.js:56)
 at makeError (/bundled-source/.../node_modules/ses/src/error/assert.js:243)
 at decodeErrorCommon (/bundled-source/.../node_modules/@endo/marshal/src/marshal.js:281)
 at decodeFromSmallcaps (/bundled-source/.../node_modules/@endo/marshal/src/encodeToSmallcaps.js:434)
 at fromCapData (/bundled-source/.../node_modules/@endo/marshal/src/marshal.js:356)
 at notifyOnePromise (/bundled-source/.../packages/swingset-liveslots/src/liveslots.js:1225)
 at notify (/bundled-source/.../packages/swingset-liveslots/src/liveslots.js:1249)
 at dispatchToUserspace (/bundled-source/.../packages/swingset-liveslots/src/liveslots.js:1514)
 at runWithoutMetering (/bundled-source/.../packages/swingset-xsnap-supervisor/lib/supervisor-subprocess-xsnap.js:60)
 at ()

2023-11-17T03:17:11.570Z block-manager: block 67367 commit
2023-11-17T03:17:12.500Z block-manager: block 67368 begin
2023-11-17T03:17:12.505Z block-manager: block 67368 commit
2023-11-17T03:17:13.535Z block-manager: block 67369 begin
2023-11-17T03:17:13.541Z block-manager: block 67369 commit
2023-11-17T03:17:14.560Z block-manager: block 67370 begin
2023-11-17T03:17:14.566Z block-manager: block 67370 commit
2023-11-17T03:17:15.584Z block-manager: block 67371 begin
2023-11-17T03:17:15.588Z block-manager: block 67371 commit
2023-11-17T03:17:16.613Z block-manager: block 67372 begin
2023-11-17T03:17:16.619Z block-manager: block 67372 commit
2023-11-17T03:17:17.633Z block-manager: block 67373 begin
2023-11-17T03:17:17.638Z block-manager: block 67373 commit
2023-11-17T03:17:18.667Z block-manager: block 67374 begin
2023-11-17T03:17:18.675Z block-manager: block 67374 commit
2023-11-17T03:17:19.672Z block-manager: block 67375 begin
2023-11-17T03:17:19.675Z block-manager: block 67375 commit
2023-11-17T03:17:20.697Z block-manager: block 67376 begin
2023-11-17T03:17:20.703Z block-manager: block 67376 commit
2023-11-17T03:17:21.711Z block-manager: block 67377 begin
2023-11-17T03:17:21.717Z block-manager: block 67377 commit
2023-11-17T03:17:22.751Z block-manager: block 67378 begin
2023-11-17T03:17:22.757Z block-manager: block 67378 commit
2023-11-17T03:17:23.779Z block-manager: block 67379
0xpatrickdev commented 10 months ago
$ yarn workspace oracle-server run dev
$ ts-node-esm src/server.ts
InteractiveSigner Object <[Object: null prototype] {}> {
  signingClient: SigningStargateClient {
    tmClient: Tendermint34Client {
      client: [HttpClient],
      p: [class Params [Function <Complex prototype>]],
      r: [class Responses [Function <Complex prototype>]]
    },
    queryClient: QueryClient {
      tmClient: [Tendermint34Client],
      auth: [Object <Complex prototype>],
      bank: [Object <Complex prototype>],
      staking: [Object <Complex prototype>],
      tx: [Object <Complex prototype>]
    },
    accountParser: [Function: accountFromAny] Function <Function <Complex prototype>>,
    registry: Registry { types: [Map <Complex prototype> [Map]] },
    aminoTypes: AminoTypes { register: [Object <Complex prototype>] },
    signer: DirectSecp256k1HdWallet {
      secret: [EnglishMnemonic],
      seed: [Uint8Array],
      accounts: [Array]
    },
    broadcastTimeoutMs: undefined,
    broadcastPollIntervalMs: undefined,
    gasPrice: undefined
  }
}
hi from oracleService
{"level":30,"time":1700239538206,"pid":19050,"hostname":"bldbox","msg":"Server listening at http://[::1]:5000"}
{"level":30,"time":1700239538208,"pid":19050,"hostname":"bldbox","msg":"Server listening at http://127.0.0.1:5000"}
Server is now listening on http://[::1]:5000
3s timer done
keys [
  'data.published.wallet.agoric1xfa2mphrt6292w5vxvnmjt47tfr7sqp5nd0lcj.current',
  'data.published.agoricNames.instance'
]
15s timer done
keys [
  'data.published.wallet.agoric1xfa2mphrt6292w5vxvnmjt47tfr7sqp5nd0lcj.current',
  'data.published.agoricNames.instance'
]
{"level":30,"time":1700239617862,"pid":19050,"hostname":"bldbox","reqId":"req-1","req":{"method":"POST","url":"/admin/accept","hostname":"localhost:5000","remoteAddress":"127.0.0.1","remotePort":60682},"msg":"incoming request"}
instance Promise <Promise <[Object: null prototype] {}>> [Promise] { <pending> }
[Error <Object <[Object: null prototype] {}>>: unknown id: [object Promise]
  at file:///Users/0xpatrick/repos/gimix/oracle-server/src/lib/ui-kit/marshal.ts:28:11
  at convertValToSlot (file:///Users/0xpatrick/repos/gimix/oracle-server/src/lib/ui-kit/marshal.ts:8:22)
  at Array.map (<anonymous>)
  at Array.map (<anonymous>)
  at Array.map (<anonymous>)
  at Object.makeOffer (file:///Users/0xpatrick/repos/gimix/oracle-server/src/lib/ui-kit/walletConnection.ts:13:40)
  at acceptOracleOffer (file:///Users/0xpatrick/repos/gimix/oracle-server/src/lib/oracleService.ts:44:34)
  at Object.<anonymous> (file:///Users/0xpatrick/repos/gimix/oracle-server/src/routes/admin.ts:6:19)
  at AsyncResource.runInAsyncScope (node:async_hooks:203:9)
  at IncomingMessage.emit (node:events:517:28)
  at IncomingMessage.emit (node:domain:489:12)]
{"level":30,"time":1700239617877,"pid":19050,"hostname":"bldbox","reqId":"req-1","res":{"statusCode":500},"responseTime":14.188417434692383,"msg":"request completed"}

Was missing the error handler for chainStorageWatcher before. With it including, the queryOnce promise for GiMiX's instance still hangs, but we have an error message now

dckc commented 8 months ago

I have lost track of what this PR is trying to do.

How did GiMiX work at all without it?

0xpatrickdev commented 8 months ago

I have lost track of what this PR is trying to do.

How did GiMiX work at all without it?

It's not ready for review yet, but the goal is -

  1. accept oracle invitation
  2. send job report

The ui-kit directory is messy. I am proposing changes there to decouple wallet/signer from window.keplr, so we can use DirectSecp256k1HdWallet. I made a small dent in that here. It seems it would also be nice to make the ui-kit apis a bit more ocap friendly in this refactor.

I also briefly explored using components of ag-trade here, but couldn't quite figure it out... is the pattern to exec out to endo from the fastify server, or put the fastify server in its own endo compartment?

Commits 306eefe, fbc5091, 07f1fb8 should be pulled into separate PRs. 07f1fb8 was mostly for testing as i didn't have mint4k handy.. this should allow for multiple currencies. The only other missing UI piece for mvp is surfacing the claim payment invitation.