Skip to content

Commit

Permalink
Merge pull request #4133 from iron-fish/staging
Browse files Browse the repository at this point in the history
STAGING -> MASTER
  • Loading branch information
dguenther authored Aug 1, 2023
2 parents e5551dc + d15aabb commit b240df1
Show file tree
Hide file tree
Showing 194 changed files with 11,947 additions and 3,138 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/publish-binaries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Build @ironfish binaries

on:
release:
types:
- published

jobs:
build:
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
arch: x86_64
system: apple

- host: windows-latest
arch: x86_64
system: windows

# requires 20.04 because ironfish depends on openssl 1.1.1, new ubuntu only allows 3.x
- host: ubuntu-20.04
arch: x86_64
system: linux

- host: [self-hosted, macOS, ARM64]
arch: arm64
system: apple

# currently no way to build arm64
# - host: ubuntu-20.04
# arch: aarch64
# system: linux


# - host: ubuntu-20.04
# target: aarch64-apple-darwin

name: Build ${{ matrix.settings.system }} ${{ matrix.settings.arch }}
runs-on: ${{ matrix.settings.host }}
steps:

- name: clean selfhosted node_modules
if: matrix.settings.system == 'apple' && matrix.settings.arch == 'arm64'
run: |
cd $GITHUB_WORKSPACE
find . -name . -o -prune -exec rm -rf -- {} +
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.12.1'

- name: npm init
run: npm init -y

- name: install dependencies
run: npm install ironfish [email protected]

- name: caxa package
id: caxa
run: |
npx caxa --uncompression-message "Running the CLI for the first time may take a while, please wait..." --input . --output "${{ matrix.settings.system != 'windows' && 'ironfish' || 'ironfish.exe' }}" -- "{{caxa}}/node_modules/.bin/node" "--enable-source-maps" "{{caxa}}/node_modules/ironfish/bin/run"
echo "RELEASE_NAME=ironfish-${{ matrix.settings.system }}-${{ matrix.settings.arch }}-${{ github.event.release.tag_name }}.zip"
- name: set paths
id: set_paths
shell: bash
run: |
echo "zip=ironfish-${{ matrix.settings.system }}-${{ matrix.settings.arch }}-${{ github.event.release.tag_name }}.zip" >> $GITHUB_OUTPUT
echo "binary=${{ matrix.settings.system != 'windows' && 'ironfish' || 'ironfish.exe' }}" >> $GITHUB_OUTPUT
- name: chmod binary
if: matrix.settings.system != 'windows'
run: chmod +x ${{ steps.set_paths.outputs.binary }}

- name: Zip binary
uses: thedoctor0/[email protected]
with:
type: 'zip'
filename: ${{ steps.set_paths.outputs.zip }}
path: ${{ steps.set_paths.outputs.binary }}

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: "${{ github.event.release.upload_url }}?name=${{ steps.set_paths.outputs.zip }}"
asset_path: ${{ steps.set_paths.outputs.zip }}
asset_name: ${{ steps.set_paths.outputs.zip }}
asset_content_type: application/zip
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions benchmarks/benches/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use ironfish::{
assets::{asset::Asset, asset_identifier::NATIVE_ASSET},
test_util::make_fake_witness,
transaction::batch_verify_transactions,
transaction::{batch_verify_transactions, verify_transaction},
Note, ProposedTransaction, SaplingKey, Transaction,
};

Expand Down Expand Up @@ -101,7 +101,7 @@ pub fn verify(c: &mut Criterion) {
},
// Benchmark
|tx| {
tx.verify().unwrap();
verify_transaction(&tx).unwrap();
},
BatchSize::LargeInput,
);
Expand Down
6 changes: 3 additions & 3 deletions ironfish-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ironfish",
"version": "1.6.0",
"version": "1.7.0",
"description": "CLI for running and interacting with an Iron Fish node",
"author": "Iron Fish <[email protected]> (https://ironfish.network)",
"main": "build/src/index.js",
Expand Down Expand Up @@ -59,8 +59,8 @@
"@aws-sdk/client-s3": "3",
"@aws-sdk/client-secrets-manager": "3",
"@aws-sdk/s3-request-presigner": "3",
"@ironfish/rust-nodejs": "1.5.0",
"@ironfish/sdk": "1.6.0",
"@ironfish/rust-nodejs": "1.6.0",
"@ironfish/sdk": "1.7.0",
"@oclif/core": "1.23.1",
"@oclif/plugin-help": "5.1.12",
"@oclif/plugin-not-found": "2.3.1",
Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/chain/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class Asset extends IronfishCommand {

this.log(`Name: ${BufferUtils.toHuman(Buffer.from(data.content.name, 'hex'))}`)
this.log(`Metadata: ${BufferUtils.toHuman(Buffer.from(data.content.metadata, 'hex'))}`)
this.log(`Owner: ${data.content.owner}`)
this.log(`Creator: ${data.content.creator}`)
this.log(`Supply: ${data.content.supply}`)
this.log(`Identifier: ${data.content.id}`)
this.log(`Transaction Created: ${data.content.createdTransactionHash}`)
Expand Down
4 changes: 2 additions & 2 deletions ironfish-cli/src/commands/chain/benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ export default class Benchmark extends IronfishCommand {
if (endingHeader.noteSize === null) {
return this.error(`Header should have a noteSize`)
}
const nodeNotesHash = await node.chain.notes.pastRoot(endingHeader.noteSize)
const tempNodeNotesHash = await tempNode.chain.notes.rootHash()
const nodeNotesHash = await node.chain.getNotesPastRoot(endingHeader.noteSize)
const tempNodeNotesHash = await tempNode.chain.getNotesRootHash()
if (!nodeNotesHash.equals(tempNodeNotesHash)) {
throw new Error('/!\\ Note tree hashes were not consistent /!\\')
}
Expand Down
12 changes: 6 additions & 6 deletions ironfish-cli/src/commands/chain/repair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ export default class RepairChain extends IronfishCommand {
Assert.isNotNull(node.chain.head)

CliUx.ux.action.start('Clearing hash to next hash table')
await node.chain.hashToNextHash.clear()
await node.chain.clearHashToNextHash()
CliUx.ux.action.stop()

CliUx.ux.action.start('Clearing Sequence to hash table')
await node.chain.sequenceToHash.clear()
await node.chain.clearSequenceToHash()
CliUx.ux.action.stop()

const total = Number(node.chain.head.sequence)
Expand All @@ -105,8 +105,8 @@ export default class RepairChain extends IronfishCommand {
})

while (head && head.sequence > BigInt(0)) {
await node.chain.sequenceToHash.put(head.sequence, head.hash)
await node.chain.hashToNextHash.put(head.previousBlockHash, head.hash)
await node.chain.putSequenceToHash(head.sequence, head.hash)
await node.chain.putNextHash(head.previousBlockHash, head.hash)

head = await node.chain.getHeader(head.previousBlockHash)

Expand All @@ -130,7 +130,7 @@ export default class RepairChain extends IronfishCommand {
): Promise<void> {
Assert.isNotNull(node.chain.head)

const noNotes = (await node.chain.notes.size()) === 0
const noNotes = (await node.chain.getNotesSize()) === 0
const noNullifiers = (await node.chain.nullifiers.size()) === 0
const headBlock = await node.chain.getBlock(node.chain.head)
Assert.isNotNull(headBlock)
Expand All @@ -155,7 +155,7 @@ export default class RepairChain extends IronfishCommand {
const noteSize = prev && prev.noteSize !== null ? prev.noteSize : 0

CliUx.ux.action.start('Clearing notes MerkleTree')
await node.chain.notes.truncate(noteSize)
await node.chain.truncateNotes(noteSize)
CliUx.ux.action.stop()

CliUx.ux.action.start('Clearing nullifier set')
Expand Down
4 changes: 2 additions & 2 deletions ironfish-cli/src/commands/repl.ts
Original file line number Diff line number Diff line change
@@ -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 { NodeUtils, RpcMemoryClient } from '@ironfish/sdk'
import { ALL_API_NAMESPACES, NodeUtils, RpcMemoryClient } from '@ironfish/sdk'
import { Flags } from '@oclif/core'
import fs from 'fs/promises'
import repl from 'node:repl'
Expand Down Expand Up @@ -33,7 +33,7 @@ export default class Repl extends IronfishCommand {
const { flags } = await this.parse(Repl)

const node = await this.sdk.node()
const client = new RpcMemoryClient(this.logger, node)
const client = new RpcMemoryClient(this.logger, node.rpc.getRouter(ALL_API_NAMESPACES))

if (flags.opendb) {
await NodeUtils.waitForOpen(node)
Expand Down
4 changes: 1 addition & 3 deletions ironfish-cli/src/commands/service/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ export default class Sync extends IronfishCommand {
this.log(`Starting from head ${head}`)
}

const response = client.chain.followChainStream({
head: head,
})
const response = client.chain.followChainStream(head ? { head } : undefined)

const speed = new Meter()
speed.start()
Expand Down
4 changes: 2 additions & 2 deletions ironfish-cli/src/commands/wallet/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ export class AssetsCommand extends IronfishCommand {
minWidth: 16,
get: (row) => row.supply ?? 'NULL',
},
owner: {
header: 'Owner',
creator: {
header: 'Creator',
minWidth: PUBLIC_ADDRESS_LENGTH + 1,
},
},
Expand Down
18 changes: 16 additions & 2 deletions ironfish-cli/src/commands/wallet/burn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class Burn extends IronfishCommand {
const asset = await selectAsset(client, account, {
action: 'burn',
showNativeAsset: false,
showNonOwnerAsset: true,
showNonCreatorAsset: true,
showSingleAssetChoice: true,
confirmations: flags.confirmations,
})
Expand Down Expand Up @@ -191,7 +191,21 @@ export class Burn extends IronfishCommand {

CliUx.ux.action.stop()

const assetResponse = await client.chain.getAsset({ id: assetId })
if (response.content.accepted === false) {
this.warn(
`Transaction '${transaction.hash().toString('hex')}' was not accepted into the mempool`,
)
}

if (response.content.broadcasted === false) {
this.warn(`Transaction '${transaction.hash().toString('hex')}' failed to broadcast`)
}

const assetResponse = await client.wallet.getAsset({
account,
id: assetId,
confirmations: flags.confirmations,
})
const assetName = BufferUtils.toHuman(Buffer.from(assetResponse.content.name, 'hex'))

this.log(`Burned asset ${assetName} from ${account}`)
Expand Down
12 changes: 11 additions & 1 deletion ironfish-cli/src/commands/wallet/mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class Mint extends IronfishCommand {
const asset = await selectAsset(client, account, {
action: 'mint',
showNativeAsset: false,
showNonOwnerAsset: false,
showNonCreatorAsset: false,
showSingleAssetChoice: true,
confirmations: flags.confirmations,
})
Expand Down Expand Up @@ -233,6 +233,16 @@ export class Mint extends IronfishCommand {

const minted = transaction.mints[0]

if (response.content.accepted === false) {
this.warn(
`Transaction '${transaction.hash().toString('hex')}' was not accepted into the mempool`,
)
}

if (response.content.broadcasted === false) {
this.warn(`Transaction '${transaction.hash().toString('hex')}' failed to broadcast`)
}

this.log(`Minted asset ${BufferUtils.toHuman(minted.asset.name())} from ${account}`)
this.log(`Asset Identifier: ${minted.asset.id().toString('hex')}`)
this.log(
Expand Down
10 changes: 10 additions & 0 deletions ironfish-cli/src/commands/wallet/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ export class PostCommand extends IronfishCommand {

const posted = new Transaction(Buffer.from(response.content.transaction, 'hex'))

if (response.content.accepted === false) {
this.warn(
`Transaction '${posted.hash().toString('hex')}' was not accepted into the mempool`,
)
}

if (response.content.broadcasted === false) {
this.warn(`Transaction '${posted.hash().toString('hex')}' failed to broadcast`)
}

this.log(`Posted transaction with hash ${posted.hash().toString('hex')}\n`)
this.log(response.content.transaction)

Expand Down
12 changes: 11 additions & 1 deletion ironfish-cli/src/commands/wallet/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class Send extends IronfishCommand {
const asset = await selectAsset(client, from, {
action: 'send',
showNativeAsset: true,
showNonOwnerAsset: true,
showNonCreatorAsset: true,
showSingleAssetChoice: false,
confirmations: flags.confirmations,
})
Expand Down Expand Up @@ -229,6 +229,16 @@ export class Send extends IronfishCommand {

CliUx.ux.action.stop()

if (response.content.accepted === false) {
this.warn(
`Transaction '${transaction.hash().toString('hex')}' was not accepted into the mempool`,
)
}

if (response.content.broadcasted === false) {
this.warn(`Transaction '${transaction.hash().toString('hex')}' failed to broadcast`)
}

this.log(`Sent ${CurrencyUtils.renderIron(amount, true, assetId)} to ${to} from ${from}`)
this.log(`Hash: ${transaction.hash().toString('hex')}`)
this.log(`Fee: ${CurrencyUtils.renderIron(transaction.fee(), true)}`)
Expand Down
6 changes: 3 additions & 3 deletions ironfish-cli/src/utils/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export async function selectAsset(
options: {
action: string
showNativeAsset: boolean
showNonOwnerAsset: boolean
showNonCreatorAsset: boolean
showSingleAssetChoice: boolean
confirmations?: number
},
Expand All @@ -97,12 +97,12 @@ export async function selectAsset(
balances = balances.filter((b) => b.assetId !== Asset.nativeId().toString('hex'))
}

if (!options.showNonOwnerAsset) {
if (!options.showNonCreatorAsset) {
const accountResponse = await client.wallet.getAccountPublicKey({
account: account,
})

balances = balances.filter((b) => b.assetOwner === accountResponse.content.publicKey)
balances = balances.filter((b) => b.assetCreator === accountResponse.content.publicKey)
}

if (balances.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion ironfish-cli/src/utils/fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function selectFee(options: {
confirmations?: number
logger: Logger
}): Promise<RawTransaction> {
const feeRates = await options.client.chain.estimateFeeRates()
const feeRates = await options.client.wallet.estimateFeeRates()

const [slow, average, fast] = [
await getTxWithFee(
Expand Down
2 changes: 1 addition & 1 deletion ironfish-phase2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.2.2"
authors = ["Sean Bowe <[email protected]>", "Iron Fish <[email protected]> (https://ironfish.network)"]
description = "Library for performing MPCs for creating zk-SNARK public parameters"
homepage = "https://github.com/iron-fish/ironfish"
license = "MIT/Apache-2.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/iron-fish/ironfish"

publish = false
Expand Down
Loading

0 comments on commit b240df1

Please sign in to comment.