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

feat: inter-tool bid list #7939

Draft
wants to merge 33 commits into
base: master
Choose a base branch
from
Draft

feat: inter-tool bid list #7939

wants to merge 33 commits into from

Conversation

dckc
Copy link
Member

@dckc dckc commented Jun 16, 2023

closes: #7905

stacked on:

Description

Tasks for Functional Requirements, followed by engineering goals:

Tasks

Security Considerations

  • unlike agops, this CLI code is suspicious of data from vstorage: static type declarations are enforced by dynamic checks such as pattern matches

Scaling Considerations

Documentation Considerations

Testing Considerations

@dckc
Copy link
Member Author

dckc commented Jun 16, 2023

list bids from auction works in 1 case

Using

not nicely formatted yet, but fetched from vstorage, unmarshalled:

packages/inter-cli$ node src/inter-tool.js auction list-bids
...
@@@bid {
  balance: {
    brand: Object [Alleged: BoardRemoteIST brand] { getBoardId: {} },
    value: 1000n
  },
  exitAfterBuy: false,
  price: {
    denominator: { brand: [Object [Alleged: BoardRemoteATOM brand]], value: 1n },
    numerator: { brand: [Object [Alleged: BoardRemoteIST brand]], value: 9n }
  },
  sequence: 1n,
  timestamp: {
    absValue: 1686951226n,
    timerBrand: Object [Alleged: BoardRemotetimerBrand] { getBoardId: {} }
  },
  wanted: {
    brand: Object [Alleged: BoardRemoteATOM brand] { getBoardId: {} },
    value: 1000000000000n
  }
}
prep: start chain, place bid
agoric-sdk/packages/inter-protocol$ ./scripts/start-local-chain.sh
...

$ agops inter bid by-price --price=9 --give 0.001IST --from gov1
2023-06-16T21:33:46.894667486Z tx not in block 145 retrying...
bid is broadcast:
{"timestamp":"2023-06-16T21:33:51Z","height":"146","offerId":"bid-1686951234745","txhash":"042B4D6BDBC1F23EBED1D02C9CF6394A4643B96FFD6A4C87834DAE14CA412EBB"}
2023-06-16T21:33:51.906915122Z offer not in wallet at block 146 retrying...
2023-06-16T21:33:51.906915122Z offer not in wallet at block 146 retrying...
{"id":"bid-1686951234745","price":"9 IST/ATOM","give":{"Bid":"0.001 IST"},"maxBuy":"1000000 ATOM","result":"Your bid has been accepted"}

$ agops inter bid list --from gov1
{"id":"bid-1686951234745","price":"9 IST/ATOM","give":{"Bid":"0.001 IST"},"maxBuy":"1000000 ATOM","result":"Your bid has been accepted"}
Raw book0.bids from auction contract
$ agd query vstorage data published.auction.book0.bids
value: '{"blockHeight":"147","values":["{\"body\":\"#{\\\"pricedBids\\\":[{\\\"balance\\\":{\\\"brand\\\":\\\"$0.Alleged:
  IST brand\\\",\\\"value\\\":\\\"+1000\\\"},\\\"exitAfterBuy\\\":false,\\\"price\\\":{\\\"denominator\\\":{\\\"brand\\\":\\\"$1.Alleged:
  ATOM brand\\\",\\\"value\\\":\\\"+1\\\"},\\\"numerator\\\":{\\\"brand\\\":\\\"$0\\\",\\\"value\\\":\\\"+9\\\"}},\\\"sequence\\\":\\\"+1\\\",\\\"timestamp\\\":{\\\"absValue\\\":\\\"+1686951226\\\",\\\"timerBrand\\\":\\\"$2.Alleged:
  timerBrand\\\"},\\\"wanted\\\":{\\\"brand\\\":\\\"$1\\\",\\\"value\\\":\\\"+1000000000000\\\"}}],\\\"scaledBids\\\":[]}\",\"slots\":[\"board0257\",\"board02152\",\"board0425\"]}"]}'

actual output from 1638dd384 , which merges #7618 with b6ac9a3

full output with debug logging
$ yarn --silent node src/inter-tool.js auction list-bids
XXX is sync IO essential?
XXX: rpcAddrs after [0] are ignored
{ rpcAddr: 'http://0.0.0.0:26657' }
XXX why is vstorage QueryClientImpl any???
TODO: test empty stream cell
{
  "pricedBids": [
    {
      "balance": {
        "brand": {},
        "value": "1000"
      },
      "exitAfterBuy": false,
      "price": {
        "denominator": {
          "brand": {},
          "value": "1"
        },
        "numerator": {
          "brand": {},
          "value": "9"
        }
      },
      "sequence": "1",
      "timestamp": {
        "absValue": "1686951226",
        "timerBrand": {}
      },
      "wanted": {
        "brand": {},
        "value": "1000000000000"
      }
    }
  ],
  "scaledBids": []
}
@@@bid {
  balance: {
    brand: Object [Alleged: BoardRemoteIST brand] { getBoardId: {} },
    value: 1000n
  },
  exitAfterBuy: false,
  price: {
    denominator: { brand: [Object [Alleged: BoardRemoteATOM brand]], value: 1n },
    numerator: { brand: [Object [Alleged: BoardRemoteIST brand]], value: 9n }
  },
  sequence: 1n,
  timestamp: {
    absValue: 1686951226n,
    timerBrand: Object [Alleged: BoardRemotetimerBrand] { getBoardId: {} }
  },
  wanted: {
    brand: Object [Alleged: BoardRemoteATOM brand] { getBoardId: {} },
    value: 1000000000000n
  }
}

@dckc dckc force-pushed the dc-inter-cli-pola branch 3 times, most recently from 122049b to cef90cd Compare June 18, 2023 04:13
@dckc dckc force-pushed the dc-inter-cli-pola branch 2 times, most recently from ea886be to afe38c5 Compare June 20, 2023 23:42
@dckc dckc mentioned this pull request Jul 11, 2023
@turadg
Copy link
Member

turadg commented Jul 11, 2023

I see this is in Draft. Are there parts of it that are ready to consider landing?

@dckc
Copy link
Member Author

dckc commented Jul 11, 2023

I see this is in Draft.

Yeah... IOU a TODO list...

Are there parts of it that are ready to consider landing?

I factored out #7935

@dckc
Copy link
Member Author

dckc commented Jul 12, 2023

fetches each bid at its own vstorage key

I caught up with the current state of...

so we now get:

$ yarn --silent node src/inter-tool.js auction list-bids
fetching 3 bids: [ 'bid1001', 'bid1002', 'bid1003' ] 
{"timestamp":"2023-07-11T17:49:18.000Z","sequence":1001,"price":"5.0000 IST/ATOM","balance":"0.00123 IST","wanted":"1000000 ATOM"}
{"timestamp":"2023-07-11T23:50:04.000Z","sequence":1002,"price":"5.0000 IST/ATOM","balance":"0.00456 IST","wanted":"1000000 ATOM"}
{"timestamp":"2023-07-12T03:59:28.000Z","sequence":1003,"bidScaling":"90.0000%","balance":"0.00321 IST","wanted":"1000000 ATOM"}

the current code also emits some debug/todo info:

XXX is sync IO essential?
XXX: rpcAddrs after [0] are ignored
TODO: pick among >1 rpcAddrs { rpcAddr: 'http://0.0.0.0:26657' }
TODO: pagination

test status

I refined the RPC fixture to avoid base64 gorp in most cases.

  ✔ [expected fail] format › format price > 1e20
  ✔ format › makeAssetFormatters handles all nat amounts, ratios (with seed=1107299986)
  ✔ auction › inter auction list-bids
  ✔ vstorage › extractStreamCellValue() handles empty response
  ✔ vstorage › extractStreamCellValue() handles all valid non-empty responses
  ✔ boardClient › boardProxy.provide() preserves identity
  ✔ boardClient › boardCtx ingest() preserves identity for passable keys
  ─

  6 tests passed
  1 known failure

@dckc dckc changed the title WIP: taking inter cli beyond test tool feat: inter-tool auction list-bids Jul 12, 2023
dckc added 2 commits July 12, 2023 13:56
currently:

-----------------|---------|----------|---------|---------|
File             | % Stmts | % Branch | % Funcs | % Lines |
-----------------|---------|----------|---------|---------|
All files        |    95.4 |    75.94 |   77.14 |    95.4 |
@dckc dckc changed the title feat: inter-tool auction list-bids feat: inter-tool bid list Jul 12, 2023
@dckc
Copy link
Member Author

dckc commented Jul 12, 2023

updated usage / tests to better match product spec

test-auction.js.md is a snapshot of help / usage text.

Tests such as "see all bids for a collateral type" have t.log() output to match the product spec.

$ yarn test
yarn run v1.22.19
$ ava

  ✔ auction › see all bids for a collateral type
    ℹ inter-tool bid list
fetching 3 bids: [ 'bid1001', 'bid1002', 'bid1003' ] 
TODO: pagination
    ℹ {"timestamp":"2023-07-11T17:49:18Z","sequence":1001,"price":"9.5000 IST/ATOM","balance":"500 IST","wanted":"1000000 ATOM"}
    ℹ {"timestamp":"2023-07-11T23:50:04Z","sequence":1002,"price":"8.5000 IST/ATOM","balance":"300 IST","wanted":"1000000 ATOM"}
    ℹ {"timestamp":"2023-07-12T03:59:28Z","sequence":1003,"bidScaling":"90.0000%","balance":"200 IST","wanted":"1000000 ATOM"}
  ✔ auction › FR5: Usage: inter-tool --help
  ✔ auction › FR5: Usage: inter-tool bid --help
  ✔ auction › FR5: Usage: inter-tool bid list --help
  - [todo] auction › FR5: --asset
  - [todo] auction › should timestamps really not show timezone?
  - [todo] auction › FR3: show partially filled bids
  - [todo] auction › FR5: --from-bidder, --from-everyone
  - [todo] auction › want should be maxBuy
  - [todo] auction › balance should be give
  - [todo] auction › give should be formatted as keyword record with Bid keyword
  - [todo] auction › price should be a number with implicit brands (?)
  ✔ format › makeAssetFormatters handles all nat amounts, ratios (with seed=-906316278)
  - [todo] format › prices truncate at 4 decimal places
  ✔ [expected fail] format › format price > 1e20
  ✔ networkConfig › support AGORIC_NET
  ✔ vstorage › extractStreamCellValue() handles empty response
  ✔ vstorage › extractStreamCellValue() handles all valid non-empty responses
  ✔ boardClient › boardProxy.provide() preserves identity
  ✔ boardClient › boardCtx ingest() preserves identity for passable keys
  ─

  10 tests passed
  1 known failure
  9 tests todo
Done in 1.23s.

I took the liberty of re-ordering the test output for clarity.

Test Coverage

-------------------|---------|----------|---------|---------|----------------------------
File               | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s          
-------------------|---------|----------|---------|---------|----------------------------
All files          |   95.03 |    75.29 |   76.92 |   95.03 |                            
 commands          |     100 |    85.71 |     100 |     100 |                            
  auction.js       |     100 |    85.71 |     100 |     100 | 76,129                     
 lib               |   93.61 |    73.23 |   74.28 |   93.61 |                            
  boardClient.js   |   93.65 |    76.19 |      50 |   93.65 | ...-50,128-129,183-187,192 
  format.js        |    98.4 |    80.76 |     100 |    98.4 | 31-32                      
  networkConfig.js |   91.07 |    71.42 |      75 |   91.07 | 33-34,43-44,54             
  vstorage.js      |   89.56 |    58.82 |     100 |   89.56 | 39-40,86-87,94-98,104-106  
-------------------|---------|----------|---------|---------|----------------------------

src/lib/agd-lib.js is not used/tested at all.
src/lib/tui.js is not tested either.

2023-07-12 14:39 cb8d491

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI-based reader for showing auction bids
3 participants