From 93e8fe0a8f551641477e105b8878b286eaf58bf6 Mon Sep 17 00:00:00 2001 From: jowparks Date: Wed, 18 Jan 2023 12:42:33 -0800 Subject: [PATCH 01/11] fix: networkId defaults set upon run of reset command (#2982) --- ironfish-cli/src/commands/reset.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ironfish-cli/src/commands/reset.ts b/ironfish-cli/src/commands/reset.ts index 8159729a3a..946b46f9f6 100644 --- a/ironfish-cli/src/commands/reset.ts +++ b/ironfish-cli/src/commands/reset.ts @@ -45,6 +45,9 @@ export default class Reset extends IronfishCommand { this.exit(0) } + this.sdk.internal.set('networkId', this.sdk.config.defaults.networkId) + this.sdk.internal.set('isFirstRun', true) + await this.sdk.internal.save() const walletDatabasePath = this.sdk.config.walletDatabasePath const chainDatabasePath = this.sdk.config.chainDatabasePath const hostFilePath: string = this.sdk.config.files.join( From 26f20da00158a7c43e625cce00722edb749d1a03 Mon Sep 17 00:00:00 2001 From: Jason Spafford Date: Wed, 18 Jan 2023 16:44:16 -0500 Subject: [PATCH 02/11] Fix catching validation error as invalid email (#2988) We're sending 422 for all validation errors, with specific codes, and not printing out the right message. --- ironfish/src/rpc/routes/faucet/getFunds.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ironfish/src/rpc/routes/faucet/getFunds.ts b/ironfish/src/rpc/routes/faucet/getFunds.ts index 17d739a286..27daaeb362 100644 --- a/ironfish/src/rpc/routes/faucet/getFunds.ts +++ b/ironfish/src/rpc/routes/faucet/getFunds.ts @@ -3,6 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import { AxiosError } from 'axios' import * as yup from 'yup' +import { Assert } from '../../../assert' import { WebApi } from '../../../webApi' import { ERROR_CODES, ResponseError, ValidationError } from '../../adapters' import { ApiNamespace, router } from '../router' @@ -44,7 +45,13 @@ router.register( .catch((error: AxiosError<{ code: string; message?: string }>) => { if (error.response) { const { data, status } = error.response + if (status === 422) { + if (data.code === 'faucet_max_requests_reached') { + Assert.isNotUndefined(data.message) + throw new ResponseError(data.message, ERROR_CODES.VALIDATION, status) + } + throw new ResponseError( 'You entered an invalid email.', ERROR_CODES.VALIDATION, From 3cc70929de6e9976c431b725f674f2320afc0625 Mon Sep 17 00:00:00 2001 From: mat-if <97762857+mat-if@users.noreply.github.com> Date: Thu, 19 Jan 2023 12:32:56 -0700 Subject: [PATCH 03/11] fix(cli): faucet service now checks public address validity (#3009) * fix(cli): faucet service now checks public address validity * feat(cli): Process invalid faucet requests as well * rename var for clarity --- ironfish-cli/src/commands/service/faucet.ts | 26 ++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/ironfish-cli/src/commands/service/faucet.ts b/ironfish-cli/src/commands/service/faucet.ts index 171a8a074c..d1480c8d70 100644 --- a/ironfish-cli/src/commands/service/faucet.ts +++ b/ironfish-cli/src/commands/service/faucet.ts @@ -1,7 +1,7 @@ /* 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 { Asset } from '@ironfish/rust-nodejs' +import { Asset, isValidPublicAddress } from '@ironfish/rust-nodejs' import { Meter, PromiseUtils, RpcConnectionError, RpcSocketClient, WebApi } from '@ironfish/sdk' import { Flags } from '@oclif/core' import { IronfishCommand } from '../../command' @@ -126,14 +126,27 @@ export default class Faucet extends IronfishCommand { return } - let faucetTransactions = await api.getNextFaucetTransactions(MAX_RECIPIENTS_PER_TRANSACTION) + const unprocessedFaucetTransactions = await api.getNextFaucetTransactions( + MAX_RECIPIENTS_PER_TRANSACTION, + ) - if (faucetTransactions.length === 0) { + if (unprocessedFaucetTransactions.length === 0) { this.log('No faucet jobs, waiting 5s') await PromiseUtils.sleep(5000) return } + const invalidFaucetTransactions = [] + let faucetTransactions = [] + + for (const transaction of unprocessedFaucetTransactions) { + if (isValidPublicAddress(transaction.public_key)) { + faucetTransactions.push(transaction) + } else { + invalidFaucetTransactions.push(transaction) + } + } + const response = await client.getAccountBalance({ account }) if (BigInt(response.content.confirmed) < BigInt(FAUCET_AMOUNT + FAUCET_FEE)) { @@ -200,5 +213,12 @@ export default class Faucet extends IronfishCommand { for (const faucetTransaction of faucetTransactions) { await api.completeFaucetTransaction(faucetTransaction.id, tx.content.hash) } + + for (const invalidFaucetTransactions of faucetTransactions) { + await api.completeFaucetTransaction( + invalidFaucetTransactions.id, + '000000000000000000000000000000000000000000000000000000000000000', + ) + } } } From e1ff45d5c8b1080b903a458f943f18ee30ea6892 Mon Sep 17 00:00:00 2001 From: omahs <73983677+omahs@users.noreply.github.com> Date: Thu, 19 Jan 2023 20:33:43 +0100 Subject: [PATCH 04/11] Fix: typo (#2990) Fix: typo --- ironfish-cli/src/commands/wallet/send.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ironfish-cli/src/commands/wallet/send.ts b/ironfish-cli/src/commands/wallet/send.ts index b92b4df77c..8cf34c6a39 100644 --- a/ironfish-cli/src/commands/wallet/send.ts +++ b/ironfish-cli/src/commands/wallet/send.ts @@ -129,7 +129,7 @@ export class Send extends IronfishCommand { } if (!to) { - to = await CliUx.ux.prompt('Enter the the public address of the recipient', { + to = await CliUx.ux.prompt('Enter the public address of the recipient', { required: true, }) From 864321425623924fddafe819e977bbec5ed7ae0e Mon Sep 17 00:00:00 2001 From: Hugh Cunningham <57735705+hughy@users.noreply.github.com> Date: Thu, 19 Jan 2023 11:34:46 -0800 Subject: [PATCH 05/11] removes extra ' character in error message (#2994) purely cosmetic change to error text --- ironfish/src/wallet/errors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ironfish/src/wallet/errors.ts b/ironfish/src/wallet/errors.ts index c681c188dc..ca0a87fff8 100644 --- a/ironfish/src/wallet/errors.ts +++ b/ironfish/src/wallet/errors.ts @@ -13,7 +13,7 @@ export class NotEnoughFundsError extends Error { amountNeeded, true, assetId.toString('hex'), - )} but have '${CurrencyUtils.renderIron( + )} but have ${CurrencyUtils.renderIron( amount, )} available to spend. Please fund your account and/or wait for any pending transactions to be confirmed.'` } From e8739f5085a7d79da960b17e2d45797aec22fcb9 Mon Sep 17 00:00:00 2001 From: jowparks Date: Thu, 19 Jan 2023 11:35:23 -0800 Subject: [PATCH 06/11] chore: update NoteEncrypted.merkleHash to NoteEncrypted.hash (#3015) --- ironfish/src/blockchain/blockchain.test.ts | 32 +++++++++---------- ironfish/src/merkletree/hasher.ts | 12 +++---- ironfish/src/merkletree/merkletree.ts | 4 +-- ironfish/src/primitives/noteEncrypted.ts | 2 +- ironfish/src/rpc/routes/chain/followChain.ts | 2 +- ironfish/src/rpc/routes/chain/getBlock.ts | 2 +- ironfish/src/strategy.test.slow.ts | 2 +- ironfish/src/testUtilities/fixtures/blocks.ts | 2 +- ironfish/src/wallet/account.test.ts | 32 +++++++++---------- ironfish/src/wallet/account.ts | 6 ++-- ironfish/src/workerPool/tasks/decryptNotes.ts | 4 +-- 11 files changed, 49 insertions(+), 51 deletions(-) diff --git a/ironfish/src/blockchain/blockchain.test.ts b/ironfish/src/blockchain/blockchain.test.ts index c0074a1ca5..3c4d26fd12 100644 --- a/ironfish/src/blockchain/blockchain.test.ts +++ b/ironfish/src/blockchain/blockchain.test.ts @@ -480,10 +480,10 @@ describe('Blockchain', () => { let addedNoteA2 = (await nodeA.chain.notes.getLeaf(countNoteA + 1)).merkleHash let addedNoteA3 = (await nodeA.chain.notes.getLeaf(countNoteA + 2)).merkleHash let addedNoteA4 = (await nodeA.chain.notes.getLeaf(countNoteA + 3)).merkleHash - expect(addedNoteA1.equals(minersFeeA1.getNote(0).merkleHash())).toBe(true) - expect(addedNoteA2.equals(minersFeeA2.getNote(0).merkleHash())).toBe(true) - expect(addedNoteA3.equals(txA2.getNote(0).merkleHash())).toBe(true) - expect(addedNoteA4.equals(txA2.getNote(1).merkleHash())).toBe(true) + expect(addedNoteA1.equals(minersFeeA1.getNote(0).hash())).toBe(true) + expect(addedNoteA2.equals(minersFeeA2.getNote(0).hash())).toBe(true) + expect(addedNoteA3.equals(txA2.getNote(0).hash())).toBe(true) + expect(addedNoteA4.equals(txA2.getNote(1).hash())).toBe(true) // Check nodeA has nullifiers from blockA2 expect(await nodeA.chain.nullifiers.size()).toBe(countNullifierA + 1) @@ -499,11 +499,11 @@ describe('Blockchain', () => { const addedNoteB3 = (await nodeB.chain.notes.getLeaf(countNoteB + 2)).merkleHash const addedNoteB4 = (await nodeB.chain.notes.getLeaf(countNoteB + 3)).merkleHash const addedNoteB5 = (await nodeB.chain.notes.getLeaf(countNoteB + 4)).merkleHash - expect(addedNoteB1.equals(minersFeeB1.getNote(0).merkleHash())).toBe(true) - expect(addedNoteB2.equals(minersFeeB2.getNote(0).merkleHash())).toBe(true) - expect(addedNoteB3.equals(minersFeeB3.getNote(0).merkleHash())).toBe(true) - expect(addedNoteB4.equals(txB3.getNote(0).merkleHash())).toBe(true) - expect(addedNoteB5.equals(txB3.getNote(1).merkleHash())).toBe(true) + expect(addedNoteB1.equals(minersFeeB1.getNote(0).hash())).toBe(true) + expect(addedNoteB2.equals(minersFeeB2.getNote(0).hash())).toBe(true) + expect(addedNoteB3.equals(minersFeeB3.getNote(0).hash())).toBe(true) + expect(addedNoteB4.equals(txB3.getNote(0).hash())).toBe(true) + expect(addedNoteB5.equals(txB3.getNote(1).hash())).toBe(true) // Check nodeB has nullifiers from blockB3 expect(await nodeB.chain.nullifiers.size()).toBe(countNullifierB + 1) @@ -523,11 +523,11 @@ describe('Blockchain', () => { addedNoteA3 = (await nodeA.chain.notes.getLeaf(countNoteA + 2)).merkleHash addedNoteA4 = (await nodeA.chain.notes.getLeaf(countNoteA + 3)).merkleHash const addedNoteA5 = (await nodeA.chain.notes.getLeaf(countNoteA + 4)).merkleHash - expect(addedNoteA1.equals(minersFeeB1.getNote(0).merkleHash())).toBe(true) - expect(addedNoteA2.equals(minersFeeB2.getNote(0).merkleHash())).toBe(true) - expect(addedNoteA3.equals(minersFeeB3.getNote(0).merkleHash())).toBe(true) - expect(addedNoteA4.equals(txB3.getNote(0).merkleHash())).toBe(true) - expect(addedNoteA5.equals(txB3.getNote(1).merkleHash())).toBe(true) + expect(addedNoteA1.equals(minersFeeB1.getNote(0).hash())).toBe(true) + expect(addedNoteA2.equals(minersFeeB2.getNote(0).hash())).toBe(true) + expect(addedNoteA3.equals(minersFeeB3.getNote(0).hash())).toBe(true) + expect(addedNoteA4.equals(txB3.getNote(0).hash())).toBe(true) + expect(addedNoteA5.equals(txB3.getNote(1).hash())).toBe(true) // Check nodeA's chain has removed blockA2 nullifiers and added blockB3 expect(await nodeA.chain.nullifiers.size()).toBe(countNullifierA + 1) @@ -1312,9 +1312,7 @@ describe('Blockchain', () => { const doubleSpend = await useBlockFixture(node.chain, async () => { // The note to double spend - const note = await account.getDecryptedNote( - mined.transactions[0].getNote(0).merkleHash(), - ) + const note = await account.getDecryptedNote(mined.transactions[0].getNote(0).hash()) Assert.isNotUndefined(note) Assert.isNotNull(note.index) diff --git a/ironfish/src/merkletree/hasher.ts b/ironfish/src/merkletree/hasher.ts index fe3840dc43..cc66f54b24 100644 --- a/ironfish/src/merkletree/hasher.ts +++ b/ironfish/src/merkletree/hasher.ts @@ -30,7 +30,7 @@ export interface MerkleHasher H + hash: (element: E) => H /** * Combine two hashes to get the parent hash @@ -66,8 +66,8 @@ export class NoteHasher return this._merkleNoteHashSerde } - merkleHash(note: NoteEncrypted): Buffer { - return note.merkleHash() + hash(note: NoteEncrypted): Buffer { + return note.hash() } combineHash( @@ -97,7 +97,7 @@ export class ConcatHasher implements MerkleHasher return leftSplit[0] + '-' + rightSplit[rightSplit.length - 1] } - merkleHash(element: string): string { + hash(element: string): string { return element } } @@ -148,7 +148,7 @@ export class StructureHasher implements MerkleHasher` } - merkleHash(element: string): string { + hash(element: string): string { return element } } diff --git a/ironfish/src/merkletree/merkletree.ts b/ironfish/src/merkletree/merkletree.ts index a971a0b13c..8c0b7e7054 100644 --- a/ironfish/src/merkletree/merkletree.ts +++ b/ironfish/src/merkletree/merkletree.ts @@ -207,7 +207,7 @@ export class MerkleTree< */ private async addLeafWithNodes(element: E, tx?: IDatabaseTransaction): Promise { await this.db.withTransaction(tx, async (tx) => { - const merkleHash = this.hasher.merkleHash(element) + const merkleHash = this.hasher.hash(element) const indexOfNewLeaf = await this.getCount('Leaves', tx) let newParentIndex: NodeIndex @@ -579,7 +579,7 @@ export class MerkleTree< */ async contains(value: E, tx?: IDatabaseTransaction): Promise { const currSize = await this.size(tx) - const elementIndex = await this.leavesIndex.get(this.hasher.merkleHash(value), tx) + const elementIndex = await this.leavesIndex.get(this.hasher.hash(value), tx) return elementIndex !== undefined && elementIndex < currSize } diff --git a/ironfish/src/primitives/noteEncrypted.ts b/ironfish/src/primitives/noteEncrypted.ts index 3c51cbb420..89ce607130 100644 --- a/ironfish/src/primitives/noteEncrypted.ts +++ b/ironfish/src/primitives/noteEncrypted.ts @@ -86,7 +86,7 @@ export class NoteEncrypted { } } - merkleHash(): NoteEncryptedHash { + hash(): NoteEncryptedHash { return this._noteCommitment } diff --git a/ironfish/src/rpc/routes/chain/followChain.ts b/ironfish/src/rpc/routes/chain/followChain.ts index 9308f699bb..9d99010c73 100644 --- a/ironfish/src/rpc/routes/chain/followChain.ts +++ b/ironfish/src/rpc/routes/chain/followChain.ts @@ -120,7 +120,7 @@ router.register ({ - commitment: note.merkleHash().toString('hex'), + commitment: note.hash().toString('hex'), })), spends: transaction.spends.map((spend) => ({ nullifier: spend.nullifier.toString('hex'), diff --git a/ironfish/src/rpc/routes/chain/getBlock.ts b/ironfish/src/rpc/routes/chain/getBlock.ts index e2dee0c987..89f9258715 100644 --- a/ironfish/src/rpc/routes/chain/getBlock.ts +++ b/ironfish/src/rpc/routes/chain/getBlock.ts @@ -161,7 +161,7 @@ router.register( const transactions = block.transactions.map((transaction) => { const notes = transaction.notes.map((note) => ({ - commitment: Buffer.from(note.merkleHash()).toString('hex'), + commitment: Buffer.from(note.hash()).toString('hex'), })) const spends = transaction.spends.map((spend) => ({ diff --git a/ironfish/src/strategy.test.slow.ts b/ironfish/src/strategy.test.slow.ts index 5d8ab9b2d4..4d2bbfed55 100644 --- a/ironfish/src/strategy.test.slow.ts +++ b/ironfish/src/strategy.test.slow.ts @@ -246,7 +246,7 @@ describe('Demonstrate the Sapling API', () => { // Get the note we added in the previous example const leaf = await tree.getLeaf(receiverWitnessIndex) const latestNote = new NoteEncrypted(publicTransaction.getNote(0)) - expect(leaf.merkleHash.equals(latestNote.merkleHash())).toBe(true) + expect(leaf.merkleHash.equals(latestNote.hash())).toBe(true) // We should be able to decrypt the note as owned by the receiver const decryptedNote = latestNote.decryptNoteForOwner(receiverKey.incoming_view_key) diff --git a/ironfish/src/testUtilities/fixtures/blocks.ts b/ironfish/src/testUtilities/fixtures/blocks.ts index de4e26aa17..30c8fbf385 100644 --- a/ironfish/src/testUtilities/fixtures/blocks.ts +++ b/ironfish/src/testUtilities/fixtures/blocks.ts @@ -152,7 +152,7 @@ export async function useBlockWithRawTxFixture( notesToSpend.map(async (n) => { const note = n.decryptNoteForOwner(sender.incomingViewKey) Assert.isNotUndefined(note) - const treeIndex = await chain.notes.leavesIndex.get(n.merkleHash()) + const treeIndex = await chain.notes.leavesIndex.get(n.hash()) Assert.isNotUndefined(treeIndex) const witness = await chain.notes.witness(treeIndex) Assert.isNotNull(witness) diff --git a/ironfish/src/wallet/account.test.ts b/ironfish/src/wallet/account.test.ts index 7af8d86951..8597aee53f 100644 --- a/ironfish/src/wallet/account.test.ts +++ b/ironfish/src/wallet/account.test.ts @@ -74,8 +74,8 @@ describe('Accounts', () => { ) expect(noteHashesNotOnChain).toHaveLength(2) - expect(noteHashesNotOnChain).toContainEqual(note1Encrypted.merkleHash()) - expect(noteHashesNotOnChain).toContainEqual(note2Encrypted.merkleHash()) + expect(noteHashesNotOnChain).toContainEqual(note1Encrypted.hash()) + expect(noteHashesNotOnChain).toContainEqual(note2Encrypted.hash()) expect(notesInSequence).toHaveLength(0) expect(notesInSequence2).toHaveLength(0) expect(notesInSequence3).toHaveLength(0) @@ -102,21 +102,21 @@ describe('Accounts', () => { expect(notesInSequence2).toHaveLength(1) expect(notesInSequence2).toContainEqual( expect.objectContaining({ - hash: note1Encrypted.merkleHash(), + hash: note1Encrypted.hash(), }), ) expect(notesInSequence3).toHaveLength(1) expect(notesInSequence3).toContainEqual( expect.objectContaining({ - hash: note2Encrypted.merkleHash(), + hash: note2Encrypted.hash(), }), ) // Check the notes are returned and in order expect(notesInSequence).toHaveLength(2) - expect(notesInSequence[0].hash).toEqual(note1Encrypted.merkleHash()) - expect(notesInSequence[1].hash).toEqual(note2Encrypted.merkleHash()) + expect(notesInSequence[0].hash).toEqual(note1Encrypted.hash()) + expect(notesInSequence[1].hash).toEqual(note2Encrypted.hash()) // And that no notes are returned in a range where there are none await expect(notesInSequenceAfter).resolves.toHaveLength(0) @@ -271,13 +271,13 @@ describe('Accounts', () => { // transaction from A -> A, so all notes belong to A for (const note of transaction.notes) { - const decryptedNote = await accountA.getDecryptedNote(note.merkleHash()) + const decryptedNote = await accountA.getDecryptedNote(note.hash()) expect(decryptedNote).toBeDefined() const nonChainIndex = await accountA['walletDb'].nonChainNoteHashes.get([ accountA.prefix, - note.merkleHash(), + note.hash(), ]) expect(nonChainIndex).toBeDefined() @@ -359,13 +359,13 @@ describe('Accounts', () => { // transaction from A -> A, so all notes belong to A for (const note of transaction.notes) { - const decryptedNote = await accountA.getDecryptedNote(note.merkleHash()) + const decryptedNote = await accountA.getDecryptedNote(note.hash()) expect(decryptedNote).toBeDefined() const nonChainIndex = await accountA['walletDb'].nonChainNoteHashes.get([ accountA.prefix, - note.merkleHash(), + note.hash(), ]) expect(nonChainIndex).toBeUndefined() @@ -374,7 +374,7 @@ describe('Accounts', () => { const sequenceIndex = await accountA['walletDb'].sequenceToNoteHash.get([ accountA.prefix, - [3, note.merkleHash()], + [3, note.hash()], ]) expect(sequenceIndex).toBeDefined() @@ -462,7 +462,7 @@ describe('Accounts', () => { // transaction from A -> A, so all notes belong to A for (const note of transaction.notes) { - const decryptedNote = await accountA.getDecryptedNote(note.merkleHash()) + const decryptedNote = await accountA.getDecryptedNote(note.hash()) expect(decryptedNote).toBeDefined() @@ -470,7 +470,7 @@ describe('Accounts', () => { const sequenceIndex = await accountA['walletDb'].sequenceToNoteHash.get([ accountA.prefix, - [3, note.merkleHash()], + [3, note.hash()], ]) expect(sequenceIndex).toBeDefined() @@ -480,7 +480,7 @@ describe('Accounts', () => { await accountA.disconnectTransaction(block3.header, transaction) for (const note of transaction.notes) { - const decryptedNote = await accountA.getDecryptedNote(note.merkleHash()) + const decryptedNote = await accountA.getDecryptedNote(note.hash()) expect(decryptedNote).toBeDefined() @@ -488,14 +488,14 @@ describe('Accounts', () => { const nonChainIndex = await accountA['walletDb'].nonChainNoteHashes.get([ accountA.prefix, - note.merkleHash(), + note.hash(), ]) expect(nonChainIndex).toBeDefined() const sequenceIndex = await accountA['walletDb'].sequenceToNoteHash.get([ accountA.prefix, - [3, note.merkleHash()], + [3, note.hash()], ]) expect(sequenceIndex).toBeUndefined() diff --git a/ironfish/src/wallet/account.ts b/ironfish/src/wallet/account.ts index c306d5e969..63f319c4a1 100644 --- a/ironfish/src/wallet/account.ts +++ b/ironfish/src/wallet/account.ts @@ -292,7 +292,7 @@ export class Account { } for (const note of transaction.notes) { - const noteHash = note.merkleHash() + const noteHash = note.hash() const decryptedNoteValue = await this.getDecryptedNote(noteHash, tx) if (decryptedNoteValue === undefined) { @@ -439,7 +439,7 @@ export class Account { await this.walletDb.db.withTransaction(tx, async (tx) => { for (const note of transaction.notes) { - await this.deleteDecryptedNote(note.merkleHash(), tx) + await this.deleteDecryptedNote(note.hash(), tx) } for (const spend of transaction.spends) { @@ -657,7 +657,7 @@ export class Account { const notes = [] for (const note of transaction.notes) { - const noteHash = note.merkleHash() + const noteHash = note.hash() const decryptedNote = await this.getDecryptedNote(noteHash) if (decryptedNote) { diff --git a/ironfish/src/workerPool/tasks/decryptNotes.ts b/ironfish/src/workerPool/tasks/decryptNotes.ts index c23d134317..fabd06a439 100644 --- a/ironfish/src/workerPool/tasks/decryptNotes.ts +++ b/ironfish/src/workerPool/tasks/decryptNotes.ts @@ -228,7 +228,7 @@ export class DecryptNotesTask extends WorkerTask { decryptedNotes.push({ index: currentNoteIndex, forSpender: false, - hash: note.merkleHash(), + hash: note.hash(), nullifier: currentNoteIndex !== null ? receivedNote.nullifier(spendingKey, BigInt(currentNoteIndex)) @@ -244,7 +244,7 @@ export class DecryptNotesTask extends WorkerTask { decryptedNotes.push({ index: currentNoteIndex, forSpender: true, - hash: note.merkleHash(), + hash: note.hash(), nullifier: null, serializedNote: spentNote.serialize(), }) From 92c9ccc76a84dde99e6aa5fa5c727aeb6d74fbf0 Mon Sep 17 00:00:00 2001 From: mat-if <97762857+mat-if@users.noreply.github.com> Date: Thu, 19 Jan 2023 13:38:42 -0700 Subject: [PATCH 07/11] fix(napi): upgrade napi version to fix segfault (#3017) --- Cargo.lock | 16 ++++++++-------- ironfish-rust-nodejs/Cargo.toml | 4 ++-- ironfish-rust-nodejs/package.json | 2 +- yarn.lock | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4c09c982cb..5479bc86a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -764,9 +764,9 @@ dependencies = [ [[package]] name = "napi" -version = "2.10.4" +version = "2.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "838b5b414a008e75b97edb3c3e6f189034af789a0608686299b149d3b0e66c39" +checksum = "b60e2bc632f89dad5d47da61591bd468f87f5dbfc85af27aa876772c89d8c4e4" dependencies = [ "bitflags", "ctor", @@ -783,9 +783,9 @@ checksum = "882a73d9ef23e8dc2ebbffb6a6ae2ef467c0f18ac10711e4cc59c5485d41df0e" [[package]] name = "napi-derive" -version = "2.9.3" +version = "2.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4e44e34e70aa61be9036ae652e27c20db5bca80e006be0f482419f6601352a" +checksum = "47bff5a8ed70117bce55053a74ff8f423f90c48c704030609272e6e3bde1c5a4" dependencies = [ "convert_case", "napi-derive-backend", @@ -796,9 +796,9 @@ dependencies = [ [[package]] name = "napi-derive-backend" -version = "1.0.40" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17925fff04b6fa636f8e4b4608cc1a4f1360b64ac8ecbfdb7da1be1dc74f6843" +checksum = "e13b412301aeebee17724fff6d73536e9ecb8387f10bbbf317a9f7a006cc1c5b" dependencies = [ "convert_case", "once_cell", @@ -810,9 +810,9 @@ dependencies = [ [[package]] name = "napi-sys" -version = "2.2.2" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "529671ebfae679f2ce9630b62dd53c72c56b3eb8b2c852e7e2fa91704ff93d67" +checksum = "166b5ef52a3ab5575047a9fe8d4a030cdd0f63c96f071cd6907674453b07bae3" dependencies = [ "libloading", ] diff --git a/ironfish-rust-nodejs/Cargo.toml b/ironfish-rust-nodejs/Cargo.toml index 321d99779a..65ec2b960f 100644 --- a/ironfish-rust-nodejs/Cargo.toml +++ b/ironfish-rust-nodejs/Cargo.toml @@ -17,10 +17,10 @@ crate-type = ["cdylib"] [dependencies] base64 = "0.13.0" ironfish_rust = { path = "../ironfish-rust" } -napi-derive = "2.9.3" +napi-derive = "2.9.5" [dependencies.napi] -version = "2.10.4" +version = "2.10.9" features = ["napi6"] [build-dependencies] diff --git a/ironfish-rust-nodejs/package.json b/ironfish-rust-nodejs/package.json index 923f0883d7..55938ce388 100644 --- a/ironfish-rust-nodejs/package.json +++ b/ironfish-rust-nodejs/package.json @@ -33,7 +33,7 @@ "node": "18.x" }, "devDependencies": { - "@napi-rs/cli": "2.14.1", + "@napi-rs/cli": "2.14.3", "@types/jest": "29.2.4", "jest": "29.3.1", "jest-jasmine2": "29.3.1", diff --git a/yarn.lock b/yarn.lock index ce6def7aca..53d952eb90 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3116,10 +3116,10 @@ "@napi-rs/blake-hash-win32-ia32-msvc" "1.3.1" "@napi-rs/blake-hash-win32-x64-msvc" "1.3.1" -"@napi-rs/cli@2.14.1": - version "2.14.1" - resolved "https://registry.yarnpkg.com/@napi-rs/cli/-/cli-2.14.1.tgz#08cb9573eb1d9a7d5b4a0d7c14ae010cb8e0a9f9" - integrity sha512-+mnge6gvdbOrwtYrBO7iMlTjXcaRk17wDqzxSG4SPBKPhI3HroWY+tRsx+OdluAuRyJZOkWTdsvGnMsGO1ff/A== +"@napi-rs/cli@2.14.3": + version "2.14.3" + resolved "https://registry.yarnpkg.com/@napi-rs/cli/-/cli-2.14.3.tgz#fb2f554aaaf04f4583661b37149a38d9ee1045fc" + integrity sha512-yPc3dXHwynwR815s/7NczYx61wwmkZS1zlzgoVV+KaYJ9qAcd7pRiCZ7n/lBYL9lqUPWFZ7D9QYDn7b6teIsow== "@nodelib/fs.scandir@2.1.5": version "2.1.5" From 1bd861599d6e52dd4e9bd082a209233452500b3b Mon Sep 17 00:00:00 2001 From: mat-if <97762857+mat-if@users.noreply.github.com> Date: Thu, 19 Jan 2023 16:27:00 -0700 Subject: [PATCH 08/11] fix(cli): Fix typo. Fake address should be 64 characters, not 63 (#3021) This probably wouldn't cause any issues, but just in case --- ironfish-cli/src/commands/service/faucet.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ironfish-cli/src/commands/service/faucet.ts b/ironfish-cli/src/commands/service/faucet.ts index d1480c8d70..3e2757bedd 100644 --- a/ironfish-cli/src/commands/service/faucet.ts +++ b/ironfish-cli/src/commands/service/faucet.ts @@ -217,7 +217,7 @@ export default class Faucet extends IronfishCommand { for (const invalidFaucetTransactions of faucetTransactions) { await api.completeFaucetTransaction( invalidFaucetTransactions.id, - '000000000000000000000000000000000000000000000000000000000000000', + '0000000000000000000000000000000000000000000000000000000000000000', ) } } From 6a2cef3823d47222a1630817df1a39c1f46fc711 Mon Sep 17 00:00:00 2001 From: mat-if <97762857+mat-if@users.noreply.github.com> Date: Thu, 19 Jan 2023 16:48:32 -0700 Subject: [PATCH 09/11] fix(ironfish): align default network id for internal and config (#3019) --- ironfish/src/fileStores/config.ts | 3 ++- ironfish/src/fileStores/internal.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ironfish/src/fileStores/config.ts b/ironfish/src/fileStores/config.ts index b6b5e0ad42..7f5fbd6006 100644 --- a/ironfish/src/fileStores/config.ts +++ b/ironfish/src/fileStores/config.ts @@ -15,6 +15,7 @@ export const DEFAULT_USE_RPC_TCP = false export const DEFAULT_USE_RPC_TLS = true export const DEFAULT_POOL_HOST = '0.0.0.0' export const DEFAULT_POOL_PORT = 9034 +export const DEFAULT_NETWORK_ID = 0 export type ConfigOptions = { bootstrapNodes: string[] @@ -384,7 +385,7 @@ export class Config extends KeyStore { feeEstimatorPercentileLow: 10, feeEstimatorPercentileMedium: 20, feeEstimatorPercentileHigh: 30, - networkId: 2, + networkId: DEFAULT_NETWORK_ID, customNetwork: '', maxSyncedAgeBlocks: 60, networkDefinitionPath: files.resolve(files.join(dataDir, 'network.json')), diff --git a/ironfish/src/fileStores/internal.ts b/ironfish/src/fileStores/internal.ts index be8b35f065..3b128217e0 100644 --- a/ironfish/src/fileStores/internal.ts +++ b/ironfish/src/fileStores/internal.ts @@ -2,6 +2,7 @@ * 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 { FileSystem } from '../fileSystems' +import { DEFAULT_NETWORK_ID } from './config' import { KeyStore } from './keyStore' export type InternalOptions = { @@ -17,7 +18,7 @@ export const InternalOptionsDefaults: InternalOptions = { networkIdentity: '', telemetryNodeId: '', rpcAuthToken: '', - networkId: 0, + networkId: DEFAULT_NETWORK_ID, } export class InternalStore extends KeyStore { From 72919f52d3bf5b316fb0c41e080aa2d0238c4225 Mon Sep 17 00:00:00 2001 From: mat-if <97762857+mat-if@users.noreply.github.com> Date: Thu, 19 Jan 2023 18:08:37 -0700 Subject: [PATCH 10/11] fix(ci): dont build windows binary with zig (#3023) --- .github/workflows/build-ironfish-rust-nodejs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-ironfish-rust-nodejs.yml b/.github/workflows/build-ironfish-rust-nodejs.yml index 967e0095fb..263bd43ad3 100644 --- a/.github/workflows/build-ironfish-rust-nodejs.yml +++ b/.github/workflows/build-ironfish-rust-nodejs.yml @@ -62,7 +62,7 @@ jobs: working-directory: ./ironfish-rust-nodejs - name: Build - run: yarn build --zig ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' && '--zig-abi-suffix=2.17' || ''}} --target ${{ matrix.settings.target }} + run: yarn build ${{ matrix.settings.target != 'x86_64-pc-windows-msvc' && '--zig' || '' }} ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' && '--zig-abi-suffix=2.17' || ''}} --target ${{ matrix.settings.target }} working-directory: ./ironfish-rust-nodejs - name: Upload artifact @@ -140,4 +140,4 @@ jobs: - name: Run tests natively if: ${{ !matrix.settings.docker }} run: npm run test:slow - working-directory: ./ironfish-rust-nodejs \ No newline at end of file + working-directory: ./ironfish-rust-nodejs From e25db8fc1e21ccdcf6549b4285fa5e3c18b0fafc Mon Sep 17 00:00:00 2001 From: mat-if <97762857+mat-if@users.noreply.github.com> Date: Thu, 19 Jan 2023 18:09:46 -0700 Subject: [PATCH 11/11] chore: version bump 0.1.62 (#3022) --- ironfish-cli/package.json | 6 +++--- ironfish-rust-nodejs/npm/darwin-arm64/package.json | 2 +- ironfish-rust-nodejs/npm/darwin-x64/package.json | 2 +- ironfish-rust-nodejs/npm/linux-arm64-gnu/package.json | 2 +- ironfish-rust-nodejs/npm/linux-arm64-musl/package.json | 2 +- ironfish-rust-nodejs/npm/linux-x64-gnu/package.json | 2 +- ironfish-rust-nodejs/npm/linux-x64-musl/package.json | 2 +- ironfish-rust-nodejs/npm/win32-x64-msvc/package.json | 2 +- ironfish-rust-nodejs/package.json | 2 +- ironfish/package.json | 4 ++-- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ironfish-cli/package.json b/ironfish-cli/package.json index d6a7dd6495..56d74a3710 100644 --- a/ironfish-cli/package.json +++ b/ironfish-cli/package.json @@ -1,6 +1,6 @@ { "name": "ironfish", - "version": "0.1.61", + "version": "0.1.62", "description": "CLI for running and interacting with an Iron Fish node", "author": "Iron Fish (https://ironfish.network)", "main": "build/src/index.js", @@ -58,8 +58,8 @@ "dependencies": { "@aws-sdk/client-cognito-identity": "3.215.0", "@aws-sdk/client-s3": "3.127.0", - "@ironfish/rust-nodejs": "0.1.22", - "@ironfish/sdk": "0.0.38", + "@ironfish/rust-nodejs": "0.1.23", + "@ironfish/sdk": "0.0.39", "@oclif/core": "1.23.1", "@oclif/plugin-help": "5.1.12", "@oclif/plugin-not-found": "2.3.1", diff --git a/ironfish-rust-nodejs/npm/darwin-arm64/package.json b/ironfish-rust-nodejs/npm/darwin-arm64/package.json index 62f63b252f..2b09fe5c15 100644 --- a/ironfish-rust-nodejs/npm/darwin-arm64/package.json +++ b/ironfish-rust-nodejs/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@ironfish/rust-nodejs-darwin-arm64", - "version": "0.1.22", + "version": "0.1.23", "os": [ "darwin" ], diff --git a/ironfish-rust-nodejs/npm/darwin-x64/package.json b/ironfish-rust-nodejs/npm/darwin-x64/package.json index af13b88ed7..6c895f0ae7 100644 --- a/ironfish-rust-nodejs/npm/darwin-x64/package.json +++ b/ironfish-rust-nodejs/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "@ironfish/rust-nodejs-darwin-x64", - "version": "0.1.22", + "version": "0.1.23", "os": [ "darwin" ], diff --git a/ironfish-rust-nodejs/npm/linux-arm64-gnu/package.json b/ironfish-rust-nodejs/npm/linux-arm64-gnu/package.json index 84801e2913..d0befd5758 100644 --- a/ironfish-rust-nodejs/npm/linux-arm64-gnu/package.json +++ b/ironfish-rust-nodejs/npm/linux-arm64-gnu/package.json @@ -1,6 +1,6 @@ { "name": "@ironfish/rust-nodejs-linux-arm64-gnu", - "version": "0.1.22", + "version": "0.1.23", "os": [ "linux" ], diff --git a/ironfish-rust-nodejs/npm/linux-arm64-musl/package.json b/ironfish-rust-nodejs/npm/linux-arm64-musl/package.json index 86ce6a6ef7..48327486e3 100644 --- a/ironfish-rust-nodejs/npm/linux-arm64-musl/package.json +++ b/ironfish-rust-nodejs/npm/linux-arm64-musl/package.json @@ -1,6 +1,6 @@ { "name": "@ironfish/rust-nodejs-linux-arm64-musl", - "version": "0.1.22", + "version": "0.1.23", "os": [ "linux" ], diff --git a/ironfish-rust-nodejs/npm/linux-x64-gnu/package.json b/ironfish-rust-nodejs/npm/linux-x64-gnu/package.json index 2f200d06df..4f9a1d88a1 100644 --- a/ironfish-rust-nodejs/npm/linux-x64-gnu/package.json +++ b/ironfish-rust-nodejs/npm/linux-x64-gnu/package.json @@ -1,6 +1,6 @@ { "name": "@ironfish/rust-nodejs-linux-x64-gnu", - "version": "0.1.22", + "version": "0.1.23", "os": [ "linux" ], diff --git a/ironfish-rust-nodejs/npm/linux-x64-musl/package.json b/ironfish-rust-nodejs/npm/linux-x64-musl/package.json index c0c46c5fcd..d2f90dac2a 100644 --- a/ironfish-rust-nodejs/npm/linux-x64-musl/package.json +++ b/ironfish-rust-nodejs/npm/linux-x64-musl/package.json @@ -1,6 +1,6 @@ { "name": "@ironfish/rust-nodejs-linux-x64-musl", - "version": "0.1.22", + "version": "0.1.23", "os": [ "linux" ], diff --git a/ironfish-rust-nodejs/npm/win32-x64-msvc/package.json b/ironfish-rust-nodejs/npm/win32-x64-msvc/package.json index b6f8cdc009..1063bcb8a6 100644 --- a/ironfish-rust-nodejs/npm/win32-x64-msvc/package.json +++ b/ironfish-rust-nodejs/npm/win32-x64-msvc/package.json @@ -1,6 +1,6 @@ { "name": "@ironfish/rust-nodejs-win32-x64-msvc", - "version": "0.1.22", + "version": "0.1.23", "os": [ "win32" ], diff --git a/ironfish-rust-nodejs/package.json b/ironfish-rust-nodejs/package.json index 55938ce388..95eea7e6b9 100644 --- a/ironfish-rust-nodejs/package.json +++ b/ironfish-rust-nodejs/package.json @@ -1,6 +1,6 @@ { "name": "@ironfish/rust-nodejs", - "version": "0.1.22", + "version": "0.1.23", "description": "Node.js bindings for Rust code required by the Iron Fish SDK", "main": "index.js", "types": "index.d.ts", diff --git a/ironfish/package.json b/ironfish/package.json index a6ac45ced8..ec429767ac 100644 --- a/ironfish/package.json +++ b/ironfish/package.json @@ -1,6 +1,6 @@ { "name": "@ironfish/sdk", - "version": "0.0.38", + "version": "0.0.39", "description": "SDK for running and interacting with an Iron Fish node", "author": "Iron Fish (https://ironfish.network)", "main": "build/src/index.js", @@ -18,7 +18,7 @@ ], "dependencies": { "@ethersproject/bignumber": "5.7.0", - "@ironfish/rust-nodejs": "0.1.22", + "@ironfish/rust-nodejs": "0.1.23", "@napi-rs/blake-hash": "1.3.1", "axios": "0.21.4", "blru": "0.1.6",