textury / arlocal

Local testnet for your Arweave products.
MIT License
102 stars 36 forks source link

GQL transactions filter - min block height #24

Closed ppedziwiatr closed 3 years ago

ppedziwiatr commented 3 years ago

Hi.

It seems that when I'm asking GQL endpoint for transactions with filter on min and max block height, the min. value is exclusive, instead of inclusive.

Eg. current block height is 5, I'm asking for transactions with min. block height = 3 and max block height = 5 - in response I'm getting transactions on block heights 4, 5 - instead of transactions on block heights 3, 4, 5.

Let's say the network info returns:

    {
      network: 'arlocal.N.1',
      version: 1,
      release: 1,
      queue_length: 0,
      peers: 0,
      height: 2,
      current: 'uh3m601k0kfj9c1r6i4yea79dp7fh9p9xt1d7gdg9l0',
      blocks: 2,
      node_state_latency: 0
    }

I'm adding three new transactions:

    await contract.writeInteraction({ function: 'add' });
    await mine();
    await contract.writeInteraction({ function: 'add' });
    await mine();
    await contract.writeInteraction({ function: 'add' });
    await mine();

After that the network info is:

{   
      network: 'arlocal.N.1',
      version: 1,
      release: 1,
      queue_length: 0,
      peers: 0,
      height: 5,
      current: '4k4f6d13cq9u4pdxph1a5d1lghm03on2kt0tk9g5rno',
      blocks: 5,
      node_state_latency: 0
       }

Then I'm asking for transactions with min. block height = 3 and max. block height = 5.

I'm getting 2 transactions as a result, instead of 3: 2021-09-16T21:37:06.242Z DEBUG [ContractInteractionsLoader] All loaded interactions: [ { from: 3, to: 5, loaded: 2 } ]

ppedziwiatr commented 3 years ago

I've made few more tests.

This code (full example here: https://github.com/redstone-finance/redstone-smartcontracts/blob/ppe/arlocal-issue/arlocal/mre.ts): image

gives this output: image

I would expect, that it would return exactly one result - in case of arweave.net and this request (current block height at the time of writing this is 771431) image

If I uncomment line 43. from the mre.ts - it works as expected - but not sure it that is the right way to fix it?

ppedziwiatr commented 3 years ago

One last thing - if I print the full network info, I get: image

you can see, that the block height and blocks are the same (=1)

In case of arweave.net gateway: image

kouraf commented 3 years ago

fixed in #25