-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3563 from iron-fish/staging
STAGING -> MASTER (2/25/23)
- Loading branch information
Showing
44 changed files
with
1,630 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "ironfish", | ||
"version": "0.1.69", | ||
"version": "0.1.70", | ||
"description": "CLI for running and interacting with an Iron Fish node", | ||
"author": "Iron Fish <[email protected]> (https://ironfish.network)", | ||
"main": "build/src/index.js", | ||
|
@@ -61,7 +61,7 @@ | |
"@aws-sdk/client-secrets-manager": "3.276.0", | ||
"@aws-sdk/s3-request-presigner": "3.127.0", | ||
"@ironfish/rust-nodejs": "0.1.27", | ||
"@ironfish/sdk": "0.0.46", | ||
"@ironfish/sdk": "0.0.47", | ||
"@oclif/core": "1.23.1", | ||
"@oclif/plugin-help": "5.1.12", | ||
"@oclif/plugin-not-found": "2.3.1", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@ironfish/sdk", | ||
"version": "0.0.46", | ||
"version": "0.0.47", | ||
"description": "SDK for running and interacting with an Iron Fish node", | ||
"author": "Iron Fish <[email protected]> (https://ironfish.network)", | ||
"main": "build/src/index.js", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
import { Logger } from '../../logger' | ||
import { IronfishNode } from '../../node' | ||
import { IDatabase, IDatabaseTransaction } from '../../storage' | ||
import { createDB } from '../../storage/utils' | ||
import { Account } from '../../wallet' | ||
import { Migration } from '../migration' | ||
import { GetStores } from './024-unspent-notes/stores' | ||
|
||
export class Migration024 extends Migration { | ||
path = __filename | ||
|
||
prepare(node: IronfishNode): IDatabase { | ||
return createDB({ location: node.config.walletDatabasePath }) | ||
} | ||
|
||
async forward( | ||
node: IronfishNode, | ||
db: IDatabase, | ||
tx: IDatabaseTransaction | undefined, | ||
logger: Logger, | ||
): Promise<void> { | ||
const stores = GetStores(db) | ||
|
||
const accounts = [] | ||
|
||
for await (const accountValue of stores.old.accounts.getAllValuesIter()) { | ||
accounts.push( | ||
new Account({ | ||
...accountValue, | ||
walletDb: node.wallet.walletDb, | ||
}), | ||
) | ||
} | ||
|
||
logger.info(`Indexing unspent notes for ${accounts.length} accounts`) | ||
|
||
for (const account of accounts) { | ||
let unspentNotes = 0 | ||
|
||
logger.info(` Indexing unspent notes for account ${account.name}`) | ||
for await (const [[, noteHash], note] of stores.old.decryptedNotes.getAllIter( | ||
undefined, | ||
account.prefixRange, | ||
)) { | ||
if (note.sequence === null || note.spent) { | ||
continue | ||
} | ||
|
||
await stores.new.unspentNoteHashes.put( | ||
[ | ||
account.prefix, | ||
[note.note.assetId(), [note.sequence, [note.note.value(), noteHash]]], | ||
], | ||
null, | ||
) | ||
unspentNotes++ | ||
} | ||
|
||
logger.info(` Indexed ${unspentNotes} unspent notes for account ${account.name}`) | ||
} | ||
} | ||
|
||
async backward(node: IronfishNode, db: IDatabase): Promise<void> { | ||
const stores = GetStores(db) | ||
|
||
await stores.new.unspentNoteHashes.clear() | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
ironfish/src/migrations/data/024-unspent-notes/new/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
import { | ||
BigU64BEEncoding, | ||
BufferEncoding, | ||
IDatabase, | ||
IDatabaseStore, | ||
NULL_ENCODING, | ||
PrefixEncoding, | ||
U32_ENCODING_BE, | ||
} from '../../../../storage' | ||
import { Account } from '../../../../wallet' | ||
|
||
export function GetNewStores(db: IDatabase): { | ||
unspentNoteHashes: IDatabaseStore<{ | ||
key: [Account['prefix'], [Buffer, [number, [bigint, Buffer]]]] | ||
value: null | ||
}> | ||
} { | ||
const unspentNoteHashes: IDatabaseStore<{ | ||
key: [Account['prefix'], [Buffer, [number, [bigint, Buffer]]]] | ||
value: null | ||
}> = db.addStore({ | ||
name: 'un', | ||
keyEncoding: new PrefixEncoding( | ||
new BufferEncoding(), // account prefix | ||
new PrefixEncoding( | ||
new BufferEncoding(), // asset ID | ||
new PrefixEncoding( | ||
U32_ENCODING_BE, // sequence | ||
new PrefixEncoding( | ||
new BigU64BEEncoding(), // value | ||
new BufferEncoding(), // note hash | ||
8, | ||
), | ||
4, | ||
), | ||
32, | ||
), | ||
4, | ||
), | ||
valueEncoding: NULL_ENCODING, | ||
}) | ||
|
||
return { unspentNoteHashes } | ||
} |
Oops, something went wrong.