Page MenuHomePhabricator

[ecash-herald] Add staker info to block msgs
ClosedPublic

Authored by bytesofman on Thu, Nov 21, 22:59.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABC83d7ef6f100d: [ecash-herald] Add staker info to block msgs
Summary

Fetch data from CoinDance api to get information about active stakers. Include the staking rwd winners chances of winning, and total stake (if you fetch successfully from the API).

Now that we need secrets for this API key and tests, generate this file if it is not in place to keep CI working. Same model used for token-server.

Test Plan

npm test

Diff Detail

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

Event Timeline

Tail of the build log:

test/mocks/mockChronikCalls.ts(169,5): error TS2353: Object literal may only specify known properties, and 'isFinal' does not exist in type 'Tx'.
test/mocks/mockChronikCalls.ts(251,5): error TS2353: Object literal may only specify known properties, and 'isFinal' does not exist in type 'Tx'.
test/mocks/mockChronikCalls.ts(321,5): error TS2353: Object literal may only specify known properties, and 'isFinal' does not exist in type 'Tx'.

    at createTSError (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:1617:30)
    at module.exports (/usr/lib/node_modules/nyc/node_modules/default-require-extensions/js.js:7:9)
    at /usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4
    at require.extensions.<computed> (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:1621:12)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/work/apps/ecash-herald/test/chronik.test.ts:14:1)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module.replacementCompile (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:60:13)
    at Module.m._compile (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:1618:23)
    at module.exports (/usr/lib/node_modules/nyc/node_modules/default-require-extensions/js.js:7:9)
    at /usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4
    at require.extensions.<computed> (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:1621:12)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.exports.requireOrImport (/work/apps/ecash-herald/node_modules/mocha/lib/nodejs/esm-utils.js:53:16)
    at async Object.exports.loadFilesAsync (/work/apps/ecash-herald/node_modules/mocha/lib/nodejs/esm-utils.js:100:20)
    at async singleRun (/work/apps/ecash-herald/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at async Object.exports.handler (/work/apps/ecash-herald/node_modules/mocha/lib/cli/run.js:370:5)
------------------------|---------|----------|---------|---------|----------------------------------
File                    | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                
------------------------|---------|----------|---------|---------|----------------------------------
All files               |    17.6 |      1.2 |       0 |   12.94 |                                  
 ecash-herald           |     100 |      100 |     100 |     100 |                                  
  config.ts             |     100 |      100 |     100 |     100 |                                  
 ecash-herald/constants |     100 |      100 |     100 |     100 |                                  
  addresses.ts          |     100 |      100 |     100 |     100 |                                  
 ecash-herald/scripts   |      80 |       50 |     100 |      80 |                                  
  prepSecrets.ts        |      80 |       50 |     100 |      80 | 15                               
 ecash-herald/src       |   14.53 |        0 |       0 |    9.39 |                                  
  chronik.ts            |   11.82 |        0 |       0 |    7.95 | 23-64,82-141,155-182,198-265     
  utils.ts              |   15.81 |        0 |       0 |   10.11 | ...9-374,388-398,408-430,450-489 
------------------------|---------|----------|---------|---------|----------------------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='53']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='301']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='1']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='83']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='37']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='36']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='278']
##teamcity[blockClosed name='Code Coverage Summary']
mv: cannot stat 'test_results/ecash-herald-junit.xml': No such file or directory
Build ecash-herald-tests failed with exit code 1

Tail of the build log:

test/mocks/mockChronikCalls.ts(169,5): error TS2353: Object literal may only specify known properties, and 'isFinal' does not exist in type 'Tx'.
test/mocks/mockChronikCalls.ts(251,5): error TS2353: Object literal may only specify known properties, and 'isFinal' does not exist in type 'Tx'.
test/mocks/mockChronikCalls.ts(321,5): error TS2353: Object literal may only specify known properties, and 'isFinal' does not exist in type 'Tx'.

    at createTSError (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:1617:30)
    at module.exports (/usr/lib/node_modules/nyc/node_modules/default-require-extensions/js.js:7:9)
    at /usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4
    at require.extensions.<computed> (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:1621:12)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/work/apps/ecash-herald/test/chronik.test.ts:14:1)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module.replacementCompile (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:60:13)
    at Module.m._compile (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:1618:23)
    at module.exports (/usr/lib/node_modules/nyc/node_modules/default-require-extensions/js.js:7:9)
    at /usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4
    at require.extensions.<computed> (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:1621:12)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.exports.requireOrImport (/work/apps/ecash-herald/node_modules/mocha/lib/nodejs/esm-utils.js:53:16)
    at async Object.exports.loadFilesAsync (/work/apps/ecash-herald/node_modules/mocha/lib/nodejs/esm-utils.js:100:20)
    at async singleRun (/work/apps/ecash-herald/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at async Object.exports.handler (/work/apps/ecash-herald/node_modules/mocha/lib/cli/run.js:370:5)
------------------------|---------|----------|---------|---------|----------------------------------
File                    | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                
------------------------|---------|----------|---------|---------|----------------------------------
All files               |    17.6 |      1.2 |       0 |   12.94 |                                  
 ecash-herald           |     100 |      100 |     100 |     100 |                                  
  config.ts             |     100 |      100 |     100 |     100 |                                  
 ecash-herald/constants |     100 |      100 |     100 |     100 |                                  
  addresses.ts          |     100 |      100 |     100 |     100 |                                  
 ecash-herald/scripts   |      80 |       50 |     100 |      80 |                                  
  prepSecrets.ts        |      80 |       50 |     100 |      80 | 15                               
 ecash-herald/src       |   14.53 |        0 |       0 |    9.39 |                                  
  chronik.ts            |   11.82 |        0 |       0 |    7.95 | 23-64,82-141,155-182,198-265     
  utils.ts              |   15.81 |        0 |       0 |   10.11 | ...9-374,388-398,408-430,450-489 
------------------------|---------|----------|---------|---------|----------------------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='53']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='301']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='1']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='83']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='37']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='36']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='278']
##teamcity[blockClosed name='Code Coverage Summary']
mv: cannot stat 'test_results/ecash-herald-junit.xml': No such file or directory
Build ecash-herald-tests failed with exit code 1

back out chronik-client type changes

note the satsToFormatted value changes are compartmentalized in D17181

will rebase this onto there when that is approved

Fabien added inline comments.
apps/ecash-herald/scripts/generateMock.ts
211 โ†—(On Diff #51037)

This is inconsistent with how it's defined for the staking reward api (see stakingRewardApiUrl in config.ts).
There already is a config file, no need for an additional secret file. Just update the config on CI before deployment and use a public api in the config (if possible).

bytesofman added inline comments.
apps/ecash-herald/scripts/generateMock.ts
211 โ†—(On Diff #51037)

This is a distinct API endpoint that provides data in the shape of mocks/stakers.ts added in this diff.

So -- this particular comment is badly worded (will update).

This API endpoint provides information about all stakers currently active on the network, including the amount staked. Herald can use this info to determine how much a given staking reward winner has staked and the total amount staked on the network (hence, the odds of any given staking reward winner winning).

secrets.ts already exists for ecash-herald (it's used to store the telegram bot keys, so we are not adding a new file. coin.dance provided this private API with a key, to be kept out of the repo. ecash-herald happened to not need any params from secrets.ts in tests. Now tho, we need a dummy API key for tests.

To prevent any special handling in the function for test env vs prod env, we use the sample file in CI which passes stakerApiKey as the dummy key.

bytesofman marked an inline comment as done.

clear up comment about mocking stakerinfo request vs staker request

This revision is now accepted and ready to land.Sun, Nov 24, 12:48