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

Assertion error when rescanning a block with TRANSFER/FINALIZE for wallet #510

Closed
pinheadmz opened this issue Sep 2, 2020 · 0 comments · Fixed by #564
Closed

Assertion error when rescanning a block with TRANSFER/FINALIZE for wallet #510

pinheadmz opened this issue Sep 2, 2020 · 0 comments · Fixed by #564

Comments

@pinheadmz
Copy link
Member

pinheadmz commented Sep 2, 2020

This could be related to #464 but after looking at the actual assertion error I think it is a different bug we need to look in to.
@HDardenne experienced this issue and brought to my attention on telegram, using Bob wallet. Another user on telegram had the same assertion error using hsd v2.1.5 but claimed the error went away after upgrading to v2.2.0.

The assertion errors are not identical but clearly related: one throws on a FINALIZE when the transfer is not in a transferring state (ns.transfer === 0) the other throws on a TRANSFER when the name is already in a transferring state (ns.transfer !== 0)

v2.1.5 / Bob Wallet v0.4.0

Finalize when name is not in transfer state

AssertionError [ERR_ASSERTION]: Assertion failed.
    at TXDB.connectNames (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\txdb.js:2061:13)
    at async TXDB.insert (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\txdb.js:1021:23)
    at async Wallet._add (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\wallet.js:4099:21)
    at async Wallet.add (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\wallet.js:4084:14)
    at async WalletDB._addTX (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:2252:11)
    at async WalletDB._addBlock (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:2091:13)
    at async WalletDB.rescanBlock (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:2196:7)
    at async C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:150:9
    at async NodeClient._emitAsync (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\bevent\lib\asyncemitter.js:377:11)
    at async NodeClient.emitAsync (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\bevent\lib\asyncemitter.js:318:7)
    at async ChainDB.scan (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\blockchain\chaindb.js:1507:7)
    at async Chain.scan (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\blockchain\chain.js:1888:14)
    at async WalletDB.scan (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:440:7)
    at async WalletDB.rescan (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:455:14)
    at async RPC.importName (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\rpc.js:911:7)
    at async RPC.call (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\bweb\lib\rpc.js:151:18)
    at async Hook.handler (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\bweb\lib\middleware\jsonrpc.js:38:16)
    at async HTTP._handleStack (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\bweb\lib\server.js:294:9)
    at async HTTP._handleRequest (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\bweb\lib\server.js:203:9)
    at async Server.<anonymous> (C:\Users\Hugo\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\bweb\lib\server.js:126:9)

hsd/lib/wallet/txdb.js

Lines 2037 to 2063 in 97737f1

case types.FINALIZE: {
if (ns.isNull()) {
if (!path)
break;
await this.addNameMap(b, nameHash);
const start = covenant.getU32(1);
const name = covenant.get(2);
const flags = covenant.getU8(3);
const weak = (flags & 1) !== 0;
const claimed = covenant.getU32(4);
const renewals = covenant.getU32(5);
ns.set(name, start);
ns.setRegistered(true);
ns.setValue(output.value);
ns.setWeak(weak);
ns.setClaimed(claimed);
ns.setRenewals(renewals);
// Cannot get data or highest.
ns.setHighest(output.value);
} else {
assert(ns.transfer !== 0);
ns.setTransfer(0);
}

Transfer when name is already in transfer state

[error] (node) Assertion failed.
    at TXDB.connectNames (/home/ubuntu/hsd/lib/wallet/txdb.js:2029:11)
    at async TXDB.insert (/home/ubuntu/hsd/lib/wallet/txdb.js:1021:23)
    at async Wallet._add (/home/ubuntu/hsd/lib/wallet/wallet.js:4154:21)
    at async Wallet.add (/home/ubuntu/hsd/lib/wallet/wallet.js:4139:14)
    at async WalletDB._addTX (/home/ubuntu/hsd/lib/wallet/walletdb.js:2312:11)
    at async WalletDB._addBlock (/home/ubuntu/hsd/lib/wallet/walletdb.js:2151:13)
    at async WalletDB.rescanBlock (/home/ubuntu/hsd/lib/wallet/walletdb.js:2256:7)
    at async /home/ubuntu/hsd/lib/wallet/walletdb.js:150:9
    at async NodeClient._emitAsync (/home/ubuntu/hsd/node_modules/bevent/lib/asyncemitter.js:377:11)
    at async NodeClient.emitAsync (/home/ubuntu/hsd/node_modules/bevent/lib/asyncemitter.js:318:7)

hsd/lib/wallet/txdb.js

Lines 2023 to 2035 in 97737f1

case types.TRANSFER: {
if (ns.isNull())
break;
ns.setOwner(outpoint);
assert(ns.transfer === 0);
ns.setTransfer(height);
updated = true;
break;
}

@pinheadmz pinheadmz changed the title Assertion error when rescanning a block with FINALIZE Assertion error when rescanning a block with TRANSFER/FINALIZE for wallet Sep 2, 2020
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 a pull request may close this issue.

1 participant