| 
									
										
										
										
											2018-12-11 22:50:42 -08:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # |cargo install| of the top-level crate will not install binaries for | 
					
						
							| 
									
										
										
										
											2018-12-19 10:30:24 -08:00
										 |  |  | # other workspace crates or native program crates. | 
					
						
							| 
									
										
										
										
											2020-10-12 21:19:41 -06:00
										 |  |  | here="$(dirname "$0")" | 
					
						
							| 
									
										
										
										
											2021-04-19 15:05:46 -04:00
										 |  |  | readlink_cmd="readlink" | 
					
						
							|  |  |  | if [[ $OSTYPE == darwin* ]]; then | 
					
						
							|  |  |  |   # Mac OS X's version of `readlink` does not support the -f option, | 
					
						
							|  |  |  |   # But `greadlink` does, which you can get with `brew install coreutils` | 
					
						
							|  |  |  |   readlink_cmd="greadlink" | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | cargo="$("${readlink_cmd}" -f "${here}/../cargo")" | 
					
						
							| 
									
										
										
										
											2020-10-12 21:19:41 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-11 22:50:42 -08:00
										 |  |  | set -e | 
					
						
							| 
									
										
										
										
											2018-12-19 10:30:24 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 07:53:30 -07:00
										 |  |  | usage() { | 
					
						
							|  |  |  |   exitcode=0 | 
					
						
							|  |  |  |   if [[ -n "$1" ]]; then | 
					
						
							|  |  |  |     exitcode=1 | 
					
						
							|  |  |  |     echo "Error: $*" | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  |   cat <<EOF | 
					
						
							| 
									
										
										
										
											2021-04-07 14:45:03 +08:00
										 |  |  | usage: $0 [+<cargo version>] [--debug] [--validator-only] <install directory> | 
					
						
							| 
									
										
										
										
											2019-11-01 07:53:30 -07:00
										 |  |  | EOF | 
					
						
							|  |  |  |   exit $exitcode | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | maybeRustVersion= | 
					
						
							|  |  |  | installDir= | 
					
						
							|  |  |  | buildVariant=release | 
					
						
							|  |  |  | maybeReleaseFlag=--release | 
					
						
							| 
									
										
										
										
											2021-04-07 14:45:03 +08:00
										 |  |  | validatorOnly= | 
					
						
							| 
									
										
										
										
											2019-11-01 07:53:30 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | while [[ -n $1 ]]; do | 
					
						
							|  |  |  |   if [[ ${1:0:1} = - ]]; then | 
					
						
							| 
									
										
										
										
											2020-07-23 15:08:59 -06:00
										 |  |  |     if [[ $1 = --debug ]]; then | 
					
						
							| 
									
										
										
										
											2019-11-01 07:53:30 -07:00
										 |  |  |       maybeReleaseFlag= | 
					
						
							|  |  |  |       buildVariant=debug | 
					
						
							|  |  |  |       shift | 
					
						
							| 
									
										
										
										
											2021-04-07 14:45:03 +08:00
										 |  |  |     elif [[ $1 = --validator-only ]]; then | 
					
						
							|  |  |  |       validatorOnly=true | 
					
						
							|  |  |  |       shift | 
					
						
							| 
									
										
										
										
											2019-11-01 07:53:30 -07:00
										 |  |  |     else | 
					
						
							|  |  |  |       usage "Unknown option: $1" | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |   elif [[ ${1:0:1} = \+ ]]; then | 
					
						
							|  |  |  |     maybeRustVersion=$1 | 
					
						
							|  |  |  |     shift | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     installDir=$1 | 
					
						
							|  |  |  |     shift | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | done | 
					
						
							| 
									
										
										
										
											2019-03-14 19:41:05 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 07:53:30 -07:00
										 |  |  | if [[ -z "$installDir" ]]; then | 
					
						
							|  |  |  |   usage "Install directory not specified" | 
					
						
							| 
									
										
										
										
											2018-12-19 10:30:24 -08:00
										 |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2019-03-14 19:41:05 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 07:53:30 -07:00
										 |  |  | installDir="$(mkdir -p "$installDir"; cd "$installDir"; pwd)" | 
					
						
							| 
									
										
										
										
											2020-01-13 12:53:53 -08:00
										 |  |  | mkdir -p "$installDir/bin/deps" | 
					
						
							| 
									
										
										
										
											2019-08-23 19:31:18 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-13 23:46:21 -07:00
										 |  |  | echo "Install location: $installDir ($buildVariant)" | 
					
						
							| 
									
										
										
										
											2018-12-19 10:30:24 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | cd "$(dirname "$0")"/.. | 
					
						
							| 
									
										
										
										
											2018-12-11 22:50:42 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-13 21:11:09 -08:00
										 |  |  | SECONDS=0 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-17 12:37:41 -07:00
										 |  |  | if [[ $CI_OS_NAME = windows ]]; then | 
					
						
							|  |  |  |   # Limit windows to end-user command-line tools.  Full validator support is not | 
					
						
							|  |  |  |   # yet available on windows | 
					
						
							|  |  |  |   BINS=( | 
					
						
							| 
									
										
										
										
											2021-02-19 09:11:12 -08:00
										 |  |  |     cargo-build-bpf | 
					
						
							|  |  |  |     cargo-test-bpf | 
					
						
							| 
									
										
										
										
											2020-03-17 12:37:41 -07:00
										 |  |  |     solana | 
					
						
							|  |  |  |     solana-install | 
					
						
							|  |  |  |     solana-install-init | 
					
						
							|  |  |  |     solana-keygen | 
					
						
							| 
									
										
										
										
											2020-03-30 18:45:10 -06:00
										 |  |  |     solana-stake-accounts | 
					
						
							| 
									
										
											  
											
												Add solana-tokens (#10011)
* Initial commit
* Execute transfers
* Refactor for testing
* Cleanup readme
* Rewrite
* Cleanup
* Cleanup
* Cleanup client
* Use a Null Client to move prints closer to where messages are sent
* Upgrade Solana
* Move core functionality into its own module
* Handle transaction errors
* Merge allocations
* Fixes
* Cleanup readme
* Fix markdown
* Add example input
* Add integration test - currently fails
* Add integration test
* Add metrics
* Use RpcClient in dry-run, just don't send messages
* More metrics
* Fix dry run with no keys
* Only require one approval if fee-payer is the sender keypair
* Fix bugs
* Don't create the transaction log if nothing to put into it;
  otherwise the next innvocation won't add the header
* Apply previous transactions to allocations with matching recipients
* Bail out of any account already has a balance
* Polish
* Add new 'balances' command
* 9 decimal places
* Add missing file
* Better dry-run; keypair options now optional
* Change field name from 'bid' to 'accepted'
Also, tolerate precision change from 2 decimal places to 4
* Write to transaction log immediately
* Rename allocations_csv to bids_csv
So that we can bypass bids_csv with an allocations CSV file
* Upgrade Solana
* Remove faucet from integration test
* Cleaner integration test
Won't work until this lands and is released:
https://github.com/solana-labs/solana/pull/9717
* Update README
* Add TravicCI script to build and test (#1)
* Add distribute-stake command (#2)
* Distribute -> DistributeTokens (#3)
* Cache cargo deps (#4)
* Add docs (#5)
* Switch to latest Solana 1.1 release (#7)
* distribute -> distribute-tokens (#9)
* Switch from CSV to a pickledb database (#8)
* Switch from CSV to a pickledb database
* Allow PickleDb errors to bubble up
* Dedup
* Hoist db
* Add finalized field to TransactionInfo
* Don't allow RPC client to resign transactions
* Remove dead code
* Use transport::Result
* Record unconfirmed transaction
* Fix: separate stake account per allocation
* Catch transport errors
* Panic if we attempt to replay a transaction that hasn't been finalized
* Attempt to fix CI
PickleDb isn't calling flush() or close() after writing to files.
No issue on MacOS, but looks racy in CI.
* Revert "Attempt to fix CI"
This reverts commit 1632394f636c54402b3578120e8817dd1660e19b.
* Poll for signature before returning
* Add --sol-for-fees option for stake distributions
* Add --allocations-csv option (#14)
* Add allocations-csv option
* Add tests or GTFO
* Apply review feedback
* apply feedback
* Add read_allocations function
* Update arg_parser.rs
* Fix balances command (#17)
* Fix balances command
* Fix readme
* Add --force to transfer to non-empty accounts (#18)
* Add --no-wait (#16)
* Add ThinClient methods to implement --no-wait
* Plumb --no-wait through
No tests yet
* Check transaction status on startup
* Easier to test
* Wait until transaction is finalized before checking if it failed with an error
It's possible that a minority fork thinks it failed.
* Add unit tests
* Remove dead code and rustfmt
* Don't flush database to file if doing a dry-run
* Continue when transactions not yet finalized (#20)
If those transactions are dropped, the next run will execute them.
* Return the number of confirmations (#21)
* Add read_allocations() unit-test (#22)
Delete the copy-pasted top-level test.
Fixes #19
* Add a CSV printer (#23)
* Remove all the copypasta (#24)
* Move resolve_distribute_stake_args into its own function
* Add stake args to token args
* Unify option names
* Move Command::DistributeStake into DistributeTokens
* Remove process_distribute_stake
* Only unique signers
* Use sender keypair to fund new fee-payer accounts
* Unify distribute_tokens and distribute_stake
* Rename print-database command to transaction-log (#25)
* Send all transactions as quickly as possible, then wait (#26)
* Send all transactions as quickly as possible, then wait
* Exit when finalized or blockhashes have expired
* Don't need blockhash in the CSV output
* Better types
CSV library was choking on Pubkey as a type. PickleDb doesn't have that problem.
* Resend if blockhash has not expired
* Attempt to fix CI
* Move log to stderr
* Add constructor, tuck away client (#30)
* Add constructor, tuck away client
* Fix unwrap() caught by CI
* Fix optional option flagged as required
* Bunch of cleanup (#31)
* Remove untested --no-wait feature
* Make --transactions-db an option, not an arg
So that in the future, we can make it optional
* Remove more untested features
Too many false positives in that santity check.  Use --dry-run
instead.
* Add dry-run mode to ThinClient
* Cleaner dry-run
* Make key parameters required
Just don't use them in --dry-run
* Add option to write the transaction log
--dry-run doesn't write to the database. Use this option if you
want a copy of the transaction log before the final run.
* Revert --transaction-log addition
Implement #27 first
* Fix CI
* Update readme
* Fix CI in copypasta
* Sort transaction log by finalized date (#33)
* Make --transaction-db option implicit (#34)
* Move db functionality into its own module (#35)
* Move db functionality into its own module
* Rename tokens module to commands
* Version bump
* Upgrade Solana
* Add solana-tokens to build
* Remove Cargo.lock
* Remove vscode file
* Remove TravisCI build script
* Install solana-tokens
Co-authored-by: Dan Albert <dan@solana.com>
											
										 
											2020-05-13 08:36:30 -06:00
										 |  |  |     solana-tokens | 
					
						
							| 
									
										
										
										
											2020-03-17 12:37:41 -07:00
										 |  |  |   ) | 
					
						
							|  |  |  | else | 
					
						
							| 
									
										
										
										
											2020-03-17 17:03:52 -07:00
										 |  |  |   ./fetch-perf-libs.sh | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-17 12:37:41 -07:00
										 |  |  |   BINS=( | 
					
						
							|  |  |  |     solana | 
					
						
							|  |  |  |     solana-bench-exchange | 
					
						
							|  |  |  |     solana-bench-tps | 
					
						
							|  |  |  |     solana-faucet | 
					
						
							|  |  |  |     solana-gossip | 
					
						
							| 
									
										
										
										
											2020-03-17 13:47:34 -07:00
										 |  |  |     solana-install | 
					
						
							| 
									
										
										
										
											2020-03-17 12:37:41 -07:00
										 |  |  |     solana-keygen | 
					
						
							|  |  |  |     solana-ledger-tool | 
					
						
							|  |  |  |     solana-log-analyzer | 
					
						
							|  |  |  |     solana-net-shaper | 
					
						
							|  |  |  |     solana-sys-tuner | 
					
						
							|  |  |  |     solana-validator | 
					
						
							| 
									
										
										
										
											2021-05-28 13:28:30 +02:00
										 |  |  |     rbpf-cli | 
					
						
							| 
									
										
										
										
											2020-03-17 12:37:41 -07:00
										 |  |  |   ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-07 14:45:03 +08:00
										 |  |  |   # Speed up net.sh deploys by excluding unused binaries | 
					
						
							|  |  |  |   if [[ -z "$validatorOnly" ]]; then | 
					
						
							|  |  |  |     BINS+=( | 
					
						
							|  |  |  |       cargo-build-bpf | 
					
						
							|  |  |  |       cargo-test-bpf | 
					
						
							|  |  |  |       solana-dos | 
					
						
							|  |  |  |       solana-install-init | 
					
						
							|  |  |  |       solana-stake-accounts | 
					
						
							|  |  |  |       solana-test-validator | 
					
						
							|  |  |  |       solana-tokens | 
					
						
							|  |  |  |       solana-watchtower | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-17 12:37:41 -07:00
										 |  |  |   #XXX: Ensure `solana-genesis` is built LAST! | 
					
						
							|  |  |  |   # See https://github.com/solana-labs/solana/issues/5826 | 
					
						
							|  |  |  |   BINS+=(solana-genesis) | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2019-09-06 21:00:24 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-13 23:46:21 -07:00
										 |  |  | binArgs=() | 
					
						
							|  |  |  | for bin in "${BINS[@]}"; do | 
					
						
							|  |  |  |   binArgs+=(--bin "$bin") | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-14 17:02:21 -06:00
										 |  |  | mkdir -p "$installDir/bin" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-13 23:46:21 -07:00
										 |  |  | ( | 
					
						
							|  |  |  |   set -x | 
					
						
							|  |  |  |   # shellcheck disable=SC2086 # Don't want to double quote $rust_version | 
					
						
							| 
									
										
										
										
											2020-10-12 21:19:41 -06:00
										 |  |  |   "$cargo" $maybeRustVersion build $maybeReleaseFlag "${binArgs[@]}" | 
					
						
							| 
									
										
										
										
											2021-04-07 14:45:03 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   # Exclude `spl-token` binary for net.sh builds | 
					
						
							|  |  |  |   if [[ -z "$validatorOnly" ]]; then | 
					
						
							|  |  |  |     # shellcheck disable=SC2086 # Don't want to double quote $rust_version | 
					
						
							|  |  |  |     "$cargo" $maybeRustVersion install spl-token-cli --root "$installDir" | 
					
						
							|  |  |  |   fi | 
					
						
							| 
									
										
										
										
											2019-09-13 23:46:21 -07:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | for bin in "${BINS[@]}"; do | 
					
						
							|  |  |  |   cp -fv "target/$buildVariant/$bin" "$installDir"/bin | 
					
						
							| 
									
										
										
										
											2018-12-13 21:11:09 -08:00
										 |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-26 13:36:51 -07:00
										 |  |  | if [[ -d target/perf-libs ]]; then | 
					
						
							|  |  |  |   cp -a target/perf-libs "$installDir"/bin/perf-libs | 
					
						
							| 
									
										
										
										
											2019-09-19 20:50:34 -07:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-23 12:41:29 -07:00
										 |  |  | mkdir -p "$installDir"/bin/sdk/bpf | 
					
						
							|  |  |  | cp -a sdk/bpf/* "$installDir"/bin/sdk/bpf | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-01 14:02:42 -07:00
										 |  |  | ( | 
					
						
							|  |  |  |   set -x | 
					
						
							| 
									
										
										
										
											2020-09-16 17:46:33 +09:00
										 |  |  |   # deps dir can be empty | 
					
						
							|  |  |  |   shopt -s nullglob | 
					
						
							|  |  |  |   for dep in target/"$buildVariant"/deps/libsolana*program.*; do | 
					
						
							|  |  |  |     cp -fv "$dep" "$installDir/bin/deps" | 
					
						
							|  |  |  |   done | 
					
						
							| 
									
										
										
										
											2020-06-01 14:02:42 -07:00
										 |  |  | ) | 
					
						
							| 
									
										
										
										
											2019-10-31 14:40:54 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-13 21:11:09 -08:00
										 |  |  | echo "Done after $SECONDS seconds" | 
					
						
							| 
									
										
										
										
											2020-06-01 14:02:42 -07:00
										 |  |  | echo | 
					
						
							|  |  |  | echo "To use these binaries:" | 
					
						
							|  |  |  | echo "  export PATH=\"$installDir\"/bin:\"\$PATH\"" |