Skip to content

Commit

Permalink
Merge pull request #2900 from iron-fish/staging
Browse files Browse the repository at this point in the history
STAGING -> MASTER
  • Loading branch information
NullSoldier authored Jan 12, 2023
2 parents 7886c32 + b17f6ae commit d49b13f
Show file tree
Hide file tree
Showing 83 changed files with 1,724 additions and 1,226 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/build-ironfish-rust-nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ jobs:
node-version: '18.12.1'
cache: yarn

- name: Install
uses: actions-rs/toolchain@v1
with:
profile: minimal
target: ${{ matrix.settings.target }}
- name: Install Rust
run: |
rustup target add ${{ matrix.settings.target }}
- name: Install ziglang
uses: goto-bus-stop/setup-zig@v2
Expand Down
41 changes: 16 additions & 25 deletions .github/workflows/rust_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
- "ironfish-zkp/**"
- "rust-toolchain"
- ".github/workflows/rust*"
- ".cargo/**"
- "Cargo*"
push:
branches:
- master
Expand All @@ -15,6 +17,8 @@ on:
- "ironfish-zkp/**"
- "rust-toolchain"
- ".github/workflows/rust*"
- ".cargo/**"
- "Cargo*"

name: Rust CI

Expand All @@ -24,21 +28,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
components: rustfmt, clippy

- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
save-if: false
shared-key: base

- name: Install Cargo tools
run: |
rustup component add rustfmt clippy
- name: Check that cargo lockfile is up to date
uses: actions-rs/cargo@v1
with:
command: check
args: --locked
run: |
cargo check --locked
# Note: ironfish-zkp is does not need this due to different licensing
- name: Check for license headers for ironfish-rust
Expand All @@ -47,28 +50,19 @@ jobs:
- name: Check for license headers for ironfish-rust-nodejs
run: ./ci/lintHeaders.sh ./ironfish-rust-nodejs/src *.rs

# fmt
- uses: actions-rs/cargo@v1
name: "`cargo fmt` check on ironfish-rust"
with:
command: fmt
args: --all -- --check
- name: "`cargo fmt` check on ironfish-rust"
run: |
cargo fmt --all -- --check
# clippy
- uses: actions-rs/cargo@v1
name: "Clippy check on ironfish-rust"
with:
command: clippy
args: --all-targets -- -D warnings
- name: "Clippy check on ironfish-rust"
run: |
cargo clippy --all-targets -- -D warnings
ironfish_rust:
name: Test ironfish-rust
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
components: rustfmt, clippy

- name: Cache Rust
uses: Swatinem/rust-cache@v2
Expand All @@ -95,9 +89,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
components: rustfmt, clippy

- name: Cache Rust
uses: Swatinem/rust-cache@v2
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/rust_ci_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
- "ironfish-zkp/**"
- "rust-toolchain"
- ".github/workflows/rust*"
- ".cargo/**"
- "Cargo*"

name: Cache Rust build

Expand All @@ -18,15 +20,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1

- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
shared-key: nodejs

- name: Build NAPI bindings for the cache
uses: actions-rs/cargo@v1
with:
command: build
args: --release
run: |
cargo build --release
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ If you are working on something in one of these categories, we will not accept y

In case of problems with trying to contribute to Iron Fish, you can contact us:
- On [Github Discussions](https://github.com/iron-fish/ironfish/discussions)
- On [Discord](https://discord.gg/ironfish)
- On [Discord](https://discord.ironfish.network)
- Via [email](mailto:[email protected])
8 changes: 4 additions & 4 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion ironfish-cli/bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ if (process.platform !== 'win32') {
}

if(process.versions.node.split('.')[0] !== '18') {
console.log('NodeJS version ' + process.versions.node + ' is not compatible. Must have node v18.x installed: https://nodejs.org/en/download/')
console.log('NodeJS version ' + process.versions.node + ' is not compatible. Must have Node v18 installed: https://nodejs.org/en/download/')
console.log('After v18 is installed, MAKE SURE TO run `npm install -g ironfish` again to install ironfish with the correct Node version')
process.exit(1)
}

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": "0.1.57",
"version": "0.1.58",
"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 @@ -57,8 +57,8 @@
"dependencies": {
"@aws-sdk/client-cognito-identity": "3.215.0",
"@aws-sdk/client-s3": "3.127.0",
"@ironfish/rust-nodejs": "0.1.20",
"@ironfish/sdk": "0.0.34",
"@ironfish/rust-nodejs": "0.1.21",
"@ironfish/sdk": "0.0.35",
"@oclif/core": "1.23.1",
"@oclif/plugin-help": "5.1.12",
"@oclif/plugin-not-found": "2.3.1",
Expand Down
10 changes: 5 additions & 5 deletions ironfish-cli/src/commands/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export default class Backup extends IronfishCommand {
chain: Flags.boolean({
default: true,
allowNo: true,
description: 'Export the chain DB',
description: 'Backup the chain DB',
}),
accounts: Flags.boolean({
wallet: Flags.boolean({
default: false,
allowNo: true,
description: 'Export the accounts',
description: 'Backup the wallet',
}),
accessKeyId: Flags.string({
char: 'a',
Expand Down Expand Up @@ -96,8 +96,8 @@ export default class Backup extends IronfishCommand {
excludes.push(path.basename(path.dirname(this.sdk.config.chainDatabasePath)))
}

if (!flags.accounts) {
excludes.push(path.basename(path.dirname(this.sdk.config.accountDatabasePath)))
if (!flags.wallet) {
excludes.push(path.basename(path.dirname(this.sdk.config.walletDatabasePath)))
}

await TarUtils.zipDir(source, dest, excludes)
Expand Down
4 changes: 2 additions & 2 deletions ironfish-cli/src/commands/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ export default class Debug extends IronfishCommand {
const output = new Map<string, string>()

const headHashes = new Map<string, Buffer | null>()
for await (const { accountId, headHash } of node.wallet.walletDb.loadHeadHashes()) {
headHashes.set(accountId, headHash)
for await (const { accountId, head } of node.wallet.walletDb.loadHeads()) {
headHashes.set(accountId, head?.hash ?? null)
}

for (const [accountId, headHash] of headHashes.entries()) {
Expand Down
8 changes: 4 additions & 4 deletions ironfish-cli/src/commands/reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class Reset extends IronfishCommand {
let confirmed = flags.confirm

const warningMessage =
`\n/!\\ WARNING: This will permanently delete your accounts. You can back them up by loading the previous version of ironfish and running ironfish export. /!\\\n` +
`\n/!\\ WARNING: This will permanently delete your wallets. You can back them up by loading the previous version of ironfish and running ironfish export. /!\\\n` +
'\nHave you read the warning? (Y)es / (N)o'

confirmed = flags.confirm || (await CliUx.ux.confirm(warningMessage))
Expand All @@ -45,7 +45,7 @@ export default class Reset extends IronfishCommand {
this.exit(0)
}

const accountDatabasePath = this.sdk.config.accountDatabasePath
const walletDatabasePath = this.sdk.config.walletDatabasePath
const chainDatabasePath = this.sdk.config.chainDatabasePath
const hostFilePath: string = this.sdk.config.files.join(
this.sdk.config.dataDir,
Expand All @@ -54,7 +54,7 @@ export default class Reset extends IronfishCommand {

const message =
'\nYou are about to destroy your node databases. The following directories and files will be deleted:\n' +
`\nAccounts: ${accountDatabasePath}` +
`\nWallet: ${walletDatabasePath}` +
`\nBlockchain: ${chainDatabasePath}` +
`\nHosts: ${hostFilePath}` +
`\n\nAre you sure? (Y)es / (N)o`
Expand All @@ -69,7 +69,7 @@ export default class Reset extends IronfishCommand {
CliUx.ux.action.start('Deleting databases...')

await Promise.all([
fsAsync.rm(accountDatabasePath, { recursive: true, force: true }),
fsAsync.rm(walletDatabasePath, { recursive: true, force: true }),
fsAsync.rm(chainDatabasePath, { recursive: true, force: true }),
fsAsync.rm(hostFilePath, { recursive: true, force: true }),
])
Expand Down
19 changes: 10 additions & 9 deletions ironfish-cli/src/commands/service/sync-multi-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { Asset } from '@ironfish/rust-nodejs'
import {
ApiMultiAssetUpload,
BufferUtils,
GENESIS_BLOCK_SEQUENCE,
GetTransactionStreamResponse,
Meter,
Expand Down Expand Up @@ -90,7 +91,7 @@ export default class SyncMultiAsset extends IronfishCommand {
const client = await this.sdk.connectRpc()

this.log(`Fetching head from ${api.host}`)
const head = await api.headMaspTransactions()
const head = await api.headMultiAsset()

let lastCountedSequence: number
if (head) {
Expand All @@ -114,7 +115,7 @@ export default class SyncMultiAsset extends IronfishCommand {
async function commit(): Promise<void> {
const serialized = buffer.map(serializeMultiAssets)
buffer.length = 0
await api.uploadMaspTransactions(serialized)
await api.uploadMultiAsset(serialized)
}

for await (const content of response.contentStream()) {
Expand Down Expand Up @@ -155,7 +156,7 @@ export default class SyncMultiAsset extends IronfishCommand {
async syncRandom(api: WebApi): Promise<void> {
// eslint-disable-next-line no-constant-condition
while (true) {
const headHash = (await api.headMaspTransactions()) || ''
const headHash = (await api.headMultiAsset()) || ''

const choices: MultiAssetTypes[] = [
'MULTI_ASSET_TRANSFER',
Expand All @@ -164,7 +165,7 @@ export default class SyncMultiAsset extends IronfishCommand {
]
const choice = choices[Math.floor(Math.random() * choices.length)]
const connectedblockHash = uuid()
await api.uploadMaspTransactions([
await api.uploadMultiAsset([
{
type: 'connected',
block: {
Expand All @@ -184,7 +185,7 @@ export default class SyncMultiAsset extends IronfishCommand {
await PromiseUtils.sleep(5000)
if (Math.floor(Math.random() * 2) === 0) {
// randomly disconnect blocks
await api.uploadMaspTransactions([
await api.uploadMultiAsset([
{
type: 'disconnected',
block: {
Expand All @@ -205,27 +206,27 @@ export default class SyncMultiAsset extends IronfishCommand {
function serializeMultiAssets(data: GetTransactionStreamResponse): ApiMultiAssetUpload {
const txs = []
// should not send transactions if block is disconnected
if (data.type !== 'connected') {
if (data.type === 'connected') {
for (const tx of data.transactions) {
const multiAssets = []
for (const mint of tx.mints) {
multiAssets.push({
type: 'MULTI_ASSET_MINT' as MultiAssetTypes,
assetName: mint.assetName,
assetName: BufferUtils.toHuman(Buffer.from(mint.assetName, 'hex')),
})
}
for (const burn of tx.burns) {
multiAssets.push({
type: 'MULTI_ASSET_BURN' as MultiAssetTypes,
assetName: burn.assetName,
assetName: BufferUtils.toHuman(Buffer.from(burn.assetName, 'hex')),
})
}
for (const note of tx.notes) {
// standard notes should not be included
if (note.assetId !== Asset.nativeId().toString('hex')) {
multiAssets.push({
type: 'MULTI_ASSET_TRANSFER' as MultiAssetTypes,
assetName: note.assetName,
assetName: BufferUtils.toHuman(Buffer.from(note.assetName, 'hex')),
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions ironfish-cli/src/commands/wallet/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class BalanceCommand extends IronfishCommand {
const response = await client.getAccountBalance({
account,
assetId: flags.assetId,
minimumBlockConfirmations: flags.confirmations,
confirmations: flags.confirmations,
})
const assetId = response.content.assetId

Expand Down Expand Up @@ -99,7 +99,7 @@ export class BalanceCommand extends IronfishCommand {
this.log(
`${response.unconfirmedCount} notes worth ${CurrencyUtils.renderIron(
unconfirmedDelta,
)} are on the chain within ${response.minimumBlockConfirmations.toString()} blocks of the head`,
)} are on the chain within ${response.confirmations.toString()} blocks of the head`,
)
this.log(`Unconfirmed: ${CurrencyUtils.renderIron(unconfirmed, true, assetId)}`)
}
Expand Down
Loading

0 comments on commit d49b13f

Please sign in to comment.