Page MenuHomePhabricator

[alias-server] Only include avalanche confirmed txs in getValidAliasRegistrations function
AbandonedPublic

Authored by bytesofman on Mar 31 2023, 16:44.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Summary

T3060

Depends on D13523

Add avalancheConfirmedBlockheight as a paramater to getValidAliasRegistrations. Use it to confirm that only txs in a block <= to avalancheConfirmedBlockheight are considered valid alias registrations.

Test Plan

Review new unit tests and
npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
rpc-avalanche-check
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 22925
Build 45470: Build Diffalias-server-tests
Build 45469: arc lint + arc unit

Event Timeline

is this downstream from D13521? If so, what is the benefit of using avalanche's isFinalBlock RPC call to get the tipheight over the existing method of using chronik-client and calling chronik's`blockchainInfo.tipHeight`? If the node hosting the chronk-client has different firstSeen timestamps than the node hosting the avalanche rpc calls then it may introduce edge cases.

is this downstream from D13521? If so, what is the benefit of using avalanche's isFinalBlock RPC call to get the tipheight over the existing method of using chronik-client and calling chronik's`blockchainInfo.tipHeight`? If the node hosting the chronk-client has different firstSeen timestamps than the node hosting the avalanche rpc calls then it may introduce edge cases.

Benefit of using the blockhash we get from chronik is that we know that specific node has that specific block -- and that's the same node we are pinging for tx history, which is then filtered by blockheight. So if that block is final and that chronik node has that block, the tx history from that chronik node thru that blockheight is avalanche confirmed.

Will also add isFinalTx RPC call to confirm each tx before adding to alias db after ironing out incremental tx processing.

In general, we should use the same node for both chronik and the RPC calls. But as long as the RPC node says a block of a given hash is final, and chronik says it has that identical block (same hash), should be fine. Still, better to use the same node. I updated T3060 to reflect this.

Fabien added a subscriber: Fabien.
Fabien added inline comments.
web/alias-server/src/alias.js
161–186 ↗(On Diff #39109)

Unrelated to this changes, but you can simplify the code flow here

170 ↗(On Diff #39109)

Out of curiosity, where did the magic number comes from ? Is blockheight set to something absurdly high while the tx is unconfirmed ?

This revision is now accepted and ready to land.Apr 3 2023, 08:55
web/alias-server/src/alias.js
161–186 ↗(On Diff #39109)

nice this is much better

added a task to handle this in its own diff

170 ↗(On Diff #39109)

commented in parseAliasTx function:

// arbitrary to set unconfirmed txs at blockheight of 100,000,000
            // note that this constant must be adjusted in the fall of 3910 A.D., assuming 10 min blocks
            // setting it high instead of zero because it's important we sort aliases by blockheight
            // for sortAliasTxsByTxidAndBlockheight function
            blockheight:
                aliasTx && aliasTx.block
                    ? aliasTx.block.height
                    : config.unconfirmedBlockheight,

Tail of the build log:

    at Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/work/web/alias-server/src/websocket.js:2:621)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Module.replacementCompile (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:60:13)
    at Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/work/web/alias-server/test/websocketTests.js:3:35)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Module.replacementCompile (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:60:13)
    at Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:201:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:154:23)
    at async Loader.import (node:internal/modules/esm/loader:177:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at async formattedImport (/work/web/alias-server/node_modules/mocha/lib/nodejs/esm-utils.js:9:14)
    at async Object.exports.requireOrImport (/work/web/alias-server/node_modules/mocha/lib/nodejs/esm-utils.js:42:28)
    at async Object.exports.loadFilesAsync (/work/web/alias-server/node_modules/mocha/lib/nodejs/esm-utils.js:100:20)
    at async singleRun (/work/web/alias-server/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at async Object.exports.handler (/work/web/alias-server/node_modules/mocha/lib/cli/run.js:370:5)
--------------------|---------|----------|---------|---------|-------------------
File                | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
--------------------|---------|----------|---------|---------|-------------------
All files           |     7.1 |        0 |       0 |    7.33 |                   
 alias-server       |     100 |      100 |     100 |     100 |                   
  config.js         |     100 |      100 |     100 |     100 |                   
  secrets.sample.js |     100 |      100 |     100 |     100 |                   
 alias-server/src   |    6.57 |        0 |       0 |    6.78 |                   
  alias.js          |    6.34 |        0 |       0 |    6.66 | 13-186            
  chronik.js        |    6.32 |        0 |       0 |    6.66 | 11-205            
  log.js            |      20 |        0 |       0 |      20 | 9-13              
  rpc.js            |   17.64 |        0 |       0 |   17.64 | 7-57              
  telegram.js       |   14.28 |      100 |       0 |   14.28 | 3-17              
  utils.js          |       6 |        0 |       0 |    6.25 | 12-134            
  websocket.js      |    4.65 |        0 |       0 |    4.72 | 13-447            
--------------------|---------|----------|---------|---------|-------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='25']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='352']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='117']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='34']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='25']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='341']
##teamcity[blockClosed name='Code Coverage Summary']
mv: cannot stat 'test_results/alias-server-junit.xml': No such file or directory
Build alias-server-tests failed with exit code 1

To be rebuilt after other diffs