Skip to content
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

v2.5.0 staging to master #5193

Closed
wants to merge 81 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
8cceace
Have WalletScanner use chain directly if available (#5063) (#5066)
NullSoldier Jun 25, 2024
30bba2f
Introduce optional pagination to ChainProcessor (#5068)
NullSoldier Jun 25, 2024
00c8efd
Update remaining artifact github actions to v4 (#5072)
mat-if Jun 25, 2024
57d21ed
Update our fork of `jubjub` to the latest version
andiflabs Jun 25, 2024
d4d2e1a
Prune the `cargo vet` exemptions
andiflabs Jun 25, 2024
96457b0
Add a development-only feature to print statistics related to notes e…
andiflabs Jun 25, 2024
04fddc5
Simplify ChainProcessor return logic (#5073)
NullSoldier Jun 25, 2024
45ef180
fixes dkg round3 prompt for secret package (#5076)
hughy Jun 25, 2024
a2e2e17
Suppress logs during nodeless wallet rescans
andiflabs Jun 26, 2024
1f27bdb
add ability to create unsigned transaction for mint cli command (#5081)
patnir Jun 27, 2024
64e5737
Add unsigned transaction flag to `wallet:burn` (#5088)
patnir Jun 27, 2024
8059ee9
Make unsignedTransaction flag visible in send command. (#5087)
patnir Jun 27, 2024
0f321c1
DecryptNotes: move the code that groups notes by account from WorkerP…
andiflabs Jun 27, 2024
5483ee5
Fix `Worker` handling of `JobAborted` requests
andiflabs Jun 28, 2024
518c427
Maximize decryption parallelism during wallet scans
andiflabs Jun 17, 2024
bf4472f
Fast construction of `NoteEncrypted` during wallet scans
andiflabs Jun 20, 2024
e62e36c
add_signature to unsigned transaction (#5096)
patnir Jul 1, 2024
8e6dfda
wallet/adSignature: RPC to add signature to a transaction. (#5097)
patnir Jul 1, 2024
e22b3b8
Wallet cleanup should use an iter to load records (#5098)
NullSoldier Jul 2, 2024
82406d9
Add lint rule to not use Promise.race (#5103)
dguenther Jul 2, 2024
37c42fc
adds ledger utility class (#5099)
patnir Jul 2, 2024
2bb8ed2
Prevent race conditions when getting list of accounts during scanning
andiflabs Jun 28, 2024
d24f751
Add test for ArrayUtils (#5102)
NullSoldier Jul 2, 2024
73fc1e0
Move transactions outside of options (#5104)
NullSoldier Jul 3, 2024
50053b0
stops scanState meter on scan completion (#5108)
hughy Jul 3, 2024
1ca1922
update to latest ledger hq version (#5107)
patnir Jul 3, 2024
be16edb
ensures that postTransaction uses a spending account (#5092)
hughy Jul 8, 2024
a8c8c51
Fix a style warning from Docker
andiflabs Jul 8, 2024
2c1b273
Include the git commit hash in Docker images
andiflabs Jul 8, 2024
07810f7
Import duplicate spending key says account name (#5115)
NullSoldier Jul 8, 2024
fbe79db
version bump for v2.4.1 (#5117)
hughy Jul 8, 2024
c80830a
wallet sign command and rpc (#5111)
patnir Jul 9, 2024
88f33b1
import ledger account through cli (#5100)
patnir Jul 9, 2024
e71b18f
Add check for locked ledger device (#5120)
patnir Jul 9, 2024
24dfc3c
Rename Wallet.accounts -> Wallet.accountsById (#5123)
NullSoldier Jul 9, 2024
5fcd314
Add Wallet.accounts property (#5124)
NullSoldier Jul 9, 2024
846f90d
Implement custom CLI table logic (#5118)
mat-if Jul 10, 2024
c02055b
add ledger flag to send command (#5122)
patnir Jul 11, 2024
2e42f19
Use an optimized method for note decryption when multiple accounts ar…
andiflabs Jul 9, 2024
f6439a7
Remove `@types/jest`, and use Jest's own type annotations instead
andiflabs Jul 2, 2024
15b8bb0
Replace ux.prompt for oclif 4.x upgrade prep (#5121)
mat-if Jul 11, 2024
02e4cae
Fast construction of `Transaction` when reading from the chain db
andiflabs Jun 26, 2024
6143c20
Upgrade to oclif 4.x (#5130)
mat-if Jul 11, 2024
9b5d616
Worker pool: use the transfer feature and shared buffers for message …
andiflabs Jul 10, 2024
dad63ba
Use a sparse array in `DecryptNotesResponse`
andiflabs Jul 10, 2024
6207960
Optimize `WalletDB.loadNoteHash()` to avoid hitting the database if t…
andiflabs Jul 12, 2024
fbb0cfe
Renders transaction summary at the end of the sign command. (#5129)
patnir Jul 17, 2024
8f62bbe
Remove chain:show command (#5145)
NullSoldier Jul 18, 2024
12bc990
Make chain:rewind command hidden (#5144)
NullSoldier Jul 18, 2024
910ba36
Delete readd-block command (#5148)
NullSoldier Jul 18, 2024
29b2a80
Move `chain:asset` to `chain:assets:info` (#5147)
mat-if Jul 18, 2024
e7f7090
Move `blocks:show` to `chain:blocks:info` (#5141)
mat-if Jul 18, 2024
0e0e18a
Remove RPC chain/showChain (#5146)
NullSoldier Jul 18, 2024
38fcbff
Make rpc get network power request optional (#5151)
NullSoldier Jul 18, 2024
c957642
Abstract out rendering network name (#5152)
NullSoldier Jul 18, 2024
0a3187f
Add UI card element to CLI (#5153)
NullSoldier Jul 19, 2024
d021340
Add chain:status command (#5150)
NullSoldier Jul 19, 2024
cf0704b
Add `chain:transactions:info` command (#5149)
mat-if Jul 19, 2024
cef7055
Adjust descriptions of chain commands (#5158)
NullSoldier Jul 22, 2024
6051320
Delete dupliacate RPC serializers (#5167)
NullSoldier Jul 23, 2024
c67e561
CLI command: replace unneeded type hacking with built-in ctor propert…
mat-if Jul 23, 2024
904d035
Add ability to use JSON flag with CLI commands (#5163)
mat-if Jul 23, 2024
8b44818
Add missing offline flag (#5169)
mat-if Jul 23, 2024
541660d
Dont serialize rpc notes if not transaction (#5166)
NullSoldier Jul 23, 2024
31b8a02
Convert existing commands to use new ui card (#5160)
mat-if Jul 23, 2024
db33b40
Update style guide to document command output info (#5162)
NullSoldier Jul 23, 2024
04dcfaa
refreshes WalletScanner scanningAccounts on disconnect (#5161)
hughy Jul 23, 2024
65d8f58
ChainProcessor returns when head is not found (#5170)
NullSoldier Jul 24, 2024
fe7f552
Fixes chain:rewind to properly rewind the wallet head (#5173)
NullSoldier Jul 24, 2024
04d941b
Add the ability for CLI commands to track and close an RPC client (#5…
mat-if Jul 24, 2024
44e2c7f
Convert alises to hiddenAlias (#5178)
NullSoldier Jul 24, 2024
105a03e
Add Config, DataDir and Verbose flags as base flags to all commands (…
mat-if Jul 25, 2024
88f16bc
Move the flags in baseFlags into the global category (#5180)
mat-if Jul 26, 2024
0eaa25f
Add mining reward to chain:blocks:info (#5185)
NullSoldier Jul 29, 2024
3c45707
CLI commands: use built-in JSON functionality instead of re-implement…
mat-if Jul 29, 2024
a641103
Have chain:power support --json flag (#5187)
NullSoldier Jul 30, 2024
d154e24
Add json support for chain:assets:info (#5186)
mat-if Jul 30, 2024
d406695
Add --json support for chain:status (#5188)
NullSoldier Jul 30, 2024
79fbe89
Add --json support to chain:transactions:info cmd (#5189)
NullSoldier Jul 30, 2024
c3f6843
Make chain:getTransaction use rpcSerializer (#5190)
NullSoldier Jul 30, 2024
db5ea25
version bump for v2.5 (#5192)
patnir Aug 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy-npm-ironfish-rust-nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: npm install --no-workspaces

- name: Download all artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: ironfish-rust-nodejs/artifacts

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
echo "Runner architecture does not match specified architecture"
exit 1
fi

# needed for distutils, which is used by nodegyp, arm64 mac runners have 3.12
- name: Set up Python
uses: actions/setup-python@v3
Expand Down Expand Up @@ -193,7 +193,7 @@ jobs:
xcrun notarytool submit "${{ steps.set_paths.outputs.zip }}" --keychain-profile "notarytool-profile" --wait

- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ steps.set_paths.outputs.name }}
path: tools/${{ steps.set_paths.outputs.zip }}
Expand Down
22 changes: 21 additions & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ homepage = "https://ironfish.network/"
repository = "https://github.com/iron-fish/ironfish"

[profile.release]
debug = true
debug = true
1 change: 1 addition & 0 deletions config/eslint-config-ironfish/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ module.exports = {
rules: {
'ironfish/no-vague-imports': 'error',
'ironfish/no-buffer-cmp': 'error',
'ironfish/no-promise-race': 'error',

// Catches expressions that aren't assigned
'@typescript-eslint/no-unused-expressions': [
Expand Down
15 changes: 15 additions & 0 deletions config/eslint-plugin-ironfish/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,19 @@ module.exports.rules = {
};
},
},
"no-promise-race": {
create(context) {
return {
MemberExpression: function (node) {
if (node.object.name === 'Promise' && node.property.name === 'race') {
context.report({
node,
message:
"Promise.race leaks memory. You can work around it by using PromiseUtils.split to pass resolve/reject to other Promises. See https://github.com/nodejs/node/issues/17469#issuecomment-685216777 for more details.",
});
}
},
};
},
},
};
2 changes: 1 addition & 1 deletion ironfish-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20-bookworm as build
FROM node:20-bookworm AS build
ENV PATH="/root/.cargo/bin:${PATH}"

RUN \
Expand Down
14 changes: 14 additions & 0 deletions ironfish-cli/STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ However, if prompting is required to complete a command, this means the user wil

## Output

When designing the output for a command, commands should output human readable output and not machine readable output. This means you should use components under the `ui` module such as `card`, `table`, or normal logs. It's fine if you only display a simplified version of the output. If the user needs the full data in machine readable format they can use the `--json` flag.

You can categorize commands in a few ways, and you will design their output differently depending on the purpose of the command. You have output commands (status, chain:blocks:info, wallet:transactions), operation commands (stop, wallet:rename).

### JSON Output

We want to support JSON output in all data commands. This will allow developers to use our CLI for basic automating purposes avoiding the need to set up an HTTP client.

If a command returns data it should have `static enableJsonFlag = true` and return an object with the JSON data in the command. The output JSON will automatically be colorized. See more here, https://oclif.io/docs/json/

It's OK to both return an object and use `log` even if JSON is not enabled. If you need custom logic and don't want to rely on returning the JSON, you can use `jsonEnabled()` and the `ui.json()` component to manually log colorized JSON.

This is not necessary for operation commands that perform actions and quit such as `wallet:rename`.

### Progress

Many commands need to run long running operations. The CLI should not look like it's unresponsive. For example, `ironfish wallet:post` posts a transaction and optionally sends it to the network:
Expand Down
5 changes: 1 addition & 4 deletions ironfish-cli/bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,4 @@ if (Number(process.versions.node.split('.')[0]) < MIN_NODE_VERSION) {
process.exit(1)
}

require('@oclif/core')
.run()
.then(require('@oclif/core/flush'))
.catch(require('@oclif/core/handle'))
require('@oclif/core').execute({ dir: __dirname })
31 changes: 21 additions & 10 deletions ironfish-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ironfish",
"version": "2.4.0",
"version": "2.5.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 All @@ -23,8 +23,9 @@
"node": ">=18"
},
"devDependencies": {
"@oclif/test": "2.1.0",
"@oclif/test": "4.0.4",
"@types/blessed": "0.1.17",
"@types/cli-progress": "3.11.6",
"@types/inquirer": "8.2.5",
"@types/node": "18.11.16",
"@types/tar": "6.1.1",
Expand All @@ -34,7 +35,7 @@
"eslint-plugin-deprecation": "2.0.0",
"jest": "29.7.0",
"jest-jasmine2": "29.7.0",
"oclif": "3.7.2",
"oclif": "4.14.0",
"rimraf": "^3.0.2",
"ts-jest": "29.1.1",
"tsc-watch": "4.2.9",
Expand All @@ -58,15 +59,17 @@
"oclif:version": "oclif readme && git add README.md"
},
"dependencies": {
"@ironfish/rust-nodejs": "2.4.0",
"@ironfish/sdk": "2.4.0",
"@oclif/core": "3.27.0",
"@oclif/plugin-autocomplete": "1.3.10",
"@oclif/plugin-help": "5.1.12",
"@oclif/plugin-not-found": "2.3.1",
"@oclif/plugin-warn-if-update-available": "2.0.40",
"@ironfish/rust-nodejs": "2.5.0",
"@ironfish/sdk": "2.5.0",
"@ledgerhq/hw-transport-node-hid": "6.29.1",
"@oclif/core": "4.0.11",
"@oclif/plugin-autocomplete": "3.1.6",
"@oclif/plugin-help": "6.2.5",
"@oclif/plugin-not-found": "3.2.10",
"@oclif/plugin-warn-if-update-available": "3.1.8",
"@types/keccak": "3.0.4",
"@types/tar": "6.1.1",
"@zondax/ledger-ironfish": "0.1.2",
"axios": "1.7.2",
"bech32": "2.0.0",
"blessed": "0.1.81",
Expand All @@ -77,6 +80,8 @@
"inquirer": "8.2.5",
"json-colorizer": "2.2.2",
"keccak": "3.0.4",
"natural-orderby": "3.0.2",
"string-width": "4.2.3",
"supports-hyperlinks": "2.2.0",
"tar": "6.1.11",
"uuid": "8.3.2"
Expand All @@ -99,6 +104,12 @@
"topics": {
"wallet:scanning": {
"description": "Turn on or off scanning for accounts"
},
"chain:blocks": {
"description": "commands to look at blocks"
},
"chain:assets": {
"description": "commands to look at assets"
}
}
},
Expand Down
8 changes: 7 additions & 1 deletion ironfish-cli/scripts/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ set -euo pipefail
cd "$(dirname "$0")/../.."

cat .gitignore - > .dockerignore <<EOF
# do not send the .git directory to the Docker daemon to make builds faster
# Do not send all the files from the .git directory to the Docker daemon to
# make builds faster. Send only the strictly necessary files/directories to
# make git know the hash of the HEAD.
.git
!.git/HEAD
!.git/refs
!.git/objects
.git/objects/*
EOF

echo "Building Docker Image"
Expand Down
42 changes: 33 additions & 9 deletions ironfish-cli/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import {
InternalOptions,
IronfishSdk,
Logger,
RpcClient,
RpcConnectionError,
} from '@ironfish/sdk'
import { Command, Config } from '@oclif/core'
import { CLIError, ExitError } from '@oclif/core/lib/errors'
import { Command, Config, ux } from '@oclif/core'
import { CLIError, ExitError } from '@oclif/core/errors'
import {
ConfigFlag,
ConfigFlagKey,
DataDirFlag,
DataDirFlagKey,
RpcAuthFlagKey,
RpcHttpHostFlagKey,
Expand All @@ -33,6 +36,7 @@ import {
VerboseFlagKey,
} from './flags'
import { IronfishCliPKG } from './package'
import * as ui from './ui'
import { hasUserResponseError } from './utils'

export type SIGNALS = 'SIGTERM' | 'SIGINT' | 'SIGUSR2'
Expand Down Expand Up @@ -68,16 +72,24 @@ export abstract class IronfishCommand extends Command {
*/
closing = false

client: RpcClient | null = null

public static baseFlags = {
[VerboseFlagKey]: VerboseFlag,
[ConfigFlagKey]: ConfigFlag,
[DataDirFlagKey]: DataDirFlag,
}

constructor(argv: string[], config: Config) {
super(argv, config)
this.logger = createRootLogger().withTag(this.ctor.id)
}

abstract start(): Promise<void> | void
abstract start(): Promise<unknown> | void

async run(): Promise<void> {
async run(): Promise<unknown> {
try {
await this.start()
return await this.start()
} catch (error: unknown) {
if (hasUserResponseError(error)) {
this.log(error.codeMessage)
Expand All @@ -103,16 +115,15 @@ export abstract class IronfishCommand extends Command {
} else {
throw error
}
} finally {
this.client?.close()
}

this.exit(0)
}

async init(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
const commandClass = this.constructor as any
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const { flags } = await this.parse(commandClass)
const { flags } = await this.parse(this.ctor)

// Get the flags from the flag object which is unknown
const dataDirFlag = getFlag(flags, DataDirFlagKey)
Expand Down Expand Up @@ -220,6 +231,19 @@ export abstract class IronfishCommand extends Command {
closeFromSignal(signal: NodeJS.Signals): Promise<unknown> {
throw new Error(`Not implemented closeFromSignal: ${signal}`)
}

// Override the built-in logJson method to implement our own colorizer that
// works with default terminal colors instead of requiring a theme to be
// configured.
logJson(json: unknown): void {
ux.stdout(ui.json(json))
}

async connectRpc(forceLocal = false, forceRemote = false): Promise<RpcClient> {
const client = await this.sdk.connectRpc(forceLocal, forceRemote)
this.client = client
return client
}
}

function getFlag(flags: unknown, flag: FLAGS): unknown {
Expand Down
31 changes: 0 additions & 31 deletions ironfish-cli/src/commands/blocks/show.ts

This file was deleted.

3 changes: 0 additions & 3 deletions ironfish-cli/src/commands/browse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
import { Platform } from '@ironfish/sdk'
import { Flags } from '@oclif/core'
import { IronfishCommand } from '../command'
import { ConfigFlag, ConfigFlagKey, DataDirFlag, DataDirFlagKey } from '../flags'
import { PlatformUtils } from '../utils'

export class BrowseCommand extends IronfishCommand {
static description = `Browse to your data directory`

static flags = {
[ConfigFlagKey]: ConfigFlag,
[DataDirFlagKey]: DataDirFlag,
cd: Flags.boolean({
default: false,
description: 'print the directory where the data directory is',
Expand Down
Loading
Loading