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

v2.5.0 staging to master #5193

wants to merge 81 commits into from

Conversation

patnir
Copy link
Contributor

@patnir patnir commented Aug 1, 2024

Summary

v2.5.0 staging to master

Testing Plan

Documentation

Does this change require any updates to the Iron Fish Docs (ex. the RPC API
Reference
)? If yes, link a
related documentation pull request for the website.

[ ] Yes

Breaking Change

Is this a breaking change? If yes, add notes below on why this is breaking and label it with breaking-change-rpc or breaking-change-sdk.

[ ] Yes

NullSoldier and others added 30 commits June 24, 2024 21:33
This PR changes it so if you're running the wallet inside of the node,
 instead of iterating the chain using the RPC system it'll use the
 chain directly. This is a large performance optimziation when scaanning
 the blockchain.

Co-authored-by: Andrea <[email protected]>
* Introduce optional pagination to ChainProcessor

* Added test
This version brings in optional elliptic curve point multiplication
stats. Not enabled by default but useful for performance analysis.
…ncryption

This commit adds an optional feature (that can be enabled only during
local development) to print the number of cryptographic operations
performed for note decryption and encryption.

This feature is enabled by building `ironfish-rust-nodejs` through `yarn
build:stats`. After doing that, and after starting `ironfish-cli`
through `yarn start <command>`, it is possible to trigger the printing
of the statistics by sending `SIGUSR1` to the CLI process.

This commit has no impact on release builds of Iron Fish.
* Simplify ChainProcessor return logic

We only ever cared if work was done, not that the specific hash was
changed from the original.

* Add test to ensure chain remains stable
makes it explicit that this should be the round 2 secret package
Running `wallet:rescan` when not connected to a node produces output
like the following:

```
Scanning blocks: [░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0% | 60 / 624032 | 0.00 / sec | ETA: N/AAdded block seq: 100, hash: 00000...bd9a1
Scanning blocks: [░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0% | 128 / 624032 | 0.00 / sec | ETA: N/AAdded block seq: 200, hash: 00000...c61b7
Scanning blocks: [░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0% | 282 / 624032 | 0.00 / sec | ETA: N/AAdded block seq: 300, hash: 00000...194db
```

That is: the progress bar output is disrupted by the scanner logs.

This commit suppresses the logs coming from the wallet so that the
progress bar is the only output displayed.
* Make unsignedTransaction flag visible in send command.

* move display transaction summary above raw and unsigned transaction exits
`Job.abort()` sends a `JobAborted` request to the worker.
`Worker.onMessageFromParent()` is able to handle such requests, but
`Worker.parseRequest()` rejects them. Fixed `Worker.parseRequest()` so
that such requests are no longer rejected.

Also fixed `JobAbortedMessage.deserializePayload()` to return the
correct type.
Perform decrypt operations in the background, fully using the worker
threads, while blocks are fetched from the chain db in parallel.
Wallet scans get the blocks/transactions/notes from the chain db. The
chain db contains data that has already been validated in the past (or
that otherwise is assumed to be valid). For this reason, it should be
possible to speed up scans by skipping expensive validation performed
when parsing notes.

More specifically, `NoteEncrypted` parses some elliptic curve points in
compressed form. The regular parsing done through
`jubjub::SubgroupPoint::from_bytes()` involves an expensive check: it
checks whether the uncompressed point belongs to the prime-order
subgroup. This check is perfromed using elliptic curve point
multiplication, which is the most predominant and slowest operation
happening during wallet scans.

Due to this check, for each note, the wallet currently performs two
elliptic curve point multiplications: one to parse the note, another to
attempt the actual decryption. By using `from_bytes_unchecked()` instead
of `from_bytes()` we can skip the first multiplication, effectively
improving note decryption performance by a factor of *almost* 2x.

This change only affects the performance of wallet scans. Note parsing
and decryption outside of a scan is unaffected at the moment. In the
future, we can disable validation in other contexts as we see fit.
This feature will be used to attach signatures to unsigned transactions. The main usecase is to allow the user to sign the transaction offline and then submit it to the network. The offline signing will happen on ledger devices.
This RPC is used to add signature to a transaction. It takes a transaction and a signature as input and returns a signed transaction.
In the case that the records to cleanup is very high, we shouldn't load
all of them in memory before cleaning up. We should only load 1 leveldb
memory block at most. This will ensure if there is a bad feedback loop
this list won't permanently grow and continue to use more memory as it
tries to clean up accounts.

This also ensures that the account record deletion is considered a
record so deleting thousands of empty account cleanup records doesn't
run forever.
* adds ledger utility class

* sorting package.json and using lastest library:

* updating lock
Calling `Wallet.reset()` while a scanning is running can sometimes
result in race conditions. In particular, `WalletScanner` may attempt to
query account heads at the same time while accounts are being reset,
resulting in errors.

This commit fixes the problem by using database transactions (1) while
`WalletScanner` read accounts and (2) while `Wallet.reset()` updates
accounts.

This commit also adds transactions in `Wallet.getEarliestHead()` and
`Wallet.getLatestHead()`. These methods are not used during scanning,
but they suffer from the same kind of problem.

Note that this commit fixes specific race conditions related to getting
the list of accounts to scan, but other race conditions that affect
scanning may still exist.
* Add test for ArrayUtils

* Improve shuffle test

* Improve sample test
when started the Meter class sets an interval to update its underlying arrays.
if the meter is not stopped then this interval will keep running and keep the
meter in the heap and leaks the meter memory.

the WalletScanner creates a new ScanState and a new Meter for each scan. when
the wallet is at the head of the chain this creates a new scan each time a block
is added.

fixes the memory leak by ensuring that the ScanState Meter is stopped when the
scan completes and its interval function is cleared
replaces 'getAccountByPublicAddress' with a more generic 'findAccount' that
takes a predicate

uses findAccount in postTransaction to find the account that has the same public
address and is a spending account

fixes issue where wallet has a spending account and a view only account with the
same public address and cannot post a transaction
```
WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 1)
```
Send to the Docker build daemon the necessary files from the `.git`
directory so that the build scripts can extract the hash of the HEAD
commit.
When importing an account twice, it would not print out the name of the
account with the duplicate spending key. This will now include that in
the message.

It also improves tests to check the error type instead of error message.
We should avoid testing error messages in tests if there is a proper
typed error to check.
NullSoldier and others added 28 commits July 18, 2024 23:36
So we can reuse this in the CLI and make this consistent everywhere.
So we can render these horizontal cards more easily
This new command shows more detailed information specifically about the
blockchain than is shown by node status.
* Add `chain:transactions:info` command

* Use new ui card element
These were duplicated under the wrong file. Must have been due to a
merge issue.
Also implements it for the `chain:blocks:info` command
This flag doesn't quite work as intended, but having missing flags can
sometimes throw compilation errors in certain scenarios. It should throw errors
in all scenarios, but that will be tackled soon.
This makes it so if you tell the RpcTransaction serializer not to
include the serialized format, the notes will also not be included.
This converts a lot of our manually configured card layouts to use our new ui
card element. This simplifies the formatting so we have more consistent, easier
to use card formatting across the CLI.
* Update style guide to document command output info

This should help users figure out how to design the output of their
commands.

* Update ironfish-cli/STYLE_GUIDE.md

Co-authored-by: mat-if <[email protected]>

---------

Co-authored-by: mat-if <[email protected]>
the WalletScanner uses a hash, 'scanFrom', for each account in its
scanningAccounts list to check whether it should decrypt notes for the account.
if scanFrom is null or equal to the previous block hash then notes are decrypted
when connecting a block.

scanFrom is set to the account head when calling refreshScanningAccounts and set
to null when connecting a block if scanFrom is equal to the previous hash.

however, when blocks are disconnected scanFrom is not currently changed. in the
event of a reorg, decryption is skipped when connecting blocks from the fork if
'scanFrom' is still set to the hash of a disconnected block.

regenerates fixtures for test of this behavior and updates disconnectBlock to
set scanFrom to null for all accounts where it is equal to the disconnected
block hash.
* ChainProcessor returns when head is not found

* Added a test

* Fixed lint
* Fix chain:rewind command to properly rewind the wallet

* Fix chain:rewind
)

* Add the ability for CLI commands to track and close an RPC client

With the addition of the JSON changes, which requires us to await on the start
command in the IronfishCommand, commands that used `this.sdk.connectRpc()` were
hanging because the clients were not being closed. This change allows us to
fetch a client from the IronfishCommand directly, which gives the
IronfishCommand the ability to track the client, and close it when the code is
done being ran/executed.

* close connections in the finally block

* remove unneeded return
This should make them not discoverable, but users can use them still.
…5174)

This removes LocalFlags entirely, as well as removing these 3 flags from
RemoteFlags.
This makes chain:power standard and return JSON when you pass in --json
flag and adds the --color flag support as well.
It already returned RpcTransaction with extra fields, so we can
just use the serializer and attach these extra fields.
@patnir patnir requested a review from a team as a code owner August 1, 2024 17:30
@patnir patnir closed this Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants