-
Notifications
You must be signed in to change notification settings - Fork 23
cli: various improvements #393
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
Conversation
| if pool_and_vote_addresses.len() > 100 { | ||
| return Err( | ||
| "Displaying more than 100 pools is not implemented; if you see \ | ||
| this error, feel free to open an issue in the SVSP repo." | ||
| .into(), | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getMultipleAccounts limit. mainnet has 40-something pools, so it wont be relevant for awhile. ill probably do the >100 chuncking and the onramp support in display at the same time, the two of them will make it complicated enough ill refactor all this stuff into its own module
| let token_amount = if let Some(amount) = self.token_amount { | ||
| &amount.to_string() | ||
| } else { | ||
| "(cannot display in simulation)" | ||
| }; | ||
| writeln_name_value(f, "Token amount:", token_amount)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after we upgrade to 3.0 (i want to do a final 2.2 program release first though) we should be able to get this off the collected balances
|
|
||
| // make clients | ||
| let rpc_client = Arc::new(validator.get_async_rpc_client()); | ||
| let program_client: PClient = Arc::new(ProgramRpcClient::new( | ||
| rpc_client.clone(), | ||
| ProgramRpcClientSendTransaction, | ||
| // make client | ||
| let rpc_client = Arc::new(RpcClient::new_with_commitment( | ||
| validator.rpc_url(), | ||
| CommitmentConfig::confirmed(), | ||
| )); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed ProgramClient from tests just because we dont need it. planning on dropping token client from the cli itself when i do the 3.0 upgrade
| loop { | ||
| let epoch_info = rpc_client.get_epoch_info().await.unwrap(); | ||
| if epoch_info.epoch > current_epoch { | ||
| if epoch_info.epoch > current_epoch && epoch_info.slot_index > 0 { | ||
| return epoch_info.epoch; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a frustrating but ultimately funny debugging experience, i was going nuts trying to figure out how my command_deposit() refactor introduced stake program error 10 (VoteAddressMismatch) in some tests and it took longer than id like to admit to notice it was actually error 0x10 (EpochRewardsActive)
i think something i changed made it slightly faster: before, by time the test transaction executed, a slot had already elapsed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof, that sounds frustrating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not important but i realized it was definitely the --dry-run fix, we used to create the ata in its own transaction which delayed enough to advance the slot, now we just prepend it to the deposit transaction
joncinque
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me! Just some tiny nits which you can take, leave, or fix in another PR
README.md
Outdated
| with: | ||
|
|
||
| ```console | ||
| solana-verify build --library-name program |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the build works with this command, but in my testing and looking at the source code, I think --library-name takes the crate name:
| solana-verify build --library-name program | |
| solana-verify build --library-name spl_single_pool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im not sure what you mean by "the build works with this command [but] --library-name takes the crate name." like both work but the latter is preferred for style? ive always built by giving it program
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that it'll build the program, but the CLI code is expecting spl_single_pool as the input, to show the build hash afterwards
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats funny, im definitely not the only one because ive had people ask about the parse error solana-verify gives at the end and been like "oh dont worry it just does that for some reason, the build still worked"
| loop { | ||
| let epoch_info = rpc_client.get_epoch_info().await.unwrap(); | ||
| if epoch_info.epoch > current_epoch { | ||
| if epoch_info.epoch > current_epoch && epoch_info.slot_index > 0 { | ||
| return epoch_info.epoch; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof, that sounds frustrating
| let output = Command::new(SVSP_CLI) | ||
| .args(["display", "-C", &env.config_file_path, "--all", "--verbose"]) | ||
| .output() | ||
| .unwrap(); | ||
| assert!(output.status.success()); | ||
|
|
||
| let stdout = String::from_utf8_lossy(&output.stdout); | ||
| let pools = stdout | ||
| .lines() | ||
| .filter(|line| line.starts_with(" Pool address:")) | ||
| .count(); | ||
| assert_eq!(pools, 3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: up to you, but since this part is checking the --verbose flag, do you want to check for an additional output not part of the normal display command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clients/cli/Cargo.toml
Outdated
| solana-transaction = "2.2" | ||
| solana-transaction-status = "2.3.4" | ||
| solana-vote-program = "2.2" | ||
| spl-associated-token-account = { version = "7.0", features = ["no-entrypoint"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: not a big deal since this is a CLI crate, but spl-associated-token-account-interface has what you need with fewer deps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let stake_addresses = pool_and_vote_addresses | ||
| .iter() | ||
| .map(|(pool_address, _)| find_pool_stake_address(&spl_single_pool::id(), pool_address)) | ||
| .collect::<Vec<_>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the idea to add the onramp accounts here in the future when the onramp account will be integrated into more instructions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i was imagining doing it in another pr later. i havent decided how to present the onramp info yet since onramp stake is disregarded for token accounted but i want to do a v2 of token math soon-ish
joncinque
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me!
display --allnow performs 4 total rpc calls total instead of 1 + (3 * number of pools)display --verbosedeposit --dry-run--dry-runinitializeProgramClientfrom testsdisplay --allpart of #118
closes #119
closes #143
closes #234
closes #392