Page MenuHomePhabricator

[Cashtab] Upgrade slpv1 send txs
ClosedPublic

Authored by bytesofman on Feb 23 2024, 00:05.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABC8cb8e1d99513: [Cashtab] Upgrade slpv1 send txs
Summary

Use upgraded ecash-coinselect to create slpv1 token send txs.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bytesofman added inline comments.
cashtab/package-lock.json
19 ↗(On Diff #45499)

Note: this is from D15520

Before landing this diff, would publish the version from D15520 and install that

Need an npm-hosted version here for CI to work in the diff

cashtab/src/transactions/fixtures/vectors.js
715 ↗(On Diff #45499)

I reviewed the rawtxs here in Electrum. All looked good and were created at 1 sat/byte, implying expected behavior of ecash-coinselect upgrade.

I broadcast this last one and it checks out.

do not parseInt what is already an int

PiRK added inline comments.
cashtab/src/components/Send/SendToken.js
186 ↗(On Diff #45527)

Does this remove all uses of that sendToken function? If so, should the function be removed? I don't see any other callsite in the repo.

bytesofman added inline comments.
cashtab/src/components/Send/SendToken.js
186 ↗(On Diff #45527)

Yes -- however, there are so many sub functions and other dependencies in utils/transactions.js that I am going to remove them all at once -- after slpBurn is also implemented in this improved method.

For example, some of the tx building helpers are used in both send and burn and the respective tests for those legacy functions...so I can't get rid of them yet. I could get rid of just sendToken, but doesn't really feel complete, I think easier to keep track of what is being used where if all the legacy functions go at once.

I think it will be easier to review that way.

This revision is now accepted and ready to land.Feb 23 2024, 19:16
bytesofman marked an inline comment as done.

rebase

found some errors testing with a bunch of slp send txs, checking it out

patch error in token send txs with change

This revision is now accepted and ready to land.Feb 23 2024, 20:19

also note to reviewers of these slp diffs -- chronik's preflight checks do prevent accidental token burns in cashtab

cashtab/src/components/Send/SendToken.js
237 ↗(On Diff #45541)

this works great

236 ↗(On Diff #45540)

discovered in testing this didn't render anything

Failed tests logs:

====== CashTab Unit Tests: Get slpv1 send token inputs and outputs from NNG chronik-client getSendTokenInputs: Legacy unit test of deprecated function generateSendOpReturn ======
Error: expect(received).toStrictEqual(expected) // deep equality

- Expected  - 1
+ Received  + 1

  Array [
-   "49995000",
+   "50000",
    "49945000",
  ]
    at Object.toStrictEqual (/work/cashtab/src/slpv1/__tests__/index.test.js:84:49)
    at Promise.then.completed (/work/cashtab/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/work/cashtab/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (/work/cashtab/node_modules/jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/work/cashtab/node_modules/jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:121:9)
    at run (/work/cashtab/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (/work/cashtab/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (/work/cashtab/node_modules/jest-runner/build/runTest.js:444:34)
    at Object.worker (/work/cashtab/node_modules/jest-runner/build/testWorker.js:106:12)
====== CashTab Unit Tests: Get slpv1 send token inputs and outputs from NNG chronik-client getSendTokenInputs: Token send with change output ======
Error: expect(received).toStrictEqual(expected) // deep equality

- Expected  - 1
+ Received  + 1

  Array [
-   "9999999689",
+   "189",
    "9999999500",
  ]
    at Object.toStrictEqual (/work/cashtab/src/slpv1/__tests__/index.test.js:84:49)
    at Promise.then.completed (/work/cashtab/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/work/cashtab/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (/work/cashtab/node_modules/jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/work/cashtab/node_modules/jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:121:9)
    at run (/work/cashtab/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (/work/cashtab/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (/work/cashtab/node_modules/jest-runner/build/runTest.js:444:34)
    at Object.worker (/work/cashtab/node_modules/jest-runner/build/testWorker.js:106:12)
====== CashTab Unit Tests: Get slpv1 send token inputs and outputs from NNG chronik-client getSendTokenInputs: We ignore un-needed utxos in a token send with change output ======
Error: expect(received).toStrictEqual(expected) // deep equality

- Expected  - 1
+ Received  + 1

  Array [
-   "9999999689",
+   "189",
    "9999999500",
  ]
    at Object.toStrictEqual (/work/cashtab/src/slpv1/__tests__/index.test.js:84:49)
    at Promise.then.completed (/work/cashtab/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/work/cashtab/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (/work/cashtab/node_modules/jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/work/cashtab/node_modules/jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:121:9)
    at run (/work/cashtab/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (/work/cashtab/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (/work/cashtab/node_modules/jest-runner/build/runTest.js:444:34)
    at Object.worker (/work/cashtab/node_modules/jest-runner/build/testWorker.js:106:12)
====== CashTab Unit Tests: Get slpv1 send token inputs and outputs from NNG chronik-client getSendTokenInputs: Token send with change output and decimals ======
Error: expect(received).toStrictEqual(expected) // deep equality

- Expected  - 1
+ Received  + 1

  Array [
-   "212",
+   "210",
    "2",
  ]
    at Object.toStrictEqual (/work/cashtab/src/slpv1/__tests__/index.test.js:84:49)
    at Promise.then.completed (/work/cashtab/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/work/cashtab/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (/work/cashtab/node_modules/jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/work/cashtab/node_modules/jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:121:9)
    at run (/work/cashtab/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (/work/cashtab/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (/work/cashtab/node_modules/jest-runner/build/runTest.js:444:34)
    at Object.worker (/work/cashtab/node_modules/jest-runner/build/testWorker.js:106:12)

Each failure log is accessible here:
CashTab Unit Tests: Get slpv1 send token inputs and outputs from NNG chronik-client getSendTokenInputs: Legacy unit test of deprecated function generateSendOpReturn
CashTab Unit Tests: Get slpv1 send token inputs and outputs from NNG chronik-client getSendTokenInputs: Token send with change output
CashTab Unit Tests: Get slpv1 send token inputs and outputs from NNG chronik-client getSendTokenInputs: We ignore un-needed utxos in a token send with change output
CashTab Unit Tests: Get slpv1 send token inputs and outputs from NNG chronik-client getSendTokenInputs: Token send with change output and decimals

update vectors for token txs with change

This revision is now accepted and ready to land.Feb 23 2024, 20:27

found some errors testing with a bunch of slp send txs, checking it out

https://www.youtube.com/watch?v=-u9zr6oF4uA

This revision was automatically updated to reflect the committed changes.