Page MenuHomePhabricator

[token-server] Implement ecash-lib for tx building
ClosedPublic

Authored by bytesofman on Jul 30 2024, 17:23.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABCeba9364028ca: [token-server] Implement ecash-lib for tx building
Summary

Start building rewards txs using ecash-lib instead of utxo-lib

Doing this now because looking to add an XEC-only airdrop for new users.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
token-server-ecash-lib
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 29907
Build 59349: Build Difftoken-server-tests
Build 59348: arc lint + arc unit

Event Timeline

Tail of the build log:

> chronik-client@0.28.1 prepublish
> npm run build


> chronik-client@0.28.1 build
> tsc


added 265 packages, and audited 267 packages in 6s

48 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Test does not depend on ecash-script, skipping ecash-script dependencies...
Test depends on ecash-coinselect. Installing ecash-coinselect dependencies...
/work/modules/ecash-coinselect /work/modules/chronik-client /work/modules/mock-chronik-client /work/modules/ecashaddrjs /work/abc-ci-builds/token-server-tests

added 293 packages, and audited 294 packages in 1s

44 packages are looking for funding
  run `npm fund` for details

1 high severity vulnerability

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
/work/apps/token-server /work/modules/ecash-coinselect /work/modules/chronik-client /work/modules/mock-chronik-client /work/modules/ecashaddrjs /work/abc-ci-builds/token-server-tests
npm warn deprecated har-validator@5.1.5: this library is no longer supported
npm warn deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm warn deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

added 622 packages, and audited 627 packages in 4s

113 packages are looking for funding
  run `npm fund` for details

7 vulnerabilities (6 moderate, 1 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
CI configured to test build. Building...

> token-server@0.0.0 prebuild
> ts-node scripts/prepSecrets.ts

secrets.ts does not exist, copying secrets.sample.ts...

> token-server@0.0.0 build
> tsc

src/transactions.ts(26,8): error TS2307: Cannot find module 'ecash-lib' or its corresponding type declarations.
Build token-server-tests failed with exit code 2
tobias_ruck added inline comments.
apps/token-server/src/transactions.ts
33 ↗(On Diff #48937)

it's technically called "token type" in the spec

remove unused dependencies, also remove building unused local dep from test CI

Tail of the build log:

> chronik-client@0.28.2 build
> tsc


added 265 packages, and audited 267 packages in 5s

48 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Test does not depend on ecash-script, skipping ecash-script dependencies...
Test depends on ecash-coinselect. Installing ecash-coinselect dependencies...
/work/modules/ecash-coinselect /work/modules/chronik-client /work/modules/mock-chronik-client /work/modules/ecashaddrjs /work/abc-ci-builds/token-server-tests

added 293 packages, and audited 294 packages in 1s

44 packages are looking for funding
  run `npm fund` for details

1 high severity vulnerability

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
/work/apps/token-server /work/modules/ecash-coinselect /work/modules/chronik-client /work/modules/mock-chronik-client /work/modules/ecashaddrjs /work/abc-ci-builds/token-server-tests
npm warn deprecated har-validator@5.1.5: this library is no longer supported
npm warn deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm warn deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

added 628 packages, and audited 633 packages in 4s

113 packages are looking for funding
  run `npm fund` for details

9 vulnerabilities (2 low, 6 moderate, 1 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
CI configured to test build. Building...

> token-server@0.0.0 prebuild
> ts-node scripts/prepSecrets.ts

secrets.ts does not exist, copying secrets.sample.ts...

> token-server@0.0.0 build
> tsc

index.ts(12,31): error TS2307: Cannot find module 'ecash-lib' or its corresponding type declarations.
index.ts(57,5): error TS7006: Parameter 'err' implicitly has an 'any' type.
src/routes.ts(22,21): error TS2307: Cannot find module 'ecash-lib' or its corresponding type declarations.
src/transactions.ts(29,8): error TS2307: Cannot find module 'ecash-lib' or its corresponding type declarations.
Build token-server-tests failed with exit code 2

Tail of the build log:

added 231 packages, and audited 233 packages in 1s

34 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Test does not depend on ecash-lib-wasm, skipping
Test depends on chronik-client. Building TypeScript...
/work/modules/chronik-client /work/modules/mock-chronik-client /work/modules/ecashaddrjs /work/abc-ci-builds/token-server-tests

> chronik-client@0.28.2 prepublish
> npm run build


> chronik-client@0.28.2 build
> tsc


added 265 packages, and audited 267 packages in 5s

48 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Test does not depend on ecash-script, skipping ecash-script dependencies...
Test does not depend on ecash-coinselect, skipping ecash-coinselect dependencies...
/work/apps/token-server /work/modules/chronik-client /work/modules/mock-chronik-client /work/modules/ecashaddrjs /work/abc-ci-builds/token-server-tests
npm warn deprecated har-validator@5.1.5: this library is no longer supported
npm warn deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm warn deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

added 591 packages, and audited 596 packages in 3s

112 packages are looking for funding
  run `npm fund` for details

7 vulnerabilities (6 moderate, 1 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
CI configured to test build. Building...

> token-server@0.0.0 prebuild
> ts-node scripts/prepSecrets.ts

secrets.ts does not exist, copying secrets.sample.ts...

> token-server@0.0.0 build
> tsc

index.ts(12,31): error TS2307: Cannot find module 'ecash-lib' or its corresponding type declarations.
index.ts(57,5): error TS7006: Parameter 'err' implicitly has an 'any' type.
src/routes.ts(22,21): error TS2307: Cannot find module 'ecash-lib' or its corresponding type declarations.
src/transactions.ts(22,8): error TS2307: Cannot find module 'ecash-lib' or its corresponding type declarations.
Build token-server-tests failed with exit code 2

add ecash-lib and its deps to CI

Tail of the build log:

   Compiling wasm-bindgen-backend v0.2.92
   Compiling secp256k1-abc v0.20.3 (https://github.com/raipay/secp256k1-abc?rev=b23e742#b23e7421)
   Compiling thiserror-impl v1.0.58
   Compiling wasm-bindgen-macro-support v0.2.92
   Compiling wasm-bindgen-macro v0.2.92
   Compiling ecash-lib-wasm v0.1.0 (/work/modules/ecash-lib-wasm)
    Finished release-wasm [optimized] target(s) in 7.24s
Test depends on chronik-client. Building TypeScript...
/work/modules/chronik-client /work/modules/ecash-lib-wasm /work/modules/mock-chronik-client /work/modules/ecashaddrjs /work/abc-ci-builds/token-server-tests

> chronik-client@0.28.2 prepublish
> npm run build


> chronik-client@0.28.2 build
> tsc


added 265 packages, and audited 267 packages in 5s

48 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Test does not depend on ecash-script, skipping ecash-script dependencies...
Test does not depend on ecash-coinselect, skipping ecash-coinselect dependencies...
/work/apps/token-server /work/modules/chronik-client /work/modules/ecash-lib-wasm /work/modules/mock-chronik-client /work/modules/ecashaddrjs /work/abc-ci-builds/token-server-tests
npm warn deprecated har-validator@5.1.5: this library is no longer supported
npm warn deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm warn deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

added 591 packages, and audited 596 packages in 4s

112 packages are looking for funding
  run `npm fund` for details

7 vulnerabilities (6 moderate, 1 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
CI configured to test build. Building...

> token-server@0.0.0 prebuild
> ts-node scripts/prepSecrets.ts

secrets.ts does not exist, copying secrets.sample.ts...

> token-server@0.0.0 build
> tsc

index.ts(12,31): error TS2307: Cannot find module 'ecash-lib' or its corresponding type declarations.
index.ts(57,5): error TS7006: Parameter 'err' implicitly has an 'any' type.
src/routes.ts(22,21): error TS2307: Cannot find module 'ecash-lib' or its corresponding type declarations.
src/transactions.ts(22,8): error TS2307: Cannot find module 'ecash-lib' or its corresponding type declarations.
Build token-server-tests failed with exit code 2

CI depends ecash lib update

Tail of the build log:

  Downloaded block-buffer v0.10.4
   Compiling proc-macro2 v1.0.86
   Compiling unicode-ident v1.0.12
   Compiling typenum v1.17.0
   Compiling version_check v0.9.4
   Compiling wasm-bindgen-shared v0.2.92
   Compiling once_cell v1.19.0
   Compiling bumpalo v3.16.0
   Compiling log v0.4.21
   Compiling cc v1.0.92
   Compiling thiserror v1.0.58
   Compiling wasm-bindgen v0.2.92
   Compiling cfg-if v1.0.0
   Compiling abc-rust-lint v0.1.0 (/work/chronik/abc-rust-lint)
   Compiling generic-array v0.14.7
   Compiling quote v1.0.36
   Compiling secp256k1-sys-abc v0.4.1 (https://github.com/raipay/secp256k1-abc?rev=b23e742#b23e7421)
   Compiling syn v2.0.72
   Compiling crypto-common v0.1.6
   Compiling block-buffer v0.10.4
   Compiling digest v0.10.7
   Compiling sha2 v0.10.8
   Compiling ripemd v0.1.3
   Compiling wasm-bindgen-backend v0.2.92
   Compiling secp256k1-abc v0.20.3 (https://github.com/raipay/secp256k1-abc?rev=b23e742#b23e7421)
   Compiling thiserror-impl v1.0.58
   Compiling wasm-bindgen-macro-support v0.2.92
   Compiling wasm-bindgen-macro v0.2.92
   Compiling ecash-lib-wasm v0.1.0 (/work/modules/ecash-lib-wasm)
    Finished release-wasm [optimized] target(s) in 8.89s
Test depends on ecash-lib. Building TypeScript...
/work/modules/ecash-lib /work/modules/ecash-lib-wasm /work/modules/mock-chronik-client /work/modules/ecashaddrjs /work/abc-ci-builds/token-server-tests

added 363 packages, and audited 366 packages in 2s

60 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> ecash-lib@0.2.0 build
> tsc && tsc -p ./tsconfig.build.json && cp -r ./src/ffi ./dist

../chronik-client/proto/chronik.ts(2,18): error TS2307: Cannot find module 'long' or its corresponding type declarations.
../chronik-client/proto/chronik.ts(3,22): error TS2307: Cannot find module 'protobufjs/minimal' or its corresponding type declarations.
../chronik-client/proto/chronikNode.ts(2,18): error TS2307: Cannot find module 'long' or its corresponding type declarations.
../chronik-client/proto/chronikNode.ts(3,17): error TS2307: Cannot find module 'protobufjs/minimal' or its corresponding type declarations.
../chronik-client/src/ChronikClient.ts(5,23): error TS2307: Cannot find module 'isomorphic-ws' or its corresponding type declarations.
../chronik-client/src/ChronikClient.ts(6,21): error TS2307: Cannot find module 'ws' or its corresponding type declarations.
../chronik-client/src/ChronikClientNode.ts(6,23): error TS2307: Cannot find module 'isomorphic-ws' or its corresponding type declarations.
../chronik-client/src/ChronikClientNode.ts(7,21): error TS2307: Cannot find module 'ws' or its corresponding type declarations.
../chronik-client/src/failoverProxy.ts(5,38): error TS2307: Cannot find module 'axios' or its corresponding type declarations.
../chronik-client/src/failoverProxy.ts(6,23): error TS2307: Cannot find module 'isomorphic-ws' or its corresponding type declarations.
../chronik-client/src/failoverProxy.ts(7,21): error TS2307: Cannot find module 'ws' or its corresponding type declarations.
../chronik-client/src/failoverProxy.ts(187,35): error TS7006: Parameter 'x' implicitly has an 'any' type.
../chronik-client/src/failoverProxy.ts(273,32): error TS7006: Parameter 'e' implicitly has an 'any' type.
../chronik-client/src/failoverProxy.ts(279,30): error TS7006: Parameter 'e' implicitly has an 'any' type.
../chronik-client/src/failoverProxy.ts(299,43): error TS7006: Parameter 'msg' implicitly has an 'any' type.
../chronik-client/src/failoverProxy.ts(315,43): error TS7006: Parameter 'msg' implicitly has an 'any' type.
Build token-server-tests failed with exit code 2

build chronik-client before ecash-lib

bytesofman published this revision for review.Aug 8 2024, 22:43
bytesofman added inline comments.
apps/token-server/config.ts
10 ↗(On Diff #49109)

ecash-lib uses bigint for token amounts. no issue with storing this type in the config file, so might as well keep it that way instead of using string.

Previously, slp-mdm required BigNumber which is a more complicated object not natively supported in js.

apps/token-server/index.ts
18 ↗(On Diff #49109)

When I first created token-server, I assumed it would use a chronik websocket connection. At the moment, it does not use this for anything.

Arguably could remove this in a separate diff. However, it is easy to replace this with initWasm() on startup, which we now need.

apps/token-server/src/wallet.ts
48 ↗(On Diff #49109)

useful for storing in mocks. this function is only used by a script, so logging to console is for dev use and convenience.

apps/token-server/test/routes.test.ts
91 ↗(On Diff #49109)

can check with electrum -- the "new" tx mocks are the same inputs/outputs, except schnorr signed, so slightly smaller bytes and slightly more change.

This revision is now accepted and ready to land.Aug 9 2024, 04:30