-
Notifications
You must be signed in to change notification settings - Fork 812
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
Wallet TX count and time indexing #605
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great! Excited to see the progress on this.
a21aa49
to
b5c970a
Compare
98940c3
to
817f208
Compare
This comment has been minimized.
This comment has been minimized.
3be3a7d
to
43cf827
Compare
160c365
to
75dbdcb
Compare
f1aa81b
to
6d6718e
Compare
5361774
to
05f4898
Compare
13b7d03
to
adfd21b
Compare
This will be resolved with a blgr update.
1f351b4
to
7d8ddf8
Compare
Closing this pull request for now, as I haven't worked on this in quite some time. This solves the issue with many transactions within a wallet, and I've added this branch at https://github.com/bcoin-org/bcoin/tree/wallet-pagination and will leave it as it is currently until this topic is visited again. There is also the topic of the ability to recover the wallet from a seed that is important. |
Bug related to unconfirmed indexBug is related to how unconfirmed count recovery happens. It may rewrite the existing last transaction details. Here's is the idea how it could happen: Situation 1: this can happen on scale as well: Solution
Test caseApply to test/wallet-test.js describe('Pagination indexes', function() {
let wdb;
before(async () => {
wdb = new WalletDB({ memory: true });
await wdb.open();
});
after(async () => {
await wdb.close();
});
it('should reindex newly unconfirmed txs after disconnect', async () => {
const N = 2;
const toConfirm = [];
for (let i = 0; i < N; i++) {
const address = await wdb.primary.receiveAddress();
const mtx = new MTX();
mtx.addInput(dummyInput());
mtx.addOutput(address, 1);
const tx = mtx.toTX();
toConfirm.push(tx);
await wdb.addTX(tx);
}
{
const unconfirmed = await wdb.primary.listUnconfirmed(0, {
limit: 100,
reverse: false
});
assert.strictEqual(unconfirmed.length, N);
}
const entry = nextBlock(wdb);
await wdb.addBlock(entry, toConfirm);
{
const unconfirmed = await wdb.primary.listUnconfirmed(0, {
limit: 100,
reverse: false
});
assert.strictEqual(unconfirmed.length, 0);
}
for (let i = 0; i < N; i++) {
const address = await wdb.primary.receiveAddress();
const mtx = new MTX();
mtx.addInput(dummyInput());
mtx.addOutput(address, 1);
const tx = mtx.toTX();
toConfirm.push(tx);
await wdb.addTX(tx);
}
{
const unconfirmed = await wdb.primary.listUnconfirmed(0, {
limit: 100,
reverse: false
});
const all = await wdb.primary.listHistory(0, {
limit: 100,
reverse: false
})
assert.strictEqual(unconfirmed.length, N);
assert.strictEqual(all.length, N * 2);
}
console.log(await wdb.dump());
await wdb.removeBlock(entry);
{
const unconfirmed = await wdb.primary.listUnconfirmed(0, {
limit: 100,
reverse: false
});
const all = await wdb.primary.listHistory(0, {
limit: 100,
reverse: false
})
console.log(await wdb.dump());
assert.strictEqual(unconfirmed.length, N * 2);
assert.strictEqual(all.length, N * 2);
}
});
}); |
HSD: handshake-org#888 BCOIN: bcoin-org/bcoin#605 Co-authored-by: Braydon Fuller <courier@braydon.com>
HSD: handshake-org#888 BCOIN: bcoin-org/bcoin#605 Co-authored-by: Braydon Fuller <courier@braydon.com>
z: bdb.key('z', ['uint32', 'uint32']), | ||
Z: bdb.key('Z', ['uint32', 'uint32', 'uint32']), | ||
y: bdb.key('y', ['hash256']), | ||
x: bdb.key('u', ['hash256']), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo here. Should be x: bdb.key('x') instead of bdb.key('u')
This resolves CPU and memory exhaustion issues when requesting transaction history for a wallet with many transactions. Transactions are now also able to be queried by time based on median-time-past (MTP) based on chain data.
Closes: #559
See
TODO.md
for a full list.