PaimaStudios / paima-engine

Novel trustless web3/blockchain gaming engine.
MIT License
55 stars 20 forks source link

add avail funnels #385

Closed ecioppettini closed 3 months ago

ecioppettini commented 4 months ago

There are two funnels added here. The first one is an analog to the evm parallel funnel, and has to be configured as avail-other:

Avail:
  type: avail-other
  lightClient: 'http://localhost:7007'
  rpc: ws://127.0.0.1:9944
  delay: 200
  confirmationDepth: 10

The other one is an analog to the block funnel, and it has the same configuration, except that it has the key of avail-main.

In both cases the data is added as part of the submittedData field. Example

{
  realAddress: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
  inputData: 'avail|test1',
  inputNonce: '0xdacc51013196e97e83236c92370b8b0b1fe43a2cc4c6b2ee17a768932def1a7f',
  suppliedValue: '0',
  scheduled: false,
  userAddress: '5grwvaef5zxb26fz9rcqpdws57cterhpnehxcpcnohgkutqy',
  userId: 1
}

Notes

This means the submitted data has to be utf8 text (I think it's how the evm version works too).

suppliedValue is always '0' because I don't think there is a concept of sending more tokens in a data submission. I think probably that would require setting up an extra transaction, and then submitting an input with the tx info or something (because tracking all the transfers may not work well with the data index?).

There is no presync phase for these funnels.

The delay on the base funnel version is something that we don't have in the block funnel. I don't know if it's needed here, but in any case it's there (defaults to no delay and no confirmation depth).

A light client is used for access to the app's data, but the rpc is used to get the slots for the blocks (from the headers). This is used to compute timestamps without relying on the steady block production. (Also see https://github.com/availproject/avail-light/issues/574)

TODO