Compare commits

...

496 Commits

Author SHA1 Message Date
50ebc3f4d8 Add fixed tick rate adjustment (#14447) (#14458)
(cherry picked from commit c282586753)

Co-authored-by: sakridge <sakridge@gmail.com>
2021-01-06 04:47:13 +00:00
599f5a16b2 Enable program-id account index for supply calculations (#14444) (#14455)
* Enable program-id account index for supply calculations

* Fixup comments

(cherry picked from commit ce1766d798)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2021-01-06 04:12:48 +00:00
d916a16115 Save 7G mem on mainnet fixing AccIndex overalloc. (#14435) (#14451)
(cherry picked from commit c9df6134fa)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2021-01-06 03:43:04 +00:00
d44d8e929b Bump serum-dex pegged commit (#14448) (#14453)
(cherry picked from commit d2b0fd973f)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2021-01-05 18:59:50 -07:00
f05347f549 Introduce rpc url monikers for cli (#14409) (#14432)
* Introduce rpc url monikers for cli

* Use https:// and support initials as well

(cherry picked from commit 54a5876c48)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2021-01-05 12:28:07 +00:00
56acbcdf5f Improve solana catchup (#14313) (#14423)
* Improve solana catchup

* Overidable port, retry, args error clean up

* print cleanup

* Reduce diff

* Tweak warns a bit

(cherry picked from commit aa4da339ff)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2021-01-05 02:53:38 +00:00
c083661a6b Fix pre-merge old name in the docs (#14425) (#14426)
(cherry picked from commit 974eb6e1ef)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2021-01-05 02:53:24 +00:00
b8d3800f57 Add try_find_program_address syscall (bp #14118) (#14421)
* Add try_find_program_address syscall (#14118)

(cherry picked from commit ab98c1f2d4)

# Conflicts:
#	programs/bpf_loader/src/syscalls.rs
#	sdk/program/src/pubkey.rs
#	sdk/src/feature_set.rs

* fix conflicts

Co-authored-by: Jack May <jack@solana.com>
2021-01-05 01:41:41 +00:00
6960eed856 Upgradeable programs needs program account's program id (bp #14417) (#14419)
* Upgradeable programs needs program account's address as program id (#14417)

(cherry picked from commit 0619805806)

# Conflicts:
#	programs/bpf_loader/src/lib.rs

* fix conflicts

Co-authored-by: Jack May <jack@solana.com>
2021-01-05 00:42:20 +00:00
2e67f093be docs: Use "msg!" instead of "info!" (#14411) (#14415)
* docs: Use "msg!" instead of "info!"

* Update docs/src/developing/deployed-programs/developing-rust.md

Co-authored-by: Michael Vines <mvines@gmail.com>

* Fix typo / format

Co-authored-by: Michael Vines <mvines@gmail.com>
(cherry picked from commit a41b5137f6)

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-01-04 19:56:05 +00:00
72c6faff99 Use max commitment when fetching epoch info for block production (#14402)
(cherry picked from commit 2724f37d0e)

Co-authored-by: Michael Vines <mvines@gmail.com>
2021-01-04 05:53:53 +00:00
d8753631db Tune rewards output (#14394)
(cherry picked from commit 560ed90168)

Co-authored-by: Michael Vines <mvines@gmail.com>
2021-01-03 02:51:33 +00:00
789e2d7f33 Bump version to 1.4.21 2021-01-02 08:52:35 +00:00
bbafd9783b Add secondary indexes (#14212) (#14381)
(cherry picked from commit 5affd8aa72)

Co-authored-by: carllin <wumu727@gmail.com>
2021-01-01 07:29:48 +00:00
624abc7434 Only initialize BigTable upload service when requested (#14379)
(cherry picked from commit 4a3d217839)

Co-authored-by: Michael Vines <mvines@gmail.com>
2021-01-01 03:06:28 +00:00
a8bd92ef70 Add --ignore-http-bad-gateway flag (#14376)
(cherry picked from commit 6c167615ad)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-31 22:14:14 +00:00
3fa08e620a Gate CPI authorized programs (bp #14361) (#14364)
* Gate CPI authorized programs (#14361)

(cherry picked from commit 2d8dacb72b)

# Conflicts:
#	programs/bpf_loader/src/syscalls.rs

* resolve conflicts

Co-authored-by: Jack May <jack@solana.com>
2020-12-31 03:43:55 +00:00
bfe9f12fe0 Remove assert (#14356) (#14359)
(cherry picked from commit 1c5427ff17)

Co-authored-by: Jack May <jack@solana.com>
2020-12-30 22:32:42 +00:00
b88c56cd36 Limit CPI instruction size (bp #14317) (#14354)
* Limit CPI instruction size (#14317)

(cherry picked from commit 5524938a50)

# Conflicts:
#	programs/bpf_loader/src/syscalls.rs
#	sdk/src/feature_set.rs

* resolve conflicts

Co-authored-by: Jack May <jack@solana.com>
2020-12-30 20:23:52 +00:00
cfb28a1b2e Prevent bpf loader impersonators (bp #14278) (#14353)
* Prevent bpf loader impersonators (#14278)

(cherry picked from commit ee0a80a092)

# Conflicts:
#	programs/bpf_loader/src/lib.rs
#	runtime/src/message_processor.rs

* resolve conflicts

Co-authored-by: Jack May <jack@solana.com>
2020-12-30 20:10:13 +00:00
a9ee6ef2d1 Save cloning program account data (#14251) (#14352)
(cherry picked from commit 5945305b1d)

Co-authored-by: Jack May <jack@solana.com>
2020-12-30 19:14:41 +00:00
4e6e415e40 Upgradeable programs called same as non-upgradeable (#14239) (#14347)
* Upgradeable programs called same as non-upgradeable

* nudge

(cherry picked from commit ab205b682a)

Co-authored-by: Jack May <jack@solana.com>
2020-12-30 06:53:16 +00:00
7eb5db98cf Limit CPI from calling loader or native programs (#14252) (#14319)
(cherry picked from commit 0b479ab180)

Co-authored-by: Jack May <jack@solana.com>
2020-12-30 06:39:22 +00:00
fb4204b135 Add experimental knob for tuning PoH pinned CPU core (bp #14330) (#14340)
* core: Update stale error message

(cherry picked from commit 82f61c0c4a)

* validator: Add experimental flag to select PoH pinned core

(cherry picked from commit fe667db910)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-12-30 03:52:58 +00:00
cd5bb89a15 Add Program loader/environment instruction errors (bp #14120) (#14333)
* Add Program loader/environment instruction errors (#14120)

(cherry picked from commit d513b0c4ca)

# Conflicts:
#	programs/bpf_loader/src/lib.rs

* resolve conflicts

* update error

Co-authored-by: Jack May <jack@solana.com>
2020-12-30 01:19:02 +00:00
30d7f6fa0b Rework upgradeable loader cli (bp #14209) (#14337)
* Rework upgradeable loader cli (#14209)

(cherry picked from commit 3316e7166c)

# Conflicts:
#	cli/src/cli.rs
#	cli/tests/program.rs

* fix conflicts

Co-authored-by: Jack May <jack@solana.com>
2020-12-30 01:01:19 +00:00
50e733837a Add poh speed check and tick speed calibration (#14292) (#14327)
(cherry picked from commit 2074e407cd)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-12-30 00:06:53 +00:00
403220a559 Add CPI support for upgradeable loader (bp #14193) (#14335)
* Add CPI support for upgradeable loader (#14193)


(cherry picked from commit e8cc0bef6c)

* update crate version

* nudge

Co-authored-by: Jack May <jack@solana.com>
2020-12-29 23:05:40 +00:00
ebfbe5ed8a Fix program account rent exemption (#14176) (#14334)
(cherry picked from commit 593ad80954)

Co-authored-by: Jack May <jack@solana.com>
2020-12-29 22:32:32 +00:00
1ae516fd4a core/validator: Wrap std::process:exit(1) for easier testing (#13990) (#14332)
(cherry picked from commit 3d9d7557c8)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-29 22:12:47 +00:00
db55eead5c Upgradeable loader (bp #13689) (#14318)
* Upgradeable loader (#13689)

(cherry picked from commit 9e90394583)

# Conflicts:
#	cli/src/cli.rs
#	ledger/src/builtins.rs
#	programs/bpf_loader/src/lib.rs
#	sdk/src/feature_set.rs

* fix conflits

* fix commitment

* fix local cluster test

Co-authored-by: Jack May <jack@solana.com>
2020-12-29 20:01:17 +00:00
715fdfefe4 Retry durable-nonce transactions (#14308) (#14324)
* Retry durable-nonce transactions

* Add metric to track durable-nonce txs in queue

* Populate send-tx-service initial addresses with tpu_address if empty (primarily for testing)

* Reinstate last_valid_slot check for durable-nonce txs; use arbitrary future slot

(cherry picked from commit 3f10fb993b)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-12-29 18:12:47 +00:00
9dfe50ecab Update serialization docs (#14323)
(cherry picked from commit 03fc031611)

Co-authored-by: Jack May <jack@solana.com>
2020-12-29 07:09:19 +00:00
9ea5e78852 Log error from AppendVec removal & a panic clean (bp #14302) (#14309)
* Log error from AppendVec removal & a panic clean (#14302)

(cherry picked from commit addffd7694)

# Conflicts:
#	runtime/src/append_vec.rs

* fix conflict? (blind commit!)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-28 22:51:57 +00:00
cad95e8f4f Remove Testnet-specific old code (#14305) (#14314)
(cherry picked from commit 7893e2e307)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-28 22:02:00 +00:00
97f6e87322 CLI: Support retrieving past leader schedules (bp #14304) (#14311)
* clap-utils: Add epoch validator

(cherry picked from commit a709850ee4)

* CLI: Support displaying past leader schedules

(cherry picked from commit bd761e2a52)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-12-28 21:33:20 +00:00
8fb9992dde run.sh: add env knob for solana-validor (#14303) (#14306)
(cherry picked from commit 4af33674a7)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-28 20:46:32 +00:00
c9a8736a5a net/gce.sh: Upgrade to Ubuntu 20.04
(cherry picked from commit 3322b83183)
2020-12-28 11:22:32 -07:00
6388603ba0 net/gce.sh: Switch to SSD boot disks
(cherry picked from commit a0507505f4)
2020-12-28 11:22:32 -07:00
69ef980307 net/gce.sh: Bump machine type to 24-core, 64GB RAM
(cherry picked from commit ffe0532ded)
2020-12-28 11:22:32 -07:00
bc8300a308 Add transactionCount field to GetEpochInfo
(cherry picked from commit efc091e28a)
2020-12-24 14:13:54 -08:00
34b3387104 fix: add transactionCount field to GetEpochInfo
(cherry picked from commit 01fe835e73)
2020-12-24 14:13:54 -08:00
6f2b37b015 Deinit zero-lamport account data (bp #14242) (#14265)
* Deinitialize nonce data upon zero balance

(cherry picked from commit 3881ae10fb)

* vote: Add helper for creating current-versioned states

(cherry picked from commit 5b903318b2)

* Deinitialize vote data upon zero balance

(cherry picked from commit db5bd6ea1a)

* Deinitialize stake data upon zero balance

(cherry picked from commit 50710473a8)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-12-23 04:34:52 +00:00
09a3b5001c Add log message for when a local snapshot is too old
(cherry picked from commit 65dcb3dc81)
2020-12-22 19:58:46 -08:00
7e4bd087ae Feature-gate stake-program-v3 (bp #14232) (#14249)
* Feature-gate stake-program-v3 (#14232)

* Remove deprecated legacy stake program

* Add legacy stake program

* Strip out duplicative legacy code

* Feature-deploy stake-program-v3

* Add ownership check in stake processor

(cherry picked from commit 7042f11791)

# Conflicts:
#	programs/stake/src/stake_instruction.rs
#	sdk/src/feature_set.rs

* Fix conflicts

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
2020-12-23 00:12:01 +00:00
266c63f105 Ignore long/hanging test (#14260) 2020-12-22 15:39:09 -07:00
8afa345eb3 Bump version to 1.4.20 2020-12-21 20:18:12 -08:00
4e7049bdf2 v1.4 fix timestamp metrics (#14235)
* Fix genesis timestamp metric source

* Move timestamp metrics to report even on estimate failure
2020-12-21 22:02:32 +00:00
9466ad3c1f Add shrink paths (#14208) 2020-12-21 13:05:07 -08:00
6d0b1bd93e Fix test_max_hashes (#14189)
(cherry picked from commit a5db6399ad)
2020-12-21 09:05:37 -08:00
a0565e2fbd Restore Content-Length header for streaming snapshot download
(cherry picked from commit 57b03c5bc1)
2020-12-21 09:03:31 -08:00
1f309d0bae Do not delete ALL other snapshots before downloading a new snapshot (#14226)
(cherry picked from commit 93ae177503)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-21 10:18:06 +00:00
a3342c57db Allow multiple --accounts arguments (#14224)
(cherry picked from commit 8082a2454c)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-21 09:13:00 +00:00
71eef63fce Stream RPC snapshot downloads (bp #14213) (#14214)
* Stream RPC snapshot downloads

(cherry picked from commit b3dc988564)

# Conflicts:
#	core/Cargo.toml

* Update Cargo.toml

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-20 01:25:16 +00:00
420e4c772f getBlockTime RPC method now falls back to BigTable in all cases (#14206)
(cherry picked from commit 0090106f60)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-18 22:11:26 +00:00
9f69f79577 Reject invalid --expected-shred-version (#14183) (#14201)
* Reject invalid --expected-shred-version

* less code

(cherry picked from commit 3c9b853268)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-18 19:19:32 +09:00
d4b2b787eb Improved Transaction Forwarding (bp #13944) (#14194)
* Improved Transaction Forwarding (#13944)

* Forwarding

* Dedupe leaders

* Use consistent commitment for last_valid_slot in rpc send_transaction

* Plumb rpc send_transaction options into solana-validator

* Extend num slots banking-stage holds forwarded txs

Co-authored-by: Tyera Eulberg <tyera@solana.com>
(cherry picked from commit da7d1e2302)

# Conflicts:
#	cli/src/cli.rs
#	core/src/validator.rs
#	validator/src/main.rs

* Fix conflicts

Co-authored-by: sakridge <sakridge@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
2020-12-17 18:13:41 -07:00
91a2d03f28 Update version to 1.4.19 (#14196) 2020-12-18 00:36:20 +00:00
5490c47c68 Add --bpf-jit stub argument for v1.5 forward compatibility 2020-12-17 11:00:40 -08:00
7424f7ba7f Revert "Ignore RUSTSEC-2020-0077 until next 1.4 release"
This reverts commit bd6cad3891.
2020-12-17 03:00:18 +00:00
206accb59a Override socket2 crate to v0.3.17 2020-12-17 03:00:18 +00:00
120074f1c1 Bump SPL crates 2020-12-17 03:00:18 +00:00
dcc2b10efa Add timings for store accounts (#12882) (#14169) 2020-12-16 17:17:03 -08:00
7adcbae866 Add blockstore skipped api (#14145) (#14166)
* Add blockstore api to determine if a slot was skipped

* Return custom rpc error if slot is skipped

(cherry picked from commit ac0d32bc7e)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-12-16 22:22:41 +00:00
238b596773 cargo-build-bpf: Create a random -keypair.json file alongside the program deploy artifact for easy upgrades (bp #14162) (#14164)
* Use AsRef

(cherry picked from commit 9993d2c623)

* Create a random `-keypair.json` file alongside the program deploy artifact for easy upgrades

(cherry picked from commit 636a455790)

* Update Cargo.toml

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-16 21:21:22 +00:00
cb145b9dd5 Correctly show reward percent changes (#14160)
(cherry picked from commit bebfa6e93c)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-16 18:23:23 +00:00
e91b124cd9 check for resize access violations (bp #14142) (#14151)
* check for resize access violations (#14142)

(cherry picked from commit 025f886e10)

# Conflicts:
#	programs/bpf_loader/src/syscalls.rs

* resolve conflicts

Co-authored-by: Jack May <jack@solana.com>
2020-12-16 12:20:52 +00:00
5c379db925 Remove lock files from programs/bpf/rust (#14148) (#14157)
(cherry picked from commit 49c3f14016)

Co-authored-by: Jack May <jack@solana.com>
2020-12-16 11:43:46 +00:00
82add14782 Bump version to v1.4.18 (#14144) 2020-12-16 04:15:05 +00:00
599b22baf3 Partial shred deserialize cleanup and shred type differentiation (#14094) (#14138)
* Partial shred deserialize cleanup and shred type differentiation in retransmit

* consolidate packet hashing logic

(cherry picked from commit d4a174fb7c)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-12-16 02:25:40 +00:00
fdb1c5ab06 Add wait for max stake command (#13532) (#14137)
(cherry picked from commit 598e5f58d5)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-12-16 01:32:00 +00:00
db339cb925 Fix race between setting tick height and calculating accounts hash (#14101) (#14131)
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit 75e9e321de)

Co-authored-by: carllin <wumu727@gmail.com>
2020-12-15 22:55:13 +00:00
ff76fccf2e Remove regular expressions, speeds up untar (#14119) (#14125)
(cherry picked from commit 53fe0bb5eb)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-12-15 20:51:18 +00:00
539f108ea6 Bump version to 1.4.17 2020-12-14 15:57:53 -08:00
78c4f946f4 Terminology fixes (#14112) (#14114)
(cherry picked from commit 42be09afb6)

Co-authored-by: Jeff Washington (jwash) <75863576+jeffwashington@users.noreply.github.com>
2020-12-14 21:15:12 +00:00
87a578a1f9 Simple cap by including sysvars and native programs (#13884) (#14110)
* Simpler cap by including sysvars and native programs

* Fix tests

* Add comment

* revert some unrelated code

* Update test_bank_update_sysvar_account for cap.

* Test cap. for add_native_program using new helper

* Improve the cap adjustment with new tests

* Fix typo...

* Adjust test for improved code coverage

* Rename simpler_capitalization => simple_capitalization

* More rename and bonus commenting

(cherry picked from commit de9ac43ebf)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-14 13:29:09 +00:00
7e3bf25991 Shrink slots by sparseness of written data size (#14072) (#14097)
(cherry picked from commit 5788e75188)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-13 19:15:44 +00:00
a844310911 spelling 2020-12-12 22:36:27 -08:00
4ad66fa7a4 Demote bank-process_transactions-error counters to info! 2020-12-12 22:04:20 -08:00
5d07195b7e stake-account command no longer errors when time goes backwards over an epoch (#14090)
(cherry picked from commit 52c2cbd630)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-13 05:03:36 +00:00
a209984ec9 Add subscription cap (#14011) (#14089)
* Add subscription cap

* Elide unwraps

(cherry picked from commit 8541ffa328)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-12-12 03:29:36 +00:00
a7e6cd56e9 Filter out stake and vote accounts with incorrect owners (#14062) (#14080)
* Add failing test

* Check stake/vote accounts for validity

* Feature gate change

* Add datapoint

* Add test realism

(cherry picked from commit d6eff3d62c)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-12-12 02:13:50 +00:00
bd6cad3891 Ignore RUSTSEC-2020-0077 until next 1.4 release 2020-12-12 00:16:37 +00:00
6d7e7f47b8 Override yanked arc-swap crate to 0.4.8 2020-12-12 00:16:37 +00:00
82f00bf9f7 Override yanked miow crate to 0.2.2 2020-12-12 00:16:37 +00:00
8fdfb291a9 Override yanked net2 0.2.37 2020-12-12 00:16:37 +00:00
1e5a662706 Override yanked mio crate to 0.7.6 2020-12-12 00:16:37 +00:00
277d4c9ae4 Switch to memmap2 fork 2020-12-12 00:16:37 +00:00
e6abf50bf7 Bump socket2 crate to 0.3.17 2020-12-12 00:16:37 +00:00
f7621c091a Add more comments in Stakes::store for its subtlety (#14065) (#14070)
* Add more comments in Stakes::store for its subtlety

* more comment tweak

(cherry picked from commit 7078a6ac61)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-11 20:54:42 +00:00
069f83be97 Increase another snapshot limit: UNPACKED_COUNT (#14071) (#14073)
(cherry picked from commit 2d3a337200)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-11 12:25:10 +00:00
5b31f3d790 Wrong rpc inflation rate (#14063) (#14064)
* Fix wrong inflation calculation in rpc

* Reorder

* Fix test

(cherry picked from commit 09bd412b13)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-11 09:07:17 +00:00
980c7cdf64 Retry inflation parameter update (bp #12778) (#14060)
* Retry inflation parameter update along with documentation updates (#12778)

* update initial inflation parameter

* update economics section of docs

(cherry picked from commit 1ab36203de)

# Conflicts:
#	docs/docusaurus.config.js
#	docs/package-lock.json

* Revert doc changes

* Revert doc changes

Co-authored-by: Eric Williams <ericlwilliams@gmail.com>
Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-11 05:19:51 +00:00
0b5beac561 Check shred type in is_duplicate (#14050) (#14058)
(cherry picked from commit aa2751e614)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-12-11 04:22:25 +00:00
83801f2b05 Clean invoke in prep for native invoke (#14055) (#14059)
(cherry picked from commit 83fda2d972)

Co-authored-by: Jack May <jack@solana.com>
2020-12-10 18:47:18 -08:00
13527fc937 Tiny add_native_program bug fixes with cleanups (#14042) (#14057)
* Tiny add_native_program bug fixes with cleanups

* Fix typo

(cherry picked from commit 164b7895b3)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-10 18:46:57 -08:00
bfc9932b17 Add get_minimum_balance_for_rent_excemption to Client (#14048) (#14052)
(cherry picked from commit 7abd8084b6)

Co-authored-by: Jack May <jack@solana.com>
2020-12-11 02:03:18 +00:00
1ea1a70d2b Remove "Timezone For Log Messages" section (#14014) (#14056)
To my understanding, the Solana process always logs a UTC timestamp
anyway, so this is not needed. Plus, using PST on servers is really
weird from a systems engineering point of view.

(cherry picked from commit d33ab34d75)

Co-authored-by: Leopold Schabel <leo@certus.one>
2020-12-11 02:01:50 +00:00
0039861984 Add message helpers to get program info (#14047) (#14053)
(cherry picked from commit d9655ea507)

Co-authored-by: Jack May <jack@solana.com>
2020-12-10 17:43:06 -08:00
fb3e88bb7e Bump version to v1.4.16 (#14054) 2020-12-10 17:04:34 -08:00
c01bff61f8 Fix priv escalation test (#14046) (#14049)
(cherry picked from commit 5ea80e673f)

Co-authored-by: Jack May <jack@solana.com>
2020-12-11 00:08:21 +00:00
6a0ba2587d Lower priority for hashing threads. (#14043) (#14044)
(cherry picked from commit 68109a46e0)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-12-10 21:49:52 +00:00
3520990271 adds the instance token to crds-labels for node-instance crds-values (bp #14037) (#14040)
* adds the instance token to crds-labels for node-instance crds-values (#14037)

If a node "a" receives instance-info from node "b1" it will override any
instance-info associated with "b1" pubkey in its crds table. This makes
it less likely that when "b1" receives crds values from "a" (either
through pull or push), it sees other instances of itself (because node
"a" discarded them when it received "b1" instance info).

In order for the crds table to contain all instance-info associated with
the same pubkey at the same time, we need to add the instance tokens to
the keys in the crds table (i.e. the CrdsValueLabel).

(cherry picked from commit 409fe3bca1)

# Conflicts:
#	core/src/cluster_info.rs

* removes backport merge conflicts

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-12-10 18:42:26 +00:00
f7d2ba24f0 adds ledger-tool mode to print raw shred metadata (#13962) (#14017)
(cherry picked from commit f6a7732ff9)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-12-10 17:56:30 +00:00
90c6f8ae1a Shred filter (#14030) (#14038)
(cherry picked from commit 5c95d8e963)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-12-10 17:12:16 +00:00
24bd147b1a Better dupe detection (#13992) (#14033)
(cherry picked from commit c5fe076432)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-12-10 08:32:44 +00:00
07191dc224 checks for duplicate validator instances using gossip (bp #14018) (#14028)
* checks for duplicate validator instances using gossip

(cherry picked from commit 8cd5eb9863)

# Conflicts:
#	core/src/cluster_info.rs

* pushes node-instance along with version early in gossip

(cherry picked from commit 542198180a)

* removes RwLock on ClusterInfo.instance

(cherry picked from commit 895d7d6a65)

# Conflicts:
#	core/src/cluster_info.rs

* std::process::exit to kill all threads

(cherry picked from commit 1d267eae6b)

* removes backport merge conflicts

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-12-09 13:04:57 -08:00
c20e74a248 Increase snapshot file size limits (#14024) (#14026)
* Increase snapshot file size limits

* Fix test

* Reorder code a bit

(cherry picked from commit 14e241be35)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-09 19:08:51 +00:00
f52feddfcd Cap CPI signers (bp #14021) (#14023)
* Cap CPI signers (#14021)

(cherry picked from commit e1a4251b07)

# Conflicts:
#	programs/bpf/tests/programs.rs

* resolve conflicts

Co-authored-by: Jack May <jack@solana.com>
2020-12-09 11:46:46 +00:00
a46d14a2d7 Don't use stale executor cache (bp #13966) (#13969)
* Don't use stale executor cache (#13966)


(cherry picked from commit 882d033233)

* fix conflicts

Co-authored-by: Jack May <jack@solana.com>
2020-12-09 09:11:31 +00:00
fb9f35d2f0 Rent account passed to loader can be read-only (#13997) (#14000)
(cherry picked from commit 20c0e8793e)

Co-authored-by: Jack May <jack@solana.com>
2020-12-09 07:52:49 +00:00
3687dccda6 Remove unneeded BankWeight fork choice (#13978) (#14003)
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit 239a191612)

Co-authored-by: carllin <wumu727@gmail.com>
2020-12-09 03:53:21 +00:00
8d96797e68 Use LRU cache and blake3 hash of shreds to filter duplicates (#13976) (#14007)
Co-authored-by: sakridge <sakridge@gmail.com>
2020-12-08 18:38:42 +00:00
820aa7e0ea Add tests for store_account_and_update_capitalization (#14008) (#14016)
(cherry picked from commit 28b014ccf4)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-08 17:45:23 +00:00
eea3c4e4f1 Docs: Correct the system.conf NOFILE variable name (#14010)
(cherry picked from commit 845c783b0e)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-12-08 07:56:41 +00:00
c66ee3c623 Add --rpc-max-multiple-accounts to override the getMultipleAccounts JSON RPC maximum (#14006)
(cherry picked from commit 6e9dbb4f6e)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-08 02:43:23 +00:00
871066fb8d Bump criterion to v2.3.3 (#14002) (#14004)
(cherry picked from commit 1dc71fb5aa)

Co-authored-by: Jack May <jack@solana.com>
2020-12-07 23:05:46 +00:00
aa084e1d3c Fix logsSubscribe (#13996) (#13998)
(cherry picked from commit 6ae4d2e5cb)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-12-07 21:39:51 +00:00
be0f9d4837 Bump rust-sysroot to v0.13 (#14001) 2020-12-07 13:26:12 -08:00
38485489c9 Cannot change owner if account is executable (#13977) (#13999)
(cherry picked from commit dca579851c)

Co-authored-by: Jack May <jack@solana.com>
2020-12-07 20:53:57 +00:00
abbc146508 genesis, ledger-tool: --inflation/--vote-commission-percentaage (#13989) (#13991)
(cherry picked from commit 82c75c3786)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-07 17:48:14 +00:00
d58e2f1c68 Don't abort for missing epoch rewards; intead display warn (#13457) 2020-12-07 08:30:20 -08:00
fa32b4a848 Don't show confusing message for blacklist expires (#13983) (#13986)
(cherry picked from commit 2f374df494)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-07 14:48:26 +00:00
aeb6ef3969 solana ping: add --blockhash and --print-timestamp (#13980) (#13984)
* solana ping: add --blockhash and --print-timestamp

* fix typo in hash...

(cherry picked from commit 26df122386)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-07 13:34:43 +00:00
a0c1e4a6e2 removes recursive read-locks on gossip (#13973) (#13974)
ClusterInfo::tvu_peers acquires a read-lock on gossip:
https://github.com/solana-labs/solana/blob/f0e934145/core/src/cluster_info.rs#L1171-L1185
and so, ClusterInfo::repair_peers is recursively locking gossip for
read twice:
https://github.com/solana-labs/solana/blob/f0e934145/core/src/cluster_info.rs#L1202-L1223
But std::sync::RwLock is not re-entrant (recursive).

(cherry picked from commit 6706f2b3bb)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-12-06 17:32:56 +00:00
c1047b48fe Add --remove-account option to create-snapshot command (#13971)
(cherry picked from commit c59cb28bbf)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-05 18:48:00 +00:00
add6989289 Report highest_confirmed_root and _slot in commitment metric (#13964) (#13968)
(cherry picked from commit ca35bb3ac8)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-12-05 02:13:15 +00:00
363b9d7209 Remove associated functions on AccountsDb, replace with methods (#13953) (#13954)
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit 5dceddd21d)

Co-authored-by: carllin <wumu727@gmail.com>
2020-12-04 04:20:07 +00:00
9846a8089e verifies that serialized size of transactions does not exceed packet data size (#13945) (#13952)
(cherry picked from commit 4e8565253c)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-12-03 23:47:05 +00:00
d96bcc9ead Blockstore exact purge cleanup (#13946) (#13948)
* Add failing test

* Clean up signature get

(cherry picked from commit 85aa632be0)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-12-03 23:08:05 +00:00
de445ec83e Refresh testnet restart instructions (#13950)
(cherry picked from commit ced9f889a4)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-03 22:27:33 +00:00
bb4943d8a7 samples repair peers using WeightedIndex (#13919) (#13938)
To output one random sample, weighted_best generates n random numbers:
https://github.com/solana-labs/solana/blob/f751a5d4e/core/src/weighted_shuffle.rs#L38-L63
WeightedIndex does so with only one random number:
https://github.com/rust-random/rand/blob/eb02f0e46/src/distributions/weighted_index.rs#L223-L240
Additionally, if the index is already constructed, it only does a total
of O(log(n)) amount of work; which can be achieved if RepairCache,
caches the weighted index:
https://github.com/solana-labs/solana/blob/f751a5d4e/core/src/serve_repair.rs#L83

Also, the repair-peers code can be reorganized to have fewer redundant
unlock-then-lock code.

(cherry picked from commit c3048b451d)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-12-03 19:48:09 +00:00
0f3705340b Cap seeds not signers (#13943) 2020-12-03 11:46:34 -08:00
d972a21aab Add non-progress bar download status (#13370) (#13942) 2020-12-03 11:30:31 -08:00
f705340971 Invoke with empty account slice (bp #13931) (#13940)
* Invoke with empty account slice (#13931)


(cherry picked from commit 1c51711c75)

* nudge ci

Co-authored-by: Jack May <jack@solana.com>
2020-12-03 09:52:08 -08:00
e313cf8332 BankServer::send_transaction_with_context() now performs signature verification (#13932)
(cherry picked from commit 3b39e98298)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-03 03:35:48 +00:00
38d7d7df50 Bump version to v1.4.15 2020-12-03 01:55:39 +00:00
eb0a448b99 Add credits_observed to verbose and json CliStakeStake prints (#13926) 2020-12-02 16:03:04 -07:00
e6f54ffd56 Cap number of program address seeds (#13925)
* Cap number of program address seeds

* fmt

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-02 23:01:58 +00:00
44315895cf Add a ramdisk section to the validator start guide (#13927)
(cherry picked from commit 5bfe93e74c)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-02 21:37:59 +00:00
9899e6fb39 Use add_builtin, as user-supplied builtins may not yet exist 2020-12-02 13:35:02 -08:00
da1796f97a Nonce cleanup followup (bp #13868) (#13922)
* runtime: Factor out `DurableNoncePartial` finishing logic and add tests

(cherry picked from commit 8df2a4bac0)

* accounts: Don't assume fee-payer is the first account

(cherry picked from commit 47af5933ca)

* accounts: Replace nonce_rollback unreachable block with descriptive panic

(cherry picked from commit be7760caa1)

* sdk: Check owner when verifying nonce accounts

(cherry picked from commit 274312ebb5)

* runtime: Replace `HashAgeKind` with `NonceRollbackInfo`

(cherry picked from commit 404fc1570d)

* Make `Accounts::is_non_loader_key()` a method on `Message`

(cherry picked from commit 17defbff13)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-12-02 21:34:21 +00:00
501fea7a3c Translate data length and owner as writable (bp #13914) (#13918)
* Translate data length and owner as writable (#13914)

(cherry picked from commit 85bec37be4)

# Conflicts:
#	programs/bpf_loader/src/syscalls.rs

* Resolve conflicts

* nudge

* fmt funk

* ugh

* nudge

Co-authored-by: Jack May <jack@solana.com>
2020-12-02 19:28:15 +00:00
2583174cbd Ledger tool cap basic columns (#13904) (#13913)
* ledger-tool cap: Add more basic columns

* simplify InflationRecord::rewarded_epoch type

(cherry picked from commit 480dd15b1e)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-12-02 08:26:55 +00:00
72aa24db2c Remove rpc_banks from validator (bp #13882) (#13905)
* Remove rpc_banks from validator (#13882)

* Remove rpc_banks from validator

* Bump abi-digest

(cherry picked from commit 10c81a2448)

# Conflicts:
#	core/src/validator.rs

* Fix conflicts

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
2020-12-02 04:47:42 +00:00
bbf53f9050 Add specific page for rpc endpoints (#13899) (#13910)
(cherry picked from commit 0f76daaf7a)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-12-02 04:25:58 +00:00
e7a95b1189 solana-tokens: optimize PickleDb dumps (bp #13879) (#13903)
* solana-tokens: optimize PickleDb dumps (#13879)

* Dump PickleDb after transaction sends/confirmation

* Dump PickleDb on ctrlc

* Don't exit during tests

* Add build_messages helper and test db dump

* Add send_messages helper and test db dump

* Add combined test

* Add log_transaction_confirmations helper and test db dump

* Add update_finalized_transactions test

* Return error instead of process::exit

* Close TestValidator

(cherry picked from commit 8c40dd34b2)

* Fix conflicts

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
2020-12-02 03:49:11 +00:00
311a1a38dc Lock serum-dex to older version to avoid build failures (#13900)
(cherry picked from commit 4e90a9f5fd)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-01 23:51:15 +00:00
a1828a0e45 Reduce the number of snapshots
(cherry picked from commit 73111b005f)
2020-12-01 13:05:24 -08:00
01d9062f7b Check that the program was granted access to program_id (bp #13890) (#13893)
* Check that the program was granted access to program_id (#13890)

(cherry picked from commit 733fcbaa6c)

# Conflicts:
#	programs/bpf/Cargo.toml
#	programs/bpf/tests/programs.rs

* Resolve conflicts

Co-authored-by: Jack May <jack@solana.com>
2020-12-01 17:49:17 +00:00
446e02bad1 Add logging in check_blockstore_max_root (#13887) (#13888)
(cherry picked from commit 8fd1e55805)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-12-01 09:01:09 +00:00
3955778cb6 Add msg! macro for program logging, deprecate info! macro (#13885)
(cherry picked from commit 6705b5a98c)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-01 06:05:31 +00:00
4f4a0b9dc8 Fully clean up temporary snapshot staging directories (#13883)
(cherry picked from commit 254790f8c8)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-01 05:10:53 +00:00
97c1c944fb solana-tokens: enable confirmation of many transactions (#13876) (#13881)
* Update comment

* Chunk signature status checks to handle distributions greater than 256 tx

(cherry picked from commit c59e088142)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-12-01 04:15:22 +00:00
7890957250 Bump to rbpf v0.1.34 (#13874) 2020-12-01 01:43:50 +00:00
535c7a44db Strengthen EpochSlots sanitization (#13873)
(cherry picked from commit 90d557d916)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-01 00:04:01 +00:00
fbbc640958 Revert solana-tokens to RpcClient (#13623) (#13863)
* Revert solana-tokens to RpcClient

* Fixup check_payer_balances tests

* Use RpcClient::new_with_commitment in other tests

* Sneak in helper fn from #13820

Co-authored-by: Tyera Eulberg <tyera@solana.com>

Co-authored-by: Greg Fitzgerald <greg@solana.com>
2020-11-30 19:57:33 +00:00
3559062c00 caches vote-state de-serialized from vote accounts (#13795) (#13862)
Gossip and other places repeatedly de-serialize vote-state stored in
vote accounts. Ideally the first de-serialization should cache the
result.

This commit adds new VoteAccount type which lazily de-serializes
VoteState from Account data and caches the result internally.

Serialize and Deserialize traits are manually implemented to match
existing code. So, despite changes to frozen_abi, this commit should be
backward compatible.

(cherry picked from commit e1793e5a13)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-11-30 18:36:23 +00:00
1a7e5669bf Add flatten to logs_subscribe commitment (#13861)
Currently, commitment for `logs_subscribe` must be specified using the
non-flattened form in JSON, ie `{"commitment":{"commitment":"max}}`.
This brings the commitment in line with documentation.

(cherry picked from commit 6203d1c94c)

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2020-11-30 18:00:27 +00:00
5511d52c62 Don't reset credits_observed due to stale voters (#13836) (#13860)
* Don't reset credits_observed due to stale voters

* Add tests

* Fix comment

(cherry picked from commit e81c2c826c)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-30 15:06:19 +00:00
50d5978b00 add zsh trouble shooting note to ledger docs (#13854)
(cherry picked from commit daebade239)

Co-authored-by: Tommy Johnson <tommyjohnson1028@gmail.com>
2020-11-30 03:33:12 +00:00
cea722ac09 Bump version to v1.4.14 (#13852) 2020-11-29 18:20:19 +00:00
82b087e51e Add extra checks to verify_and_update (#13848) (#13850)
* Add extra checks to verify_and_update

* nudge

(cherry picked from commit ce4304cc9a)

Co-authored-by: Jack May <jack@solana.com>
2020-11-29 11:22:46 +00:00
da682eaef6 Add --unhealthy_threshold option 2020-11-28 23:51:11 -08:00
688562c049 Perform all RPC activity in the same place, also clean up Sol display 2020-11-28 23:51:11 -08:00
50e6fad0e6 Remove support to monitor all validators in a cluster for delinquency
This feature is no longer useful with hundreds of validators
2020-11-28 23:51:11 -08:00
d5cce435ce Remove --notify-on-transaction support.
It's not longer useful due to the volume of transactions on mainnet-beta
and there are now other means of monitoring transactions
2020-11-28 23:51:11 -08:00
8f75cfe247 Record instructions after account translation (#13845)
(cherry picked from commit cc78667118)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-28 20:13:31 +00:00
686b775e35 Add --maximum-local-snapshot-age argument 2020-11-28 09:20:28 +00:00
a3be6bacc6 Enhance ledger-tool for multi-epoch rewards (#13837) (#13839)
* Support ledger-tool for multi-epoch rewards

* nits

* Ensure not to skip some records in csv

(cherry picked from commit 6048342c57)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-27 05:36:08 +00:00
b493d554ad Update examples to use Tokenkeg 2020-11-26 18:27:24 -08:00
0fc3bcabfd Fix roots_and_ref_count (#13827) (#13833)
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit 955b99cf69)

Co-authored-by: carllin <wumu727@gmail.com>
2020-11-26 22:33:43 +00:00
7cf36c488d Revert "hidapi 1.2.4 is broken, lock version to 1.2.3" (#13831)
This reverts commit 9dc9a1ef6c.

(cherry picked from commit 761499dfbf)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-26 21:32:51 +00:00
89c39d0be1 hidapi 1.2.4 is broken, lock version to 1.2.3 (#13826)
(cherry picked from commit 9dc9a1ef6c)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-26 10:30:25 +00:00
f5eb5a3ba6 Bump version to v1.4.13 2020-11-26 06:59:28 +00:00
64c2e759ab Use u64 behind the scenes for solana-tokens (bp #13815) (#13818)
* Use u64 behind the scenes for solana-tokens (#13815)

* Use u64 behind the scenes for Allocations

* Fixup readme

* Clippy and remove errant comments

(cherry picked from commit 5e2d38227f)

# Conflicts:
#	tokens/src/commands.rs

* Fix conflicts

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
2020-11-26 03:05:36 +00:00
a09ee672a6 Separate blockstore checks for not (yet) rooted and cleaned up (#13814) (#13817)
(cherry picked from commit 4ff0f0949a)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-26 00:17:06 +00:00
057b5d7e24 Add commonly-used SPL programs as a convenience to the user (#13813)
(cherry picked from commit 0e2578a0b8)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-25 22:44:51 +00:00
fe4c59e38d Add solana logs command (#13812)
(cherry picked from commit 4ef2da0ff0)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-25 22:22:23 +00:00
305d5d97d8 Nonce updates (#13799) (#13810)
* runtime: Add `FeeCalculator` resolution method to `HashAgeKind`

* runtime: Plumb fee-collected accounts for failed nonce tx rollback

* runtime: Use fee-collected nonce/fee account for nonced TX error rollback

* runtime: Add test for failed nonced TX accounts rollback

* Fee payer test

* fixup: replace nonce account when it pays the fee

* fixup: nonce fee-payer collect test

* fixup: fixup: clippy/fmt for replace...

* runtime: Test for `HashAgeKind::fee_calculator()`

* Clippy

Co-authored-by: Trent Nelson <trent@solana.com>
(cherry picked from commit b70abdc645)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-11-25 18:18:04 +00:00
05f464798f Add stake calculation tests with inflation/slashing (#13605) (#13798)
* Add stake calculation tests with inflation/slashing

* Clean up the test

(cherry picked from commit 42421e77a9)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-25 05:16:09 +00:00
96d8ee9e07 Add base64+zstd encoding for RPC account data (#13796)
(cherry picked from commit 215ddecaa5)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-25 03:20:20 +00:00
471a3f991b Revert "Check out specific downstream commit (#13787)" (#13793) (#13794)
This reverts commit 630288c1cc.

(cherry picked from commit 465ab490e1)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-24 23:36:30 +00:00
fd9e003ae1 Bump version to 1.4.12 (#13792) 2020-11-24 22:53:36 +00:00
e26ff09df7 tiny doc fix 2020-11-24 12:28:23 -08:00
fdcf589f7c Restore bank feature used to deprecate Rewards sysvar (#13786) (#13788)
(cherry picked from commit c930f92411)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-24 18:57:26 +00:00
f44dfc8d04 Check out specific downstream commit 2020-11-24 10:29:41 -07:00
c736c4633e Clean up default commitment handling for subscriptions (#13781)
(cherry picked from commit 61ab2072bd)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-24 08:10:11 +00:00
7099d07fd3 Bump version to 1.4.11 (#13780) 2020-11-24 06:30:35 +00:00
e3b47d22d7 Check SlotNotRooted if confirmed block not found in blockstore or bigtable (#13778) 2020-11-24 04:23:05 +00:00
f789da1e20 Prevent splitting when either source or split stake will equal zero (#13775) (#13777)
(cherry picked from commit e3a92d6905)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-24 04:08:17 +00:00
b74bb12ebe Truncate logs immediately upon collection. Also reduce limit from 100k to 10k (#13774)
(cherry picked from commit 60ce6f1a9b)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-24 02:36:23 +00:00
ddf019c1a4 Stake: Support merging fully-activated stake accounts (bp #13712) (#13770)
* stake: De-replicode mergable info extraction

(cherry picked from commit dc7f89715a)

* stake: Cosmetic - rename variable

(cherry picked from commit bb2772d068)

* stake: Allow compatible, fully-active stake accounts to be merged

(cherry picked from commit 8e73187990)

* stake: Remove disused test helper function

(cherry picked from commit 6b9a019c0a)

* stake: Disallow stakes merging with themselves

(cherry picked from commit 488ce982f0)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-11-23 22:48:30 +00:00
74d57b1c2f Fail stake init if account data is the wrong size (#13767) (#13769)
(cherry picked from commit 38a3ed96bb)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-23 21:30:33 +00:00
086e653a0b Cap split stake at source stake when splitting entire balance (#13754) (#13766)
(cherry picked from commit f0f99ffc7e)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-23 18:42:22 +00:00
225d15bde8 processes pull-request callers only once per unique caller (#13750) (#13753)
process_pull_requests acquires a write lock on crds table to update
records timestamp for each of the pull-request callers:
https://github.com/solana-labs/solana/blob/3087c9049/core/src/crds_gossip_pull.rs#L287-L300
However, pull-requests overlap a lot in callers and this function ends
up doing a lot of redundant duplicate work.

This commit obtains unique callers before acquiring an exclusive lock on
crds table.

(cherry picked from commit 26bf2b7e45)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-11-22 19:08:33 +00:00
6d8d5d1379 fix arithmetic overflow in slice translation (bp #13624) (#13625)
* fix arithmetic overflow in slice translation (#13624)

* fix arithmetic overflow in slice translation

* nudge

(cherry picked from commit 8c922a0198)

# Conflicts:
#	programs/bpf_loader/src/syscalls.rs

* fix conflicts

Co-authored-by: Jack May <jack@solana.com>
2020-11-22 03:30:27 +00:00
fcd2a78d73 Guard against bsd sed (#13735) (#13751)
(cherry picked from commit 1d008bab4a)

Co-authored-by: Jack May <jack@solana.com>
2020-11-22 02:03:23 +00:00
5cf52c3c20 ledger-tool cap: output credits_observed (#13746) (#13748)
(cherry picked from commit 3bc7d85986)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-21 17:30:10 +00:00
bc334427e3 stake: Don't pay out rewards for epochs where inflation was not enabled (#13745)
(cherry picked from commit 13aa38d307)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-11-21 05:41:53 +00:00
d0cac2a2ea Prevent scans on unrooted slots from seeing partial clean (#13628) (#13741)
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit 791fb17437)

Co-authored-by: carllin <wumu727@gmail.com>
2020-11-20 22:14:51 +00:00
3743e44fb3 Add new inflation feature-ids (#13671) (#13736)
* Add new inflation feature-ids, and full_inflation default values

* Compute inflation start from full_inflation activation

* Include pico_inflation in inflation start computation

* Add full-inflation constructor

* Align inflation taper with rewards accrual start and catch overflow edge case

(cherry picked from commit c75d97e3f2)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-20 18:08:57 +00:00
f5ef999b31 Snapshot archives are now cleaned up when --snapshot-compression none is used (#13733)
(cherry picked from commit 11e92f0c9f)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-20 17:54:27 +00:00
55d5339daa --vote-account doesn't support ASK but --authorized-voter does (#13731)
(cherry picked from commit 8808a74593)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-20 15:24:36 +00:00
594b69395a Cleanup (#13728) (#13729)
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit 9bb11a2dcc)

Co-authored-by: carllin <wumu727@gmail.com>
2020-11-20 12:57:40 +00:00
6dc62bfb77 Fix fragile tests in prep of stake rewrite pr (#13654) (#13721)
* Fix fragile tests in prep of stake rewrite pr

* Restore BOOTSTRAP_VALIDATOR_LAMPORTS where appropriate

* Further clean up

* Further clean up

* Aligh with other call site change

* Remove false warn!

* fix ci!

(cherry picked from commit b74d7b5758)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-20 09:34:46 +00:00
08b53c0963 Use info for failed to match slot vote error (#13715) (#13720)
(cherry picked from commit 2cb006fa44)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-11-20 01:34:42 +00:00
b5baa966ac Fix avx check with newest nightly compiler (#13465) (#13719)
(cherry picked from commit c644b05c54)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-11-20 01:23:16 +00:00
ff38a46af6 sanitizes bloom filters to avoid division by zero (#13714) (#13718)
Pull requests received over the wire can cause a validator to panic
because of division by zero in bloom filters:
https://github.com/solana-labs/solana/blob/af08ba93e/runtime/src/bloom.rs#L86-L88

(cherry picked from commit a8c29505f0)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-11-20 01:07:30 +00:00
841f596b26 Document get_account() gotcha (#13713)
(cherry picked from commit f9acbd6e3f)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-19 23:21:43 +00:00
5e1497856b Add SPL Feature Proposal program (#13683)
(cherry picked from commit 9d75b82840)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-19 23:04:38 +00:00
e085b580b5 makes crds fields private (#13703) (#13708)
Crds fields should maintain several invariants between themselves, so
exposing them as public fields can be bug prone. In addition these
invariants are asserted on every write:
https://github.com/solana-labs/solana/blob/9668dd85d/core/src/crds.rs#L138-L154
https://github.com/solana-labs/solana/blob/9668dd85d/core/src/crds.rs#L239-L262
which adds extra instructions and is not optimal. Should these fields be
private the asserts will be redundant.

(cherry picked from commit b58f69297f)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-11-19 22:26:28 +00:00
d967ff0138 Allow GNUSparse for genesis.bin (#13704) (#13707)
(cherry picked from commit 397cf726fc)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-19 21:57:12 +00:00
71e3a99742 fix doc redirects (#13709) (#13710)
(cherry picked from commit af08ba93e6)

Co-authored-by: Jack May <jack@solana.com>
2020-11-19 21:41:23 +00:00
640f4a1ec7 Rewrite stake accounts for clear migration (#13461) (#13705)
* Reduce overage stake by rewritng stake accounts

* Write tests and finish implemention

* Create and use new feature gate

* Clean up logging

* Fix typo

* Simplify enable_rewrite_stake

* Fix typo...

* Even simplify gating

* Add metrics

(cherry picked from commit 43d5e47ea9)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-19 21:29:42 +00:00
8d904877ef fix rust example section link (#13701) (#13702)
(cherry picked from commit 9668dd85d4)

Co-authored-by: Jack May <jack@solana.com>
2020-11-19 18:14:42 +00:00
fbe4e95e6a breaks prunes data into chunks to fit into packets (#13613) (#13698)
Validator logs show that prune messages are dropped because they exceed
packet data size:
https://github.com/solana-labs/solana/blob/f25c969ad/perf/src/packet.rs#L90-L92
This can exacerbate gossip traffic by redundantly increasing push
messages across network. The workaround is to break prunes into smaller
chunks and send over in multiple messages.

(cherry picked from commit 1ffab5de77)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-11-19 17:53:03 +00:00
e7e7cbe632 v1.4: Distribute spl tokens (#13688)
* Add helpers to covert between sdk types

* Add distribute-spl-tokens to args and arg-parsing

* Build spl-token transfer-checked instructions

* Check spl-token balances properly

* Add display handling to support spl-token

* Small refactor to allow failures in allocation iter

* Use Associated Token Account for spl-token distributions

* Add spl token support to balances command

* Update readme

* Add spl-token tests

* Rename spl-tokens file

* Move a couple more things out of commands

* Stop requiring lockup_date heading for non-stake distributions

* Adjust solana_rbpf log level up in coverage

* Use epsilon for allocation retention
2020-11-19 10:32:27 -07:00
7e5b75fa7e Check for overflow in rent partition calculation (#13569) (#13696)
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit 110acd20dc)

Co-authored-by: carllin <wumu727@gmail.com>
2020-11-19 13:41:48 +00:00
60beb509f7 Prevent scans from seeing root updates/clean (#13464) (#13686)
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit 6276360468)

Co-authored-by: carllin <wumu727@gmail.com>
2020-11-19 07:11:59 +00:00
15f6b6ccd6 RPC: Demote missing block error to warning (#13685)
It frightens the tourists

(cherry picked from commit f2a1a0ac5c)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-11-19 07:05:32 +00:00
f56f3d81b5 audit: Ignore RUSTSEC-2020-0071, potential SEGV in time 2020-11-18 22:28:41 -07:00
098c94352d Fix doc proposal sidebar layout (#13675) (#13677)
(cherry picked from commit 13a08c7f08)

Co-authored-by: Jack May <jack@solana.com>
2020-11-18 22:29:04 +00:00
c929e8e02b Disable publishing of cargo-build-bpf/cargo-test-bpf to crates.io (#13669)
(cherry picked from commit f25c969ad8)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-18 20:23:05 +00:00
80f2c485ba Recommend --no-port-check to improve validator restart time (#13667)
(cherry picked from commit 31d2f445a2)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-18 17:32:47 +00:00
f855f4d1c0 Update development docs (#13661) 2020-11-18 09:27:11 +00:00
81a26aa4fc solana-tokens: Add real --version (bp #13659) (#13660)
* Add real --version

(cherry picked from commit 78dc334afe)

# Conflicts:
#	Cargo.lock
#	tokens/Cargo.toml

* Update Cargo.toml

* Update Cargo.lock

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-18 03:25:05 +00:00
855cf9a362 Bump version to 1.4.10 (#13657) 2020-11-18 01:29:58 +00:00
96ba314281 Bump rbpf to v0.1.33 (#13643) 2020-11-17 16:00:20 -08:00
e52e6dfbaa v1.4: Improve monitoring of timestamp correction and bounding (#13655)
* Include rejuvenated field in Clock parsing

* Expand timestamp-correction logging info
2020-11-17 14:46:30 -07:00
181ff3d13e Update Initialized split rent-exempt value (#13646) (#13653)
(cherry picked from commit 39932d7664)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-17 20:43:30 +00:00
195ce0ed79 Remove overflow opportunities (#13649) (#13651)
(cherry picked from commit a7bed62af0)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-17 20:26:06 +00:00
b24e301201 helloworld no longer supports program feature (#13645) (#13648)
(cherry picked from commit df1f53950e)

Co-authored-by: Jack May <jack@solana.com>
2020-11-17 18:08:48 +00:00
fb492efda8 Add RpcClient::new_with_commitment()
(cherry picked from commit c5299b60ed)
2020-11-17 09:14:25 -08:00
c40216350c Add back BPF error logging (#13633) (#13639)
* Add back BPF error logging

* Update programs/bpf_loader/src/lib.rs

Co-authored-by: Michael Vines <mvines@gmail.com>
(cherry picked from commit 3a9dca0c67)

Co-authored-by: Jack May <jack@solana.com>
2020-11-17 09:33:58 +00:00
d031bbcf2e Quiet notification logs when no subscriptions (#13629) (#13637)
(cherry picked from commit 3e4acba72f)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-17 08:26:15 +00:00
c183c3a5ec Improve TestValidator instantiation (bp #13627) (#13635)
* Improve TestValidator instantiation (#13627)

* Add TestValidator::new_with_fees constructor, and warning for low bootstrap_validator_lamports

* Add logging to solana-tokens integration test to help catch low bootstrap_validator_lamports in the future

* Reasonable TestValidator mint_lamports

(cherry picked from commit ef99689592)

# Conflicts:
#	tokens/Cargo.toml

* Fix conflict

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
2020-11-17 01:08:58 -07:00
f04d4af4f2 Default preflight_commitment to confirmation commitment (#13632)
(cherry picked from commit c2f77a3473)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-17 07:31:35 +00:00
ea0a3521ed Fix assertion failure (#13626) (#13631)
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit afc1b59475)

Co-authored-by: carllin <wumu727@gmail.com>
2020-11-17 07:01:10 +00:00
a75898a415 Remove program cap from CLI checks (bp #13617) (#13622)
* Remove program cap from CLI checks (#13617)

(cherry picked from commit 64a3cf03e2)

# Conflicts:
#	cli/src/cli.rs

* Fix conflict

Co-authored-by: Jack May <jack@solana.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
2020-11-17 05:23:32 +00:00
a77fce465a run.sh: Use default client keypair for the faucet (bp #13614) (#13618)
* Use default client keypair if --keypair argument is not provided

(cherry picked from commit e9e5ee4362)

# Conflicts:
#	faucet/Cargo.toml

* Use default client keypair if --faucet-keypair is not provided

(cherry picked from commit 4069e7b663)

# Conflicts:
#	genesis/Cargo.toml

* Cargo.lock

(cherry picked from commit ab5814cd90)

# Conflicts:
#	Cargo.lock

* Use default client keypair for faucet to avoid the need for airdrops

(cherry picked from commit b5820f9325)

* Fix conflicts

Co-authored-by: Michael Vines <mvines@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
2020-11-17 02:23:01 +00:00
719f162229 Reject faked stake/vote accounts in stake mgmt. (#13615) (#13621)
* Reject faked stake/vote accounts in stake mgmt.

* Use clearer name

(cherry picked from commit 2b3faa1947)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-16 23:19:54 +00:00
a39cc8d21f Build more of the SPL repo in CI (#13619)
(cherry picked from commit e5f4442325)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-16 20:56:23 +00:00
87767b181d Document feature-set field in getVersion 2020-11-15 18:03:06 -08:00
88b19e10cb ledger-tool cap: delegation owner and stake v2 flag (#13602) (#13607)
* Output delegation owner as well

* Add --enable-stake-program-v2

* Small cleanup and add sanity assertion

* Fix typo...

(cherry picked from commit bcd303a447)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-15 20:55:14 +00:00
b42cda32ff packs more crds-values in a single gossip packet (#13500) (#13604)
split_gossip_messages:
https://github.com/solana-labs/solana/blob/a97c04b40/core/src/cluster_info.rs#L1536-L1574
splits crds-values into chunks to fit into a gossip packet. However it is
using a global upper-bound for the header-size across all protocols:
https://github.com/solana-labs/solana/blob/a97c04b40/core/src/cluster_info.rs#L90-L93
This can be wasteful as the specific gossip protocol can have smaller
header than this upper-bound (e.g. Protocol::PushMessage is 170 bytes
smaller). Adding more crds-values in one gossip packet can avoid the
overheads of separate packets and reduce total number of bytes sent over
the wire.

This commit updates the splitting function to take a max-chunk-size
argument. At call-site, this value is set to the size of the protocol
which the values are sent over.

(cherry picked from commit 5e8490ab9d)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-11-15 19:49:18 +00:00
2344391c48 indexes nodes' contact infos in crds table (#13553) (#13601)
In several places in gossip code, the entire crds table is scanned only
to filter out nodes' contact infos. Currently on mainnet, crds table is
of size ~70k, while there are only ~470 nodes. So the full table scan is
inefficient. Instead we may maintain an index of only nodes' contact
infos.

(cherry picked from commit cbea9ebc34)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-11-15 17:58:39 +00:00
207d13e429 Disable the PubSub vote subscription by default (#13600)
The --rpc-pubsub-enable-vote-subscription flag may be used to enable it.
The current vote subscription is problematic because it emits a
notification for *every* vote, so hundreds a second in a real cluster.
Critically it's also missing information about *who* is voting,
rendering all those notifications practically useless.

Until these two issues can be resolved, the vote subscription is not
much more than a potential DoS vector.

(cherry picked from commit 5d72e52ad0)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-14 22:06:38 +00:00
360f166f5a Add counter metrics to rpc-subscriptions (#13596) (#13598)
(cherry picked from commit 88ae321d3f)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-14 21:09:43 +00:00
b4deeb8e36 Add stable program logging for BPF and native programs 2020-11-14 08:26:54 -08:00
b3e1fde8b2 Revert "Release: Omit spl-token CLI binary"
This reverts commit 67c36f8680.
2020-11-14 01:56:36 +00:00
b838aba840 Bump version to 1.4.9 2020-11-13 17:50:10 -07:00
c8b3d0ba07 Release: Omit spl-token CLI binary
Required to work around yanked ouroboros crate release
2020-11-13 17:37:29 -07:00
e7106278e9 add missing c logging stubs (#13511) (#13515)
(cherry picked from commit 23c558510a)

Co-authored-by: Jack May <jack@solana.com>
2020-11-13 22:14:05 +00:00
63cf168fef Send pubsub metrics to metrics server (#13584) (#13586)
(cherry picked from commit 34bf80ba9c)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-13 20:56:04 +00:00
71ea198a07 Stop searching for incorrect shred version after a minute (#13512) (#13582)
(cherry picked from commit c1f3f9d27b)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-11-13 18:01:16 +00:00
f6b65b033e Fix overflow in entry tick verification (bp #13572) (#13581)
* Fix overflow in entry hash count verification

(cherry picked from commit d611337394)

* clippy

(cherry picked from commit 01a4889b53)

Co-authored-by: Justin Starry <justin@solana.com>
2020-11-13 16:49:05 +00:00
0311ad5ddf Small cleaning update_epoch_stakes (#13576) (#13578)
(cherry picked from commit c97a7d1105)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-13 12:40:51 +00:00
f5454e62a1 Fix potential undefined behavior (#13555) (#13575)
* Switch to ouroboros 0.5.1

* Update other lock files

(cherry picked from commit a8a77614fe)

Co-authored-by: joshua-maros <60271685+joshua-maros@users.noreply.github.com>
2020-11-13 10:40:10 +00:00
89ea4dfa8b ip-echo-server: Don't use framed decoder, it can't be read-limited (#13571)
(cherry picked from commit 6dc735e996)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-11-13 09:22:27 +00:00
fefcfdba80 --gossip-host may now be specified with --entrypoint (#13567)
(cherry picked from commit 328f59ebef)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-13 07:49:02 +00:00
1072bd7640 Add --offline flag (#13564)
(cherry picked from commit 9f95704706)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-13 05:18:44 +00:00
a7280f117a fix bpf lddw check (#13554) (#13558)
(cherry picked from commit 30ef53cb13)

Co-authored-by: Jack May <jack@solana.com>
2020-11-12 22:35:13 +00:00
d46a19098a Bound ip-echo-server reply read (bp #13543) (#13546)
* ip-echo-server: Name the header length magic number

(cherry picked from commit aab5f24518)

* ip-echo-server: Add helper to compute reply length

(cherry picked from commit 7481ba5618)

* ip-echo-server: Limit socket read to expected reply length

(cherry picked from commit d2cfeb31b9)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-11-12 19:26:26 +00:00
44fffcbb1c filters out offline nodes from pull options (#13533) (#13551)
Inactive nodes are still observing incoming gossip traffic:
https://discord.com/channels/428295358100013066/670512312339398668/776140351291260968
likely because of pull-requests.

Previous related issues and commits:
https://github.com/solana-labs/solana/issues/12409
https://github.com/solana-labs/solana/pull/12620
https://github.com/solana-labs/solana/pull/12674

This commit implements same logic as
https://github.com/solana-labs/solana/pull/12674
to exclude inactive nodes from pull options, with the same periodic
retry logic for offline staked nodes in order to mitigate eclipse
attack.

(cherry picked from commit 4e4e12b384)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-11-12 18:43:04 +00:00
e14c2f94f4 Bump version to v1.4.8 (#13552) 2020-11-12 17:43:31 +00:00
437c356626 Discard pre hard fork persisted tower if hard-forking (#13536) (#13550)
* Discard pre hard fork persisted tower if hard-forking

* Relax config.require_tower

* Add cluster test

* nits

* Remove unnecessary check

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit 9821a7754c)

Co-authored-by: carllin <wumu727@gmail.com>
2020-11-12 15:43:43 +00:00
fd68f8ba2e program-test now generates new blockhashes for test usage 2020-11-11 20:29:20 -08:00
2374664e95 Custom heap is BPF only (#13537) 2020-11-11 16:37:18 -08:00
2cb9ca5966 Fix slow/stuck unstaking due to toggling in epoch (#13501) (#13535)
* Fix slow/stuck unstaking due to toggling in epoch

* nits

* nits

* Add stake_program_v2 feature status check to cli

Co-authored-by: Tyera Eulberg <tyera@solana.com>
(cherry picked from commit 89b474e192)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-11 22:27:10 +00:00
4f247a232f Validator: Periodically log what we're waiting for during --wait-for-supermajority (#13531)
(cherry picked from commit 38f15e41b5)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-11-11 21:29:50 +00:00
15a2c73826 Use a non-zero fee_calculator for a more realistic test environment (#13525)
(cherry picked from commit 58724cb687)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-11 09:59:57 +00:00
d23f1436c5 docs: add log messages to json-rpc docs (#13317) 2020-11-11 00:43:32 -08:00
70c87d1a23 Add stubs and heap region definitions (#13521) (#13523)
* Add stubs and heap region definitions

* nudge

(cherry picked from commit e390c8cb7f)

Co-authored-by: Jack May <jack@solana.com>
2020-11-11 06:48:02 +00:00
053ce10ce5 Refactor function (#13294) (#13520)
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit 2c2432fddc)

Co-authored-by: carllin <wumu727@gmail.com>
2020-11-11 04:07:51 +00:00
055eb360c2 Add printf declaration (#13514) (#13518)
(cherry picked from commit 9ca8e98525)

Co-authored-by: Jack May <jack@solana.com>
2020-11-11 01:50:42 +00:00
25cd1ceeeb Fix parsing CreateAccountWithSeed instructions (#13513) (#13517)
* Reduce required num_system_accounts and handle 2-account instructions properly

* Update CreateAccountWithSeed account docs to be correct

* Add CreateAccountWithSeed test

(cherry picked from commit 91f4e99b4c)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-11 01:13:12 +00:00
52ee3b1cee watchtower: Fix all clear duration message (#13510)
(cherry picked from commit 2a96e722b4)

Co-authored-by: Justin Starry <justin@solana.com>
2020-11-10 19:11:51 +00:00
bbadcca414 Bump token version fetched for localnet (#13490) (#13506)
(cherry picked from commit 3282334741)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-10 18:04:15 +00:00
e9eba97299 Fix signature access (#13491) (#13503)
(cherry picked from commit 70c4626efe)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-11-10 17:53:43 +00:00
920b63944e Make testnet section less ambiguous (#13504) (#13508)
(cherry picked from commit 599dae8f09)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-10 17:12:57 +00:00
8104895a07 Send RPC notification when account is deleted (#13440) (#13496)
* Send RPC notification when account is deleted

* Remove unwrap

(cherry picked from commit a97c04b400)

Co-authored-by: Justin Starry <justin@solana.com>
2020-11-10 13:07:51 +00:00
c9e646b86b Bump version to v1.4.7 (#13488) 2020-11-10 05:55:26 +00:00
7c47db1e3d align cluster and sim logging as hex (#13484) (#13486)
(cherry picked from commit c280d40b40)

Co-authored-by: Jack May <jack@solana.com>
2020-11-10 03:58:19 +00:00
c619e9b560 Docs update rpc getaccountinfo (bp #13483) (#13487)
* docs: Wrap RPC `getAccountInfo` at 80 char

(cherry picked from commit 1d7c00c915)

* docs: Consistently use "jsonParsed" param for RPC `getAccountInfo`

(cherry picked from commit 87924c7111)

* docs: Consistent used of "jsonParsed" throughout RPC reference

(cherry picked from commit fb815294b3)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-11-10 03:41:26 +00:00
ccd48923a0 Fix Bank accounts hash mismatch related to Clock::unix_timestamp (#13477) (#13485)
* Test for different ancestors with mismatch bank hash

* Test cleanup

* Remove nondeterministic ancestor check

* Update timestamp bounding feature key

* Update design doc

* Filter recent_timestamps to nodes voting within the last epoch

Co-authored-by: Stephen Akridge <sakridge@gmail.com>

Co-authored-by: Stephen Akridge <sakridge@gmail.com>
2020-11-10 03:35:22 +00:00
4e797cc867 Clean up Delegation::stake_activating_and_deactivating (#13471) (#13473)
(cherry picked from commit 5306eb93cc)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-09 09:57:32 +00:00
9627bfced3 propagates errors out of Packet::from_data (#13445) (#13470)
Packet::from_data is ignoring serialization errors:
https://github.com/solana-labs/solana/blob/d08c3232e/sdk/src/packet.rs#L42-L48
This is likely never useful as the packet will be sent over the wire
taking bandwidth but at the receiving end will either fail to
deserialize or it will be invalid.
This commit will propagate the errors out of the function to the
call-site, allowing the call-site to handle the error.

(cherry picked from commit 73ac104df2)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-11-08 16:25:36 +00:00
f823b10597 Clean up Delegation::stake_and_activating (#13460) (#13469)
(cherry picked from commit 737d3e376d)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-08 09:47:47 +00:00
c9e56c9749 Output more inflation calc details in ledger-tool (#13345) (#13467)
* Output more inflation calc details in ledger-tool

* Fix broken ci...

* Rename confusing variables

* Fix panic by wrapping PointValue with Opiton...

* Minor modifications

* Remove explict needless flush; Drop already does

* Yet another csv field adjustments

* Add data_size and rename epochs to earned_epochs

* Introduce null_tracer

* Unwrap Option in new_from_parent_with_tracer

* Don't shorten identifiers

* Allow irrefutable_let_patterns temporalily

* More null_tracer

* More field adjustments

(cherry picked from commit a81e7e7749)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-08 09:01:36 +00:00
da7482d631 Add PATH to GNU readlink 2020-11-07 11:28:28 -08:00
97650c7f37 Install coreutils on osx for 'readlink -f' support 2020-11-06 23:01:32 -08:00
e738bf1c9a Bump version to v1.4.6 2020-11-07 02:49:14 +00:00
afebb2a8a5 CLI: Make clear that nonce account 'Nonce' field is a blockhash
(cherry picked from commit b4790120cb)
2020-11-06 17:19:52 -08:00
4e4fd03b65 Add builtin mem tests (bp #13429) (#13437)
* Add builtin mem tests (#13429)


(cherry picked from commit 84b139cc94)

* resolve crate version

* nudge

Co-authored-by: Jack May <jack@solana.com>
2020-11-07 01:15:35 +00:00
049ca18dc5 Fix stake split rent-exempt adjustment (#13357) (#13453)
* Add failing tests

* Fix stake split

* Calculate split rent-exempt-reserve and use

* Add comment in rent.rs

* Add tests for edge cases when splitting to larger accounts, and reject overflow splits

* Reframe InsufficientFunds checks in terms of lamports var

* Test hardening review comments

(cherry picked from commit 4c5f345798)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-06 22:05:57 +00:00
495c64556e cargo-build-bpf/cargo-test-bpf now support --workspace/--all (#13451)
(cherry picked from commit 0ea795caa8)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-06 21:43:12 +00:00
747e91d434 Fix stake redelegate (bp #13358) (#13450)
* stake: Add redelegation failing test

(cherry picked from commit 491ad59d2e)

* stake: Consider withdraws we redelegating

(cherry picked from commit fe1e08b9ad)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-11-06 20:07:46 +00:00
6d4f6e79b0 cargo-test-bpf now sets the "test-bpf" feature for crate tests (#13447)
The feature allows for tests to distinguish between `cargo test` and
`cargo test-bpf` primarily for the purpose of excluding CPI tests that
require the system program under `cargo test`, as the path to enabling
CPI in `cargo test`-based testing is unclear

(cherry picked from commit 1a70a2a25b)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-06 19:39:18 +00:00
98e9f34704 Feature-gate stake program (#13394) (#13439)
* Add legacy stake-program handling

* Strip out duplicative legacy code

* Add feature for stake-program-fix

* Feature-deploy new stake program

* Expand comment

(cherry picked from commit 1b1d9f6b0c)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-06 09:25:34 +00:00
70f74174e8 program-test: Remove special case for Rent sysvar (bp #13434) (#13435)
* Revert "Include Rent in ProgramTest::start() output"

This reverts commit c3d2d2134c.

(cherry picked from commit 920cd5285a)

* Add get_rent()

(cherry picked from commit 9a1c1fbab8)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-06 05:24:44 +00:00
70985f82f1 CI: Check monorepo for consistent crate versions (bp #13431) (#13433)
* increment-cargo-version.sh: Add check subcommand

(cherry picked from commit 5d4015358a)

* CI: Check monorepo for consistent crate versions

(cherry picked from commit 7a4e293b3b)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-11-06 02:29:26 +00:00
3b2bdd9f8a Fix duplicate records of inner instructions (#13380) (#13413)
* Fix duplicate records of inner instructions

* fix tests

* fix clippy

* Remove bad_inner_instructions

(cherry picked from commit c24fbb6f8b)

Co-authored-by: Justin Starry <justin@solana.com>
2020-11-06 01:30:24 +00:00
d33ae59fbf SPL Associated Token Account plumbing (bp #13398) (#13430)
* Fetch associated-program-account

(cherry picked from commit 4d553f4879)

* Add SPL Associated Token Account Program label to explorer

(cherry picked from commit 2d24160376)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-06 00:01:31 +00:00
9ead7ca11a Define BPF_OUT_DIR for program-test, also handle -- arguments better 2020-11-05 22:42:35 +00:00
dbcef35f7d Search BPF_OUT_DIR for programs 2020-11-05 22:42:35 +00:00
9e733d7d9b Check file modification times before strip and dump 2020-11-05 22:42:35 +00:00
39f1240ec2 Cargo.lock 2020-11-05 22:42:35 +00:00
fa249721fa Search for program files in 'target/deploy' 2020-11-05 22:42:35 +00:00
137793cd4c Add cargo-test-bpf 2020-11-05 22:42:35 +00:00
47d8608aee Remove unneeded .gitignore 2020-11-05 22:42:35 +00:00
ed410aea10 adds the missing slash in cargo path (#13424) (#13427)
(cherry picked from commit 44b12a1594)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-11-05 22:10:06 +00:00
957dfa8f73 docs: Clarify the commitment levels based on questions (#13387)
* Clarify the commitment levels based on questions

Many people have asked about what commitment levels mean, and which to
choose.  This update includes some of the language at
`sdk/src/commitment_config.rs` and a recommendation for different use
cases.

Additionally, the preflight commitment documentation was out of date,
specifying that "max" was always used, and this is no longer the case.

* Update docs/src/developing/clients/jsonrpc-api.md

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>

* Update docs/src/developing/clients/jsonrpc-api.md

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>

* Update docs/src/developing/clients/jsonrpc-api.md

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>

* Fix typo

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
(cherry picked from commit ede891a6c6)
2020-11-05 13:25:23 -08:00
98095b6f8d drops older gossip packets when load shedding (#13364) (#13423)
Gossip drops incoming packets when overloaded:
https://github.com/solana-labs/solana/blob/f6a73098a/core/src/cluster_info.rs#L2462-L2475
However newer packets are dropped in favor of the older ones.
This is probably not ideal as newer packets are more likely to contain
more recent data, so dropping them will keep the validator state
lagging.

(cherry picked from commit 7f4debdad5)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-11-05 18:30:00 +00:00
a2c32d7d0e shares the lock on gossip when processing prune messages (#13339) (#13422)
Processing prune messages acquires an exclusive lock on gossip:
https://github.com/solana-labs/solana/blob/55b0428ff/core/src/cluster_info.rs#L1824-L1825
This can be reduced to a shared lock if active-sets are changed to use
atomic bloom filters:
https://github.com/solana-labs/solana/blob/55b0428ff/core/src/crds_gossip_push.rs#L50

(cherry picked from commit 8f0796436a)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-11-05 17:18:22 +00:00
b15d826476 Allow feature builtins to overwrite existing builtins (#13403) (#13420)
* Allow feature builtins to overwrite existing builtins

* Add feature_builtin ActivationType

* Correctly retain idempotent for replacing case

* Fix test

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
(cherry picked from commit bc62313c66)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-05 16:51:25 +00:00
ed97a2578d measures processing time of each kind of gossip packets (#13366) (#13418)
(cherry picked from commit 118ce47b97)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-11-05 16:46:25 +00:00
89f61f0b41 Bump low end validator RAM requirement (#13406) (#13408) 2020-11-05 15:24:16 +08:00
04cc9c1148 CI: Use branch-versioned cargo throughout (#13411)
(cherry picked from commit 66c3c6c2b3)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-11-05 06:25:11 +00:00
8314ab4508 Improve invoke_signed() docs (#13405)
(cherry picked from commit 8c4995b22b)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-05 01:07:24 +00:00
3a98042753 Final program ELF is now placed in ./target/deploy/ instead of . (#13404)
(cherry picked from commit 661a935075)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-05 00:19:19 +00:00
60d316c9fd Bump spl-token and spl-memo crate versions (#13400)
Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-04 23:16:41 +00:00
e324c221a6 uses thread-pool when handling push messages (#13338) (#13395)
From runtime profiles, the majority time of solana-listen thread:
https://github.com/solana-labs/solana/blob/55b0428ff/core/src/cluster_info.rs#L2720
is spent handling push messages. The code here:
https://github.com/solana-labs/solana/blob/55b0428ff/core/src/cluster_info.rs#L2272-L2364
may utilize the idle gossip thread-pool.

(cherry picked from commit 10fa4f45ab)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-11-04 20:28:56 +00:00
61246999ac Update SPL Token exchange documentation to include associated-token-account workflow (#13397)
(cherry picked from commit 97284adabb)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-04 19:57:02 +00:00
e476dc4eaa Comment Stakes::clone_with_epoch (#13388) (#13390)
(cherry picked from commit b0d1ae1d8b)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-04 12:29:13 +00:00
ee18e7668b Refine transaction log count message (#13378)
(cherry picked from commit b5ef319038)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-04 06:44:49 +00:00
62db7f6562 Surface transaction logs in rpc client (#13376)
(cherry picked from commit 6d9ca0ae15)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-04 02:12:46 +00:00
2e9b501355 more informative feature error message (#13373) (#13375)
(cherry picked from commit 04c5e6cc48)

Co-authored-by: Jack May <jack@solana.com>
2020-11-04 01:35:22 +00:00
089a99f1e3 docs: Mainnet-beta totally has smart contract enabled (#13369)
(cherry picked from commit fefa297877)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-11-03 19:21:18 +00:00
57961b1d17 Update sol_log_compute_units (#13360) (#13363)
(cherry picked from commit f6a73098a4)

Co-authored-by: Jack May <jack@solana.com>
2020-11-03 17:28:44 +00:00
fe8b2b7850 Include Rent in ProgramTest::start() output (#13356)
(cherry picked from commit c3d2d2134c)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-03 03:12:17 +00:00
0bf45cbab6 Small code cleanup and typo fixes (#13325) (#13341)
* Small code cleanup and typo fixes

* Clean up calculate_points_and_credits

(cherry picked from commit 0e4509c497)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-02 02:42:38 +00:00
5877427389 Bump version to v1.4.5 2020-11-01 17:05:45 +00:00
25141288f4 Fix typos (#13334) (#13335)
(cherry picked from commit af9a3f004e)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-11-01 07:06:46 +00:00
b28d10d46f Add bank timestamp bounding (bp #13120) (#13331)
* Add bounding feature

(cherry picked from commit 96b8aa8bd1)

* Repurpose unused as Clock::epoch_start_timestamp; add gated update

(cherry picked from commit 0049ab69fb)

* Add bounded timestamp-estimation method

(cherry picked from commit 80db6c0980)

* Use bounded timestamp-correction when feature enabled

(cherry picked from commit 90778615f6)

* Prevent block times from ever going backward

(cherry picked from commit eb2560e782)

* Sample votes from ancestors back to root

(cherry picked from commit 4260b3b416)

* Add Clock sysvar details, update struct docs

(cherry picked from commit 3a1e125ce3)

* Add design proposal and update validator-timestamp-oracle

(cherry picked from commit a3912bc084)

* Adapt to feature::create_account

Co-authored-by: Tyera Eulberg <tyera@solana.com>
Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-01 06:02:34 +00:00
b6dc48da75 Add solana-program-test crate (bp #13324) (#13329)
* MockInvokeContext::get_programs() implementation

(cherry picked from commit 8acc47ee1b)

* start_local_server() now works with Banks > 0

(cherry picked from commit fa4bab4608)

* Add solana-program-test crate

(cherry picked from commit 52a292a75b)

* rebase

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-11-01 05:43:43 +00:00
f2d929c12d Move Feature struct to solana-program (#13321)
(cherry picked from commit 4b65e32f22)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-31 20:33:35 +00:00
c49b89091a cargo update -p futures-task / cargo update -p futures-util 2020-10-31 18:50:51 +00:00
23fe3a86d9 Switch to dirs-next 2020-10-31 18:50:51 +00:00
2f778725d6 Ignore stdweb 2020-10-31 18:50:51 +00:00
93a119a51e Print the entry type as well when checking archive (#13312) (#13314)
(cherry picked from commit bc7133d752)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-30 17:48:23 +00:00
65a7b536c9 Update AccountInfo comments (#13302)
(cherry picked from commit 72d41e5801)
2020-10-30 08:09:37 -07:00
1281483a8c Fix tower/blockstore unsync due to external causes (#12671) (#13310)
* Fix tower/blockstore unsync due to external causes

* Add and clean up long comments

* Clean up test

* Comment about warped_slot_history

* Run test_future_tower with master-only/master-slave

* Update comments about false leader condition

(cherry picked from commit 1df15d85c3)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-30 11:47:22 +00:00
4312841433 de-mut some InvokeContext methods (bp #13301) (#13309)
* de-mut some InvokeContext methods

(cherry picked from commit da9548fd12)

* Simplify CPI interface into MessageProcessor

(cherry picked from commit 9263ae1c60)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-30 10:35:59 +00:00
b859acbfea Upgrade tarpc and tokio (bp #13293) (#13300)
* Upgrade tarpc and tokio (#13293)

(cherry picked from commit ca00197009)

# Conflicts:
#	banks-client/Cargo.toml
#	banks-interface/Cargo.toml
#	banks-server/Cargo.toml

* rebase

Co-authored-by: Greg Fitzgerald <greg@solana.com>
Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-30 08:05:27 +00:00
40a3885d3b Native/builtin programs now receive an InvokeContext (bp #13286) (#13298)
* Native/builtin programs now receive an InvokeContext

(cherry picked from commit df8dab9d2b)

* Remove MessageProcessor::loaders

(cherry picked from commit 2664a1f7ef)

* Remove Entrypoint type

(cherry picked from commit 225bed11c7)

* Remove programs clone()

(cherry picked from commit 33884d847a)

* Add sol_log_compute_units syscall

(cherry picked from commit 66e51a7363)

* Add Bank::set_bpf_compute_budget()

(cherry picked from commit 7d686b72a0)

* Rebase

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-30 07:47:17 +00:00
36b7c2ea97 Refactors the common code of test and bench targets into the solana_runtime::bpf_test_utils module. (#13203)
(cherry picked from commit 65ee3a6bdd)
2020-10-29 22:03:09 -07:00
24bd4ff6d4 clarify comment (#13289) (#13292)
(cherry picked from commit b5c8b86e7c)

Co-authored-by: Jack May <jack@solana.com>
2020-10-29 22:38:26 +00:00
69b3f10207 move Account to solana-sdk (bp #13198) (#13269)
* move Account to solana-sdk (#13198)

(cherry picked from commit c458d4b213)

# Conflicts:
#	programs/bpf/benches/bpf_loader.rs

* resolve conflicts

Co-authored-by: Jack May <jack@solana.com>
2020-10-29 19:16:52 +00:00
9922f09a1d adds more parallel processing to gossip packets handling (#12988) (#13282)
(cherry picked from commit 3738611f5c)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-10-29 16:47:37 +00:00
38a99c0c25 Disable eager rent collection for less noise (#13275) (#13280)
(cherry picked from commit 363c148dbe)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-29 15:49:02 +00:00
7031235714 excludes origin from prune set (#13204) (#13276)
On the receiving end, prune messages are ignored if the origin points to
the node itself:
https://github.com/solana-labs/solana/blob/631f029fe/core/src/crds_gossip_push.rs#L285-L295
So to avoid sending these over the wire, the requester can exclude
origin from the prune set.

(cherry picked from commit be80f6d5c5)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-10-29 14:19:06 +00:00
dfb2356a9a Update FeatureSet::active to include slot-activated (#13256) (#13263)
* Update FeatureSet::active to include slot-activated

* Clippy suggestion

(cherry picked from commit c2dbf53d76)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-10-29 03:42:42 +00:00
010794806a Finer grained AccountsIndex locking (#12787) (#13240)
Co-authored-by: Carl Lin <carl@solana.com>

Co-authored-by: carllin <wumu727@gmail.com>
Co-authored-by: Carl Lin <carl@solana.com>
2020-10-28 23:46:54 +00:00
6f95d5f72a Update links from sdk to program (#13248) (#13249)
(cherry picked from commit db9ddc7e5b)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-10-28 21:32:12 +00:00
2720b939fd Calculate accounts hash async in accounts background service (#12852) (#13244)
(cherry picked from commit 456eae6ccb)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-10-28 21:20:07 +00:00
a25c3fcf7d Add doc page on sysvar accounts (#13237) (#13246)
* Add doc page on sysvar accounts

* Update with suggestions

(cherry picked from commit 664b6125b6)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-10-28 21:16:10 +00:00
7cc4810174 docs: Metrics update (bp #13239) (#13241)
* docs: Remove stale metrics steps

(cherry picked from commit 4dc4fefee2)

* docs: Reference metrics envvars for each cluster

(cherry picked from commit eb597cd60f)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-10-28 19:46:59 +00:00
c1a55bf249 Improve final report of ledger-tool capitalization (#13232) (#13236)
(cherry picked from commit 4698ee5e4a)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-28 18:45:19 +00:00
f19778b7d9 implements ping-pong packets between nodes (#12794) (#13234)
https://hackerone.com/reports/991106

> It’s possible to use UDP gossip protocol to amplify DDoS attacks. An attacker
> can spoof IP address in UDP packet when sending PullRequest to the node.
> There's no any validation if provided source IP address is not spoofed and
> the node can send much larger PullResponse to victim's IP. As I checked,
> PullRequest is about 290 bytes, while PullResponse is about 10 kB. It means
> that amplification is about 34x. This way an attacker can easily perform DDoS
> attack both on Solana node and third-party server.
>
> To prevent it, need for example to implement ping-pong mechanism similar as
> in Ethereum: Before accepting requests from remote client needs to validate
> his IP. Local node sends Ping packet to the remote node and it needs to reply
> with Pong packet that contains hash of matching Ping packet. Content of Ping
> packet is unpredictable. If hash from Pong packet matches, local node can
> remember IP where Ping packet was sent as correct and allow further
> communication.
>
> More info:
> https://github.com/ethereum/devp2p/blob/master/discv4.md#endpoint-proof
> https://github.com/ethereum/devp2p/blob/master/discv4.md#wire-protocol

The commit adds a PingCache, which maintains records of remote nodes
which have returned a valid response to a ping message, and on-the-fly
ping messages pending a pong response from the remote node.

When handling pull-requests, those from addresses which have not passed
the ping-pong check are filtered out, and additionally ping packets are
added for addresses which need to be (re)verified.

(cherry picked from commit ae91270961)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-10-28 18:36:28 +00:00
eecdacac42 Don't hold dashmap write lock in store create (#13007) (#13230)
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit c8fc0a6ba1)

Co-authored-by: carllin <wumu727@gmail.com>
2020-10-28 11:36:28 +00:00
429f130532 Switch accounts storage lock to DashMap (#12126) (#13223)
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit f8d338c9cb)

Co-authored-by: carllin <wumu727@gmail.com>
2020-10-28 08:07:28 +00:00
19b9839dfc Use pico inflation for ledger-tool capitalization --enable-inflation (#13215) (#13222)
* Use pico inflation for ledger-tool capitalization --enable-inflation

* rust fmt

(cherry picked from commit 7d2962135d)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-28 07:40:21 +00:00
ad2bf3afa6 more portable install.sh (#13114) (#13220)
(cherry picked from commit 4e0d1b1d4a)

Co-authored-by: Jack May <jack@solana.com>
2020-10-28 06:45:32 +00:00
5c739ba236 Use zstd for create-snapshot (#13214) (#13218)
(cherry picked from commit 6d4c69b7c3)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-28 06:38:20 +00:00
9fac507606 Fix log (#13207) (#13211)
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit f96ab5a818)

Co-authored-by: carllin <wumu727@gmail.com>
2020-10-28 03:21:01 +00:00
d5a37cb06e Parse vote instructions (#13202) (#13209)
(cherry picked from commit c4962af9eb)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-10-28 01:19:29 +00:00
86eb0157c0 Account for forward delay in transaction simulation (#13199) (#13201)
(cherry picked from commit 631f029fe9)

Co-authored-by: Justin Starry <justin@solana.com>
2020-10-27 18:35:43 +00:00
072dab0948 Fix pr crossing for sysvar keyed-accounts (#13189) (#13191)
(cherry picked from commit 26eba5ac7d)

Co-authored-by: Jack May <jack@solana.com>
2020-10-27 08:33:13 +00:00
e20e79f412 ignore .so files (#13188) (#13192)
(cherry picked from commit bb6ab3a62d)

Co-authored-by: Jack May <jack@solana.com>
2020-10-27 07:23:50 +00:00
f118db81ce check sysvar id for AccountInfo (#13175) (#13185)
(cherry picked from commit 322c667655)

Co-authored-by: Jack May <jack@solana.com>
2020-10-27 00:22:27 -07:00
4ecb78d303 Move KeyedAccount out of solana-program. Native programs are not supported by solana-program (bp #13159) (#13181)
* Move KeyedAccount out of solana-program.  Native programs are not supported by solana-program

(cherry picked from commit 1b343665a1)

# Conflicts:
#	programs/bpf/benches/bpf_loader.rs

* rebase

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-27 05:43:14 +00:00
0a28e40606 fix .gitignore (#13177) (#13190)
(cherry picked from commit e3c0cc980b)

Co-authored-by: Jack May <jack@solana.com>
2020-10-27 05:26:59 +00:00
4d7a5a9daf macos portable rust-bpf (#13176) (#13187)
(cherry picked from commit fc83a666fc)

Co-authored-by: Jack May <jack@solana.com>
2020-10-27 04:51:14 +00:00
64cf6b4388 Add SSH key for buildkite-agent on achille (#13183)
(cherry picked from commit ff4b34202c)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-10-27 03:19:32 +00:00
f334c3b895 Add Bank::get_signature_status_with_blockhash() (#13167) (#13178)
Get the signature status in O(1) time, instead of O(n) where
n is the number of blockhashes in the StatusCache.

(cherry picked from commit f58bc8589d)

Co-authored-by: Greg Fitzgerald <greg@solana.com>
2020-10-27 01:29:16 +00:00
15a7bcd4fe Delete .lib.rs.swo 2020-10-26 16:01:43 -07:00
8d6636d02a CLI: Surface deploy transaction errors (#13170)
(cherry picked from commit a82971879f)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-10-26 22:43:32 +00:00
cf896dbeee Use bank timestamp to populate Blockstore::blocktime_cf when correction active (#13158) (#13160)
(cherry picked from commit 39686ef098)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-10-26 20:34:15 +00:00
e5b60b75f8 Docs: Testnet has a faucet now (#13165)
(cherry picked from commit 8b1638f026)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-10-26 20:28:59 +00:00
0e155fdbd9 update call depth docs (#13155) (#13162)
(cherry picked from commit 35f77ccc73)

Co-authored-by: Jack May <jack@solana.com>
2020-10-26 19:58:55 +00:00
b79a337ddd Don't reuse BPF target build artifacts
(cherry picked from commit 41a56e14fc)
2020-10-26 12:01:38 -07:00
c4050f541d Fix reward type encoding
(cherry picked from commit 0a89bb4d3c)
2020-10-26 12:01:38 -07:00
f0b74a4ecf marks pull request creation time only once per peer (#13113) (#13156)
mark_pull_request_creation time requires an exclusive lock on gossip:
https://github.com/solana-labs/solana/blob/16944e218/core/src/cluster_info.rs#L1547-L1548
Current code is redundantly marking each peer once for each request.
There are at most only 2 unique peers, whereas there are hundreds of
requests per each. So the lock is acquired hundreds of time longer than
necessary.

(cherry picked from commit 4bfda3e766)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-10-26 18:27:26 +00:00
f7979378fd Fix test_optimistic_confirmation_violation_without_tower() (#13043) (#13145)
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit dd6cccaf7e)

Co-authored-by: carllin <wumu727@gmail.com>
2020-10-26 06:33:20 +00:00
d7c5607982 Hide noisy specialization warnings for frozen abi (#13141) (#13144)
(cherry picked from commit 5caf81dbf8)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-26 06:19:58 +00:00
91ab5ae990 Remove program feature from SPL builds 2020-10-25 21:08:53 -07:00
605e767259 Allow existence of vote on root in saved tower (#13135) (#13139)
(cherry picked from commit 66c7a98009)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-26 12:34:58 +09:00
597618846b Bump version to v1.4.4 2020-10-24 22:10:32 +00:00
712267bf51 Rename "everything" feature to "full"
(cherry picked from commit 0cc9c94c43)
2020-10-24 13:21:11 -07:00
eb9cef0cd4 Separate the "program" feature of solana-sdk into a new crate called solana-program (bp #12989) (#13131)
* Add solana-program-sdk boilerplate

(cherry picked from commit 3718771ffb)

# Conflicts:
#	sdk/Cargo.toml

* Initial population of solana-program-sdk

(cherry picked from commit 63db324204)

# Conflicts:
#	Cargo.lock

* Port programs to solana-program-sdk

(cherry picked from commit fe68f7f786)

# Conflicts:
#	programs/bpf/Cargo.lock
#	programs/bpf/rust/128bit/Cargo.toml
#	programs/bpf/rust/128bit_dep/Cargo.toml
#	programs/bpf/rust/alloc/Cargo.toml
#	programs/bpf/rust/call_depth/Cargo.toml
#	programs/bpf/rust/custom_heap/Cargo.toml
#	programs/bpf/rust/dep_crate/Cargo.toml
#	programs/bpf/rust/deprecated_loader/Cargo.toml
#	programs/bpf/rust/dup_accounts/Cargo.toml
#	programs/bpf/rust/error_handling/Cargo.toml
#	programs/bpf/rust/external_spend/Cargo.toml
#	programs/bpf/rust/instruction_introspection/Cargo.toml
#	programs/bpf/rust/invoke/Cargo.toml
#	programs/bpf/rust/invoked/Cargo.toml
#	programs/bpf/rust/iter/Cargo.toml
#	programs/bpf/rust/many_args/Cargo.toml
#	programs/bpf/rust/many_args_dep/Cargo.toml
#	programs/bpf/rust/noop/Cargo.toml
#	programs/bpf/rust/panic/Cargo.toml
#	programs/bpf/rust/param_passing/Cargo.toml
#	programs/bpf/rust/param_passing_dep/Cargo.toml
#	programs/bpf/rust/rand/Cargo.toml
#	programs/bpf/rust/ristretto/Cargo.toml
#	programs/bpf/rust/sanity/Cargo.toml
#	programs/bpf/rust/sha256/Cargo.toml
#	programs/bpf/rust/sysval/Cargo.toml

* Only activate legacy program feature for the solana-sdk crate

(cherry picked from commit 85c51f5787)

* Run serum-dex unit tests

(cherry picked from commit 92ce381d60)

* Rename solana-program-sdk to solana-program

(cherry picked from commit dd711ab5fb)

# Conflicts:
#	programs/bpf/rust/128bit/Cargo.toml
#	programs/bpf/rust/128bit_dep/Cargo.toml
#	programs/bpf/rust/alloc/Cargo.toml
#	programs/bpf/rust/call_depth/Cargo.toml
#	programs/bpf/rust/custom_heap/Cargo.toml
#	programs/bpf/rust/dep_crate/Cargo.toml
#	programs/bpf/rust/deprecated_loader/Cargo.toml
#	programs/bpf/rust/dup_accounts/Cargo.toml
#	programs/bpf/rust/error_handling/Cargo.toml
#	programs/bpf/rust/external_spend/Cargo.toml
#	programs/bpf/rust/instruction_introspection/Cargo.toml
#	programs/bpf/rust/invoke/Cargo.toml
#	programs/bpf/rust/invoked/Cargo.toml
#	programs/bpf/rust/iter/Cargo.toml
#	programs/bpf/rust/many_args/Cargo.toml
#	programs/bpf/rust/many_args_dep/Cargo.toml
#	programs/bpf/rust/noop/Cargo.toml
#	programs/bpf/rust/panic/Cargo.toml
#	programs/bpf/rust/param_passing/Cargo.toml
#	programs/bpf/rust/param_passing_dep/Cargo.toml
#	programs/bpf/rust/rand/Cargo.toml
#	programs/bpf/rust/ristretto/Cargo.toml
#	programs/bpf/rust/sanity/Cargo.toml
#	programs/bpf/rust/sha256/Cargo.toml
#	programs/bpf/rust/sysval/Cargo.toml

* Update frozen_abi hashes

The movement of files in sdk/ caused ABI hashes to change

(cherry picked from commit a4956844bd)

* Resolve merge conflicts

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-24 17:25:22 +00:00
62e0e19961 add precompile verification to simulate_transaction (#13080) (#13126)
(cherry picked from commit 766406fd23)

Co-authored-by: Josh <josh.hundley@gmail.com>
2020-10-24 05:02:41 +00:00
9aee9cb867 Clean up opt conf verifier and vote state tracker (#13081) (#13124)
* Clean up opt conf verifier and vote state tracker

* Update test to follow new message and some knob

* Rename

(cherry picked from commit 0264147d42)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-24 04:12:02 +00:00
2b11558b36 Shorten magic install URL (#13122)
(cherry picked from commit b5170b993e)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-23 23:28:19 +00:00
18c4e1b023 ci: Add downstream project build testing (bp #13112) (#13119)
* Use local cargo for CI

(cherry picked from commit c7c50bd32c)

* Add downstream project build testing

(cherry picked from commit c7f4f15e60)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-23 22:13:51 +00:00
6bac44ed92 Move bpf sdk packaging from publish-tarball to cargo-install-all (#13117)
(cherry picked from commit 965ea97b56)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-23 21:39:41 +00:00
8cb622084f Cli: deploy programs via TPU (#13090) (#13111)
* Deploy: send write transactions to leader tpu

* Less apparent stalling during confirmation

* Add EpochInfo mock

* Only get cluster nodes once

* Send deploy writes to next leader

(cherry picked from commit 16944e218f)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-10-23 17:29:41 +00:00
38f7e9a979 shrink debug (#13089) (#13109)
(cherry picked from commit 7d2729f6bd)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-10-23 17:02:00 +00:00
a536f779ee scans crds table in parallel for finding old labels (#13073) (#13107)
From runtime profiles, the majority time of ClusterInfo::handle_purge
https://github.com/solana-labs/solana/blob/0776fa05c/core/src/cluster_info.rs#L1605-L1626
is spent scanning crds table finding old labels:
https://github.com/solana-labs/solana/blob/0776fa05c/core/src/crds.rs#L175-L197

This can be done in parallel given that gossip thread-pool:
https://github.com/solana-labs/solana/blob/0776fa05c/core/src/cluster_info.rs#L1637-L1641
is idle when handle_purge is invoked:
https://github.com/solana-labs/solana/blob/0776fa05c/core/src/cluster_info.rs#L1681

(cherry picked from commit 37c8842bcb)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-10-23 15:36:06 +00:00
84a5e5ec97 Remove spammy invalid rpc log (#13100) (#13102)
(cherry picked from commit c95f6c4b83)

Co-authored-by: Justin Starry <justin@solana.com>
2020-10-23 08:32:46 +00:00
dd33aae3cf Add --bpf-out-dir argument to control where the final build products land (#13099)
(cherry picked from commit b169d9cfbe)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-23 07:56:35 +00:00
be2ace47e3 Add deploy err if program-account balance is too high (#13091) (#13098)
* Add deploy err if program-account balance is too high

* Review comments

* Add system-program check

* Rename and unhide flag

(cherry picked from commit 4669fa0f98)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-10-23 07:02:16 +00:00
53b074aa35 Bump version to 1.4.3 2020-10-23 04:20:28 +00:00
a4ad2925a2 Allow nodes to advertise a different rpc address over gossip (#13053) (#13078)
* Allow nodes to advertise a different rpc address over gossip

* Feedback

(cherry picked from commit 8b0242a5d8)

Co-authored-by: Justin Starry <justin@solana.com>
2020-10-22 07:06:27 +00:00
edfbd8d65a Add replacements for Pubkey::new_rand()/Hash::new_rand() (bp #12987) (#13076)
* Add pubkey_new_rand(), mark Pubkey::new_rand() deprecated

(cherry picked from commit 0e68ed6a8d)

* Add hash_new_rand(), mark Hash::new_rand() as deprecated

(cherry picked from commit 76f11c7dae)

* Run `codemod --extensions rs Pubkey::new_rand solana_sdk::pubkey::new_rand`

(cherry picked from commit 7bc073defe)

# Conflicts:
#	programs/bpf/benches/bpf_loader.rs
#	runtime/benches/accounts.rs
#	runtime/src/accounts.rs

* Run `codemod --extensions rs Hash::new_rand solana_sdk:#️⃣:new_rand`

(cherry picked from commit 17c391121a)

* Remove unused pubkey::Pubkey imports

(cherry picked from commit 959880db60)

# Conflicts:
#	runtime/src/accounts_index.rs

* Resolve conflicts

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-22 05:08:01 +00:00
e0ae54fd7e Add cargo-build-bpf (bp #13040) (#13075)
* Add cargo-build-bpf

(cherry picked from commit 07a853d6cc)

* Remove do.sh

(cherry picked from commit 61be155413)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-22 03:09:52 +00:00
60297951ec CLI: Print address ephemeral keypair seed phrase to stderr on deploy failure (bp #13046) (#13055)
* CLI: Print address ephemeral keypair seed phrase to stderr on deploy failure

(cherry picked from commit 2905ccc7ec)

# Conflicts:
#	cli/Cargo.toml

* Fix conflicts

Co-authored-by: Trent Nelson <trent@solana.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
2020-10-21 15:29:56 -06:00
e0f9f72a2c RPC: Don't send base64 TXs to old clusters (#13072)
Co-authored-by: Trent Nelson <trent@solana.com>
2020-10-21 20:25:36 +00:00
5236acf4b0 Add ledger-tool dead-slots and improve purge a lot (#13065) (#13071)
* Add ledger-tool dead-slots and improve purge a lot

* Reduce batch size...

* Add --dead-slots-only and fixed purge ordering

(cherry picked from commit 0776fa05c7)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-21 18:57:22 +00:00
5dd61b5db2 Port various rent fixes to runtime feature (#12842) (#13068)
* Port various rent fixes to runtime feature

* Fix CI

* Use more consistent naming...

(cherry picked from commit 608b81b412)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-21 14:47:48 +00:00
8752bf0826 Skip 'Stake by Feature Set' output when showing status of a single feature (#13052)
(cherry picked from commit ad65d4785e)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-21 07:14:49 +00:00
b1712e80ec Parse stake and system instructions (#13035) (#13045)
* Fix token account check

* Add helper to check num accounts

* Add parse_stake

* Add parse_system

* Fix AuthorizeNonce docs

* Remove jsonParsed unstable markers

* Clippy

(cherry picked from commit 46d0019955)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-10-21 04:35:05 +00:00
2fe1a4677c Ignore more paths in increment-cargo-version.sh
(cherry picked from commit c1c69ecc34)
2020-10-20 20:55:34 -07:00
f76c128f4f Various clean-ups before assert adjustment (#13006) (#13041)
* Various clean-ups before assert adjustment

* oops

(cherry picked from commit efdb560e97)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-21 02:41:20 +00:00
b143b9c3c2 Remove frozen ABI modules from solana-sdk (bp #13008) (#13036)
* Remove frozen ABI modules from solana-sdk

(cherry picked from commit 6858950f76)

# Conflicts:
#	Cargo.lock
#	core/Cargo.toml
#	frozen-abi/macro/Cargo.toml
#	programs/bpf/Cargo.lock
#	programs/stake/Cargo.toml
#	programs/vote/Cargo.toml
#	runtime/Cargo.toml
#	sdk/Cargo.toml
#	version/Cargo.toml

* rebase

* fix broken ci (#13039)

Co-authored-by: Michael Vines <mvines@gmail.com>
Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-21 02:00:45 +00:00
b4178b75e7 Add --eval flag to solana-install info (#13038)
(cherry picked from commit 6f930351d2)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-21 01:12:48 +00:00
c54b751df7 Include sdk/bpf in the main release tarball
(cherry picked from commit f71677164f)
2020-10-20 16:25:04 -07:00
0fde9e893f Force unset CARGO to use correct version of cargo (#13027) (#13034)
(cherry picked from commit 81d0c8ae7f)

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2020-10-20 23:06:57 +00:00
d24abbdac9 Fix secp256k1 instruction indexing and add tests (#13026) (#13032)
(cherry picked from commit 83c53ae4b5)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-10-20 22:25:59 +00:00
3b03985f28 Remove unsupported metrics tarball from release artifacts
(cherry picked from commit 62f20bc170)
2020-10-20 13:16:35 -07:00
d05bfa08c7 improves threads' utilization in processing gossip packets (#12962) (#13023)
ClusterInfo::process_packets handles incoming packets in a thread_pool:
https://github.com/solana-labs/solana/blob/87311cce7/core/src/cluster_info.rs#L2118-L2134

However, profiling runtime shows that threads are not well utilized and
a lot of the processing is done sequentially.

This commit redistributes the work done in parallel. Testing on a gce
cluster shows 20%+ improvement in processing gossip packets with much
smaller variations.

(cherry picked from commit 75d62ca095)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-10-20 19:59:35 +00:00
9da2ac7a44 passes through feature-set to gossip requests handling (#12878) (#12991)
* passes through feature-set to down to gossip requests handling
* takes the feature-set from root_bank instead of working_bank

(cherry picked from commit 48283161c3)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-10-20 18:25:44 +00:00
9e95d0fb58 Add more info for --limit-ledger-size (#13021)
(cherry picked from commit de04a208c7)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-20 17:50:11 +00:00
94cad9873c Support Debug Bank (#13017) (#13019)
(cherry picked from commit c0675968b1)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-20 17:20:40 +00:00
f33171b32f Remove errant print 2020-10-20 09:02:51 -06:00
aa6406f263 implements DataBudget using atomics (#12856) (#12990)
(cherry picked from commit 05cf15a382)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2020-10-20 12:51:42 +00:00
77864a6bee Parse bpf loader instructions (#12998) (#13005)
* Add parsing for BpfLoader2 instructions

* Skip info if null

* Return account address in info map

(cherry picked from commit 942e4273ba)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-10-20 06:25:56 +00:00
b51715d33c validator: Activate RPC before halting on slot (#13002)
(cherry picked from commit 3b3f7341fa)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-10-20 03:31:04 +00:00
7d395177d4 Add everything feature (#12999)
(cherry picked from commit c5e16383b0)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-20 01:52:21 +00:00
77ba6d6784 sdk: Add SyscallStubs to enable syscall interception when building programs for non-BPF (bp #12984) (#12993)
* Add SyscallStubs to enable syscall interception when building programs for non-BPF

(cherry picked from commit 9c53e1dfb2)

* Remove program_stubs!()

(cherry picked from commit 6d5889bdb5)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-19 22:28:44 +00:00
4bf0a54ed7 Revert "CLI: Put deploy ephemeral keypair behind a flag (#12942)" (#12982)
This reverts commit 8cac6835c0.
2020-10-19 17:41:10 +00:00
8a526f2f53 Follow up to persistent tower with tests and API cleaning (#12350) (#12972)
* Follow up to persistent tower

* Ignore for now...

* Hard-code validator identities for easy reasoning

* Add a test for opt. conf violation without tower

* Fix compile with rust < 1.47

* Remove unused method

* More move of assert tweak to the asser pr

* Add comments

* Clean up

* Clean the test addressing various review comments

* Clean up a bit

(cherry picked from commit 54517ea454)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-19 08:47:58 +00:00
43f99bdb31 Improve vote-account "Recent Timestamp" output (#12971)
(cherry picked from commit 2cc3d7511a)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-19 07:30:29 +00:00
0008dc62e4 Fix zero-lamport accounts preventing slot cleanup (#12606) (#12969)
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit 16d45b8480)

Co-authored-by: carllin <wumu727@gmail.com>
2020-10-19 07:07:08 +00:00
7e8174fb79 Minor doc typo (#12966)
(cherry picked from commit 6123d71489)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-19 03:23:24 +00:00
4ad2ebcde9 Mention monitoring and updating for exchanges (#12953) (#12959)
* Mention monitoring and updating for exchanges

* Fix link syntax...

* Apply suggestions from code review

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>

* Apply suggestions from code review

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>

* More review comments and word-wrapping

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>
(cherry picked from commit 87311cce7f)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-17 06:49:59 +00:00
da183d655a keygen: add more mnemonic language support (#12944) (#12957)
(cherry picked from commit 4451042c76)

Co-authored-by: guanqun <guanqun.lu@gmail.com>
2020-10-17 04:00:29 +00:00
2e449276be Check payer balance for program account rent as needed (#12952) (#12955)
(cherry picked from commit b6bfed64cb)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-10-16 19:14:26 +00:00
8cac6835c0 CLI: Put deploy ephemeral keypair behind a flag (#12942)
(cherry picked from commit 5a5b7f39c1)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-10-16 16:56:50 +00:00
677c184e47 Another some tower logging improvements (#12940) (#12943)
(cherry picked from commit fd8ec27fe8)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-16 07:00:27 +00:00
f36cfb92f7 Convert Blockstore Rewards cf to protobuf (bp #12860) (#12935)
* Convert Blockstore Rewards cf to protobuf (#12860)

* Add Blockstore protobuf cf type

* Add Rewards message to proto and make generated pub

* Convert Rewards cf to ProtobufColumn

* Add bench

* Adjust tags

* Move solana proto definitions and conversion methods to new crate

(cherry picked from commit 359707c85e)

# Conflicts:
#	Cargo.lock
#	ledger/Cargo.toml
#	storage-bigtable/Cargo.toml

* v1.4-ify

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
2020-10-16 01:27:37 +00:00
e7062de05f Report compute budget usage (#12931) (#12934)
(cherry picked from commit b510474dcb)

Co-authored-by: Jack May <jack@solana.com>
2020-10-16 00:05:18 +00:00
a443e2e773 Update get-block method in get_confirmed_transaction (#12923) (#12930)
* Update get-block method in get_confirmed_transaction

* Remove superfluous into()

(cherry picked from commit 42943ab86d)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-10-15 21:38:38 +00:00
3a6db787e2 Support arbitrary toolchains with cargo wrapper script (#12926)
(cherry picked from commit 99aecdaf65)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-10-15 20:26:35 +00:00
f3c986385f Bump version to 1.4.2 2020-10-15 20:26:29 +00:00
3df811348f program log pubkey as base58 (bp #12901) (#12911)
* program log pubkey as base58 (#12901)

(cherry picked from commit 3f9e6a600b)

# Conflicts:
#	programs/bpf/benches/bpf_loader.rs
#	programs/bpf/c/src/tuner/tuner.c

* resolve conflicts

* fix bench conflict

Co-authored-by: Jack May <jack@solana.com>
2020-10-15 19:40:20 +00:00
e8c86ed3e5 Drop 'Pubkey' in 'solana validators' header (#12919)
(cherry picked from commit 3073dc9801)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-15 19:02:10 +00:00
489a7bb576 Bump spl-memo and spl-token versions (#12914) 2020-10-15 18:05:41 +00:00
688dd85e61 Release: Use pinned cargo version to install spl-token-cli (#12916)
(cherry picked from commit bb2f0df9e1)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-10-15 17:59:24 +00:00
fe54a30084 Docs: Clarify validator disk requirements (#12921)
(cherry picked from commit cc0781e0ac)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-10-15 17:56:46 +00:00
80942841a2 Surface 'Program account allocation failed' error details (#12904)
(cherry picked from commit eec3d25ab9)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-15 16:22:12 +00:00
d2808a8e29 docs: Rework JSON RPC curl examples to be more readable (bp #12893) (#12899)
* Rework curl examples to be more readable

(cherry picked from commit f0d0bdc572)

# Conflicts:
#	docs/src/apps/jsonrpc-api.md

* rebase

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-15 15:47:49 +00:00
f8413a28b5 Better tower logs for SwitchForkDecision and etc (#12875) (#12905)
* Better tower logs for SwitchForkDecision and etc

* nits

* Update comment

(cherry picked from commit a44e4d386f)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-15 10:41:03 +00:00
bc96332899 Respect RefCell when calling invoke (#12858) (#12891)
* Respect RefCell when calling invoke

* nudge

(cherry picked from commit 969f7b015b)

Co-authored-by: Jack May <jack@solana.com>
2020-10-15 02:15:36 +00:00
ceeeb3c9dd Change developer CTA (#12857) (#12892)
* change `index.js`

(cherry picked from commit 9e7fad1fd2)

Co-authored-by: R. M. Shea <8948187+rmshea@users.noreply.github.com>
2020-10-15 01:45:06 +00:00
bd058ec8f1 Release: Include SPL Token in release tarballs (#12889)
(cherry picked from commit f70762913c)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-10-15 01:32:34 +00:00
4b5ac44fc8 RPC: Add metrics for TX encoding (#12880)
(cherry picked from commit c26512255d)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-10-14 19:39:08 +00:00
fef979f0e5 Don't report RewardType::Fee when none was awarded (#12877)
(cherry picked from commit 4b04ed86b6)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-14 17:15:41 +00:00
cca2cdf39b Expose program error constants (#12861) (#12871)
(cherry picked from commit d4e953277e)

Co-authored-by: Jack May <jack@solana.com>
2020-10-14 08:48:50 +00:00
6e91996606 Bump version to 1.4.1 2020-10-14 03:05:04 +00:00
99be00d61f Add separate push queue to reduce push lock contention (#12713) (#12867)
(cherry picked from commit 1f1eb9f26e)

Co-authored-by: sakridge <sakridge@gmail.com>
2020-10-14 02:46:13 +00:00
68f808026e Add log_messages to proto file (#12859) (#12863)
(cherry picked from commit 67ed44c007)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-10-14 01:50:55 +00:00
0c7ab0a1bb Update programming-faq.md (#12864) (#12865)
Fix typo

(cherry picked from commit b8f03c9b0f)

Co-authored-by: kemargrant <kemargrant@gmail.com>
2020-10-14 01:15:52 +00:00
3d8ccbc079 terminology update, nonce to bump seed (#12840) (#12851)
(cherry picked from commit 56211378d3)

Co-authored-by: Jack May <jack@solana.com>
2020-10-13 18:31:48 +00:00
275d096a46 solana vote-account/solana stake-account now works with RPC servers without --enable-rpc-transaction-history (bp #12826) (#12849)
* Implementation-defined RPC server errors are now accessible to client/ users

(cherry picked from commit 247228ee61)

* Cleanly handle RPC servers that don't have --enable-rpc-transaction-history enabled

(cherry picked from commit 14d793b22c)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-13 18:28:15 +00:00
6d70a06b23 Add nop feature set for upcoming ported rent fixes (#12841) (#12847)
(cherry picked from commit 7de7efe96c)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-13 17:47:59 +00:00
7e68b2e1bd Add transaction log messages to |solana confirm -v| output (#12836)
(cherry picked from commit e9dbbdeb81)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-13 06:57:21 +00:00
f0d761630e get_vote_accounts: access HashMap directly instead of turning it into an iterator (#12829)
(cherry picked from commit 649fe6d3b6)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-13 05:25:31 +00:00
1986927eb6 Check ELF file for errors before deploy (bp #12741) (#12801)
* Check ELF file for errors before deploy (#12741)

* Check ELF file for errors before deploy

* Update cli/src/cli.rs

Co-authored-by: Michael Vines <mvines@gmail.com>

* Fix formatting

* Bump solana_rbpf

Co-authored-by: Michael Vines <mvines@gmail.com>
(cherry picked from commit 6bbf6a79b7)

# Conflicts:
#	cli/Cargo.toml

* rebase

Co-authored-by: Alexandre Esteves <2335822+alexfmpe@users.noreply.github.com>
Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-13 04:41:51 +00:00
9a0ea61007 Add docs on vote account key rotation (bp #12815) (#12831)
* Add docs on vote account key rotation

(cherry picked from commit 253114ca20)

* Update docs/src/running-validator/vote-accounts.md

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>
(cherry picked from commit d83027c0cd)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-13 04:32:03 +00:00
51a70e52f2 CI: Fix crate publication (#12825)
(cherry picked from commit c38021502e)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-10-12 23:15:46 +00:00
9797c93db3 fix native_loader behavior for invalid accounts (#12814) (#12819)
(cherry picked from commit c24da1ee16)

Co-authored-by: Jack May <jack@solana.com>
2020-10-12 22:14:56 +00:00
9598114658 Use latest stable channel release if there's no beta release (#12823)
(cherry picked from commit 65213a1782)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-12 22:12:16 +00:00
d3ef061044 RpcClient: Encode TXs as base64 by default (#12817)
(cherry picked from commit efbe37ba20)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-10-12 21:56:18 +00:00
1f102d2617 Move no-0-rent rent dist. behavior under feature (#12804) (#12811)
(cherry picked from commit 2f5bb7e507)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-12 09:57:32 +00:00
5e97bd3d8a simulate_transaction_with_config() now passes full config to server (#12803)
(cherry picked from commit b3c2752bb0)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-12 05:58:30 +00:00
ed06e8b85d Pacify cargo audit (bp #12797) (#12799)
* Bump reqwest/rayon to get past `cargo audit`

(cherry picked from commit 8a119c1483)

# Conflicts:
#	dos/Cargo.toml
#	download-utils/Cargo.toml
#	metrics/Cargo.toml

* Switch to tempfile

(cherry picked from commit d3b0f87a49)

* Rework cargo audit ignores

(cherry picked from commit 2301dcf973)

* Cargo.lock

(cherry picked from commit 859eb606da)

* rebase

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-12 04:29:55 +00:00
10b9225edb Don't bother paying 0 rent (#12793)
(cherry picked from commit 1fc7c1ecee)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-10 18:12:14 +00:00
b1b5ddd2b9 Update gossip entrypoints 2020-10-10 08:39:38 -07:00
6b9b107ead Fix various ledger-tool error due to no builtins (bp #12759) (#12766)
* Fix various ledger-tool error due to no builtins (#12759)

* Fix various ledger-tool error due to no builtins

* Add missing file...

(cherry picked from commit 1f4bcf70b0)

# Conflicts:
#	core/Cargo.toml
#	ledger/Cargo.toml

* Rebase

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-10 07:10:38 +00:00
3fef98fd1e Expose all rewards (fees, rent, voting and staking) in RPC getConfirmedBlock and the cli (bp #12768) (#12790)
* Expose all rewards (fees, rent, voting and staking) in RPC getConfirmedBlock and the cli

(cherry picked from commit c5c8da1ac0)

# Conflicts:
#	Cargo.lock
#	transaction-status/Cargo.toml

* fix: surface full block rewards type

(cherry picked from commit 1b16790325)

* resolve conflicts

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-10 06:11:42 +00:00
e999823b4b document program address collisions (#12774)
(cherry picked from commit 9ac8db3533)
2020-10-09 22:35:47 -07:00
1e46a5b147 Fix typo (#12780) (#12784)
(cherry picked from commit 5800217998)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-10-10 02:09:09 +00:00
567a1cb944 Correct Bank timestamp drift every slot (#12737) (#12777)
* Move timestamp helper to sdk

* Add Bank method for getting timestamp estimate

* Return sysvar info from Bank::clock

* Add feature-gated timestamp correction

* Rename unix_timestamp method to be more descriptive

* Review comments

* Add timestamp metric

(cherry picked from commit b028c47d2b)

# Conflicts:
#	runtime/src/feature_set.rs

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2020-10-10 00:42:44 +00:00
2996cebfaa Add convenience script for working in stability branches (#12765) (#12773)
* Add convenience script for working in stability branches

* Update scripts/curgo.sh

Co-authored-by: Michael Vines <mvines@gmail.com>

* re{locate,name} to /cargo

Co-authored-by: Michael Vines <mvines@gmail.com>
(cherry picked from commit ed95071c27)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-10-09 23:02:21 +00:00
7a1889aaf9 Add adjustable stack size and call depth (bp #12728) (#12770)
* Add adjustable stack size and call depth (#12728)

(cherry picked from commit c3907be623)

# Conflicts:
#	programs/bpf/Cargo.toml
#	programs/bpf_loader/Cargo.toml

* resolve conflicts

Co-authored-by: Jack May <jack@solana.com>
2020-10-09 22:08:01 +00:00
9188153b7d Fix fee mismatch on snapshot deserialize (#12697) (#12754)
Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit c879e7c1ad)

Co-authored-by: carllin <wumu727@gmail.com>
2020-10-09 20:21:50 +00:00
4b9f2e987a Bump max invoke depth to 4 (#12742) (#12764)
(cherry picked from commit 2cd7cd3149)

Co-authored-by: Jack May <jack@solana.com>
2020-10-09 18:49:44 +00:00
bb5c76483a Advise setting --wal-recovery-mode, and using --private-rpc for mainnet-beta (#12761)
(cherry picked from commit 3fedcdc6bc)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-09 15:56:56 +00:00
aafbb251b9 Only fetch snapshot if it's newer than local (#12663) (#12752)
* Only fetch snapshot if it's newer than local

* Prefer as_ref over clone

* More nits

* Don't wait forwever for newer snapshot

(cherry picked from commit 81489ccb76)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-10-09 07:15:34 +00:00
dd32540ceb Add inflation_kill_switch feature (#12749)
(cherry picked from commit c8807d227a)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-09 05:55:51 +00:00
e1a9cbaf3c Add new internal accounts (#12740) (#12747)
Co-authored-by: publish-docs.sh <maintainers@solana.com>
(cherry picked from commit 2c5f83c264)

Co-authored-by: Dan Albert <dan@solana.com>
2020-10-09 02:19:55 +00:00
83740246fc Minor variable name cleanup (#12745)
(cherry picked from commit 3a04026599)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-09 02:12:28 +00:00
7a53ca18a6 Store program logs in blockstore / bigtable (TransactionWithStatusMeta) (#12678) (#12735)
* introduce store program logs in blockstore / bigtable

* fix test, transaction logs created for successful transactions

* fix test for legacy bincode implementation around log_messages

* only api nodes should record logs

* truncate transaction logs to 100KB

* refactor log truncate for improved coverage

(cherry picked from commit 8f5431551e)

Co-authored-by: Josh <josh.hundley@gmail.com>
2020-10-08 20:19:26 +00:00
c1a8637cb5 Support multiple connected HW wallets configured with the same seed phrase (bp #12716) (#12720)
* remote-wallet: Select hardware wallets based on host device path

(cherry picked from commit 8e3353d9ef)

* remote-wallet: Append wallet "name" to entries in selector UI

(cherry picked from commit f1a2ad1b7d)

Co-authored-by: Trent Nelson <trent@solana.com>
2020-10-08 05:32:48 +00:00
d6831309cd Revert "Restore --expected-shred-version argument for mainnet-beta" (#12723)
This reverts commit 9410eab2af.

(cherry picked from commit dadc84fa8c)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-10-08 05:00:44 +00:00
652 changed files with 56993 additions and 16372 deletions

View File

@ -31,4 +31,9 @@ export CARGO_TARGET_CACHE=$HOME/cargo-target-cache/"$CHANNEL"-"$BUILDKITE_LABEL"
mkdir -p "$CARGO_TARGET_CACHE"/target
rsync -a --delete --link-dest="$CARGO_TARGET_CACHE" "$CARGO_TARGET_CACHE"/target .
# Don't reuse BPF target build artifacts due to incremental build issues with
# `std:
# "found possibly newer version of crate `std` which `xyz` depends on
rm -rf target/bpfel-unknown-unknown
)

View File

@ -0,0 +1,4 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by fontconfig.
# For information about cache directory tags, see:
# http://www.brynosaurus.com/cachedir/

View File

@ -34,6 +34,8 @@ jobs:
- stable
install:
- source ci/rust-version.sh
- PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
- readlink -f .
script:
- source ci/env.sh
- ci/publish-tarball.sh

1495
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,7 @@ members = [
"dos",
"download-utils",
"faucet",
"frozen-abi",
"perf",
"validator",
"genesis",
@ -30,12 +31,14 @@ members = [
"merkle-tree",
"stake-o-matic",
"storage-bigtable",
"storage-proto",
"streamer",
"measure",
"metrics",
"net-shaper",
"notifier",
"poh-bench",
"program-test",
"programs/secp256k1",
"programs/bpf_loader",
"programs/budget",
@ -51,6 +54,8 @@ members = [
"ramp-tps",
"runtime",
"sdk",
"sdk/cargo-build-bpf",
"sdk/cargo-test-bpf",
"scripts",
"stake-accounts",
"stake-monitor",

View File

@ -61,8 +61,9 @@ $ cargo test
### Starting a local testnet
Start your own testnet locally, instructions are in the [online docs](https://docs.solana.com/cluster/bench-tps).
### Accessing the remote testnet
* `testnet` - public stable testnet accessible via devnet.solana.com. Runs 24/7
### Accessing the remote development cluster
* `devnet` - stable public cluster for development accessible via
devnet.solana.com. Runs 24/7. Learn more about the [public clusters](https://docs.solana.com/clusters)
# Benchmarking

View File

@ -1,6 +1,6 @@
[package]
name = "solana-account-decoder"
version = "1.4.0"
version = "1.4.21"
description = "Solana account decoder"
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
repository = "https://github.com/solana-labs/solana"
@ -18,12 +18,13 @@ lazy_static = "1.4.0"
serde = "1.0.112"
serde_derive = "1.0.103"
serde_json = "1.0.56"
solana-config-program = { path = "../programs/config", version = "1.4.0" }
solana-sdk = { path = "../sdk", version = "1.4.0" }
solana-stake-program = { path = "../programs/stake", version = "1.4.0" }
solana-vote-program = { path = "../programs/vote", version = "1.4.0" }
spl-token-v2-0 = { package = "spl-token", version = "=2.0.6", features = ["skip-no-mangle"] }
solana-config-program = { path = "../programs/config", version = "1.4.21" }
solana-sdk = { path = "../sdk", version = "1.4.21" }
solana-stake-program = { path = "../programs/stake", version = "1.4.21" }
solana-vote-program = { path = "../programs/vote", version = "1.4.21" }
spl-token-v2-0 = { package = "spl-token", version = "=3.0.1", features = ["no-entrypoint"] }
thiserror = "1.0"
zstd = "0.5.1"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

View File

@ -12,9 +12,14 @@ pub mod parse_token;
pub mod parse_vote;
pub mod validator_info;
use crate::parse_account_data::{parse_account_data, AccountAdditionalData, ParsedAccount};
use solana_sdk::{account::Account, clock::Epoch, fee_calculator::FeeCalculator, pubkey::Pubkey};
use std::str::FromStr;
use {
crate::parse_account_data::{parse_account_data, AccountAdditionalData, ParsedAccount},
solana_sdk::{account::Account, clock::Epoch, fee_calculator::FeeCalculator, pubkey::Pubkey},
std::{
io::{Read, Write},
str::FromStr,
},
};
pub type StringAmount = String;
@ -44,6 +49,8 @@ pub enum UiAccountEncoding {
Base58,
Base64,
JsonParsed,
#[serde(rename = "base64+zstd")]
Base64Zstd,
}
impl UiAccount {
@ -66,6 +73,19 @@ impl UiAccount {
base64::encode(slice_data(&account.data, data_slice_config)),
encoding,
),
UiAccountEncoding::Base64Zstd => {
let mut encoder = zstd::stream::write::Encoder::new(Vec::new(), 0).unwrap();
match encoder
.write_all(slice_data(&account.data, data_slice_config))
.and_then(|()| encoder.finish())
{
Ok(zstd_data) => UiAccountData::Binary(base64::encode(zstd_data), encoding),
Err(_) => UiAccountData::Binary(
base64::encode(slice_data(&account.data, data_slice_config)),
UiAccountEncoding::Base64,
),
}
}
UiAccountEncoding::JsonParsed => {
if let Ok(parsed_data) =
parse_account_data(pubkey, &account.owner, &account.data, additional_data)
@ -92,6 +112,16 @@ impl UiAccount {
UiAccountData::Binary(blob, encoding) => match encoding {
UiAccountEncoding::Base58 => bs58::decode(blob).into_vec().ok(),
UiAccountEncoding::Base64 => base64::decode(blob).ok(),
UiAccountEncoding::Base64Zstd => base64::decode(blob)
.ok()
.map(|zstd_data| {
let mut data = vec![];
zstd::stream::read::Decoder::new(zstd_data.as_slice())
.and_then(|mut reader| reader.read_to_end(&mut data))
.map(|_| data)
.ok()
})
.flatten(),
UiAccountEncoding::Binary | UiAccountEncoding::JsonParsed => None,
},
}?;
@ -179,4 +209,25 @@ mod test {
});
assert_eq!(slice_data(&data, slice_config), &[] as &[u8]);
}
#[test]
fn test_base64_zstd() {
let encoded_account = UiAccount::encode(
&Pubkey::default(),
Account {
data: vec![0; 1024],
..Account::default()
},
UiAccountEncoding::Base64Zstd,
None,
None,
);
assert!(matches!(
encoded_account.data,
UiAccountData::Binary(_, UiAccountEncoding::Base64Zstd)
));
let decoded_account = encoded_account.decode().unwrap();
assert_eq!(decoded_account.data, vec![0; 1024]);
}
}

View File

@ -111,14 +111,14 @@ mod test {
#[test]
fn test_parse_account_data() {
let account_pubkey = Pubkey::new_rand();
let other_program = Pubkey::new_rand();
let account_pubkey = solana_sdk::pubkey::new_rand();
let other_program = solana_sdk::pubkey::new_rand();
let data = vec![0; 4];
assert!(parse_account_data(&account_pubkey, &other_program, &data, None).is_err());
let vote_state = VoteState::default();
let mut vote_account_data: Vec<u8> = vec![0; VoteState::size_of()];
let versioned = VoteStateVersions::Current(Box::new(vote_state));
let versioned = VoteStateVersions::new_current(vote_state);
VoteState::serialize(&versioned, &mut vote_account_data).unwrap();
let parsed = parse_account_data(
&account_pubkey,

View File

@ -117,7 +117,7 @@ mod test {
}))
.unwrap(),
};
let info_pubkey = Pubkey::new_rand();
let info_pubkey = solana_sdk::pubkey::new_rand();
let validator_info_config_account = create_config_account(
vec![(validator_info::id(), false), (info_pubkey, true)],
&validator_info,

View File

@ -134,7 +134,6 @@ impl From<Delegation> for UiDelegation {
mod test {
use super::*;
use bincode::serialize;
use solana_sdk::pubkey::Pubkey;
#[test]
fn test_parse_stake() {
@ -145,8 +144,8 @@ mod test {
StakeAccountType::Uninitialized
);
let pubkey = Pubkey::new_rand();
let custodian = Pubkey::new_rand();
let pubkey = solana_sdk::pubkey::new_rand();
let custodian = solana_sdk::pubkey::new_rand();
let authorized = Authorized::auto(&pubkey);
let lockup = Lockup {
unix_timestamp: 0,
@ -180,7 +179,7 @@ mod test {
})
);
let voter_pubkey = Pubkey::new_rand();
let voter_pubkey = solana_sdk::pubkey::new_rand();
let stake = Stake {
delegation: Delegation {
voter_pubkey,

View File

@ -105,6 +105,7 @@ pub enum SysvarAccountType {
pub struct UiClock {
pub slot: Slot,
pub epoch: Epoch,
pub epoch_start_timestamp: UnixTimestamp,
pub leader_schedule_epoch: Epoch,
pub unix_timestamp: UnixTimestamp,
}
@ -114,6 +115,7 @@ impl From<Clock> for UiClock {
Self {
slot: clock.slot,
epoch: clock.epoch,
epoch_start_timestamp: clock.epoch_start_timestamp,
leader_schedule_epoch: clock.leader_schedule_epoch,
unix_timestamp: clock.unix_timestamp,
}
@ -212,15 +214,14 @@ pub struct UiStakeHistoryEntry {
mod test {
use super::*;
use solana_sdk::{
fee_calculator::FeeCalculator,
hash::Hash,
sysvar::{recent_blockhashes::IterItem, Sysvar},
account::create_account, fee_calculator::FeeCalculator, hash::Hash,
sysvar::recent_blockhashes::IterItem,
};
use std::iter::FromIterator;
#[test]
fn test_parse_sysvars() {
let clock_sysvar = Clock::default().create_account(1);
let clock_sysvar = create_account(&Clock::default(), 1);
assert_eq!(
parse_sysvar(&clock_sysvar.data, &sysvar::clock::id()).unwrap(),
SysvarAccountType::Clock(UiClock::default()),
@ -233,13 +234,13 @@ mod test {
first_normal_epoch: 1,
first_normal_slot: 12,
};
let epoch_schedule_sysvar = epoch_schedule.create_account(1);
let epoch_schedule_sysvar = create_account(&epoch_schedule, 1);
assert_eq!(
parse_sysvar(&epoch_schedule_sysvar.data, &sysvar::epoch_schedule::id()).unwrap(),
SysvarAccountType::EpochSchedule(epoch_schedule),
);
let fees_sysvar = Fees::default().create_account(1);
let fees_sysvar = create_account(&Fees::default(), 1);
assert_eq!(
parse_sysvar(&fees_sysvar.data, &sysvar::fees::id()).unwrap(),
SysvarAccountType::Fees(UiFees::default()),
@ -251,7 +252,7 @@ mod test {
};
let recent_blockhashes =
RecentBlockhashes::from_iter(vec![IterItem(0, &hash, &fee_calculator)].into_iter());
let recent_blockhashes_sysvar = recent_blockhashes.create_account(1);
let recent_blockhashes_sysvar = create_account(&recent_blockhashes, 1);
assert_eq!(
parse_sysvar(
&recent_blockhashes_sysvar.data,
@ -269,13 +270,13 @@ mod test {
exemption_threshold: 2.0,
burn_percent: 5,
};
let rent_sysvar = rent.create_account(1);
let rent_sysvar = create_account(&rent, 1);
assert_eq!(
parse_sysvar(&rent_sysvar.data, &sysvar::rent::id()).unwrap(),
SysvarAccountType::Rent(rent.into()),
);
let rewards_sysvar = Rewards::default().create_account(1);
let rewards_sysvar = create_account(&Rewards::default(), 1);
assert_eq!(
parse_sysvar(&rewards_sysvar.data, &sysvar::rewards::id()).unwrap(),
SysvarAccountType::Rewards(UiRewards::default()),
@ -283,7 +284,7 @@ mod test {
let mut slot_hashes = SlotHashes::default();
slot_hashes.add(1, hash);
let slot_hashes_sysvar = slot_hashes.create_account(1);
let slot_hashes_sysvar = create_account(&slot_hashes, 1);
assert_eq!(
parse_sysvar(&slot_hashes_sysvar.data, &sysvar::slot_hashes::id()).unwrap(),
SysvarAccountType::SlotHashes(vec![UiSlotHashEntry {
@ -294,7 +295,7 @@ mod test {
let mut slot_history = SlotHistory::default();
slot_history.add(42);
let slot_history_sysvar = slot_history.create_account(1);
let slot_history_sysvar = create_account(&slot_history, 1);
assert_eq!(
parse_sysvar(&slot_history_sysvar.data, &sysvar::slot_history::id()).unwrap(),
SysvarAccountType::SlotHistory(UiSlotHistory {
@ -310,7 +311,7 @@ mod test {
deactivating: 3,
};
stake_history.add(1, stake_history_entry.clone());
let stake_history_sysvar = stake_history.create_account(1);
let stake_history_sysvar = create_account(&stake_history, 1);
assert_eq!(
parse_sysvar(&stake_history_sysvar.data, &sysvar::stake_history::id()).unwrap(),
SysvarAccountType::StakeHistory(vec![UiStakeHistoryEntry {
@ -319,7 +320,7 @@ mod test {
}]),
);
let bad_pubkey = Pubkey::new_rand();
let bad_pubkey = solana_sdk::pubkey::new_rand();
assert!(parse_sysvar(&stake_history_sysvar.data, &bad_pubkey).is_err());
let bad_data = vec![0; 4];

View File

@ -4,7 +4,9 @@ use crate::{
};
use solana_sdk::pubkey::Pubkey;
use spl_token_v2_0::{
solana_sdk::{program_option::COption, program_pack::Pack, pubkey::Pubkey as SplTokenPubkey},
solana_program::{
program_option::COption, program_pack::Pack, pubkey::Pubkey as SplTokenPubkey,
},
state::{Account, AccountState, Mint, Multisig},
};
use std::str::FromStr;
@ -21,6 +23,16 @@ pub fn spl_token_v2_0_native_mint() -> Pubkey {
Pubkey::from_str(&spl_token_v2_0::native_mint::id().to_string()).unwrap()
}
// A helper function to convert a solana_sdk::pubkey::Pubkey to spl_sdk::pubkey::Pubkey
pub fn spl_token_v2_0_pubkey(pubkey: &Pubkey) -> SplTokenPubkey {
SplTokenPubkey::from_str(&pubkey.to_string()).unwrap()
}
// A helper function to convert a spl_sdk::pubkey::Pubkey to solana_sdk::pubkey::Pubkey
pub fn pubkey_from_spl_token_v2_0(pubkey: &SplTokenPubkey) -> Pubkey {
Pubkey::from_str(&pubkey.to_string()).unwrap()
}
pub fn parse_token(
data: &[u8],
mint_decimals: Option<u8>,

View File

@ -128,7 +128,7 @@ mod test {
fn test_parse_vote() {
let vote_state = VoteState::default();
let mut vote_account_data: Vec<u8> = vec![0; VoteState::size_of()];
let versioned = VoteStateVersions::Current(Box::new(vote_state));
let versioned = VoteStateVersions::new_current(vote_state);
VoteState::serialize(&versioned, &mut vote_account_data).unwrap();
let mut expected_vote_state = UiVoteState::default();
expected_vote_state.node_pubkey = Pubkey::default().to_string();

View File

@ -2,7 +2,7 @@
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
edition = "2018"
name = "solana-accounts-bench"
version = "1.4.0"
version = "1.4.21"
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
@ -11,11 +11,11 @@ publish = false
[dependencies]
log = "0.4.6"
rayon = "1.4.0"
solana-logger = { path = "../logger", version = "1.4.0" }
solana-runtime = { path = "../runtime", version = "1.4.0" }
solana-measure = { path = "../measure", version = "1.4.0" }
solana-sdk = { path = "../sdk", version = "1.4.0" }
solana-version = { path = "../version", version = "1.4.0" }
solana-logger = { path = "../logger", version = "1.4.21" }
solana-runtime = { path = "../runtime", version = "1.4.21" }
solana-measure = { path = "../measure", version = "1.4.21" }
solana-sdk = { path = "../sdk", version = "1.4.21" }
solana-version = { path = "../version", version = "1.4.21" }
rand = "0.7.0"
clap = "2.33.1"
crossbeam-channel = "0.4"

View File

@ -98,7 +98,10 @@ fn main() {
} else {
let mut pubkeys: Vec<Pubkey> = vec![];
let mut time = Measure::start("hash");
let hash = accounts.accounts_db.update_accounts_hash(0, &ancestors).0;
let hash = accounts
.accounts_db
.update_accounts_hash(0, &ancestors, true)
.0;
time.stop();
println!("hash: {} {}", hash, time);
create_test_accounts(&accounts, &mut pubkeys, 1, 0);

View File

@ -2,7 +2,7 @@
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
edition = "2018"
name = "solana-banking-bench"
version = "1.4.0"
version = "1.4.21"
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
@ -14,16 +14,16 @@ crossbeam-channel = "0.4"
log = "0.4.6"
rand = "0.7.0"
rayon = "1.4.0"
solana-core = { path = "../core", version = "1.4.0" }
solana-clap-utils = { path = "../clap-utils", version = "1.4.0" }
solana-streamer = { path = "../streamer", version = "1.4.0" }
solana-perf = { path = "../perf", version = "1.4.0" }
solana-ledger = { path = "../ledger", version = "1.4.0" }
solana-logger = { path = "../logger", version = "1.4.0" }
solana-runtime = { path = "../runtime", version = "1.4.0" }
solana-measure = { path = "../measure", version = "1.4.0" }
solana-sdk = { path = "../sdk", version = "1.4.0" }
solana-version = { path = "../version", version = "1.4.0" }
solana-core = { path = "../core", version = "1.4.21" }
solana-clap-utils = { path = "../clap-utils", version = "1.4.21" }
solana-streamer = { path = "../streamer", version = "1.4.21" }
solana-perf = { path = "../perf", version = "1.4.21" }
solana-ledger = { path = "../ledger", version = "1.4.21" }
solana-logger = { path = "../logger", version = "1.4.21" }
solana-runtime = { path = "../runtime", version = "1.4.21" }
solana-measure = { path = "../measure", version = "1.4.21" }
solana-sdk = { path = "../sdk", version = "1.4.21" }
solana-version = { path = "../version", version = "1.4.21" }
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

View File

@ -20,7 +20,6 @@ use solana_perf::packet::to_packets_chunked;
use solana_runtime::{bank::Bank, bank_forks::BankForks};
use solana_sdk::{
hash::Hash,
pubkey::Pubkey,
signature::Keypair,
signature::Signature,
system_transaction,
@ -69,7 +68,7 @@ fn make_accounts_txs(
hash: Hash,
same_payer: bool,
) -> Vec<Transaction> {
let to_pubkey = Pubkey::new_rand();
let to_pubkey = solana_sdk::pubkey::new_rand();
let payer_key = Keypair::new();
let dummy = system_transaction::transfer(&payer_key, &to_pubkey, 1, hash);
(0..total_num_transactions)
@ -78,9 +77,9 @@ fn make_accounts_txs(
let mut new = dummy.clone();
let sig: Vec<u8> = (0..64).map(|_| thread_rng().gen()).collect();
if !same_payer {
new.message.account_keys[0] = Pubkey::new_rand();
new.message.account_keys[0] = solana_sdk::pubkey::new_rand();
}
new.message.account_keys[1] = Pubkey::new_rand();
new.message.account_keys[1] = solana_sdk::pubkey::new_rand();
new.signatures = vec![Signature::new(&sig[0..64])];
new
})
@ -241,7 +240,7 @@ fn main() {
let base_tx_count = bank.transaction_count();
let mut txs_processed = 0;
let mut root = 1;
let collector = Pubkey::new_rand();
let collector = solana_sdk::pubkey::new_rand();
let config = Config {
packets_per_batch: packets_per_chunk,
chunk_len,

View File

@ -1,6 +1,6 @@
[package]
name = "solana-banks-client"
version = "1.4.0"
version = "1.4.21"
description = "Solana banks client"
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
repository = "https://github.com/solana-labs/solana"
@ -12,15 +12,16 @@ edition = "2018"
async-trait = "0.1.36"
bincode = "1.3.1"
futures = "0.3"
solana-banks-interface = { path = "../banks-interface", version = "1.4.0" }
solana-sdk = { path = "../sdk", version = "1.4.0" }
tarpc = { version = "0.22.0", features = ["full"] }
tokio = "0.2"
mio = "0.7.6"
solana-banks-interface = { path = "../banks-interface", version = "1.4.21" }
solana-sdk = { path = "../sdk", version = "1.4.21" }
tarpc = { version = "0.23.0", features = ["full"] }
tokio = { version = "0.3", features = ["full"] }
tokio-serde = { version = "0.6", features = ["bincode"] }
[dev-dependencies]
solana-runtime = { path = "../runtime", version = "1.4.0" }
solana-banks-server = { path = "../banks-server", version = "1.4.0" }
solana-runtime = { path = "../runtime", version = "1.4.21" }
solana-banks-server = { path = "../banks-server", version = "1.4.21" }
[lib]
crate-type = ["lib"]

View File

@ -10,9 +10,17 @@ use futures::future::join_all;
pub use solana_banks_interface::{BanksClient, TransactionStatus};
use solana_banks_interface::{BanksRequest, BanksResponse};
use solana_sdk::{
account::Account, clock::Slot, commitment_config::CommitmentLevel,
fee_calculator::FeeCalculator, hash::Hash, pubkey::Pubkey, signature::Signature,
transaction::Transaction, transport,
account::{from_account, Account},
clock::Slot,
commitment_config::CommitmentLevel,
fee_calculator::FeeCalculator,
hash::Hash,
pubkey::Pubkey,
rent::Rent,
signature::Signature,
sysvar,
transaction::Transaction,
transport,
};
use std::io::{self, Error, ErrorKind};
use tarpc::{
@ -40,6 +48,9 @@ pub trait BanksClientExt {
/// use them to calculate the transaction fee.
async fn get_fees(&mut self) -> io::Result<(FeeCalculator, Hash, Slot)>;
/// Return the cluster rent
async fn get_rent(&mut self) -> io::Result<Rent>;
/// Send a transaction and return after the transaction has been rejected or
/// reached the given level of commitment.
async fn process_transaction_with_commitment(
@ -108,6 +119,17 @@ impl BanksClientExt for BanksClient {
.await
}
async fn get_rent(&mut self) -> io::Result<Rent> {
let rent_sysvar = self
.get_account(sysvar::rent::id())
.await?
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Rent sysvar not present"))?;
from_account::<Rent>(&rent_sysvar).ok_or_else(|| {
io::Error::new(io::ErrorKind::Other, "Failed to deserialize Rent sysvar")
})
}
async fn get_recent_blockhash(&mut self) -> io::Result<Hash> {
Ok(self.get_fees().await?.1)
}
@ -213,10 +235,10 @@ mod tests {
use super::*;
use solana_banks_server::banks_server::start_local_server;
use solana_runtime::{bank::Bank, bank_forks::BankForks, genesis_utils::create_genesis_config};
use solana_sdk::{message::Message, pubkey::Pubkey, signature::Signer, system_instruction};
use solana_sdk::{message::Message, signature::Signer, system_instruction};
use std::sync::{Arc, RwLock};
use tarpc::transport;
use tokio::{runtime::Runtime, time::delay_for};
use tokio::{runtime::Runtime, time::sleep};
#[test]
fn test_banks_client_new() {
@ -235,7 +257,7 @@ mod tests {
&genesis.genesis_config,
))));
let bob_pubkey = Pubkey::new_rand();
let bob_pubkey = solana_sdk::pubkey::new_rand();
let mint_pubkey = genesis.mint_keypair.pubkey();
let instruction = system_instruction::transfer(&mint_pubkey, &bob_pubkey, 1);
let message = Message::new(&[instruction], Some(&mint_pubkey));
@ -265,7 +287,7 @@ mod tests {
))));
let mint_pubkey = &genesis.mint_keypair.pubkey();
let bob_pubkey = Pubkey::new_rand();
let bob_pubkey = solana_sdk::pubkey::new_rand();
let instruction = system_instruction::transfer(&mint_pubkey, &bob_pubkey, 1);
let message = Message::new(&[instruction], Some(&mint_pubkey));
@ -285,7 +307,7 @@ mod tests {
if root_slot > last_valid_slot {
break;
}
delay_for(Duration::from_millis(100)).await;
sleep(Duration::from_millis(100)).await;
status = banks_client.get_transaction_status(signature).await?;
}
assert!(status.unwrap().err.is_none());

View File

@ -1,6 +1,6 @@
[package]
name = "solana-banks-interface"
version = "1.4.0"
version = "1.4.21"
description = "Solana banks RPC interface"
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
repository = "https://github.com/solana-labs/solana"
@ -9,9 +9,10 @@ homepage = "https://solana.com/"
edition = "2018"
[dependencies]
mio = "0.7.6"
serde = { version = "1.0.112", features = ["derive"] }
solana-sdk = { path = "../sdk", version = "1.4.0" }
tarpc = { version = "0.22.0", features = ["full"] }
solana-sdk = { path = "../sdk", version = "1.4.21" }
tarpc = { version = "0.23.0", features = ["full"] }
[lib]
crate-type = ["lib"]

View File

@ -1,6 +1,6 @@
[package]
name = "solana-banks-server"
version = "1.4.0"
version = "1.4.21"
description = "Solana banks server"
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
repository = "https://github.com/solana-labs/solana"
@ -12,12 +12,13 @@ edition = "2018"
bincode = "1.3.1"
futures = "0.3"
log = "0.4.8"
solana-banks-interface = { path = "../banks-interface", version = "1.4.0" }
solana-runtime = { path = "../runtime", version = "1.4.0" }
solana-sdk = { path = "../sdk", version = "1.4.0" }
solana-metrics = { path = "../metrics", version = "1.4.0" }
tarpc = { version = "0.22.0", features = ["full"] }
tokio = "0.2"
mio = "0.7.6"
solana-banks-interface = { path = "../banks-interface", version = "1.4.21" }
solana-runtime = { path = "../runtime", version = "1.4.21" }
solana-sdk = { path = "../sdk", version = "1.4.21" }
solana-metrics = { path = "../metrics", version = "1.4.21" }
tarpc = { version = "0.23.0", features = ["full"] }
tokio = { version = "0.3", features = ["full"] }
tokio-serde = { version = "0.6", features = ["bincode"] }
[lib]

View File

@ -5,11 +5,7 @@ use futures::{
prelude::stream::{self, StreamExt},
};
use solana_banks_interface::{Banks, BanksRequest, BanksResponse, TransactionStatus};
use solana_runtime::{
bank::Bank,
bank_forks::BankForks,
commitment::{BlockCommitmentCache, CommitmentSlots},
};
use solana_runtime::{bank::Bank, bank_forks::BankForks, commitment::BlockCommitmentCache};
use solana_sdk::{
account::Account,
clock::Slot,
@ -21,7 +17,6 @@ use solana_sdk::{
transaction::{self, Transaction},
};
use std::{
collections::HashMap,
io,
net::{Ipv4Addr, SocketAddr},
sync::{
@ -38,7 +33,7 @@ use tarpc::{
server::{self, Channel, Handler},
transport,
};
use tokio::time::delay_for;
use tokio::time::sleep;
use tokio_serde::formats::Bincode;
#[derive(Clone)]
@ -84,11 +79,9 @@ impl BanksServer {
let (transaction_sender, transaction_receiver) = channel();
let bank = bank_forks.read().unwrap().working_bank();
let slot = bank.slot();
let block_commitment_cache = Arc::new(RwLock::new(BlockCommitmentCache::new(
HashMap::default(),
0,
CommitmentSlots::new_from_slot(slot),
)));
let block_commitment_cache = Arc::new(RwLock::new(
BlockCommitmentCache::new_for_tests_with_slots(slot, slot),
));
Builder::new()
.name("solana-bank-forks-client".to_string())
.spawn(move || Self::run(&bank, transaction_receiver))
@ -109,23 +102,36 @@ impl BanksServer {
async fn poll_signature_status(
self,
signature: Signature,
signature: &Signature,
blockhash: &Hash,
last_valid_slot: Slot,
commitment: CommitmentLevel,
) -> Option<transaction::Result<()>> {
let mut status = self.bank(commitment).get_signature_status(&signature);
let mut status = self
.bank(commitment)
.get_signature_status_with_blockhash(signature, blockhash);
while status.is_none() {
delay_for(Duration::from_millis(200)).await;
sleep(Duration::from_millis(200)).await;
let bank = self.bank(commitment);
if bank.slot() > last_valid_slot {
break;
}
status = bank.get_signature_status(&signature);
status = bank.get_signature_status_with_blockhash(signature, blockhash);
}
status
}
}
fn verify_transaction(transaction: &Transaction) -> transaction::Result<()> {
if let Err(err) = transaction.verify() {
Err(err)
} else if let Err(err) = transaction.verify_precompiles() {
Err(err)
} else {
Ok(())
}
}
#[tarpc::server]
impl Banks for BanksServer {
async fn send_transaction_with_context(self, _: Context, transaction: Transaction) {
@ -187,19 +193,23 @@ impl Banks for BanksServer {
transaction: Transaction,
commitment: CommitmentLevel,
) -> Option<transaction::Result<()>> {
if let Err(err) = verify_transaction(&transaction) {
return Some(Err(err));
}
let blockhash = &transaction.message.recent_blockhash;
let last_valid_slot = self
.bank_forks
.read()
.unwrap()
.root_bank()
.get_blockhash_last_valid_slot(&blockhash)
.get_blockhash_last_valid_slot(blockhash)
.unwrap();
let signature = transaction.signatures.get(0).cloned().unwrap_or_default();
let info =
TransactionInfo::new(signature, serialize(&transaction).unwrap(), last_valid_slot);
self.transaction_sender.send(info).unwrap();
self.poll_signature_status(signature, last_valid_slot, commitment)
self.poll_signature_status(&signature, blockhash, last_valid_slot, commitment)
.await
}

View File

@ -2,7 +2,7 @@
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
edition = "2018"
name = "solana-bench-exchange"
version = "1.4.0"
version = "1.4.21"
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
@ -18,21 +18,21 @@ rand = "0.7.0"
rayon = "1.4.0"
serde_json = "1.0.56"
serde_yaml = "0.8.13"
solana-clap-utils = { path = "../clap-utils", version = "1.4.0" }
solana-core = { path = "../core", version = "1.4.0" }
solana-genesis = { path = "../genesis", version = "1.4.0" }
solana-client = { path = "../client", version = "1.4.0" }
solana-faucet = { path = "../faucet", version = "1.4.0" }
solana-exchange-program = { path = "../programs/exchange", version = "1.4.0" }
solana-logger = { path = "../logger", version = "1.4.0" }
solana-metrics = { path = "../metrics", version = "1.4.0" }
solana-net-utils = { path = "../net-utils", version = "1.4.0" }
solana-runtime = { path = "../runtime", version = "1.4.0" }
solana-sdk = { path = "../sdk", version = "1.4.0" }
solana-version = { path = "../version", version = "1.4.0" }
solana-clap-utils = { path = "../clap-utils", version = "1.4.21" }
solana-core = { path = "../core", version = "1.4.21" }
solana-genesis = { path = "../genesis", version = "1.4.21" }
solana-client = { path = "../client", version = "1.4.21" }
solana-faucet = { path = "../faucet", version = "1.4.21" }
solana-exchange-program = { path = "../programs/exchange", version = "1.4.21" }
solana-logger = { path = "../logger", version = "1.4.21" }
solana-metrics = { path = "../metrics", version = "1.4.21" }
solana-net-utils = { path = "../net-utils", version = "1.4.21" }
solana-runtime = { path = "../runtime", version = "1.4.21" }
solana-sdk = { path = "../sdk", version = "1.4.21" }
solana-version = { path = "../version", version = "1.4.21" }
[dev-dependencies]
solana-local-cluster = { path = "../local-cluster", version = "1.4.0" }
solana-local-cluster = { path = "../local-cluster", version = "1.4.21" }
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

View File

@ -39,7 +39,7 @@ fn test_exchange_local_cluster() {
} = config;
let accounts_in_groups = batch_size * account_groups;
let cluster = LocalCluster::new(&ClusterConfig {
let cluster = LocalCluster::new(&mut ClusterConfig {
node_stakes: vec![100_000; NUM_NODES],
cluster_lamports: 100_000_000_000_000,
validator_configs: vec![ValidatorConfig::default(); NUM_NODES],
@ -86,7 +86,7 @@ fn test_exchange_bank_client() {
solana_logger::setup();
let (genesis_config, identity) = create_genesis_config(100_000_000_000_000);
let mut bank = Bank::new(&genesis_config);
bank.add_builtin_program("exchange_program", id(), process_instruction);
bank.add_builtin("exchange_program", id(), process_instruction);
let clients = vec![BankClient::new(bank)];
let mut config = Config::default();

View File

@ -2,7 +2,7 @@
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
edition = "2018"
name = "solana-bench-streamer"
version = "1.4.0"
version = "1.4.21"
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
@ -10,11 +10,11 @@ publish = false
[dependencies]
clap = "2.33.1"
solana-clap-utils = { path = "../clap-utils", version = "1.4.0" }
solana-streamer = { path = "../streamer", version = "1.4.0" }
solana-logger = { path = "../logger", version = "1.4.0" }
solana-net-utils = { path = "../net-utils", version = "1.4.0" }
solana-version = { path = "../version", version = "1.4.0" }
solana-clap-utils = { path = "../clap-utils", version = "1.4.21" }
solana-streamer = { path = "../streamer", version = "1.4.21" }
solana-logger = { path = "../logger", version = "1.4.21" }
solana-net-utils = { path = "../net-utils", version = "1.4.21" }
solana-version = { path = "../version", version = "1.4.21" }
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

View File

@ -2,7 +2,7 @@
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
edition = "2018"
name = "solana-bench-tps"
version = "1.4.0"
version = "1.4.21"
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
@ -15,23 +15,23 @@ log = "0.4.8"
rayon = "1.4.0"
serde_json = "1.0.56"
serde_yaml = "0.8.13"
solana-clap-utils = { path = "../clap-utils", version = "1.4.0" }
solana-core = { path = "../core", version = "1.4.0" }
solana-genesis = { path = "../genesis", version = "1.4.0" }
solana-client = { path = "../client", version = "1.4.0" }
solana-faucet = { path = "../faucet", version = "1.4.0" }
solana-logger = { path = "../logger", version = "1.4.0" }
solana-metrics = { path = "../metrics", version = "1.4.0" }
solana-measure = { path = "../measure", version = "1.4.0" }
solana-net-utils = { path = "../net-utils", version = "1.4.0" }
solana-runtime = { path = "../runtime", version = "1.4.0" }
solana-sdk = { path = "../sdk", version = "1.4.0" }
solana-version = { path = "../version", version = "1.4.0" }
solana-clap-utils = { path = "../clap-utils", version = "1.4.21" }
solana-core = { path = "../core", version = "1.4.21" }
solana-genesis = { path = "../genesis", version = "1.4.21" }
solana-client = { path = "../client", version = "1.4.21" }
solana-faucet = { path = "../faucet", version = "1.4.21" }
solana-logger = { path = "../logger", version = "1.4.21" }
solana-metrics = { path = "../metrics", version = "1.4.21" }
solana-measure = { path = "../measure", version = "1.4.21" }
solana-net-utils = { path = "../net-utils", version = "1.4.21" }
solana-runtime = { path = "../runtime", version = "1.4.21" }
solana-sdk = { path = "../sdk", version = "1.4.21" }
solana-version = { path = "../version", version = "1.4.21" }
[dev-dependencies]
serial_test = "0.4.0"
serial_test_derive = "0.4.0"
solana-local-cluster = { path = "../local-cluster", version = "1.4.0" }
solana-local-cluster = { path = "../local-cluster", version = "1.4.21" }
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

View File

@ -15,7 +15,7 @@ fn test_bench_tps_local_cluster(config: Config) {
solana_logger::setup();
const NUM_NODES: usize = 1;
let cluster = LocalCluster::new(&ClusterConfig {
let cluster = LocalCluster::new(&mut ClusterConfig {
node_stakes: vec![999_990; NUM_NODES],
cluster_lamports: 200_000_000,
validator_configs: vec![ValidatorConfig::default(); NUM_NODES],

31
cargo Executable file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env bash
# shellcheck source=ci/rust-version.sh
here=$(dirname "$0")
source "${here}"/ci/rust-version.sh all
toolchain=
case "$1" in
stable)
# shellcheck disable=SC2054 # rust_stable is sourced from rust-version.sh
toolchain="$rust_stable"
shift
;;
nightly)
# shellcheck disable=SC2054 # rust_nightly is sourced from rust-version.sh
toolchain="$rust_nightly"
shift
;;
+*)
toolchain="${1#+}"
shift
;;
*)
# shellcheck disable=SC2054 # rust_stable is sourced from rust-version.sh
toolchain="$rust_stable"
;;
esac
set -x
exec cargo "+${toolchain}" "${@}"

13
cargo-build-bpf Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
here=$(dirname "$0")
maybe_bpf_sdk="--bpf-sdk $here/sdk/bpf"
for a in "$@"; do
if [[ $a = --bpf-sdk ]]; then
maybe_bpf_sdk=
fi
done
set -x
exec "$here"/cargo run --manifest-path "$here"/sdk/cargo-build-bpf/Cargo.toml -- $maybe_bpf_sdk "$@"

14
cargo-test-bpf Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
here=$(dirname "$0")
maybe_bpf_sdk="--bpf-sdk $here/sdk/bpf"
for a in "$@"; do
if [[ $a = --bpf-sdk ]]; then
maybe_bpf_sdk=
fi
done
export CARGO_BUILD_BPF="$here"/cargo-build-bpf
set -x
exec "$here"/cargo run --manifest-path "$here"/sdk/cargo-test-bpf/Cargo.toml -- $maybe_bpf_sdk "$@"

View File

@ -175,6 +175,30 @@ EOF
"Stable-perf skipped as no relevant files were modified"
fi
# Downstream backwards compatibility
if affects \
.rs$ \
Cargo.lock$ \
Cargo.toml$ \
^ci/rust-version.sh \
^ci/test-stable-perf.sh \
^ci/test-stable.sh \
^ci/test-local-cluster.sh \
^core/build.rs \
^fetch-perf-libs.sh \
^programs/ \
^sdk/ \
^scripts/build-downstream-projects.sh \
; then
cat >> "$output_file" <<"EOF"
- command: "scripts/build-downstream-projects.sh"
name: "downstream-projects"
timeout_in_minutes: 30
EOF
else
annotate --style info \
"downstream-projects skipped as no relevant files were modified"
fi
# Benches...
if affects \
.rs$ \

View File

@ -26,8 +26,9 @@ declare print_free_tree=(
':runtime/src/**.rs'
':sdk/bpf/rust/rust-utils/**.rs'
':sdk/**.rs'
':^sdk/src/program_option.rs'
':^sdk/src/program_stubs.rs'
':^sdk/cargo-build-bpf/**.rs'
':^sdk/program/src/program_option.rs'
':^sdk/program/src/program_stubs.rs'
':programs/**.rs'
':^**bin**.rs'
':^**bench**.rs'

View File

@ -42,10 +42,10 @@ def get_packages():
sys.exit(1)
# Order dependencies
deleted_dependencies = []
sorted_dependency_graph = []
max_iterations = pow(len(dependency_graph),2)
while len(deleted_dependencies) < len(dependency_graph):
while dependency_graph:
deleted_packages = []
if max_iterations == 0:
# One day be more helpful and find the actual cycle for the user...
sys.exit('Error: Circular dependency suspected between these packages: \n {}\n'.format('\n '.join(dependency_graph.keys())))
@ -53,13 +53,17 @@ def get_packages():
max_iterations -= 1
for package, dependencies in dependency_graph.items():
if package in deleted_packages:
continue
for dependency in dependencies:
if dependency in dependency_graph:
break
else:
deleted_dependencies.append(package)
deleted_packages.append(package)
sorted_dependency_graph.append((package, manifest_path[package]))
dependency_graph = {p: d for p, d in dependency_graph.items() if not p in deleted_packages }
return sorted_dependency_graph

View File

@ -4,6 +4,8 @@ cd "$(dirname "$0")/.."
source ci/semver_bash/semver.sh
source ci/rust-version.sh stable
cargo="$(readlink -f ./cargo)"
# shellcheck disable=SC2086
is_crate_version_uploaded() {
name=$1
@ -66,11 +68,11 @@ for Cargo_toml in $Cargo_tomls; do
(
set -x
rm -rf crate-test
cargo +"$rust_stable" init crate-test
"$cargo" stable init crate-test
cd crate-test/
echo "${crate_name} = \"${expectedCrateVersion}\"" >> Cargo.toml
echo "[workspace]" >> Cargo.toml
cargo +"$rust_stable" check
"$cargo" stable check
) && really_uploaded=1
if ((really_uploaded)); then
break;

View File

@ -91,17 +91,15 @@ echo --- Creating release tarball
cp "${RELEASE_BASENAME}"/version.yml "${TARBALL_BASENAME}"-$TARGET.yml
)
# Metrics tarball is platform agnostic, only publish it from Linux
# Maybe tarballs are platform agnostic, only publish them from the Linux build
MAYBE_TARBALLS=
if [[ "$CI_OS_NAME" = linux ]]; then
metrics/create-metrics-tarball.sh
(
set -x
sdk/bpf/scripts/package.sh
[[ -f bpf-sdk.tar.bz2 ]]
)
MAYBE_TARBALLS="bpf-sdk.tar.bz2 solana-metrics.tar.bz2"
MAYBE_TARBALLS="bpf-sdk.tar.bz2"
fi
source ci/upload-ci-artifact.sh
@ -126,7 +124,7 @@ for file in "${TARBALL_BASENAME}"-$TARGET.tar.bz2 "${TARBALL_BASENAME}"-$TARGET.
/usr/bin/s3cmd --acl-public put /solana/"$file" s3://release.solana.com/"$CHANNEL_OR_TAG"/"$file"
echo Published to:
$DRYRUN ci/format-url.sh http://release.solana.com/"$CHANNEL_OR_TAG"/"$file"
$DRYRUN ci/format-url.sh https://release.solana.com/"$CHANNEL_OR_TAG"/"$file"
)
if [[ -n $TAG ]]; then
@ -149,4 +147,30 @@ for file in "${TARBALL_BASENAME}"-$TARGET.tar.bz2 "${TARBALL_BASENAME}"-$TARGET.
fi
done
# Create install wrapper for release.solana.com
if [[ -n $BUILDKITE ]]; then
cat > release.solana.com-install <<EOF
SOLANA_RELEASE=$CHANNEL_OR_TAG
SOLANA_INSTALL_INIT_ARGS=$CHANNEL_OR_TAG
SOLANA_DOWNLOAD_ROOT=http://release.solana.com
EOF
cat install/solana-install-init.sh >> release.solana.com-install
echo --- AWS S3 Store: "install"
(
set -x
$DRYRUN docker run \
--rm \
--env AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY \
--volume "$PWD:/solana" \
eremite/aws-cli:2018.12.18 \
/usr/bin/s3cmd --acl-public put /solana/release.solana.com-install s3://release.solana.com/"$CHANNEL_OR_TAG"/install
echo Published to:
$DRYRUN ci/format-url.sh https://release.solana.com/"$CHANNEL_OR_TAG"/install
)
fi
echo --- ok

View File

@ -6,7 +6,8 @@ source ci/_
source ci/upload-ci-artifact.sh
eval "$(ci/channel-info.sh)"
source ci/rust-version.sh all
cargo="$(readlink -f "./cargo")"
set -o pipefail
export RUST_BACKTRACE=1
@ -27,35 +28,35 @@ test -d target/debug/bpf && find target/debug/bpf -name '*.d' -delete
test -d target/release/bpf && find target/release/bpf -name '*.d' -delete
# Ensure all dependencies are built
_ cargo +$rust_nightly build --release
_ "$cargo" nightly build --release
# Remove "BENCH_FILE", if it exists so that the following commands can append
rm -f "$BENCH_FILE"
# Run sdk benches
_ cargo +$rust_nightly bench --manifest-path sdk/Cargo.toml ${V:+--verbose} \
_ "$cargo" nightly bench --manifest-path sdk/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
# Run runtime benches
_ cargo +$rust_nightly bench --manifest-path runtime/Cargo.toml ${V:+--verbose} \
_ "$cargo" nightly bench --manifest-path runtime/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
# Run core benches
_ cargo +$rust_nightly bench --manifest-path core/Cargo.toml ${V:+--verbose} \
_ "$cargo" nightly bench --manifest-path core/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
# Run bpf benches
_ cargo +$rust_nightly bench --manifest-path programs/bpf/Cargo.toml ${V:+--verbose} --features=bpf_c \
_ "$cargo" nightly bench --manifest-path programs/bpf/Cargo.toml ${V:+--verbose} --features=bpf_c \
-- -Z unstable-options --format=json --nocapture | tee -a "$BENCH_FILE"
# Run banking/accounts bench. Doesn't require nightly, but use since it is already built.
_ cargo +$rust_nightly run --release --manifest-path banking-bench/Cargo.toml ${V:+--verbose} | tee -a "$BENCH_FILE"
_ cargo +$rust_nightly run --release --manifest-path accounts-bench/Cargo.toml ${V:+--verbose} -- --num_accounts 10000 --num_slots 4 | tee -a "$BENCH_FILE"
_ "$cargo" nightly run --release --manifest-path banking-bench/Cargo.toml ${V:+--verbose} | tee -a "$BENCH_FILE"
_ "$cargo" nightly run --release --manifest-path accounts-bench/Cargo.toml ${V:+--verbose} -- --num_accounts 10000 --num_slots 4 | tee -a "$BENCH_FILE"
# `solana-upload-perf` disabled as it can take over 30 minutes to complete for some
# reason
exit 0
_ cargo +$rust_nightly run --release --package solana-upload-perf \
_ "$cargo" nightly run --release --package solana-upload-perf \
-- "$BENCH_FILE" "$TARGET_BRANCH" "$UPLOAD_METRICS" | tee "$BENCH_ARTIFACT"
upload-ci-artifact "$BENCH_FILE"

View File

@ -8,6 +8,9 @@ source ci/_
source ci/rust-version.sh stable
source ci/rust-version.sh nightly
eval "$(ci/channel-info.sh)"
cargo="$(readlink -f "./cargo")"
scripts/increment-cargo-version.sh check
echo --- build environment
(
@ -16,14 +19,14 @@ echo --- build environment
rustup run "$rust_stable" rustc --version --verbose
rustup run "$rust_nightly" rustc --version --verbose
cargo +"$rust_stable" --version --verbose
cargo +"$rust_nightly" --version --verbose
"$cargo" stable --version --verbose
"$cargo" nightly --version --verbose
cargo +"$rust_stable" clippy --version --verbose
cargo +"$rust_nightly" clippy --version --verbose
"$cargo" stable clippy --version --verbose
"$cargo" nightly clippy --version --verbose
# audit is done only with stable
cargo +"$rust_stable" audit --version
"$cargo" stable audit --version
)
export RUST_BACKTRACE=1
@ -41,7 +44,7 @@ if [[ $CI_BASE_BRANCH = "$EDGE_CHANNEL" ]]; then
echo "$0: [tree (for outdated Cargo.lock sync)|check (for compilation error)|update -p foo --precise x.y.z (for your Cargo.toml update)] ..." >&2
exit "$check_status"
fi
# Ensure nightly and --benches
_ scripts/cargo-for-all-lock-files.sh +"$rust_nightly" check --locked --all-targets
else
@ -49,26 +52,49 @@ else
fi
_ ci/order-crates-for-publishing.py
_ cargo +"$rust_stable" fmt --all -- --check
_ "$cargo" stable fmt --all -- --check
# -Z... is needed because of clippy bug: https://github.com/rust-lang/rust-clippy/issues/4612
# run nightly clippy for `sdk/` as there's a moderate amount of nightly-only code there
_ cargo +"$rust_nightly" clippy \
_ "$cargo" nightly clippy \
-Zunstable-options --workspace --all-targets \
-- --deny=warnings --allow=clippy::stable_sort_primitive
_ scripts/cargo-for-all-lock-files.sh +"$rust_stable" audit --ignore RUSTSEC-2020-0002 --ignore RUSTSEC-2020-0008
cargo_audit_ignores=(
# failure is officially deprecated/unmaintained
#
# Blocked on multiple upstream crates removing their `failure` dependency.
--ignore RUSTSEC-2020-0036
# `net2` crate has been deprecated; use `socket2` instead
#
# Blocked on https://github.com/paritytech/jsonrpc/issues/575
--ignore RUSTSEC-2020-0016
# stdweb is unmaintained
#
# Blocked on multiple upstream crates removing their `stdweb` dependency.
--ignore RUSTSEC-2020-0056
# Potential segfault in the time crate
#
# Blocked on multiple crates updating `time` to >= 0.2.23
--ignore RUSTSEC-2020-0071
)
_ scripts/cargo-for-all-lock-files.sh +"$rust_stable" audit "${cargo_audit_ignores[@]}"
{
cd programs/bpf
_ cargo +"$rust_stable" audit
_ "$cargo" stable audit
for project in rust/*/ ; do
echo "+++ do_bpf_checks $project"
(
cd "$project"
_ cargo +"$rust_stable" fmt -- --check
_ cargo +"$rust_nightly" test
_ cargo +"$rust_nightly" clippy -- --deny=warnings --allow=clippy::missing_safety_doc
_ "$cargo" stable fmt -- --check
_ "$cargo" nightly test
_ "$cargo" nightly clippy -- --deny=warnings \
--allow=clippy::missing_safety_doc \
--allow=clippy::stable_sort_primitive
)
done
}

View File

@ -2,6 +2,8 @@
set -e
cd "$(dirname "$0")/.."
cargo="$(readlink -f "./cargo")"
source ci/_
annotate() {
@ -37,12 +39,15 @@ NPROC=$((NPROC>14 ? 14 : NPROC))
echo "Executing $testName"
case $testName in
test-stable)
_ cargo +"$rust_stable" test --jobs "$NPROC" --all --exclude solana-local-cluster ${V:+--verbose} -- --nocapture
_ "$cargo" stable test --jobs "$NPROC" --all --exclude solana-local-cluster ${V:+--verbose} -- --nocapture
;;
test-stable-perf)
# BPF solana-sdk legacy compile test
./cargo-build-bpf --manifest-path sdk/Cargo.toml
# BPF program tests
_ make -C programs/bpf/c tests
_ cargo +"$rust_stable" test \
_ "$cargo" stable test \
--manifest-path programs/bpf/Cargo.toml \
--no-default-features --features=bpf_c,bpf_rust -- --nocapture
@ -62,13 +67,13 @@ test-stable-perf)
export SOLANA_CUDA=1
fi
_ cargo +"$rust_stable" build --bins ${V:+--verbose}
_ cargo +"$rust_stable" test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- --nocapture
_ cargo +"$rust_stable" run --manifest-path poh-bench/Cargo.toml ${V:+--verbose} -- --hashes-per-tick 10
_ "$cargo" stable build --bins ${V:+--verbose}
_ "$cargo" stable test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- --nocapture
_ "$cargo" stable run --manifest-path poh-bench/Cargo.toml ${V:+--verbose} -- --hashes-per-tick 10
;;
test-local-cluster)
_ cargo +"$rust_stable" build --release --bins ${V:+--verbose}
_ cargo +"$rust_stable" test --release --package solana-local-cluster ${V:+--verbose} -- --nocapture --test-threads=1
_ "$cargo" stable build --release --bins ${V:+--verbose}
_ "$cargo" stable test --release --package solana-local-cluster ${V:+--verbose} -- --nocapture --test-threads=1
exit 0
;;
*)

View File

@ -1,6 +1,6 @@
[package]
name = "solana-clap-utils"
version = "1.4.0"
version = "1.4.21"
description = "Solana utilities for the clap"
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
repository = "https://github.com/solana-labs/solana"
@ -11,8 +11,8 @@ edition = "2018"
[dependencies]
clap = "2.33.0"
rpassword = "4.0"
solana-remote-wallet = { path = "../remote-wallet", version = "1.4.0" }
solana-sdk = { path = "../sdk", version = "1.4.0" }
solana-remote-wallet = { path = "../remote-wallet", version = "1.4.21" }
solana-sdk = { path = "../sdk", version = "1.4.21" }
thiserror = "1.0.20"
tiny-bip39 = "0.7.0"
url = "2.1.0"

View File

@ -189,6 +189,7 @@ pub fn commitment_of(matches: &ArgMatches<'_>, name: &str) -> Option<CommitmentC
"recent" => CommitmentConfig::recent(),
"root" => CommitmentConfig::root(),
"single" => CommitmentConfig::single(),
"singleGossip" => CommitmentConfig::single_gossip(),
_ => CommitmentConfig::default(),
})
}
@ -228,8 +229,8 @@ mod tests {
assert_eq!(values_of(&matches, "multiple"), Some(vec![50, 39]));
assert_eq!(values_of::<u64>(&matches, "single"), None);
let pubkey0 = Pubkey::new_rand();
let pubkey1 = Pubkey::new_rand();
let pubkey0 = solana_sdk::pubkey::new_rand();
let pubkey1 = solana_sdk::pubkey::new_rand();
let matches = app().clone().get_matches_from(vec![
"test",
"--multiple",
@ -251,7 +252,7 @@ mod tests {
assert_eq!(value_of(&matches, "single"), Some(50));
assert_eq!(value_of::<u64>(&matches, "multiple"), None);
let pubkey = Pubkey::new_rand();
let pubkey = solana_sdk::pubkey::new_rand();
let matches = app()
.clone()
.get_matches_from(vec!["test", "--single", &pubkey.to_string()]);
@ -331,8 +332,8 @@ mod tests {
#[test]
fn test_pubkeys_sigs_of() {
let key1 = Pubkey::new_rand();
let key2 = Pubkey::new_rand();
let key1 = solana_sdk::pubkey::new_rand();
let key2 = solana_sdk::pubkey::new_rand();
let sig1 = Keypair::new().sign_message(&[0u8]);
let sig2 = Keypair::new().sign_message(&[1u8]);
let signer1 = format!("{}={}", key1, sig1);

View File

@ -1,7 +1,7 @@
use crate::keypair::{parse_keypair_path, KeypairUrl, ASK_KEYWORD};
use chrono::DateTime;
use solana_sdk::{
clock::Slot,
clock::{Epoch, Slot},
hash::Hash,
pubkey::Pubkey,
signature::{read_keypair_file, Signature},
@ -148,6 +148,40 @@ where
}
}
pub fn is_url_or_moniker<T>(string: T) -> Result<(), String>
where
T: AsRef<str> + Display,
{
match url::Url::parse(&normalize_to_url_if_moniker(string.as_ref())) {
Ok(url) => {
if url.has_host() {
Ok(())
} else {
Err("no host provided".to_string())
}
}
Err(err) => Err(format!("{}", err)),
}
}
pub fn normalize_to_url_if_moniker(url_or_moniker: &str) -> String {
match url_or_moniker {
"m" | "mainnet-beta" => "https://api.mainnet-beta.solana.com",
"t" | "testnet" => "https://testnet.solana.com",
"d" | "devnet" => "https://devnet.solana.com",
"l" | "localhost" => "http://localhost:8899",
url => url,
}
.to_string()
}
pub fn is_epoch<T>(epoch: T) -> Result<(), String>
where
T: AsRef<str> + Display,
{
is_parsable_generic::<Epoch, _>(epoch)
}
pub fn is_slot<T>(slot: T) -> Result<(), String>
where
T: AsRef<str> + Display,

View File

@ -58,6 +58,15 @@ impl CliSignerInfo {
Some(0)
}
}
pub fn index_of_or_none(&self, pubkey: Option<Pubkey>) -> Option<usize> {
if let Some(pubkey) = pubkey {
self.signers
.iter()
.position(|signer| signer.pubkey() == pubkey)
} else {
None
}
}
}
pub struct DefaultSigner {
@ -298,7 +307,24 @@ pub fn keypair_from_seed_phrase(
keypair_from_seed_phrase_and_passphrase(&seed_phrase, &passphrase)?
} else {
let sanitized = sanitize_seed_phrase(seed_phrase);
let mnemonic = Mnemonic::from_phrase(&sanitized, Language::English)?;
let parse_language_fn = || {
for language in &[
Language::English,
Language::ChineseSimplified,
Language::ChineseTraditional,
Language::Japanese,
Language::Spanish,
Language::Korean,
Language::French,
Language::Italian,
] {
if let Ok(mnemonic) = Mnemonic::from_phrase(&sanitized, *language) {
return Ok(mnemonic);
}
}
Err("Can't get mnemonic from seed phrases")
};
let mnemonic = parse_language_fn()?;
let passphrase = prompt_passphrase(&passphrase_prompt)?;
let seed = Seed::new(&mnemonic, &passphrase);
keypair_from_seed(seed.as_bytes())?

View File

@ -3,13 +3,13 @@ authors = ["Solana Maintainers <maintainers@solana.foundation>"]
edition = "2018"
name = "solana-cli-config"
description = "Blockchain, Rebuilt for Scale"
version = "1.4.0"
version = "1.4.21"
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
[dependencies]
dirs = "2.0.2"
dirs-next = "2.0.0"
lazy_static = "1.4.0"
serde = "1.0.112"
serde_derive = "1.0.103"

View File

@ -5,7 +5,7 @@ use url::Url;
lazy_static! {
pub static ref CONFIG_FILE: Option<String> = {
dirs::home_dir().map(|mut path| {
dirs_next::home_dir().map(|mut path| {
path.extend(&[".config", "solana", "cli", "config.yml"]);
path.to_str().unwrap().to_string()
})
@ -25,7 +25,7 @@ pub struct Config {
impl Default for Config {
fn default() -> Self {
let keypair_path = {
let mut keypair_path = dirs::home_dir().expect("home directory");
let mut keypair_path = dirs_next::home_dir().expect("home directory");
keypair_path.extend(&[".config", "solana", "id.json"]);
keypair_path.to_str().unwrap().to_string()
};
@ -76,17 +76,6 @@ impl Config {
ws_url.to_string()
}
pub fn compute_rpc_banks_url(json_rpc_url: &str) -> String {
let json_rpc_url: Option<Url> = json_rpc_url.parse().ok();
if json_rpc_url.is_none() {
return "".to_string();
}
let mut url = json_rpc_url.unwrap();
let port = url.port().unwrap_or(8899);
url.set_port(Some(port + 3)).expect("unable to set port");
url.to_string()
}
pub fn import_address_labels<P>(&mut self, filename: P) -> Result<(), io::Error>
where
P: AsRef<Path>,
@ -133,28 +122,4 @@ mod test {
assert_eq!(Config::compute_websocket_url(&"garbage"), String::new());
}
#[test]
fn compute_rpc_banks_url() {
assert_eq!(
Config::compute_rpc_banks_url(&"http://devnet.solana.com"),
"http://devnet.solana.com:8902/".to_string()
);
assert_eq!(
Config::compute_rpc_banks_url(&"https://devnet.solana.com"),
"https://devnet.solana.com:8902/".to_string()
);
assert_eq!(
Config::compute_rpc_banks_url(&"http://example.com:8899"),
"http://example.com:8902/".to_string()
);
assert_eq!(
Config::compute_rpc_banks_url(&"https://example.com:1234"),
"https://example.com:1237/".to_string()
);
assert_eq!(Config::compute_rpc_banks_url(&"garbage"), String::new());
}
}

View File

@ -3,7 +3,7 @@ authors = ["Solana Maintainers <maintainers@solana.foundation>"]
edition = "2018"
name = "solana-cli-output"
description = "Blockchain, Rebuilt for Scale"
version = "1.4.0"
version = "1.4.21"
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
@ -17,13 +17,13 @@ indicatif = "0.15.0"
serde = "1.0.112"
serde_derive = "1.0.103"
serde_json = "1.0.56"
solana-account-decoder = { path = "../account-decoder", version = "1.4.0" }
solana-clap-utils = { path = "../clap-utils", version = "1.4.0" }
solana-client = { path = "../client", version = "1.4.0" }
solana-sdk = { path = "../sdk", version = "1.4.0" }
solana-stake-program = { path = "../programs/stake", version = "1.4.0" }
solana-transaction-status = { path = "../transaction-status", version = "1.4.0" }
solana-vote-program = { path = "../programs/vote", version = "1.4.0" }
solana-account-decoder = { path = "../account-decoder", version = "1.4.21" }
solana-clap-utils = { path = "../clap-utils", version = "1.4.21" }
solana-client = { path = "../client", version = "1.4.21" }
solana-sdk = { path = "../sdk", version = "1.4.21" }
solana-stake-program = { path = "../programs/stake", version = "1.4.21" }
solana-transaction-status = { path = "../transaction-status", version = "1.4.21" }
solana-vote-program = { path = "../programs/vote", version = "1.4.21" }
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

View File

@ -132,7 +132,7 @@ impl fmt::Display for CliBlockProduction {
"{}",
style(format!(
" {:<44} {:>15} {:>15} {:>15} {:>23}",
"Identity Pubkey",
"Identity",
"Leader Slots",
"Blocks Produced",
"Skipped Slots",
@ -241,6 +241,9 @@ impl fmt::Display for CliEpochInfo {
)?;
writeln_name_value(f, "Slot:", &self.epoch_info.absolute_slot.to_string())?;
writeln_name_value(f, "Epoch:", &self.epoch_info.epoch.to_string())?;
if let Some(transaction_count) = &self.epoch_info.transaction_count {
writeln_name_value(f, "Transaction Count:", &transaction_count.to_string())?;
}
let start_slot = self.epoch_info.absolute_slot - self.epoch_info.slot_index;
let end_slot = start_slot + self.epoch_info.slots_in_epoch;
writeln_name_value(
@ -301,7 +304,7 @@ pub struct CliValidatorsStakeByVersion {
pub struct CliValidators {
pub total_active_stake: u64,
pub total_current_stake: u64,
pub total_deliquent_stake: u64,
pub total_delinquent_stake: u64,
pub current_validators: Vec<CliValidator>,
pub delinquent_validators: Vec<CliValidator>,
pub stake_by_version: BTreeMap<String, CliValidatorsStakeByVersion>,
@ -360,7 +363,7 @@ impl fmt::Display for CliValidators {
"Active Stake:",
&build_balance_message(self.total_active_stake, self.use_lamports_unit, true),
)?;
if self.total_deliquent_stake > 0 {
if self.total_delinquent_stake > 0 {
writeln_name_value(
f,
"Current Stake:",
@ -376,11 +379,11 @@ impl fmt::Display for CliValidators {
&format!(
"{} ({:0.2}%)",
&build_balance_message(
self.total_deliquent_stake,
self.total_delinquent_stake,
self.use_lamports_unit,
true
),
100. * self.total_deliquent_stake as f64 / self.total_active_stake as f64
100. * self.total_delinquent_stake as f64 / self.total_active_stake as f64
),
)?;
}
@ -412,8 +415,8 @@ impl fmt::Display for CliValidators {
"{}",
style(format!(
" {:<44} {:<38} {} {} {} {:>10} {:^8} {}",
"Identity Pubkey",
"Vote Account Pubkey",
"Identity",
"Vote Account",
"Commission",
"Last Vote",
"Root Block",
@ -520,7 +523,7 @@ impl fmt::Display for CliNonceAccount {
)
)?;
let nonce = self.nonce.as_deref().unwrap_or("uninitialized");
writeln!(f, "Nonce: {}", nonce)?;
writeln!(f, "Nonce blockhash: {}", nonce)?;
if let Some(fees) = self.lamports_per_signature {
writeln!(f, "Fee: {} lamports per signature", fees)?;
} else {
@ -541,7 +544,15 @@ impl CliStakeVec {
}
impl QuietDisplay for CliStakeVec {}
impl VerboseDisplay for CliStakeVec {}
impl VerboseDisplay for CliStakeVec {
fn write_str(&self, w: &mut dyn std::fmt::Write) -> std::fmt::Result {
for state in &self.0 {
writeln!(w)?;
VerboseDisplay::write_str(state, w)?;
}
Ok(())
}
}
impl fmt::Display for CliStakeVec {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -562,7 +573,12 @@ pub struct CliKeyedStakeState {
}
impl QuietDisplay for CliKeyedStakeState {}
impl VerboseDisplay for CliKeyedStakeState {}
impl VerboseDisplay for CliKeyedStakeState {
fn write_str(&self, w: &mut dyn std::fmt::Write) -> std::fmt::Result {
writeln!(w, "Stake Pubkey: {}", self.stake_pubkey)?;
VerboseDisplay::write_str(&self.stake_state, w)
}
}
impl fmt::Display for CliKeyedStakeState {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -579,7 +595,7 @@ pub struct CliEpochReward {
pub amount: u64, // lamports
pub post_balance: u64, // lamports
pub percent_change: f64,
pub apr: f64,
pub apr: Option<f64>,
}
fn show_epoch_rewards(
@ -594,19 +610,22 @@ fn show_epoch_rewards(
writeln!(f, "Epoch Rewards:")?;
writeln!(
f,
" {:<8} {:<11} {:<15} {:<15} {:>14} {:>14}",
" {:<6} {:<11} {:<16} {:<16} {:>14} {:>14}",
"Epoch", "Reward Slot", "Amount", "New Balance", "Percent Change", "APR"
)?;
for reward in epoch_rewards {
writeln!(
f,
" {:<8} {:<11} ◎{:<14.9} ◎{:<14.9} {:>13.9}% {:>13.9}%",
" {:<6} {:<11} ◎{:<16.9} ◎{:<14.9} {:>13.2}% {}",
reward.epoch,
reward.effective_slot,
lamports_to_sol(reward.amount),
lamports_to_sol(reward.post_balance),
reward.percent_change,
reward.apr,
reward
.apr
.map(|apr| format!("{:>13.2}%", apr))
.unwrap_or_default(),
)?;
}
}
@ -619,6 +638,8 @@ pub struct CliStakeState {
pub stake_type: CliStakeType,
pub account_balance: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub credits_observed: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub delegated_stake: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub delegated_vote_account_address: Option<String>,
@ -647,7 +668,15 @@ pub struct CliStakeState {
}
impl QuietDisplay for CliStakeState {}
impl VerboseDisplay for CliStakeState {}
impl VerboseDisplay for CliStakeState {
fn write_str(&self, w: &mut dyn std::fmt::Write) -> std::fmt::Result {
write!(w, "{}", self)?;
if let Some(credits) = self.credits_observed {
writeln!(w, "Credits Observed: {}", credits)?;
}
Ok(())
}
}
impl fmt::Display for CliStakeState {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -661,13 +690,8 @@ impl fmt::Display for CliStakeState {
if lockup.unix_timestamp != UnixTimestamp::default() {
writeln!(
f,
"Lockup Timestamp: {} (UnixTimestamp: {})",
DateTime::<Utc>::from_utc(
NaiveDateTime::from_timestamp(lockup.unix_timestamp, 0),
Utc
)
.to_rfc3339_opts(SecondsFormat::Secs, true),
lockup.unix_timestamp
"Lockup Timestamp: {}",
unix_timestamp_to_string(lockup.unix_timestamp)
)?;
}
if lockup.epoch != Epoch::default() {
@ -952,8 +976,8 @@ impl VerboseDisplay for CliValidatorInfo {}
impl fmt::Display for CliValidatorInfo {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln_name_value(f, "Validator Identity Pubkey:", &self.identity_pubkey)?;
writeln_name_value(f, " Info Pubkey:", &self.info_pubkey)?;
writeln_name_value(f, "Validator Identity:", &self.identity_pubkey)?;
writeln_name_value(f, " Info Address:", &self.info_pubkey)?;
for (key, value) in self.info.iter() {
writeln_name_value(
f,
@ -1008,7 +1032,12 @@ impl fmt::Display for CliVoteAccount {
None => "~".to_string(),
}
)?;
writeln!(f, "Recent Timestamp: {:?}", self.recent_timestamp)?;
writeln!(
f,
"Recent Timestamp: {} from slot {}",
unix_timestamp_to_string(self.recent_timestamp.timestamp),
self.recent_timestamp.slot
)?;
if !self.votes.is_empty() {
writeln!(f, "Recent Votes:")?;
for vote in &self.votes {
@ -1093,19 +1122,22 @@ pub struct CliBlockTime {
impl QuietDisplay for CliBlockTime {}
impl VerboseDisplay for CliBlockTime {}
fn unix_timestamp_to_string(unix_timestamp: UnixTimestamp) -> String {
format!(
"{} (UnixTimestamp: {})",
match NaiveDateTime::from_timestamp_opt(unix_timestamp, 0) {
Some(ndt) =>
DateTime::<Utc>::from_utc(ndt, Utc).to_rfc3339_opts(SecondsFormat::Secs, true),
None => "unknown".to_string(),
},
unix_timestamp,
)
}
impl fmt::Display for CliBlockTime {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln_name_value(f, "Block:", &self.slot.to_string())?;
writeln_name_value(
f,
"Date:",
&format!(
"{} (UnixTimestamp: {})",
DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp(self.timestamp, 0), Utc)
.to_rfc3339_opts(SecondsFormat::Secs, true),
self.timestamp
),
)
writeln_name_value(f, "Date:", &unix_timestamp_to_string(self.timestamp))
}
}

View File

@ -197,6 +197,15 @@ pub fn write_transaction<W: io::Write>(
)?;
}
}
if let Some(log_messages) = &transaction_status.log_messages {
if !log_messages.is_empty() {
writeln!(w, "{}Log Messages:", prefix,)?;
for log_message in log_messages {
writeln!(w, "{} {}", prefix, log_message,)?;
}
}
}
} else {
writeln!(w, "{}Status: Unavailable", prefix)?;
}

View File

@ -3,7 +3,7 @@ authors = ["Solana Maintainers <maintainers@solana.foundation>"]
edition = "2018"
name = "solana-cli"
description = "Blockchain, Rebuilt for Scale"
version = "1.4.0"
version = "1.4.21"
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
@ -16,39 +16,41 @@ clap = "2.33.1"
criterion-stats = "0.3.0"
ctrlc = { version = "3.1.5", features = ["termination"] }
console = "0.11.3"
dirs = "2.0.2"
dirs-next = "2.0.0"
log = "0.4.8"
Inflector = "0.11.4"
indicatif = "0.15.0"
humantime = "2.0.1"
num-traits = "0.2"
pretty-hex = "0.1.1"
reqwest = { version = "0.10.6", default-features = false, features = ["blocking", "rustls-tls", "json"] }
reqwest = { version = "0.10.8", default-features = false, features = ["blocking", "rustls-tls", "json"] }
serde = "1.0.112"
serde_derive = "1.0.103"
serde_json = "1.0.56"
solana-account-decoder = { path = "../account-decoder", version = "1.4.0" }
solana-clap-utils = { path = "../clap-utils", version = "1.4.0" }
solana-cli-config = { path = "../cli-config", version = "1.4.0" }
solana-cli-output = { path = "../cli-output", version = "1.4.0" }
solana-client = { path = "../client", version = "1.4.0" }
solana-config-program = { path = "../programs/config", version = "1.4.0" }
solana-faucet = { path = "../faucet", version = "1.4.0" }
solana-logger = { path = "../logger", version = "1.4.0" }
solana-net-utils = { path = "../net-utils", version = "1.4.0" }
solana-remote-wallet = { path = "../remote-wallet", version = "1.4.0" }
solana-runtime = { path = "../runtime", version = "1.4.0" }
solana-sdk = { path = "../sdk", version = "1.4.0" }
solana-stake-program = { path = "../programs/stake", version = "1.4.0" }
solana-transaction-status = { path = "../transaction-status", version = "1.4.0" }
solana-version = { path = "../version", version = "1.4.0" }
solana-vote-program = { path = "../programs/vote", version = "1.4.0" }
solana-vote-signer = { path = "../vote-signer", version = "1.4.0" }
solana-account-decoder = { path = "../account-decoder", version = "1.4.21" }
solana-bpf-loader-program = { path = "../programs/bpf_loader", version = "1.4.21" }
solana-clap-utils = { path = "../clap-utils", version = "1.4.21" }
solana-cli-config = { path = "../cli-config", version = "1.4.21" }
solana-cli-output = { path = "../cli-output", version = "1.4.21" }
solana-client = { path = "../client", version = "1.4.21" }
solana-config-program = { path = "../programs/config", version = "1.4.21" }
solana-faucet = { path = "../faucet", version = "1.4.21" }
solana-logger = { path = "../logger", version = "1.4.21" }
solana-net-utils = { path = "../net-utils", version = "1.4.21" }
solana_rbpf = "=0.1.34"
solana-remote-wallet = { path = "../remote-wallet", version = "1.4.21" }
solana-sdk = { path = "../sdk", version = "1.4.21" }
solana-stake-program = { path = "../programs/stake", version = "1.4.21" }
solana-transaction-status = { path = "../transaction-status", version = "1.4.21" }
solana-version = { path = "../version", version = "1.4.21" }
solana-vote-program = { path = "../programs/vote", version = "1.4.21" }
solana-vote-signer = { path = "../vote-signer", version = "1.4.21" }
thiserror = "1.0.20"
tiny-bip39 = "0.7.0"
url = "2.1.1"
[dev-dependencies]
solana-core = { path = "../core", version = "1.4.0" }
solana-core = { path = "../core", version = "1.4.21" }
tempfile = "3.1.0"
[[bin]]

View File

@ -54,12 +54,42 @@ pub fn check_account_for_multiple_fees_with_commitment(
fee_calculator: &FeeCalculator,
messages: &[&Message],
commitment: CommitmentConfig,
) -> Result<(), CliError> {
check_account_for_spend_multiple_fees_with_commitment(
rpc_client,
account_pubkey,
0,
fee_calculator,
messages,
commitment,
)
}
pub fn check_account_for_spend_multiple_fees_with_commitment(
rpc_client: &RpcClient,
account_pubkey: &Pubkey,
balance: u64,
fee_calculator: &FeeCalculator,
messages: &[&Message],
commitment: CommitmentConfig,
) -> Result<(), CliError> {
let fee = calculate_fee(fee_calculator, messages);
if !check_account_for_balance_with_commitment(rpc_client, account_pubkey, fee, commitment)
.map_err(Into::<ClientError>::into)?
if !check_account_for_balance_with_commitment(
rpc_client,
account_pubkey,
balance + fee,
commitment,
)
.map_err(Into::<ClientError>::into)?
{
return Err(CliError::InsufficientFundsForFee(lamports_to_sol(fee)));
if balance > 0 {
return Err(CliError::InsufficientFundsForSpendAndFee(
lamports_to_sol(balance),
lamports_to_sol(fee),
));
} else {
return Err(CliError::InsufficientFundsForFee(lamports_to_sol(fee)));
}
}
Ok(())
}
@ -131,7 +161,7 @@ mod tests {
context: RpcResponseContext { slot: 1 },
value: json!(account_balance),
});
let pubkey = Pubkey::new_rand();
let pubkey = solana_sdk::pubkey::new_rand();
let fee_calculator = FeeCalculator::new(1);
let pubkey0 = Pubkey::new(&[0; 32]);
@ -191,7 +221,7 @@ mod tests {
context: RpcResponseContext { slot: 1 },
value: json!(account_balance),
});
let pubkey = Pubkey::new_rand();
let pubkey = solana_sdk::pubkey::new_rand();
let mut mocks = HashMap::new();
mocks.insert(RpcRequest::GetBalance, account_balance_response);
@ -237,9 +267,9 @@ mod tests {
#[test]
fn test_check_unique_pubkeys() {
let pubkey0 = Pubkey::new_rand();
let pubkey0 = solana_sdk::pubkey::new_rand();
let pubkey_clone = pubkey0;
let pubkey1 = Pubkey::new_rand();
let pubkey1 = solana_sdk::pubkey::new_rand();
check_unique_pubkeys((&pubkey0, "foo".to_string()), (&pubkey1, "bar".to_string()))
.expect("unexpected result");

View File

@ -1,11 +1,11 @@
use crate::{
checks::*, cluster_query::*, feature::*, inflation::*, nonce::*, spend_utils::*, stake::*,
cluster_query::*, feature::*, inflation::*, nonce::*, program::*, spend_utils::*, stake::*,
validator_info::*, vote::*,
};
use clap::{value_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand};
use log::*;
use num_traits::FromPrimitive;
use serde_json::{self, json, Value};
use serde_json::{self, Value};
use solana_account_decoder::{UiAccount, UiAccountEncoding};
use solana_clap_utils::{
self,
@ -18,9 +18,7 @@ use solana_clap_utils::{
offline::*,
};
use solana_cli_output::{
display::{
build_balance_message, new_spinner_progress_bar, println_name_value, println_transaction,
},
display::{build_balance_message, println_name_value, println_transaction},
return_signers, CliAccount, CliSignature, OutputFormat,
};
use solana_client::{
@ -28,8 +26,7 @@ use solana_client::{
client_error::{ClientError, ClientErrorKind, Result as ClientResult},
nonce_utils,
rpc_client::RpcClient,
rpc_config::{RpcLargestAccountsFilter, RpcSendTransactionConfig},
rpc_request::MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS,
rpc_config::{RpcLargestAccountsFilter, RpcSendTransactionConfig, RpcTransactionLogsFilter},
rpc_response::RpcKeyedAccount,
};
#[cfg(not(test))]
@ -38,17 +35,14 @@ use solana_faucet::faucet::request_airdrop_transaction;
use solana_faucet::faucet_mock::request_airdrop_transaction;
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use solana_sdk::{
bpf_loader, bpf_loader_deprecated,
clock::{Epoch, Slot, DEFAULT_TICKS_PER_SECOND},
clock::{Epoch, Slot},
commitment_config::CommitmentConfig,
decode_error::DecodeError,
hash::Hash,
instruction::{Instruction, InstructionError},
loader_instruction,
instruction::InstructionError,
message::Message,
pubkey::{Pubkey, MAX_SEED_LEN},
signature::{Keypair, Signature, Signer, SignerError},
signers::Signers,
signature::{Signature, Signer, SignerError},
system_instruction::{self, SystemError},
system_program,
transaction::{Transaction, TransactionError},
@ -64,7 +58,7 @@ use std::{
error,
fmt::Write as FmtWrite,
fs::File,
io::{Read, Write},
io::Write,
net::{IpAddr, SocketAddr},
str::FromStr,
sync::Arc,
@ -74,7 +68,6 @@ use std::{
use thiserror::Error;
use url::Url;
const DATA_CHUNK_SIZE: usize = 229; // Keep program chunks under PACKET_DATA_SIZE
pub const DEFAULT_RPC_TIMEOUT_SECONDS: &str = "30";
#[derive(Debug, PartialEq)]
@ -82,9 +75,11 @@ pub const DEFAULT_RPC_TIMEOUT_SECONDS: &str = "30";
pub enum CliCommand {
// Cluster Query Commands
Catchup {
node_pubkey: Pubkey,
node_pubkey: Option<Pubkey>,
node_json_rpc_url: Option<String>,
follow: bool,
our_localhost_port: Option<u16>,
log: bool,
},
ClusterDate,
ClusterVersion,
@ -98,7 +93,7 @@ pub enum CliCommand {
Fees,
FirstAvailableBlock,
GetBlock {
slot: Slot,
slot: Option<Slot>,
},
GetBlockTime {
slot: Option<Slot>,
@ -112,13 +107,20 @@ pub enum CliCommand {
LargestAccounts {
filter: Option<RpcLargestAccountsFilter>,
},
LeaderSchedule,
LeaderSchedule {
epoch: Option<Epoch>,
},
LiveSlots,
Logs {
filter: RpcTransactionLogsFilter,
},
Ping {
lamports: u64,
interval: Duration,
count: Option<u64>,
timeout: Duration,
blockhash: Option<Hash>,
print_timestamp: bool,
},
ShowBlockProduction {
epoch: Option<Epoch>,
@ -143,6 +145,9 @@ pub enum CliCommand {
limit: usize,
show_transactions: bool,
},
WaitForMaxStake {
max_stake_percent: f32,
},
// Nonce commands
AuthorizeNonceAccount {
nonce_account: Pubkey,
@ -175,7 +180,9 @@ pub enum CliCommand {
program_location: String,
address: Option<SignerIndex>,
use_deprecated_loader: bool,
allow_excessive_balance: bool,
},
Program(ProgramCliCommand),
// Stake Commands
CreateStakeAccount {
stake_account: SignerIndex,
@ -458,11 +465,12 @@ impl CliConfig<'_> {
json_rpc_cmd_url: &str,
json_rpc_cfg_url: &str,
) -> (SettingType, String) {
Self::first_nonempty_setting(vec![
let (setting_type, url_or_moniker) = Self::first_nonempty_setting(vec![
(SettingType::Explicit, json_rpc_cmd_url.to_string()),
(SettingType::Explicit, json_rpc_cfg_url.to_string()),
(SettingType::SystemDefault, Self::default_json_rpc_url()),
])
]);
(setting_type, normalize_to_url_if_moniker(&url_or_moniker))
}
pub fn compute_keypair_path_setting(
@ -491,6 +499,7 @@ impl CliConfig<'_> {
config.commitment = CommitmentConfig::recent();
config.send_transaction_config = RpcSendTransactionConfig {
skip_preflight: true,
preflight_commitment: Some(CommitmentConfig::recent().commitment),
..RpcSendTransactionConfig::default()
};
config
@ -566,15 +575,13 @@ pub fn parse_command(
("supply", Some(matches)) => parse_supply(matches),
("total-supply", Some(matches)) => parse_total_supply(matches),
("transaction-count", Some(matches)) => parse_get_transaction_count(matches),
("leader-schedule", Some(_matches)) => Ok(CliCommandInfo {
command: CliCommand::LeaderSchedule,
signers: vec![],
}),
("leader-schedule", Some(matches)) => parse_leader_schedule(matches),
("ping", Some(matches)) => parse_cluster_ping(matches, default_signer, wallet_manager),
("live-slots", Some(_matches)) => Ok(CliCommandInfo {
command: CliCommand::LiveSlots,
signers: vec![],
}),
("logs", Some(matches)) => parse_logs(matches, wallet_manager),
("block-production", Some(matches)) => parse_show_block_production(matches),
("gossip", Some(_matches)) => Ok(CliCommandInfo {
command: CliCommand::ShowGossip,
@ -606,17 +613,27 @@ pub fn parse_command(
signers.push(signer);
1
});
let use_deprecated_loader = matches.is_present("use_deprecated_loader");
Ok(CliCommandInfo {
command: CliCommand::Deploy {
program_location: matches.value_of("program_location").unwrap().to_string(),
address,
use_deprecated_loader,
use_deprecated_loader: matches.is_present("use_deprecated_loader"),
allow_excessive_balance: matches.is_present("allow_excessive_balance"),
},
signers,
})
}
("program", Some(matches)) => {
parse_program_subcommand(matches, default_signer, wallet_manager)
}
("wait-for-max-stake", Some(matches)) => {
let max_stake_percent = value_t_or_exit!(matches, "max_percent", f32);
Ok(CliCommandInfo {
command: CliCommand::WaitForMaxStake { max_stake_percent },
signers: vec![],
})
}
// Stake Commands
("create-stake-account", Some(matches)) => {
parse_stake_create_account(matches, default_signer, wallet_manager)
@ -1017,309 +1034,6 @@ fn process_show_account(
Ok(account_string)
}
fn send_and_confirm_transactions_with_spinner<T: Signers>(
rpc_client: &RpcClient,
mut transactions: Vec<Transaction>,
signer_keys: &T,
commitment: CommitmentConfig,
mut last_valid_slot: Slot,
) -> Result<(), Box<dyn error::Error>> {
let progress_bar = new_spinner_progress_bar();
let mut send_retries = 5;
loop {
let mut status_retries = 15;
// Send all transactions
let mut pending_transactions = HashMap::new();
let num_transactions = transactions.len();
for transaction in transactions {
if cfg!(not(test)) {
// Delay ~1 tick between write transactions in an attempt to reduce AccountInUse errors
// when all the write transactions modify the same program account (eg, deploying a
// new program)
sleep(Duration::from_millis(1000 / DEFAULT_TICKS_PER_SECOND));
}
let _result = rpc_client
.send_transaction_with_config(
&transaction,
RpcSendTransactionConfig {
preflight_commitment: Some(commitment.commitment),
..RpcSendTransactionConfig::default()
},
)
.ok();
pending_transactions.insert(transaction.signatures[0], transaction);
progress_bar.set_message(&format!(
"[{}/{}] Transactions sent",
pending_transactions.len(),
num_transactions
));
}
// Collect statuses for all the transactions, drop those that are confirmed
while status_retries > 0 {
status_retries -= 1;
progress_bar.set_message(&format!(
"[{}/{}] Transactions confirmed",
num_transactions - pending_transactions.len(),
num_transactions
));
let mut statuses = vec![];
let pending_signatures = pending_transactions.keys().cloned().collect::<Vec<_>>();
for pending_signatures_chunk in
pending_signatures.chunks(MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS - 1)
{
statuses.extend(
rpc_client
.get_signature_statuses_with_history(pending_signatures_chunk)?
.value
.into_iter(),
);
}
assert_eq!(statuses.len(), pending_signatures.len());
for (signature, status) in pending_signatures.into_iter().zip(statuses.into_iter()) {
if let Some(status) = status {
if status.confirmations.is_none() || status.confirmations.unwrap() > 1 {
let _ = pending_transactions.remove(&signature);
}
}
}
if pending_transactions.is_empty() {
return Ok(());
}
let slot = rpc_client.get_slot_with_commitment(commitment)?;
if slot > last_valid_slot {
break;
}
if cfg!(not(test)) {
// Retry twice a second
sleep(Duration::from_millis(500));
}
}
if send_retries == 0 {
return Err("Transactions failed".into());
}
send_retries -= 1;
// Re-sign any failed transactions with a new blockhash and retry
let (blockhash, _fee_calculator, new_last_valid_slot) = rpc_client
.get_recent_blockhash_with_commitment(commitment)?
.value;
last_valid_slot = new_last_valid_slot;
transactions = vec![];
for (_, mut transaction) in pending_transactions.into_iter() {
transaction.try_sign(signer_keys, blockhash)?;
transactions.push(transaction);
}
}
}
fn process_deploy(
rpc_client: &RpcClient,
config: &CliConfig,
program_location: &str,
address: Option<SignerIndex>,
use_deprecated_loader: bool,
) -> ProcessResult {
let new_keypair = Keypair::new(); // Create ephemeral keypair to use for program address, if not provided
let program_id = if let Some(i) = address {
config.signers[i]
} else {
&new_keypair
};
let mut file = File::open(program_location).map_err(|err| {
CliError::DynamicProgramError(format!("Unable to open program file: {}", err))
})?;
let mut program_data = Vec::new();
file.read_to_end(&mut program_data).map_err(|err| {
CliError::DynamicProgramError(format!("Unable to read program file: {}", err))
})?;
let loader_id = if use_deprecated_loader {
bpf_loader_deprecated::id()
} else {
bpf_loader::id()
};
let minimum_balance = rpc_client.get_minimum_balance_for_rent_exemption(program_data.len())?;
let signers = [config.signers[0], program_id];
// Check program account to see if partial initialization has occurred
let initial_instructions = if let Some(account) = rpc_client
.get_account_with_commitment(&program_id.pubkey(), config.commitment)?
.value
{
let mut instructions: Vec<Instruction> = vec![];
if account.executable {
return Err(CliError::DynamicProgramError(
"Program account is already executable".to_string(),
)
.into());
}
if account.owner != loader_id && !system_program::check_id(&account.owner) {
return Err(CliError::DynamicProgramError(
"Program account is already owned by another account".to_string(),
)
.into());
}
if account.data.is_empty() && system_program::check_id(&account.owner) {
instructions.push(system_instruction::allocate(
&program_id.pubkey(),
program_data.len() as u64,
));
if account.owner != loader_id {
instructions.push(system_instruction::assign(&program_id.pubkey(), &loader_id));
}
}
if account.lamports < minimum_balance {
instructions.push(system_instruction::transfer(
&config.signers[0].pubkey(),
&program_id.pubkey(),
minimum_balance - account.lamports,
));
}
instructions
} else {
vec![system_instruction::create_account(
&config.signers[0].pubkey(),
&program_id.pubkey(),
minimum_balance,
program_data.len() as u64,
&loader_id,
)]
};
let initial_message = if !initial_instructions.is_empty() {
Some(Message::new(
&initial_instructions,
Some(&config.signers[0].pubkey()),
))
} else {
None
};
// Build transactions to calculate fees
let mut messages: Vec<&Message> = Vec::new();
if let Some(message) = &initial_message {
messages.push(message);
}
let mut write_messages = vec![];
for (chunk, i) in program_data.chunks(DATA_CHUNK_SIZE).zip(0..) {
let instruction = loader_instruction::write(
&program_id.pubkey(),
&loader_id,
(i * DATA_CHUNK_SIZE) as u32,
chunk.to_vec(),
);
let message = Message::new(&[instruction], Some(&signers[0].pubkey()));
write_messages.push(message);
}
let mut write_message_refs = vec![];
for message in write_messages.iter() {
write_message_refs.push(message);
}
messages.append(&mut write_message_refs);
let instruction = loader_instruction::finalize(&program_id.pubkey(), &loader_id);
let finalize_message = Message::new(&[instruction], Some(&signers[0].pubkey()));
messages.push(&finalize_message);
let (blockhash, fee_calculator, _) = rpc_client
.get_recent_blockhash_with_commitment(config.commitment)?
.value;
check_account_for_multiple_fees_with_commitment(
rpc_client,
&config.signers[0].pubkey(),
&fee_calculator,
&messages,
config.commitment,
)?;
if let Some(message) = initial_message {
trace!("Creating or modifying program account");
let num_required_signatures = message.header.num_required_signatures;
let mut initial_transaction = Transaction::new_unsigned(message);
// Most of the initial_transaction combinations require both the fee-payer and new program
// account to sign the transaction. One (transfer) only requires the fee-payer signature.
// This check is to ensure signing does not fail on a KeypairPubkeyMismatch error from an
// extraneous signature.
if num_required_signatures == 2 {
initial_transaction.try_sign(&signers, blockhash)?;
} else {
initial_transaction.try_sign(&[signers[0]], blockhash)?;
}
let result = rpc_client.send_and_confirm_transaction_with_spinner_and_config(
&initial_transaction,
config.commitment,
config.send_transaction_config,
);
log_instruction_custom_error::<SystemError>(result, &config).map_err(|_| {
CliError::DynamicProgramError("Program account allocation failed".to_string())
})?;
}
let (blockhash, _, last_valid_slot) = rpc_client
.get_recent_blockhash_with_commitment(config.commitment)?
.value;
let mut write_transactions = vec![];
for message in write_messages.into_iter() {
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&signers, blockhash)?;
write_transactions.push(tx);
}
trace!("Writing program data");
send_and_confirm_transactions_with_spinner(
&rpc_client,
write_transactions,
&signers,
config.commitment,
last_valid_slot,
)
.map_err(|_| {
CliError::DynamicProgramError("Data writes to program account failed".to_string())
})?;
let (blockhash, _, _) = rpc_client
.get_recent_blockhash_with_commitment(config.commitment)?
.value;
let mut finalize_tx = Transaction::new_unsigned(finalize_message);
finalize_tx.try_sign(&signers, blockhash)?;
trace!("Finalizing program account");
rpc_client
.send_and_confirm_transaction_with_spinner_and_config(
&finalize_tx,
config.commitment,
RpcSendTransactionConfig {
skip_preflight: true,
..RpcSendTransactionConfig::default()
},
)
.map_err(|e| {
CliError::DynamicProgramError(format!("Finalizing program account failed: {}", e))
})?;
Ok(json!({
"programId": format!("{}", program_id.pubkey()),
})
.to_string())
}
#[allow(clippy::too_many_arguments)]
fn process_transfer(
rpc_client: &RpcClient,
@ -1425,7 +1139,17 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
node_pubkey,
node_json_rpc_url,
follow,
} => process_catchup(&rpc_client, config, node_pubkey, node_json_rpc_url, *follow),
our_localhost_port,
log,
} => process_catchup(
&rpc_client,
config,
*node_pubkey,
node_json_rpc_url.clone(),
*follow,
*our_localhost_port,
*log,
),
CliCommand::ClusterDate => process_cluster_date(&rpc_client, config),
CliCommand::ClusterVersion => process_cluster_version(&rpc_client, config),
CliCommand::CreateAddressWithSeed {
@ -1452,14 +1176,26 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
CliCommand::Inflation(inflation_subcommand) => {
process_inflation_subcommand(&rpc_client, config, inflation_subcommand)
}
CliCommand::LeaderSchedule => process_leader_schedule(&rpc_client),
CliCommand::LiveSlots => process_live_slots(&config.websocket_url),
CliCommand::LeaderSchedule { epoch } => process_leader_schedule(&rpc_client, *epoch),
CliCommand::LiveSlots => process_live_slots(&config),
CliCommand::Logs { filter } => process_logs(&config, filter),
CliCommand::Ping {
lamports,
interval,
count,
timeout,
} => process_ping(&rpc_client, config, *lamports, interval, count, timeout),
blockhash,
print_timestamp,
} => process_ping(
&rpc_client,
config,
*lamports,
interval,
count,
timeout,
blockhash,
*print_timestamp,
),
CliCommand::ShowBlockProduction { epoch, slot_limit } => {
process_show_block_production(&rpc_client, config, *epoch, *slot_limit)
}
@ -1473,6 +1209,9 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
*use_lamports_unit,
vote_account_pubkeys.as_deref(),
),
CliCommand::WaitForMaxStake { max_stake_percent } => {
process_wait_for_max_stake(&rpc_client, config, *max_stake_percent)
}
CliCommand::ShowValidators { use_lamports_unit } => {
process_show_validators(&rpc_client, config, *use_lamports_unit)
}
@ -1565,13 +1304,18 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
program_location,
address,
use_deprecated_loader,
allow_excessive_balance,
} => process_deploy(
&rpc_client,
config,
program_location,
*address,
*use_deprecated_loader,
*allow_excessive_balance,
),
CliCommand::Program(program_subcommand) => {
process_program_subcommand(&rpc_client, config, program_subcommand)
}
// Stake Commands
@ -2057,6 +1801,7 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
.feature_subcommands()
.inflation_subcommands()
.nonce_subcommands()
.program_subcommands()
.stake_subcommands()
.subcommand(
SubCommand::with_name("airdrop")
@ -2187,7 +1932,7 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
.arg(
Arg::with_name("address_signer")
.index(2)
.value_name("SIGNER_KEYPAIR")
.value_name("PROGRAM_ADDRESS_SIGNER")
.takes_value(true)
.validator(is_valid_signer)
.help("The signer for the desired address of the program [default: new random address]")
@ -2199,6 +1944,12 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
.hidden(true) // Don't document this argument to discourage its use
.help("Use the deprecated BPF loader")
)
.arg(
Arg::with_name("allow_excessive_balance")
.long("allow-excessive-deploy-account-balance")
.takes_value(false)
.help("Use the designated program id, even if the account already holds a large balance of SOL")
)
.arg(commitment_arg_with_default("max")),
)
.subcommand(
@ -2304,7 +2055,7 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
#[cfg(test)]
mod tests {
use super::*;
use serde_json::Value;
use serde_json::{json, Value};
use solana_client::{
blockhash_query,
mock_sender::SIGNATURE,
@ -2313,7 +2064,7 @@ mod tests {
};
use solana_sdk::{
pubkey::Pubkey,
signature::{keypair_from_seed, read_keypair_file, write_keypair_file, Presigner},
signature::{keypair_from_seed, read_keypair_file, write_keypair_file, Keypair, Presigner},
transaction::TransactionError,
};
use std::path::PathBuf;
@ -2355,7 +2106,10 @@ mod tests {
.unwrap();
assert_eq!(signer_info.signers.len(), 1);
assert_eq!(signer_info.index_of(None), Some(0));
assert_eq!(signer_info.index_of(Some(Pubkey::new_rand())), None);
assert_eq!(
signer_info.index_of(Some(solana_sdk::pubkey::new_rand())),
None
);
let keypair0 = keypair_from_seed(&[1u8; 32]).unwrap();
let keypair0_pubkey = keypair0.pubkey();
@ -2411,7 +2165,7 @@ mod tests {
fn test_cli_parse_command() {
let test_commands = app("test", "desc", "version");
let pubkey = Pubkey::new_rand();
let pubkey = solana_sdk::pubkey::new_rand();
let pubkey_string = format!("{}", pubkey);
let default_keypair = Keypair::new();
@ -2507,7 +2261,7 @@ mod tests {
assert!(parse_command(&test_bad_signature, &default_signer, &mut None).is_err());
// Test CreateAddressWithSeed
let from_pubkey = Some(Pubkey::new_rand());
let from_pubkey = Some(solana_sdk::pubkey::new_rand());
let from_str = from_pubkey.unwrap().to_string();
for (name, program_id) in &[
("STAKE", solana_stake_program::id()),
@ -2564,6 +2318,7 @@ mod tests {
program_location: "/Users/test/program.o".to_string(),
address: None,
use_deprecated_loader: false,
allow_excessive_balance: false,
},
signers: vec![read_keypair_file(&keypair_file).unwrap().into()],
}
@ -2585,6 +2340,7 @@ mod tests {
program_location: "/Users/test/program.o".to_string(),
address: Some(1),
use_deprecated_loader: false,
allow_excessive_balance: false,
},
signers: vec![
read_keypair_file(&keypair_file).unwrap().into(),
@ -2664,7 +2420,7 @@ mod tests {
let result = process_command(&config);
assert!(result.is_ok());
let new_authorized_pubkey = Pubkey::new_rand();
let new_authorized_pubkey = solana_sdk::pubkey::new_rand();
config.signers = vec![&bob_keypair];
config.command = CliCommand::VoteAuthorize {
vote_account_pubkey: bob_pubkey,
@ -2686,7 +2442,7 @@ mod tests {
let bob_keypair = Keypair::new();
let bob_pubkey = bob_keypair.pubkey();
let custodian = Pubkey::new_rand();
let custodian = solana_sdk::pubkey::new_rand();
config.command = CliCommand::CreateStakeAccount {
stake_account: 1,
seed: None,
@ -2709,8 +2465,8 @@ mod tests {
let result = process_command(&config);
assert!(result.is_ok());
let stake_account_pubkey = Pubkey::new_rand();
let to_pubkey = Pubkey::new_rand();
let stake_account_pubkey = solana_sdk::pubkey::new_rand();
let to_pubkey = solana_sdk::pubkey::new_rand();
config.command = CliCommand::WithdrawStake {
stake_account_pubkey,
destination_account_pubkey: to_pubkey,
@ -2727,7 +2483,7 @@ mod tests {
let result = process_command(&config);
assert!(result.is_ok());
let stake_account_pubkey = Pubkey::new_rand();
let stake_account_pubkey = solana_sdk::pubkey::new_rand();
config.command = CliCommand::DeactivateStake {
stake_account_pubkey,
stake_authority: 0,
@ -2740,7 +2496,7 @@ mod tests {
let result = process_command(&config);
assert!(result.is_ok());
let stake_account_pubkey = Pubkey::new_rand();
let stake_account_pubkey = solana_sdk::pubkey::new_rand();
let split_stake_account = Keypair::new();
config.command = CliCommand::SplitStake {
stake_account_pubkey,
@ -2758,8 +2514,8 @@ mod tests {
let result = process_command(&config);
assert!(result.is_ok());
let stake_account_pubkey = Pubkey::new_rand();
let source_stake_account_pubkey = Pubkey::new_rand();
let stake_account_pubkey = solana_sdk::pubkey::new_rand();
let source_stake_account_pubkey = solana_sdk::pubkey::new_rand();
let merge_stake_account = Keypair::new();
config.command = CliCommand::MergeStake {
stake_account_pubkey,
@ -2782,7 +2538,7 @@ mod tests {
assert_eq!(process_command(&config).unwrap(), "1234");
// CreateAddressWithSeed
let from_pubkey = Pubkey::new_rand();
let from_pubkey = solana_sdk::pubkey::new_rand();
config.signers = vec![];
config.command = CliCommand::CreateAddressWithSeed {
from_pubkey: Some(from_pubkey),
@ -2795,7 +2551,7 @@ mod tests {
assert_eq!(address.unwrap(), expected_address.to_string());
// Need airdrop cases
let to = Pubkey::new_rand();
let to = solana_sdk::pubkey::new_rand();
config.signers = vec![&keypair];
config.command = CliCommand::Airdrop {
faucet_host: None,
@ -2898,6 +2654,7 @@ mod tests {
program_location: pathbuf.to_str().unwrap().to_string(),
address: None,
use_deprecated_loader: false,
allow_excessive_balance: false,
};
let result = process_command(&config);
let json: Value = serde_json::from_str(&result.unwrap()).unwrap();
@ -2916,6 +2673,7 @@ mod tests {
program_location: "bad/file/location.so".to_string(),
address: None,
use_deprecated_loader: false,
allow_excessive_balance: false,
};
assert!(process_command(&config).is_err());
}

View File

@ -1,12 +1,17 @@
use crate::{
cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult},
spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
stake::is_stake_program_v2_enabled,
};
use chrono::{Local, TimeZone};
use clap::{value_t, value_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand};
use console::{style, Emoji};
use solana_clap_utils::{
commitment::commitment_arg, input_parsers::*, input_validators::*, keypair::DefaultSigner,
commitment::{commitment_arg, commitment_arg_with_default},
input_parsers::*,
input_validators::*,
keypair::DefaultSigner,
offline::{blockhash_arg, BLOCKHASH_ARG},
};
use solana_cli_output::{
display::{
@ -20,26 +25,28 @@ use solana_client::{
rpc_client::{GetConfirmedSignaturesForAddress2Config, RpcClient},
rpc_config::{
RpcAccountInfoConfig, RpcLargestAccountsConfig, RpcLargestAccountsFilter,
RpcProgramAccountsConfig,
RpcProgramAccountsConfig, RpcTransactionLogsConfig, RpcTransactionLogsFilter,
},
rpc_filter,
rpc_response::SlotInfo,
};
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use solana_sdk::{
account::from_account,
account_utils::StateMut,
clock::{self, Clock, Slot},
commitment_config::CommitmentConfig,
epoch_schedule::Epoch,
hash::Hash,
message::Message,
native_token::lamports_to_sol,
pubkey::{self, Pubkey},
rpc_port::DEFAULT_RPC_PORT_STR,
signature::Signature,
system_instruction, system_program,
sysvar::{
self,
stake_history::{self, StakeHistory},
Sysvar,
stake_history::{self},
},
transaction::Transaction,
};
@ -52,7 +59,7 @@ use std::{
Arc,
},
thread::sleep,
time::{Duration, Instant},
time::{Duration, Instant, SystemTime, UNIX_EPOCH},
};
static CHECK_MARK: Emoji = Emoji("", "");
@ -73,8 +80,7 @@ impl ClusterQuerySubCommands for App<'_, '_> {
.validator(is_slot)
.value_name("SLOT")
.takes_value(true)
.index(1)
.required(true),
.index(1),
),
)
.subcommand(
@ -83,14 +89,14 @@ impl ClusterQuerySubCommands for App<'_, '_> {
.arg(
pubkey!(Arg::with_name("node_pubkey")
.index(1)
.value_name("VALIDATOR_PUBKEY")
.required(true),
.value_name("OUR_VALIDATOR_PUBKEY")
.required(false),
"Identity pubkey of the validator"),
)
.arg(
Arg::with_name("node_json_rpc_url")
.index(2)
.value_name("URL")
.value_name("OUR_URL")
.takes_value(true)
.validator(is_url)
.help("JSON RPC URL for validator, which is useful for validators with a private RPC service")
@ -101,6 +107,21 @@ impl ClusterQuerySubCommands for App<'_, '_> {
.takes_value(false)
.help("Continue reporting progress even after the validator has caught up"),
)
.arg(
Arg::with_name("our_localhost")
.long("our-localhost")
.takes_value(false)
.value_name("PORT")
.default_value(&DEFAULT_RPC_PORT_STR)
.validator(is_port)
.help("Guess Identity pubkey and validator rpc node assuming local (possibly private) validator"),
)
.arg(
Arg::with_name("log")
.long("log")
.takes_value(false)
.help("Don't update the progress inplace; instead show updates with its own new lines"),
)
.arg(commitment_arg()),
)
.subcommand(
@ -127,7 +148,17 @@ impl ClusterQuerySubCommands for App<'_, '_> {
.help("Slot number of the block to query")
)
)
.subcommand(SubCommand::with_name("leader-schedule").about("Display leader schedule"))
.subcommand(SubCommand::with_name("leader-schedule")
.about("Display leader schedule")
.arg(
Arg::with_name("epoch")
.long("epoch")
.takes_value(true)
.value_name("EPOCH")
.validator(is_epoch)
.help("Epoch to show leader schedule for. (default: current)")
)
)
.subcommand(
SubCommand::with_name("epoch-info")
.about("Get information about the current epoch")
@ -209,6 +240,13 @@ impl ClusterQuerySubCommands for App<'_, '_> {
.takes_value(true)
.help("Stop after submitting count transactions"),
)
.arg(
Arg::with_name("print_timestamp")
.short("D")
.long("print-timestamp")
.takes_value(false)
.help("Print timestamp (unix time + microseconds as in gettimeofday) before each line"),
)
.arg(
Arg::with_name("lamports")
.long("lamports")
@ -227,12 +265,33 @@ impl ClusterQuerySubCommands for App<'_, '_> {
.default_value("15")
.help("Wait up to timeout seconds for transaction confirmation"),
)
.arg(blockhash_arg())
.arg(commitment_arg()),
)
.subcommand(
SubCommand::with_name("live-slots")
.about("Show information about the current slot progression"),
)
.subcommand(
SubCommand::with_name("logs")
.about("Stream transaction logs")
.arg(
pubkey!(Arg::with_name("address")
.index(1)
.value_name("ADDRESS"),
"Account address to monitor \
[default: monitor all transactions except for votes] \
")
)
.arg(
Arg::with_name("include_votes")
.long("include-votes")
.takes_value(false)
.conflicts_with("address")
.help("Include vote transactions when monitoring all transactions")
)
.arg(commitment_arg_with_default("singleGossip")),
)
.subcommand(
SubCommand::with_name("block-production")
.about("Show information about block production")
@ -318,6 +377,17 @@ impl ClusterQuerySubCommands for App<'_, '_> {
.help("Display the full transactions"),
)
)
.subcommand(
SubCommand::with_name("wait-for-max-stake")
.about("Wait for the max stake of any one node to drop below a percentage of total.")
.arg(
Arg::with_name("max_percent")
.long("max-percent")
.value_name("PERCENT")
.takes_value(true)
.index(1),
),
)
}
}
@ -325,14 +395,31 @@ pub fn parse_catchup(
matches: &ArgMatches<'_>,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> {
let node_pubkey = pubkey_of_signer(matches, "node_pubkey", wallet_manager)?.unwrap();
let node_pubkey = pubkey_of_signer(matches, "node_pubkey", wallet_manager)?;
let mut our_localhost_port = value_t!(matches, "our_localhost", u16).ok();
// if there is no explicitly specified --our-localhost,
// disable the guess mode (= our_localhost_port)
if matches.occurrences_of("our_localhost") == 0 {
our_localhost_port = None
}
let node_json_rpc_url = value_t!(matches, "node_json_rpc_url", String).ok();
// requirement of node_pubkey is relaxed only if our_localhost_port
if our_localhost_port.is_none() && node_pubkey.is_none() {
return Err(CliError::BadParameter(
"OUR_VALIDATOR_PUBKEY (and possibly OUR_URL) must be specified \
unless --our-localhost is given"
.into(),
));
}
let follow = matches.is_present("follow");
let log = matches.is_present("log");
Ok(CliCommandInfo {
command: CliCommand::Catchup {
node_pubkey,
node_json_rpc_url,
follow,
our_localhost_port,
log,
},
signers: vec![],
})
@ -351,19 +438,23 @@ pub fn parse_cluster_ping(
None
};
let timeout = Duration::from_secs(value_t_or_exit!(matches, "timeout", u64));
let blockhash = value_of(matches, BLOCKHASH_ARG.name);
let print_timestamp = matches.is_present("print_timestamp");
Ok(CliCommandInfo {
command: CliCommand::Ping {
lamports,
interval,
count,
timeout,
blockhash,
print_timestamp,
},
signers: vec![default_signer.signer_from_path(matches, wallet_manager)?],
})
}
pub fn parse_get_block(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
let slot = value_t_or_exit!(matches, "slot", Slot);
let slot = value_of(matches, "slot");
Ok(CliCommandInfo {
command: CliCommand::GetBlock { slot },
signers: vec![],
@ -508,38 +599,76 @@ pub fn parse_transaction_history(
pub fn process_catchup(
rpc_client: &RpcClient,
config: &CliConfig,
node_pubkey: &Pubkey,
node_json_rpc_url: &Option<String>,
node_pubkey: Option<Pubkey>,
mut node_json_rpc_url: Option<String>,
follow: bool,
our_localhost_port: Option<u16>,
log: bool,
) -> ProcessResult {
let sleep_interval = 5;
let progress_bar = new_spinner_progress_bar();
progress_bar.set_message("Connecting...");
let node_client = if let Some(node_json_rpc_url) = node_json_rpc_url {
RpcClient::new(node_json_rpc_url.to_string())
} else {
let rpc_addr = loop {
let cluster_nodes = rpc_client.get_cluster_nodes()?;
if let Some(contact_info) = cluster_nodes
.iter()
.find(|contact_info| contact_info.pubkey == node_pubkey.to_string())
{
if let Some(rpc_addr) = contact_info.rpc {
break rpc_addr;
}
progress_bar.set_message(&format!("RPC service not found for {}", node_pubkey));
} else {
progress_bar.set_message(&format!(
"Contact information not found for {}",
node_pubkey
));
}
sleep(Duration::from_secs(sleep_interval as u64));
};
if let Some(our_localhost_port) = our_localhost_port {
let gussed_default = Some(format!("http://localhost:{}", our_localhost_port));
if node_json_rpc_url.is_some() && node_json_rpc_url != gussed_default {
// go to new line to leave this message on console
println!(
"Prefering explicitly given rpc ({}) as us, \
although --our-localhost is given\n",
node_json_rpc_url.as_ref().unwrap()
);
} else {
node_json_rpc_url = gussed_default;
}
}
RpcClient::new_socket(rpc_addr)
let (node_client, node_pubkey) = if our_localhost_port.is_some() {
let client = RpcClient::new(node_json_rpc_url.unwrap());
let guessed_default = Some(client.get_identity()?);
(
client,
(if node_pubkey.is_some() && node_pubkey != guessed_default {
// go to new line to leave this message on console
println!(
"Prefering explicitly given node pubkey ({}) as us, \
although --our-localhost is given\n",
node_pubkey.unwrap()
);
node_pubkey
} else {
guessed_default
})
.unwrap(),
)
} else if let Some(node_pubkey) = node_pubkey {
if let Some(node_json_rpc_url) = node_json_rpc_url {
(RpcClient::new(node_json_rpc_url), node_pubkey)
} else {
let rpc_addr = loop {
let cluster_nodes = rpc_client.get_cluster_nodes()?;
if let Some(contact_info) = cluster_nodes
.iter()
.find(|contact_info| contact_info.pubkey == node_pubkey.to_string())
{
if let Some(rpc_addr) = contact_info.rpc {
break rpc_addr;
}
progress_bar.set_message(&format!("RPC service not found for {}", node_pubkey));
} else {
progress_bar.set_message(&format!(
"Contact information not found for {}",
node_pubkey
));
}
sleep(Duration::from_secs(sleep_interval as u64));
};
(RpcClient::new_socket(rpc_addr), node_pubkey)
}
} else {
unreachable!()
};
let reported_node_pubkey = loop {
@ -556,7 +685,7 @@ pub fn process_catchup(
}
};
if reported_node_pubkey != *node_pubkey {
if reported_node_pubkey != node_pubkey {
return Err(format!(
"The identity reported by node RPC URL does not match. Expected: {:?}. Reported: {:?}",
node_pubkey, reported_node_pubkey
@ -564,15 +693,41 @@ pub fn process_catchup(
.into());
}
if rpc_client.get_identity()? == *node_pubkey {
if rpc_client.get_identity()? == node_pubkey {
return Err("Both RPC URLs reference the same node, unable to monitor for catchup. Try a different --url".into());
}
let mut previous_rpc_slot = std::u64::MAX;
let mut previous_slot_distance = 0;
let mut retry_count = 0;
let max_retry_count = 5;
let mut get_slot_while_retrying = |client: &RpcClient| {
loop {
match client.get_slot_with_commitment(config.commitment) {
Ok(r) => {
retry_count = 0;
return Ok(r);
}
Err(e) => {
if retry_count >= max_retry_count {
return Err(e);
}
retry_count += 1;
if log {
// go to new line to leave this message on console
println!("Retrying({}/{}): {}\n", retry_count, max_retry_count, e);
}
sleep(Duration::from_secs(1));
}
};
}
};
loop {
let rpc_slot = rpc_client.get_slot_with_commitment(config.commitment)?;
let node_slot = node_client.get_slot_with_commitment(config.commitment)?;
// humbly retry; the reference node (rpc_client) could be spotty,
// especially if pointing to api.meinnet-beta.solana.com at times
let rpc_slot = get_slot_while_retrying(rpc_client)?;
let node_slot = get_slot_while_retrying(&node_client)?;
if !follow && node_slot > std::cmp::min(previous_rpc_slot, rpc_slot) {
progress_bar.finish_and_clear();
return Ok(format!(
@ -595,15 +750,21 @@ pub fn process_catchup(
};
progress_bar.set_message(&format!(
"{} slots behind (us:{} them:{}){}",
slot_distance,
"{} slot(s) {} (us:{} them:{}){}",
slot_distance.abs(),
if slot_distance >= 0 {
"behind"
} else {
"ahead"
},
node_slot,
rpc_slot,
if slot_distance == 0 || previous_rpc_slot == std::u64::MAX {
"".to_string()
} else {
format!(
", {} at {:.1} slots/second{}",
", {} node is {} at {:.1} slots/second{}",
if slot_distance >= 0 { "our" } else { "their" },
if slots_per_second < 0.0 {
"falling behind"
} else {
@ -612,8 +773,11 @@ pub fn process_catchup(
slots_per_second,
time_remaining
)
}
},
));
if log {
println!();
}
sleep(Duration::from_secs(sleep_interval as u64));
previous_rpc_slot = rpc_slot;
@ -625,7 +789,7 @@ pub fn process_cluster_date(rpc_client: &RpcClient, config: &CliConfig) -> Proce
let result = rpc_client
.get_account_with_commitment(&sysvar::clock::id(), CommitmentConfig::default())?;
if let Some(clock_account) = result.value {
let clock: Clock = Sysvar::from_account(&clock_account).ok_or_else(|| {
let clock: Clock = from_account(&clock_account).ok_or_else(|| {
CliError::RpcRequestError("Failed to deserialize clock sysvar".to_string())
})?;
let block_time = CliBlockTime {
@ -665,9 +829,23 @@ pub fn process_first_available_block(rpc_client: &RpcClient) -> ProcessResult {
Ok(format!("{}", first_available_block))
}
pub fn process_leader_schedule(rpc_client: &RpcClient) -> ProcessResult {
pub fn parse_leader_schedule(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
let epoch = value_of(matches, "epoch");
Ok(CliCommandInfo {
command: CliCommand::LeaderSchedule { epoch },
signers: vec![],
})
}
pub fn process_leader_schedule(rpc_client: &RpcClient, epoch: Option<Epoch>) -> ProcessResult {
let epoch_info = rpc_client.get_epoch_info()?;
let first_slot_in_epoch = epoch_info.absolute_slot - epoch_info.slot_index;
let epoch = epoch.unwrap_or(epoch_info.epoch);
if epoch > epoch_info.epoch {
return Err(format!("Epoch {} is in the future", epoch).into());
}
let epoch_schedule = rpc_client.get_epoch_schedule()?;
let first_slot_in_epoch = epoch_schedule.get_first_slot_in_epoch(epoch);
let leader_schedule = rpc_client.get_leader_schedule(Some(first_slot_in_epoch))?;
if leader_schedule.is_none() {
@ -700,7 +878,17 @@ pub fn process_leader_schedule(rpc_client: &RpcClient) -> ProcessResult {
Ok("".to_string())
}
pub fn process_get_block(rpc_client: &RpcClient, _config: &CliConfig, slot: Slot) -> ProcessResult {
pub fn process_get_block(
rpc_client: &RpcClient,
_config: &CliConfig,
slot: Option<Slot>,
) -> ProcessResult {
let slot = if let Some(slot) = slot {
slot
} else {
rpc_client.get_slot()?
};
let mut block =
rpc_client.get_confirmed_block_with_encoding(slot, UiTransactionEncoding::Base64)?;
@ -716,18 +904,23 @@ pub fn process_get_block(rpc_client: &RpcClient, _config: &CliConfig, slot: Slot
let mut total_rewards = 0;
println!("Rewards:",);
println!(
" {:<44} {:<15} {:<13} {:>14}",
"Address", "Amount", "New Balance", "Percent Change"
" {:<44} {:^15} {:<15} {:<20} {:>14}",
"Address", "Type", "Amount", "New Balance", "Percent Change"
);
for reward in block.rewards {
let sign = if reward.lamports < 0 { "-" } else { "" };
total_rewards += reward.lamports;
println!(
" {:<44} {:>15} {}",
" {:<44} {:^15} {:>15} {}",
reward.pubkey,
if let Some(reward_type) = reward.reward_type {
format!("{}", reward_type)
} else {
"-".to_string()
},
format!(
"{}{:<14.4}",
"{}{:<14.9}",
sign,
lamports_to_sol(reward.lamports.abs() as u64)
),
@ -735,10 +928,11 @@ pub fn process_get_block(rpc_client: &RpcClient, _config: &CliConfig, slot: Slot
" - -".to_string()
} else {
format!(
"{:<12.4} {:>13.4}%",
"{:<19.9} {:>13.9}%",
lamports_to_sol(reward.post_balance),
reward.lamports.abs() as f64
/ (reward.post_balance as f64 - reward.lamports as f64)
(reward.lamports.abs() as f64
/ (reward.post_balance as f64 - reward.lamports as f64))
* 100.0
)
}
);
@ -746,7 +940,7 @@ pub fn process_get_block(rpc_client: &RpcClient, _config: &CliConfig, slot: Slot
let sign = if total_rewards < 0 { "-" } else { "" };
println!(
"Total Rewards: {}{:12.9}",
"Total Rewards: {}{:<12.9}",
sign,
lamports_to_sol(total_rewards.abs() as u64)
);
@ -823,7 +1017,7 @@ pub fn process_show_block_production(
slot_limit: Option<u64>,
) -> ProcessResult {
let epoch_schedule = rpc_client.get_epoch_schedule()?;
let epoch_info = rpc_client.get_epoch_info_with_commitment(CommitmentConfig::root())?;
let epoch_info = rpc_client.get_epoch_info_with_commitment(CommitmentConfig::max())?;
let epoch = epoch.unwrap_or(epoch_info.epoch);
if epoch > epoch_info.epoch {
@ -1011,6 +1205,8 @@ pub fn process_ping(
interval: &Duration,
count: &Option<u64>,
timeout: &Duration,
fixed_blockhash: &Option<Hash>,
print_timestamp: bool,
) -> ProcessResult {
println_name_value("Source Account:", &config.signers[0].pubkey().to_string());
println!();
@ -1028,9 +1224,21 @@ pub fn process_ping(
let (mut blockhash, mut fee_calculator) = rpc_client.get_recent_blockhash()?;
let mut blockhash_transaction_count = 0;
let mut blockhash_acquired = Instant::now();
if let Some(fixed_blockhash) = fixed_blockhash {
let blockhash_origin = if *fixed_blockhash != Hash::default() {
blockhash = *fixed_blockhash;
"supplied from cli arguments"
} else {
"fetched from cluster"
};
println!(
"Fixed blockhash is used: {} ({})",
blockhash, blockhash_origin
);
}
'mainloop: for seq in 0..count.unwrap_or(std::u64::MAX) {
let now = Instant::now();
if now.duration_since(blockhash_acquired).as_secs() > 60 {
if fixed_blockhash.is_none() && now.duration_since(blockhash_acquired).as_secs() > 60 {
// Fetch a new blockhash every minute
let (new_blockhash, new_fee_calculator) = rpc_client.get_new_blockhash(&blockhash)?;
blockhash = new_blockhash;
@ -1061,6 +1269,18 @@ pub fn process_ping(
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, blockhash)?;
let timestamp = || {
let micros = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_micros();
if print_timestamp {
format!("[{}.{:06}] ", micros / 1_000_000, micros % 1_000_000)
} else {
format!("")
}
};
match rpc_client.send_transaction(&tx) {
Ok(signature) => {
let transaction_sent = Instant::now();
@ -1074,15 +1294,20 @@ pub fn process_ping(
let elapsed_time_millis = elapsed_time.as_millis() as u64;
confirmation_time.push_back(elapsed_time_millis);
println!(
"{}{} lamport(s) transferred: seq={:<3} time={:>4}ms signature={}",
"{}{}{} lamport(s) transferred: seq={:<3} time={:>4}ms signature={}",
timestamp(),
CHECK_MARK, lamports, seq, elapsed_time_millis, signature
);
confirmed_count += 1;
}
Err(err) => {
println!(
"{}Transaction failed: seq={:<3} error={:?} signature={}",
CROSS_MARK, seq, err, signature
"{}{}Transaction failed: seq={:<3} error={:?} signature={}",
timestamp(),
CROSS_MARK,
seq,
err,
signature
);
}
}
@ -1091,8 +1316,11 @@ pub fn process_ping(
if elapsed_time >= *timeout {
println!(
"{}Confirmation timeout: seq={:<3} signature={}",
CROSS_MARK, seq, signature
"{}{}Confirmation timeout: seq={:<3} signature={}",
timestamp(),
CROSS_MARK,
seq,
signature
);
break;
}
@ -1110,8 +1338,11 @@ pub fn process_ping(
}
Err(err) => {
println!(
"{}Submit failed: seq={:<3} error={:?}",
CROSS_MARK, seq, err
"{}{}Submit failed: seq={:<3} error={:?}",
timestamp(),
CROSS_MARK,
seq,
err
);
}
}
@ -1146,24 +1377,83 @@ pub fn process_ping(
Ok("".to_string())
}
pub fn process_live_slots(url: &str) -> ProcessResult {
let exit = Arc::new(AtomicBool::new(false));
pub fn parse_logs(
matches: &ArgMatches<'_>,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> {
let address = pubkey_of_signer(matches, "address", wallet_manager)?;
let include_votes = matches.is_present("include_votes");
// Disable Ctrl+C handler as sometimes the PubsubClient shutdown can stall. Also it doesn't
// really matter that the shutdown is clean because the process is terminating.
/*
let exit_clone = exit.clone();
ctrlc::set_handler(move || {
exit_clone.store(true, Ordering::Relaxed);
})?;
*/
let filter = match address {
None => {
if include_votes {
RpcTransactionLogsFilter::AllWithVotes
} else {
RpcTransactionLogsFilter::All
}
}
Some(address) => RpcTransactionLogsFilter::Mentions(vec![address.to_string()]),
};
Ok(CliCommandInfo {
command: CliCommand::Logs { filter },
signers: vec![],
})
}
pub fn process_logs(config: &CliConfig, filter: &RpcTransactionLogsFilter) -> ProcessResult {
println!(
"Streaming transaction logs{}. {:?} commitment",
match filter {
RpcTransactionLogsFilter::All => "".into(),
RpcTransactionLogsFilter::AllWithVotes => " (including votes)".into(),
RpcTransactionLogsFilter::Mentions(addresses) =>
format!(" mentioning {}", addresses.join(",")),
},
config.commitment.commitment
);
let (_client, receiver) = PubsubClient::logs_subscribe(
&config.websocket_url,
filter.clone(),
RpcTransactionLogsConfig {
commitment: Some(config.commitment),
},
)?;
loop {
match receiver.recv() {
Ok(logs) => {
println!("Transaction executed in slot {}:", logs.context.slot);
println!(" Signature: {}", logs.value.signature);
println!(
" Status: {}",
logs.value
.err
.map(|err| err.to_string())
.unwrap_or_else(|| "Ok".to_string())
);
println!(" Log Messages:");
for log in logs.value.logs {
println!(" {}", log);
}
}
Err(err) => {
return Ok(format!("Disconnected: {}", err));
}
}
}
}
pub fn process_live_slots(config: &CliConfig) -> ProcessResult {
let exit = Arc::new(AtomicBool::new(false));
let mut current: Option<SlotInfo> = None;
let mut message = "".to_string();
let slot_progress = new_spinner_progress_bar();
slot_progress.set_message("Connecting...");
let (mut client, receiver) = PubsubClient::slot_subscribe(url)?;
let (mut client, receiver) = PubsubClient::slot_subscribe(&config.websocket_url)?;
slot_progress.set_message("Connected.");
let spacer = "|";
@ -1253,14 +1543,16 @@ pub fn process_show_gossip(rpc_client: &RpcClient, config: &CliConfig) -> Proces
.into_iter()
.map(|node| {
format!(
"{:15} | {:44} | {:6} | {:5} | {:5} | {}",
"{:15} | {:44} | {:6} | {:5} | {:21} | {}",
node.gossip
.map(|addr| addr.ip().to_string())
.unwrap_or_else(|| "none".to_string()),
format_labeled_address(&node.pubkey, &config.address_labels),
format_port(node.gossip),
format_port(node.tpu),
format_port(node.rpc),
node.rpc
.map(|addr| addr.to_string())
.unwrap_or_else(|| "none".to_string()),
node.version.unwrap_or_else(|| "unknown".to_string()),
)
})
@ -1268,9 +1560,9 @@ pub fn process_show_gossip(rpc_client: &RpcClient, config: &CliConfig) -> Proces
Ok(format!(
"IP Address | Node identifier \
| Gossip | TPU | RPC | Version\n\
| Gossip | TPU | RPC Address | Version\n\
----------------+----------------------------------------------+\
--------+-------+-------+----------------\n\
--------+-------+-----------------------+----------------\n\
{}\n\
Nodes: {}",
s.join("\n"),
@ -1325,14 +1617,16 @@ pub fn process_show_stakes(
.get_program_accounts_with_config(&solana_stake_program::id(), program_accounts_config)?;
let stake_history_account = rpc_client.get_account(&stake_history::id())?;
let clock_account = rpc_client.get_account(&sysvar::clock::id())?;
let clock: Clock = Sysvar::from_account(&clock_account).ok_or_else(|| {
let clock: Clock = from_account(&clock_account).ok_or_else(|| {
CliError::RpcRequestError("Failed to deserialize clock sysvar".to_string())
})?;
progress_bar.finish_and_clear();
let stake_history = StakeHistory::from_account(&stake_history_account).ok_or_else(|| {
let stake_history = from_account(&stake_history_account).ok_or_else(|| {
CliError::RpcRequestError("Failed to deserialize stake history".to_string())
})?;
// At v1.6, this check can be removed and simply passed as `true`
let stake_program_v2_enabled = is_stake_program_v2_enabled(rpc_client);
let mut stake_accounts: Vec<CliKeyedStakeState> = vec![];
for (stake_pubkey, stake_account) in all_stake_accounts {
@ -1348,6 +1642,7 @@ pub fn process_show_stakes(
use_lamports_unit,
&stake_history,
&clock,
stake_program_v2_enabled,
),
});
}
@ -1366,6 +1661,7 @@ pub fn process_show_stakes(
use_lamports_unit,
&stake_history,
&clock,
stake_program_v2_enabled,
),
});
}
@ -1379,6 +1675,16 @@ pub fn process_show_stakes(
.formatted_string(&CliStakeVec::new(stake_accounts)))
}
pub fn process_wait_for_max_stake(
rpc_client: &RpcClient,
config: &CliConfig,
max_stake_percent: f32,
) -> ProcessResult {
let now = std::time::Instant::now();
rpc_client.wait_for_max_stake(config.commitment, max_stake_percent)?;
Ok(format!("Done waiting, took: {}s", now.elapsed().as_secs()))
}
pub fn process_show_validators(
rpc_client: &RpcClient,
config: &CliConfig,
@ -1405,12 +1711,12 @@ pub fn process_show_validators(
.map(|vote_account| vote_account.activated_stake)
.sum();
let total_deliquent_stake = vote_accounts
let total_delinquent_stake = vote_accounts
.delinquent
.iter()
.map(|vote_account| vote_account.activated_stake)
.sum();
let total_current_stake = total_active_stake - total_deliquent_stake;
let total_current_stake = total_active_stake - total_delinquent_stake;
let mut current = vote_accounts.current;
current.sort_by(|a, b| b.activated_stake.cmp(&a.activated_stake));
@ -1464,7 +1770,7 @@ pub fn process_show_validators(
let cli_validators = CliValidators {
total_active_stake,
total_current_stake,
total_deliquent_stake,
total_delinquent_stake,
current_validators,
delinquent_validators,
stake_by_version,
@ -1539,6 +1845,7 @@ mod tests {
use super::*;
use crate::cli::{app, parse_command};
use solana_sdk::signature::{write_keypair, Keypair};
use std::str::FromStr;
use tempfile::NamedTempFile;
fn make_tmp_file() -> (String, NamedTempFile) {
@ -1674,8 +1981,11 @@ mod tests {
"2",
"-t",
"3",
"-D",
"--commitment",
"max",
"--blockhash",
"4CCNp28j6AhGq7PkjPDP4wbQWBS8LLbQin2xV5n8frKX",
]);
assert_eq!(
parse_command(&test_ping, &default_signer, &mut None).unwrap(),
@ -1685,6 +1995,10 @@ mod tests {
interval: Duration::from_secs(1),
count: Some(2),
timeout: Duration::from_secs(3),
blockhash: Some(
Hash::from_str("4CCNp28j6AhGq7PkjPDP4wbQWBS8LLbQin2xV5n8frKX").unwrap()
),
print_timestamp: true,
},
signers: vec![default_keypair.into()],
}

View File

@ -9,12 +9,13 @@ use solana_clap_utils::{input_parsers::*, input_validators::*, keypair::*};
use solana_cli_output::{QuietDisplay, VerboseDisplay};
use solana_client::{client_error::ClientError, rpc_client::RpcClient};
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use solana_runtime::{
use solana_sdk::{
clock::Slot,
feature::{self, Feature},
feature_set::FEATURE_NAMES,
};
use solana_sdk::{
clock::Slot, message::Message, pubkey::Pubkey, system_instruction, transaction::Transaction,
message::Message,
pubkey::Pubkey,
transaction::Transaction,
};
use std::{collections::HashMap, fmt, sync::Arc};
@ -230,7 +231,7 @@ fn active_stake_by_feature_set(rpc_client: &RpcClient) -> Result<HashMap<u32, u6
}
// Feature activation is only allowed when 95% of the active stake is on the current feature set
fn feature_activation_allowed(rpc_client: &RpcClient) -> Result<bool, ClientError> {
fn feature_activation_allowed(rpc_client: &RpcClient, quiet: bool) -> Result<bool, ClientError> {
let my_feature_set = solana_version::Version::default().feature_set;
let active_stake_by_feature_set = active_stake_by_feature_set(rpc_client)?;
@ -240,8 +241,23 @@ fn feature_activation_allowed(rpc_client: &RpcClient) -> Result<bool, ClientErro
.map(|percentage| *percentage >= 95)
.unwrap_or(false);
if !feature_activation_allowed {
println!("\n{}", style("Stake By Feature Set:").bold());
if !feature_activation_allowed && !quiet {
if active_stake_by_feature_set.get(&my_feature_set).is_none() {
println!(
"{}",
style("To activate features the tool and cluster feature sets must match, select a tool version that matches the cluster")
.bold());
} else {
println!(
"{}",
style("To activate features the stake must be >= 95%").bold()
);
}
println!(
"{}",
style(format!("Tool Feture Set: {}", my_feature_set)).bold()
);
println!("{}", style("Cluster Feature Sets and Stakes:").bold());
for (feature_set, percentage) in active_stake_by_feature_set.iter() {
if *feature_set == 0 {
println!("unknown - {}%", percentage);
@ -258,6 +274,7 @@ fn feature_activation_allowed(rpc_client: &RpcClient) -> Result<bool, ClientErro
);
}
}
println!();
}
Ok(feature_activation_allowed)
@ -278,7 +295,7 @@ fn process_status(
let feature_id = &feature_ids[i];
let feature_name = FEATURE_NAMES.get(feature_id).unwrap();
if let Some(account) = account {
if let Some(feature) = Feature::from_account(&account) {
if let Some(feature) = feature::from_account(&account) {
let feature_status = match feature.activated_at {
None => CliFeatureStatus::Pending,
Some(activation_slot) => CliFeatureStatus::Active(activation_slot),
@ -299,9 +316,10 @@ fn process_status(
});
}
let feature_activation_allowed = feature_activation_allowed(rpc_client, features.len() <= 1)?;
let feature_set = CliFeatures {
features,
feature_activation_allowed: feature_activation_allowed(rpc_client)?,
feature_activation_allowed,
inactive,
};
Ok(config.output_format.formatted_string(&feature_set))
@ -318,12 +336,12 @@ fn process_activate(
.next()
.unwrap();
if let Some(account) = account {
if Feature::from_account(&account).is_some() {
if feature::from_account(&account).is_some() {
return Err(format!("{} has already been activated", feature_id).into());
}
}
if !feature_activation_allowed(rpc_client)? {
if !feature_activation_allowed(rpc_client, false)? {
return Err("Feature activation is not allowed at this time".into());
}
@ -338,15 +356,11 @@ fn process_activate(
&config.signers[0].pubkey(),
|lamports| {
Message::new(
&[
system_instruction::transfer(
&config.signers[0].pubkey(),
&feature_id,
lamports,
),
system_instruction::allocate(&feature_id, Feature::size_of() as u64),
system_instruction::assign(&feature_id, &feature::id()),
],
&feature::activate_with_lamports(
&feature_id,
&config.signers[0].pubkey(),
lamports,
),
Some(&config.signers[0].pubkey()),
)
},

View File

@ -26,6 +26,8 @@ pub mod cluster_query;
pub mod feature;
pub mod inflation;
pub mod nonce;
pub mod program;
pub mod send_tpu;
pub mod spend_utils;
pub mod stake;
pub mod test_utils;

View File

@ -7,7 +7,7 @@ use console::style;
use solana_clap_utils::{
commitment::COMMITMENT_ARG,
input_parsers::commitment_of,
input_validators::is_url,
input_validators::{is_url, is_url_or_moniker},
keypair::{CliSigners, DefaultSigner, SKIP_SEED_PHRASE_VALIDATION_ARG},
DisplayError,
};
@ -168,6 +168,7 @@ pub fn parse_args<'a>(
let CliCommandInfo { command, signers } =
parse_command(&matches, &default_signer, &mut wallet_manager)?;
let verbose = matches.is_present("verbose");
let output_format = matches
.value_of("output_format")
.map(|value| match value {
@ -175,7 +176,11 @@ pub fn parse_args<'a>(
"json-compact" => OutputFormat::JsonCompact,
_ => unreachable!(),
})
.unwrap_or(OutputFormat::Display);
.unwrap_or(if verbose {
OutputFormat::DisplayVerbose
} else {
OutputFormat::Display
});
let commitment = matches
.subcommand_name()
@ -198,7 +203,7 @@ pub fn parse_args<'a>(
keypair_path: default_signer_path,
rpc_client: None,
rpc_timeout,
verbose: matches.is_present("verbose"),
verbose,
output_format,
commitment,
send_transaction_config: RpcSendTransactionConfig::default(),
@ -233,11 +238,14 @@ fn main() -> Result<(), Box<dyn error::Error>> {
Arg::with_name("json_rpc_url")
.short("u")
.long("url")
.value_name("URL")
.value_name("URL_OR_MONIKER")
.takes_value(true)
.global(true)
.validator(is_url)
.help("JSON RPC URL for the solana cluster"),
.validator(is_url_or_moniker)
.help(
"URL for Solana's JSON RPC or moniker (or their first letter): \
[mainnet-beta, testnet, devnet, localhost]",
),
)
.arg(
Arg::with_name("websocket_url")

View File

@ -580,6 +580,7 @@ mod tests {
fee_calculator::FeeCalculator,
hash::hash,
nonce::{self, state::Versions, State},
nonce_account,
signature::{read_keypair_file, write_keypair, Keypair, Signer},
system_program,
};
@ -833,7 +834,7 @@ mod tests {
#[test]
fn test_check_nonce_account() {
let blockhash = Hash::default();
let nonce_pubkey = Pubkey::new_rand();
let nonce_pubkey = solana_sdk::pubkey::new_rand();
let data = Versions::new_current(State::Initialized(nonce::state::Data {
authority: nonce_pubkey,
blockhash,
@ -869,7 +870,7 @@ mod tests {
}
let data = Versions::new_current(State::Initialized(nonce::state::Data {
authority: Pubkey::new_rand(),
authority: solana_sdk::pubkey::new_rand(),
blockhash,
fee_calculator: FeeCalculator::default(),
}));
@ -891,7 +892,7 @@ mod tests {
#[test]
fn test_account_identity_ok() {
let nonce_account = nonce::create_account(1).into_inner();
let nonce_account = nonce_account::create_account(1).into_inner();
assert_eq!(account_identity_ok(&nonce_account), Ok(()));
let system_account = Account::new(1, 0, &system_program::id());
@ -910,7 +911,7 @@ mod tests {
#[test]
fn test_state_from_account() {
let mut nonce_account = nonce::create_account(1).into_inner();
let mut nonce_account = nonce_account::create_account(1).into_inner();
assert_eq!(state_from_account(&nonce_account), Ok(State::Uninitialized));
let data = nonce::state::Data {
@ -935,7 +936,7 @@ mod tests {
#[test]
fn test_data_from_helpers() {
let mut nonce_account = nonce::create_account(1).into_inner();
let mut nonce_account = nonce_account::create_account(1).into_inner();
let state = state_from_account(&nonce_account).unwrap();
assert_eq!(
data_from_state(&state),

1533
cli/src/program.rs Normal file

File diff suppressed because it is too large Load Diff

29
cli/src/send_tpu.rs Normal file
View File

@ -0,0 +1,29 @@
use log::*;
use solana_client::rpc_response::{RpcContactInfo, RpcLeaderSchedule};
use std::net::{SocketAddr, UdpSocket};
pub fn get_leader_tpu(
slot_index: u64,
leader_schedule: Option<&RpcLeaderSchedule>,
cluster_nodes: Option<&Vec<RpcContactInfo>>,
) -> Option<SocketAddr> {
leader_schedule?
.iter()
.find(|(_pubkey, slots)| slots.iter().any(|slot| *slot as u64 == slot_index))
.and_then(|(pubkey, _)| {
cluster_nodes?
.iter()
.find(|contact_info| contact_info.pubkey == *pubkey)
.and_then(|contact_info| contact_info.tpu)
})
}
pub fn send_transaction_tpu(
send_socket: &UdpSocket,
tpu_address: &SocketAddr,
wire_transaction: &[u8],
) {
if let Err(err) = send_socket.send_to(wire_transaction, tpu_address) {
warn!("Failed to send transaction to {}: {:?}", tpu_address, err);
}
}

View File

@ -23,20 +23,25 @@ use solana_cli_output::{
CliStakeType,
};
use solana_client::{
blockhash_query::BlockhashQuery, nonce_utils, rpc_client::RpcClient,
rpc_request::DELINQUENT_VALIDATOR_SLOT_DISTANCE,
blockhash_query::BlockhashQuery,
client_error::{ClientError, ClientErrorKind},
nonce_utils,
rpc_client::RpcClient,
rpc_custom_error,
rpc_request::{self, DELINQUENT_VALIDATOR_SLOT_DISTANCE},
};
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use solana_sdk::{
account::from_account,
account_utils::StateMut,
clock::{Clock, Epoch, Slot, UnixTimestamp},
clock::{Clock, Epoch, Slot, UnixTimestamp, SECONDS_PER_DAY},
feature, feature_set,
message::Message,
pubkey::Pubkey,
system_instruction::SystemError,
sysvar::{
clock,
stake_history::{self, StakeHistory},
Sysvar,
},
transaction::Transaction,
};
@ -1497,6 +1502,7 @@ pub fn build_stake_state(
use_lamports_unit: bool,
stake_history: &StakeHistory,
clock: &Clock,
stake_program_v2_enabled: bool,
) -> CliStakeState {
match stake_state {
StakeState::Stake(
@ -1508,9 +1514,12 @@ pub fn build_stake_state(
stake,
) => {
let current_epoch = clock.epoch;
let (active_stake, activating_stake, deactivating_stake) = stake
.delegation
.stake_activating_and_deactivating(current_epoch, Some(stake_history));
let (active_stake, activating_stake, deactivating_stake) =
stake.delegation.stake_activating_and_deactivating(
current_epoch,
Some(stake_history),
stake_program_v2_enabled,
);
let lockup = if lockup.is_in_force(clock, None) {
Some(lockup.into())
} else {
@ -1519,6 +1528,7 @@ pub fn build_stake_state(
CliStakeState {
stake_type: CliStakeType::Stake,
account_balance,
credits_observed: Some(stake.credits_observed),
delegated_stake: Some(stake.delegation.stake),
delegated_vote_account_address: if stake.delegation.voter_pubkey
!= Pubkey::default()
@ -1570,6 +1580,7 @@ pub fn build_stake_state(
CliStakeState {
stake_type: CliStakeType::Initialized,
account_balance,
credits_observed: Some(0),
authorized: Some(authorized.into()),
lockup,
use_lamports_unit,
@ -1605,10 +1616,26 @@ pub(crate) fn fetch_epoch_rewards(
.get(0)
.ok_or_else(|| format!("Unable to fetch first confirmed block for epoch {}", epoch))?;
let first_confirmed_block = rpc_client.get_confirmed_block_with_encoding(
let first_confirmed_block = match rpc_client.get_confirmed_block_with_encoding(
first_confirmed_block_in_epoch,
solana_transaction_status::UiTransactionEncoding::Base64,
)?;
) {
Ok(first_confirmed_block) => first_confirmed_block,
Err(ClientError {
kind:
ClientErrorKind::RpcError(rpc_request::RpcError::RpcResponseError {
code: rpc_custom_error::JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE,
..
}),
..
}) => {
// RPC node doesn't have this block
break;
}
Err(err) => {
return Err(err.into());
}
};
let epoch_start_time = if let Some(block_time) = first_confirmed_block.block_time {
block_time
@ -1620,29 +1647,37 @@ pub(crate) fn fetch_epoch_rewards(
let previous_epoch_rewards = first_confirmed_block.rewards;
if let Some((effective_slot, epoch_end_time, epoch_rewards)) = epoch_info {
let wall_clock_epoch_duration =
{ Local.timestamp(epoch_end_time, 0) - Local.timestamp(epoch_start_time, 0) }
.to_std()?
.as_secs_f64();
const SECONDS_PER_YEAR: f64 = (24 * 60 * 60 * 356) as f64;
let percent_of_year = SECONDS_PER_YEAR / wall_clock_epoch_duration;
let wallclock_epoch_duration = if epoch_end_time > epoch_start_time {
Some(
{ Local.timestamp(epoch_end_time, 0) - Local.timestamp(epoch_start_time, 0) }
.to_std()?
.as_secs_f64(),
)
} else {
None
};
if let Some(reward) = epoch_rewards
.into_iter()
.find(|reward| reward.pubkey == address.to_string())
{
if reward.post_balance > reward.lamports.try_into().unwrap_or(0) {
let balance_increase_percent = reward.lamports.abs() as f64
let rate_change = reward.lamports.abs() as f64
/ (reward.post_balance as f64 - reward.lamports as f64);
let apr = wallclock_epoch_duration.map(|wallclock_epoch_duration| {
let wallclock_epochs_per_year =
(SECONDS_PER_DAY * 356) as f64 / wallclock_epoch_duration;
rate_change * wallclock_epochs_per_year
});
all_epoch_rewards.push(CliEpochReward {
epoch,
effective_slot,
amount: reward.lamports.abs() as u64,
post_balance: reward.post_balance,
percent_change: balance_increase_percent,
apr: balance_increase_percent * percent_of_year,
percent_change: rate_change * 100.0,
apr: apr.map(|r| r * 100.0),
});
}
}
@ -1676,12 +1711,11 @@ pub fn process_show_stake_account(
match stake_account.state() {
Ok(stake_state) => {
let stake_history_account = rpc_client.get_account(&stake_history::id())?;
let stake_history =
StakeHistory::from_account(&stake_history_account).ok_or_else(|| {
CliError::RpcRequestError("Failed to deserialize stake history".to_string())
})?;
let stake_history = from_account(&stake_history_account).ok_or_else(|| {
CliError::RpcRequestError("Failed to deserialize stake history".to_string())
})?;
let clock_account = rpc_client.get_account(&clock::id())?;
let clock: Clock = Sysvar::from_account(&clock_account).ok_or_else(|| {
let clock: Clock = from_account(&clock_account).ok_or_else(|| {
CliError::RpcRequestError("Failed to deserialize clock sysvar".to_string())
})?;
@ -1691,15 +1725,17 @@ pub fn process_show_stake_account(
use_lamports_unit,
&stake_history,
&clock,
is_stake_program_v2_enabled(rpc_client), // At v1.6, this check can be removed and simply passed as `true`
);
if state.stake_type == CliStakeType::Stake {
if let Some(activation_epoch) = state.activation_epoch {
state.epoch_rewards = Some(fetch_epoch_rewards(
rpc_client,
stake_account_address,
activation_epoch,
)?);
let rewards =
fetch_epoch_rewards(rpc_client, stake_account_address, activation_epoch);
match rewards {
Ok(rewards) => state.epoch_rewards = Some(rewards),
Err(error) => eprintln!("Failed to fetch epoch rewards: {:?}", error),
};
}
}
Ok(config.output_format.formatted_string(&state))
@ -1718,7 +1754,7 @@ pub fn process_show_stake_history(
use_lamports_unit: bool,
) -> ProcessResult {
let stake_history_account = rpc_client.get_account(&stake_history::id())?;
let stake_history = StakeHistory::from_account(&stake_history_account).ok_or_else(|| {
let stake_history = from_account::<StakeHistory>(&stake_history_account).ok_or_else(|| {
CliError::RpcRequestError("Failed to deserialize stake history".to_string())
})?;
@ -1861,6 +1897,15 @@ pub fn process_delegate_stake(
}
}
pub fn is_stake_program_v2_enabled(rpc_client: &RpcClient) -> bool {
rpc_client
.get_account(&feature_set::stake_program_v2::id())
.ok()
.and_then(|account| feature::from_account(&account))
.and_then(|feature| feature.activated_at)
.is_some()
}
#[cfg(test)]
mod tests {
use super::*;
@ -2406,9 +2451,9 @@ mod tests {
);
// Test CreateStakeAccount SubCommand
let custodian = Pubkey::new_rand();
let custodian = solana_sdk::pubkey::new_rand();
let custodian_string = format!("{}", custodian);
let authorized = Pubkey::new_rand();
let authorized = solana_sdk::pubkey::new_rand();
let authorized_string = format!("{}", authorized);
let test_create_stake_account = test_commands.clone().get_matches_from(vec![
"test",
@ -2546,7 +2591,7 @@ mod tests {
);
// Test DelegateStake Subcommand
let vote_account_pubkey = Pubkey::new_rand();
let vote_account_pubkey = solana_sdk::pubkey::new_rand();
let vote_account_string = vote_account_pubkey.to_string();
let test_delegate_stake = test_commands.clone().get_matches_from(vec![
"test",
@ -2573,7 +2618,7 @@ mod tests {
);
// Test DelegateStake Subcommand w/ authority
let vote_account_pubkey = Pubkey::new_rand();
let vote_account_pubkey = solana_sdk::pubkey::new_rand();
let vote_account_string = vote_account_pubkey.to_string();
let test_delegate_stake = test_commands.clone().get_matches_from(vec![
"test",
@ -2692,7 +2737,7 @@ mod tests {
);
// Test Delegate Subcommand w/ absent fee payer
let key1 = Pubkey::new_rand();
let key1 = solana_sdk::pubkey::new_rand();
let sig1 = Keypair::new().sign_message(&[0u8]);
let signer1 = format!("{}={}", key1, sig1);
let test_delegate_stake = test_commands.clone().get_matches_from(vec![
@ -2732,7 +2777,7 @@ mod tests {
);
// Test Delegate Subcommand w/ absent fee payer and absent nonce authority
let key2 = Pubkey::new_rand();
let key2 = solana_sdk::pubkey::new_rand();
let sig2 = Keypair::new().sign_message(&[0u8]);
let signer2 = format!("{}={}", key2, sig2);
let test_delegate_stake = test_commands.clone().get_matches_from(vec![
@ -3060,7 +3105,7 @@ mod tests {
);
// Test Deactivate Subcommand w/ absent fee payer
let key1 = Pubkey::new_rand();
let key1 = solana_sdk::pubkey::new_rand();
let sig1 = Keypair::new().sign_message(&[0u8]);
let signer1 = format!("{}={}", key1, sig1);
let test_deactivate_stake = test_commands.clone().get_matches_from(vec![
@ -3097,7 +3142,7 @@ mod tests {
);
// Test Deactivate Subcommand w/ absent fee payer and nonce authority
let key2 = Pubkey::new_rand();
let key2 = solana_sdk::pubkey::new_rand();
let sig2 = Keypair::new().sign_message(&[0u8]);
let signer2 = format!("{}={}", key2, sig2);
let test_deactivate_stake = test_commands.clone().get_matches_from(vec![
@ -3276,7 +3321,7 @@ mod tests {
let stake_account_keypair = Keypair::new();
write_keypair(&stake_account_keypair, tmp_file.as_file_mut()).unwrap();
let source_stake_account_pubkey = Pubkey::new_rand();
let source_stake_account_pubkey = solana_sdk::pubkey::new_rand();
let test_merge_stake_account = test_commands.clone().get_matches_from(vec![
"test",
"merge-stake",

View File

@ -486,7 +486,7 @@ mod tests {
#[test]
fn test_parse_validator_info() {
let pubkey = Pubkey::new_rand();
let pubkey = solana_sdk::pubkey::new_rand();
let keys = vec![(validator_info::id(), false), (pubkey, true)];
let config = ConfigKeys { keys };

View File

@ -696,11 +696,14 @@ pub fn process_show_vote_account(
}
}
let epoch_rewards = Some(crate::stake::fetch_epoch_rewards(
rpc_client,
vote_account_address,
1,
)?);
let epoch_rewards = match crate::stake::fetch_epoch_rewards(rpc_client, vote_account_address, 1)
{
Ok(rewards) => Some(rewards),
Err(error) => {
eprintln!("Failed to fetch epoch rewards: {:?}", error);
None
}
};
let vote_account_data = CliVoteAccount {
account_balance: vote_account.lamports,
@ -915,7 +918,7 @@ mod tests {
);
// test init with an authed voter
let authed = Pubkey::new_rand();
let authed = solana_sdk::pubkey::new_rand();
let (keypair_file, mut tmp_file) = make_tmp_file();
let keypair = Keypair::new();
write_keypair(&keypair, tmp_file.as_file_mut()).unwrap();

View File

@ -1,118 +0,0 @@
use serde_json::Value;
use solana_cli::cli::{process_command, CliCommand, CliConfig};
use solana_client::rpc_client::RpcClient;
use solana_core::test_validator::TestValidator;
use solana_faucet::faucet::run_local_faucet;
use solana_sdk::{
bpf_loader,
commitment_config::CommitmentConfig,
pubkey::Pubkey,
signature::{Keypair, Signer},
};
use std::{
fs::{remove_dir_all, File},
io::Read,
path::PathBuf,
str::FromStr,
sync::mpsc::channel,
};
#[test]
fn test_cli_deploy_program() {
solana_logger::setup();
let mut pathbuf = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
pathbuf.push("tests");
pathbuf.push("fixtures");
pathbuf.push("noop");
pathbuf.set_extension("so");
let TestValidator {
server,
leader_data,
alice,
ledger_path,
..
} = TestValidator::run();
let (sender, receiver) = channel();
run_local_faucet(alice, sender, None);
let faucet_addr = receiver.recv().unwrap();
let rpc_client = RpcClient::new_socket(leader_data.rpc);
let mut file = File::open(pathbuf.to_str().unwrap()).unwrap();
let mut program_data = Vec::new();
file.read_to_end(&mut program_data).unwrap();
let minimum_balance_for_rent_exemption = rpc_client
.get_minimum_balance_for_rent_exemption(program_data.len())
.unwrap();
let mut config = CliConfig::recent_for_tests();
let keypair = Keypair::new();
config.json_rpc_url = format!("http://{}:{}", leader_data.rpc.ip(), leader_data.rpc.port());
config.command = CliCommand::Airdrop {
faucet_host: None,
faucet_port: faucet_addr.port(),
pubkey: None,
lamports: 3 * minimum_balance_for_rent_exemption, // min balance for rent exemption for two programs + leftover for tx processing
};
config.signers = vec![&keypair];
process_command(&config).unwrap();
config.command = CliCommand::Deploy {
program_location: pathbuf.to_str().unwrap().to_string(),
address: None,
use_deprecated_loader: false,
};
let response = process_command(&config);
let json: Value = serde_json::from_str(&response.unwrap()).unwrap();
let program_id_str = json
.as_object()
.unwrap()
.get("programId")
.unwrap()
.as_str()
.unwrap();
let program_id = Pubkey::from_str(&program_id_str).unwrap();
let account0 = rpc_client
.get_account_with_commitment(&program_id, CommitmentConfig::recent())
.unwrap()
.value
.unwrap();
assert_eq!(account0.lamports, minimum_balance_for_rent_exemption);
assert_eq!(account0.owner, bpf_loader::id());
assert_eq!(account0.executable, true);
let mut file = File::open(pathbuf.to_str().unwrap().to_string()).unwrap();
let mut elf = Vec::new();
file.read_to_end(&mut elf).unwrap();
assert_eq!(account0.data, elf);
// Test custom address
let custom_address_keypair = Keypair::new();
config.signers = vec![&keypair, &custom_address_keypair];
config.command = CliCommand::Deploy {
program_location: pathbuf.to_str().unwrap().to_string(),
address: Some(1),
use_deprecated_loader: false,
};
process_command(&config).unwrap();
let account1 = rpc_client
.get_account_with_commitment(&custom_address_keypair.pubkey(), CommitmentConfig::recent())
.unwrap()
.value
.unwrap();
assert_eq!(account1.lamports, minimum_balance_for_rent_exemption);
assert_eq!(account1.owner, bpf_loader::id());
assert_eq!(account1.executable, true);
assert_eq!(account0.data, account1.data);
// Attempt to redeploy to the same address
process_command(&config).unwrap_err();
server.close().unwrap();
remove_dir_all(ledger_path).unwrap();
}

View File

@ -10,7 +10,7 @@ use solana_client::{
rpc_client::RpcClient,
};
use solana_core::contact_info::ContactInfo;
use solana_core::test_validator::{TestValidator, TestValidatorOptions};
use solana_core::test_validator::TestValidator;
use solana_faucet::faucet::run_local_faucet;
use solana_sdk::{
commitment_config::CommitmentConfig,
@ -172,7 +172,7 @@ fn full_battery_tests(
assert_ne!(first_nonce, third_nonce);
// Withdraw from nonce account
let payee_pubkey = Pubkey::new_rand();
let payee_pubkey = solana_sdk::pubkey::new_rand();
config_payer.signers = authorized_signers;
config_payer.command = CliCommand::WithdrawFromNonceAccount {
nonce_account,
@ -231,17 +231,14 @@ fn full_battery_tests(
#[test]
fn test_create_account_with_seed() {
solana_logger::setup();
let TestValidator {
server,
leader_data,
alice: mint_keypair,
ledger_path,
..
} = TestValidator::run_with_options(TestValidatorOptions {
fees: 1,
bootstrap_validator_lamports: 42_000,
..TestValidatorOptions::default()
});
} = TestValidator::run_with_fees(1);
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);

555
cli/tests/program.rs Normal file
View File

@ -0,0 +1,555 @@
use serde_json::Value;
use solana_cli::{
cli::{process_command, CliCommand, CliConfig},
program::ProgramCliCommand,
};
use solana_client::rpc_client::RpcClient;
use solana_core::test_validator::TestValidator;
use solana_faucet::faucet::run_local_faucet;
use solana_sdk::{
bpf_loader,
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
commitment_config::CommitmentConfig,
pubkey::Pubkey,
signature::{Keypair, Signer},
};
use std::{
fs::{remove_dir_all, File},
io::Read,
path::PathBuf,
str::FromStr,
sync::mpsc::channel,
};
#[test]
fn test_cli_program_deploy_non_upgradeable() {
solana_logger::setup();
let mut pathbuf = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
pathbuf.push("tests");
pathbuf.push("fixtures");
pathbuf.push("noop");
pathbuf.set_extension("so");
let TestValidator {
server,
leader_data,
alice,
ledger_path,
..
} = TestValidator::run();
let (sender, receiver) = channel();
run_local_faucet(alice, sender, None);
let faucet_addr = receiver.recv().unwrap();
let rpc_client = RpcClient::new_socket(leader_data.rpc);
let mut file = File::open(pathbuf.to_str().unwrap()).unwrap();
let mut program_data = Vec::new();
file.read_to_end(&mut program_data).unwrap();
let minimum_balance_for_rent_exemption = rpc_client
.get_minimum_balance_for_rent_exemption(program_data.len())
.unwrap();
let mut config = CliConfig::recent_for_tests();
let keypair = Keypair::new();
config.json_rpc_url = format!("http://{}:{}", leader_data.rpc.ip(), leader_data.rpc.port());
config.signers = vec![&keypair];
config.command = CliCommand::Airdrop {
faucet_host: None,
faucet_port: faucet_addr.port(),
pubkey: None,
lamports: 4 * minimum_balance_for_rent_exemption, // min balance for rent exemption for three programs + leftover for tx processing
};
process_command(&config).unwrap();
config.command = CliCommand::Deploy {
program_location: pathbuf.to_str().unwrap().to_string(),
address: None,
use_deprecated_loader: false,
allow_excessive_balance: false,
};
let response = process_command(&config);
let json: Value = serde_json::from_str(&response.unwrap()).unwrap();
let program_id_str = json
.as_object()
.unwrap()
.get("programId")
.unwrap()
.as_str()
.unwrap();
let program_id = Pubkey::from_str(&program_id_str).unwrap();
let account0 = rpc_client
.get_account_with_commitment(&program_id, CommitmentConfig::recent())
.unwrap()
.value
.unwrap();
assert_eq!(account0.lamports, minimum_balance_for_rent_exemption);
assert_eq!(account0.owner, bpf_loader::id());
assert_eq!(account0.executable, true);
let mut file = File::open(pathbuf.to_str().unwrap().to_string()).unwrap();
let mut elf = Vec::new();
file.read_to_end(&mut elf).unwrap();
assert_eq!(account0.data, elf);
// Test custom address
let custom_address_keypair = Keypair::new();
config.signers = vec![&keypair, &custom_address_keypair];
config.command = CliCommand::Deploy {
program_location: pathbuf.to_str().unwrap().to_string(),
address: Some(1),
use_deprecated_loader: false,
allow_excessive_balance: false,
};
process_command(&config).unwrap();
let account1 = rpc_client
.get_account_with_commitment(&custom_address_keypair.pubkey(), CommitmentConfig::recent())
.unwrap()
.value
.unwrap();
assert_eq!(account1.lamports, minimum_balance_for_rent_exemption);
assert_eq!(account1.owner, bpf_loader::id());
assert_eq!(account1.executable, true);
assert_eq!(account1.data, account0.data);
// Attempt to redeploy to the same address
process_command(&config).unwrap_err();
// Attempt to deploy to account with excess balance
let custom_address_keypair = Keypair::new();
config.signers = vec![&custom_address_keypair];
config.command = CliCommand::Airdrop {
faucet_host: None,
faucet_port: faucet_addr.port(),
pubkey: None,
lamports: 2 * minimum_balance_for_rent_exemption, // Anything over minimum_balance_for_rent_exemption should trigger err
};
process_command(&config).unwrap();
config.signers = vec![&keypair, &custom_address_keypair];
config.command = CliCommand::Deploy {
program_location: pathbuf.to_str().unwrap().to_string(),
address: Some(1),
use_deprecated_loader: false,
allow_excessive_balance: false,
};
process_command(&config).unwrap_err();
// Use forcing parameter to deploy to account with excess balance
config.command = CliCommand::Deploy {
program_location: pathbuf.to_str().unwrap().to_string(),
address: Some(1),
use_deprecated_loader: false,
allow_excessive_balance: true,
};
process_command(&config).unwrap();
let account2 = rpc_client
.get_account_with_commitment(&custom_address_keypair.pubkey(), CommitmentConfig::recent())
.unwrap()
.value
.unwrap();
assert_eq!(account2.lamports, 2 * minimum_balance_for_rent_exemption);
assert_eq!(account2.owner, bpf_loader::id());
assert_eq!(account2.executable, true);
assert_eq!(account2.data, account0.data);
server.close().unwrap();
remove_dir_all(ledger_path).unwrap();
}
#[test]
fn test_cli_program_deploy_no_authority() {
solana_logger::setup();
let mut pathbuf = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
pathbuf.push("tests");
pathbuf.push("fixtures");
pathbuf.push("noop");
pathbuf.set_extension("so");
let TestValidator {
server,
leader_data,
alice: mint_keypair,
ledger_path,
..
} = TestValidator::run();
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let rpc_client = RpcClient::new_socket(leader_data.rpc);
let mut file = File::open(pathbuf.to_str().unwrap()).unwrap();
let mut program_data = Vec::new();
file.read_to_end(&mut program_data).unwrap();
let max_len = program_data.len();
let minimum_balance_for_programdata = rpc_client
.get_minimum_balance_for_rent_exemption(
UpgradeableLoaderState::programdata_len(max_len).unwrap(),
)
.unwrap();
let minimum_balance_for_program = rpc_client
.get_minimum_balance_for_rent_exemption(UpgradeableLoaderState::program_len().unwrap())
.unwrap();
let upgrade_authority = Keypair::new();
let mut config = CliConfig::recent_for_tests();
let keypair = Keypair::new();
config.json_rpc_url = format!("http://{}:{}", leader_data.rpc.ip(), leader_data.rpc.port());
config.command = CliCommand::Airdrop {
faucet_host: None,
faucet_port: faucet_addr.port(),
pubkey: None,
lamports: 100 * minimum_balance_for_programdata + minimum_balance_for_program,
};
config.signers = vec![&keypair];
process_command(&config).unwrap();
// Deploy a program with no authority
config.signers = vec![&keypair];
config.command = CliCommand::Program(ProgramCliCommand::Deploy {
program_location: pathbuf.to_str().unwrap().to_string(),
program_signer_index: None,
program_pubkey: None,
buffer_signer_index: None,
allow_excessive_balance: false,
upgrade_authority_signer_index: None,
upgrade_authority_pubkey: None,
max_len: None,
});
let response = process_command(&config);
let json: Value = serde_json::from_str(&response.unwrap()).unwrap();
let program_id_str = json
.as_object()
.unwrap()
.get("programId")
.unwrap()
.as_str()
.unwrap();
let program_id = Pubkey::from_str(&program_id_str).unwrap();
// Attempt to upgrade the program
config.signers = vec![&keypair, &upgrade_authority];
config.command = CliCommand::Program(ProgramCliCommand::Deploy {
program_location: pathbuf.to_str().unwrap().to_string(),
program_signer_index: None,
program_pubkey: Some(program_id),
buffer_signer_index: None,
allow_excessive_balance: false,
upgrade_authority_signer_index: Some(1),
upgrade_authority_pubkey: Some(upgrade_authority.pubkey()),
max_len: None,
});
process_command(&config).unwrap_err();
server.close().unwrap();
remove_dir_all(ledger_path).unwrap();
}
#[test]
fn test_cli_program_deploy_with_authority() {
solana_logger::setup();
let mut pathbuf = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
pathbuf.push("tests");
pathbuf.push("fixtures");
pathbuf.push("noop");
pathbuf.set_extension("so");
let TestValidator {
server,
leader_data,
alice,
ledger_path,
..
} = TestValidator::run();
let (sender, receiver) = channel();
run_local_faucet(alice, sender, None);
let faucet_addr = receiver.recv().unwrap();
let rpc_client = RpcClient::new_socket(leader_data.rpc);
let mut file = File::open(pathbuf.to_str().unwrap()).unwrap();
let mut program_data = Vec::new();
file.read_to_end(&mut program_data).unwrap();
let max_len = program_data.len();
let minimum_balance_for_programdata = rpc_client
.get_minimum_balance_for_rent_exemption(
UpgradeableLoaderState::programdata_len(max_len).unwrap(),
)
.unwrap();
let minimum_balance_for_program = rpc_client
.get_minimum_balance_for_rent_exemption(UpgradeableLoaderState::program_len().unwrap())
.unwrap();
let upgrade_authority = Keypair::new();
let mut config = CliConfig::recent_for_tests();
let keypair = Keypair::new();
config.json_rpc_url = format!("http://{}:{}", leader_data.rpc.ip(), leader_data.rpc.port());
config.signers = vec![&keypair];
config.command = CliCommand::Airdrop {
faucet_host: None,
faucet_port: faucet_addr.port(),
pubkey: None,
lamports: 100 * minimum_balance_for_programdata + minimum_balance_for_program,
};
process_command(&config).unwrap();
// Deploy the upgradeable program with specified program_id
let program_keypair = Keypair::new();
config.signers = vec![&keypair, &upgrade_authority, &program_keypair];
config.command = CliCommand::Program(ProgramCliCommand::Deploy {
program_location: pathbuf.to_str().unwrap().to_string(),
program_signer_index: Some(2),
program_pubkey: Some(program_keypair.pubkey()),
buffer_signer_index: None,
allow_excessive_balance: false,
upgrade_authority_signer_index: Some(1),
upgrade_authority_pubkey: Some(upgrade_authority.pubkey()),
max_len: Some(max_len),
});
let response = process_command(&config);
let json: Value = serde_json::from_str(&response.unwrap()).unwrap();
let program_id_str = json
.as_object()
.unwrap()
.get("programId")
.unwrap()
.as_str()
.unwrap();
assert_eq!(
program_keypair.pubkey(),
Pubkey::from_str(&program_id_str).unwrap()
);
let program_account = rpc_client
.get_account_with_commitment(&program_keypair.pubkey(), CommitmentConfig::recent())
.unwrap()
.value
.unwrap();
assert_eq!(program_account.lamports, minimum_balance_for_program);
assert_eq!(program_account.owner, bpf_loader_upgradeable::id());
assert_eq!(program_account.executable, true);
let (programdata_pubkey, _) = Pubkey::find_program_address(
&[program_keypair.pubkey().as_ref()],
&bpf_loader_upgradeable::id(),
);
let programdata_account = rpc_client
.get_account_with_commitment(&programdata_pubkey, CommitmentConfig::recent())
.unwrap()
.value
.unwrap();
assert_eq!(
programdata_account.lamports,
minimum_balance_for_programdata
);
assert_eq!(programdata_account.owner, bpf_loader_upgradeable::id());
assert_eq!(programdata_account.executable, false);
assert_eq!(
programdata_account.data[UpgradeableLoaderState::programdata_data_offset().unwrap()..],
program_data[..]
);
// Deploy the upgradeable program
config.signers = vec![&keypair, &upgrade_authority];
config.command = CliCommand::Program(ProgramCliCommand::Deploy {
program_location: pathbuf.to_str().unwrap().to_string(),
program_signer_index: None,
program_pubkey: None,
buffer_signer_index: None,
allow_excessive_balance: false,
upgrade_authority_signer_index: Some(1),
upgrade_authority_pubkey: Some(upgrade_authority.pubkey()),
max_len: Some(max_len),
});
let response = process_command(&config);
let json: Value = serde_json::from_str(&response.unwrap()).unwrap();
let program_id_str = json
.as_object()
.unwrap()
.get("programId")
.unwrap()
.as_str()
.unwrap();
let program_id = Pubkey::from_str(&program_id_str).unwrap();
let program_account = rpc_client
.get_account_with_commitment(&program_id, CommitmentConfig::recent())
.unwrap()
.value
.unwrap();
assert_eq!(program_account.lamports, minimum_balance_for_program);
assert_eq!(program_account.owner, bpf_loader_upgradeable::id());
assert_eq!(program_account.executable, true);
let (programdata_pubkey, _) =
Pubkey::find_program_address(&[program_id.as_ref()], &bpf_loader_upgradeable::id());
let programdata_account = rpc_client
.get_account_with_commitment(&programdata_pubkey, CommitmentConfig::recent())
.unwrap()
.value
.unwrap();
assert_eq!(
programdata_account.lamports,
minimum_balance_for_programdata
);
assert_eq!(programdata_account.owner, bpf_loader_upgradeable::id());
assert_eq!(programdata_account.executable, false);
assert_eq!(
programdata_account.data[UpgradeableLoaderState::programdata_data_offset().unwrap()..],
program_data[..]
);
// Upgrade the program
config.signers = vec![&keypair, &upgrade_authority];
config.command = CliCommand::Program(ProgramCliCommand::Deploy {
program_location: pathbuf.to_str().unwrap().to_string(),
program_signer_index: None,
program_pubkey: Some(program_id),
buffer_signer_index: None,
allow_excessive_balance: false,
upgrade_authority_signer_index: Some(1),
upgrade_authority_pubkey: Some(upgrade_authority.pubkey()),
max_len: Some(max_len),
});
let response = process_command(&config);
let json: Value = serde_json::from_str(&response.unwrap()).unwrap();
let program_id_str = json
.as_object()
.unwrap()
.get("programId")
.unwrap()
.as_str()
.unwrap();
let program_id = Pubkey::from_str(&program_id_str).unwrap();
let program_account = rpc_client
.get_account_with_commitment(&program_id, CommitmentConfig::recent())
.unwrap()
.value
.unwrap();
assert_eq!(program_account.lamports, minimum_balance_for_program);
assert_eq!(program_account.owner, bpf_loader_upgradeable::id());
assert_eq!(program_account.executable, true);
let (programdata_pubkey, _) =
Pubkey::find_program_address(&[program_id.as_ref()], &bpf_loader_upgradeable::id());
let programdata_account = rpc_client
.get_account_with_commitment(&programdata_pubkey, CommitmentConfig::recent())
.unwrap()
.value
.unwrap();
assert_eq!(
programdata_account.lamports,
minimum_balance_for_programdata
);
assert_eq!(programdata_account.owner, bpf_loader_upgradeable::id());
assert_eq!(programdata_account.executable, false);
assert_eq!(
programdata_account.data[UpgradeableLoaderState::programdata_data_offset().unwrap()..],
program_data[..]
);
// Set a new authority
let new_upgrade_authority = Keypair::new();
config.signers = vec![&keypair, &upgrade_authority];
config.command = CliCommand::Program(ProgramCliCommand::SetUpgradeAuthority {
program: program_id,
upgrade_authority_index: Some(1),
new_upgrade_authority: Some(new_upgrade_authority.pubkey()),
});
let response = process_command(&config);
let json: Value = serde_json::from_str(&response.unwrap()).unwrap();
let new_upgrade_authority_str = json
.as_object()
.unwrap()
.get("UpgradeAuthority")
.unwrap()
.as_str()
.unwrap();
assert_eq!(
Pubkey::from_str(&new_upgrade_authority_str).unwrap(),
new_upgrade_authority.pubkey()
);
// Upgrade with new authority
config.signers = vec![&keypair, &new_upgrade_authority];
config.command = CliCommand::Program(ProgramCliCommand::Deploy {
program_location: pathbuf.to_str().unwrap().to_string(),
program_signer_index: None,
program_pubkey: Some(program_id),
buffer_signer_index: None,
allow_excessive_balance: false,
upgrade_authority_signer_index: Some(1),
upgrade_authority_pubkey: Some(new_upgrade_authority.pubkey()),
max_len: None,
});
let response = process_command(&config);
let json: Value = serde_json::from_str(&response.unwrap()).unwrap();
let program_id_str = json
.as_object()
.unwrap()
.get("programId")
.unwrap()
.as_str()
.unwrap();
let program_id = Pubkey::from_str(&program_id_str).unwrap();
let program_account = rpc_client
.get_account_with_commitment(&program_id, CommitmentConfig::recent())
.unwrap()
.value
.unwrap();
assert_eq!(program_account.lamports, minimum_balance_for_program);
assert_eq!(program_account.owner, bpf_loader_upgradeable::id());
assert_eq!(program_account.executable, true);
let (programdata_pubkey, _) =
Pubkey::find_program_address(&[program_id.as_ref()], &bpf_loader_upgradeable::id());
let programdata_account = rpc_client
.get_account_with_commitment(&programdata_pubkey, CommitmentConfig::recent())
.unwrap()
.value
.unwrap();
assert_eq!(
programdata_account.lamports,
minimum_balance_for_programdata
);
assert_eq!(programdata_account.owner, bpf_loader_upgradeable::id());
assert_eq!(programdata_account.executable, false);
assert_eq!(
programdata_account.data[UpgradeableLoaderState::programdata_data_offset().unwrap()..],
program_data[..]
);
// Set no authority
config.signers = vec![&keypair, &new_upgrade_authority];
config.command = CliCommand::Program(ProgramCliCommand::SetUpgradeAuthority {
program: program_id,
upgrade_authority_index: Some(1),
new_upgrade_authority: None,
});
let response = process_command(&config);
let json: Value = serde_json::from_str(&response.unwrap()).unwrap();
let new_upgrade_authority_str = json
.as_object()
.unwrap()
.get("UpgradeAuthority")
.unwrap()
.as_str()
.unwrap();
assert_eq!(new_upgrade_authority_str, "None");
// Upgrade with no authority
config.signers = vec![&keypair, &new_upgrade_authority];
config.command = CliCommand::Program(ProgramCliCommand::Deploy {
program_location: pathbuf.to_str().unwrap().to_string(),
program_signer_index: None,
program_pubkey: Some(program_id),
buffer_signer_index: None,
allow_excessive_balance: false,
upgrade_authority_signer_index: Some(1),
upgrade_authority_pubkey: Some(new_upgrade_authority.pubkey()),
max_len: None,
});
process_command(&config).unwrap_err();
server.close().unwrap();
remove_dir_all(ledger_path).unwrap();
}

View File

@ -9,7 +9,7 @@ use solana_client::{
nonce_utils,
rpc_client::RpcClient,
};
use solana_core::test_validator::{TestValidator, TestValidatorOptions};
use solana_core::test_validator::TestValidator;
use solana_faucet::faucet::run_local_faucet;
use solana_sdk::{
account_utils::StateMut,
@ -848,11 +848,7 @@ fn test_stake_authorize_with_fee_payer() {
alice,
ledger_path,
..
} = TestValidator::run_with_options(TestValidatorOptions {
fees: SIG_FEE,
bootstrap_validator_lamports: 42_000,
..TestValidatorOptions::default()
});
} = TestValidator::run_with_fees(SIG_FEE);
let (sender, receiver) = channel();
run_local_faucet(alice, sender, None);
let faucet_addr = receiver.recv().unwrap();
@ -985,11 +981,7 @@ fn test_stake_split() {
alice,
ledger_path,
..
} = TestValidator::run_with_options(TestValidatorOptions {
fees: 1,
bootstrap_validator_lamports: 42_000,
..TestValidatorOptions::default()
});
} = TestValidator::run_with_fees(1);
let (sender, receiver) = channel();
run_local_faucet(alice, sender, None);
let faucet_addr = receiver.recv().unwrap();
@ -1140,11 +1132,7 @@ fn test_stake_set_lockup() {
alice,
ledger_path,
..
} = TestValidator::run_with_options(TestValidatorOptions {
fees: 1,
bootstrap_validator_lamports: 42_000,
..TestValidatorOptions::default()
});
} = TestValidator::run_with_fees(1);
let (sender, receiver) = channel();
run_local_faucet(alice, sender, None);
let faucet_addr = receiver.recv().unwrap();

View File

@ -9,7 +9,7 @@ use solana_client::{
nonce_utils,
rpc_client::RpcClient,
};
use solana_core::test_validator::{TestValidator, TestValidatorOptions};
use solana_core::test_validator::TestValidator;
use solana_faucet::faucet::run_local_faucet;
use solana_sdk::{
commitment_config::CommitmentConfig,
@ -21,17 +21,14 @@ use std::{fs::remove_dir_all, sync::mpsc::channel};
#[test]
fn test_transfer() {
solana_logger::setup();
let TestValidator {
server,
leader_data,
alice: mint_keypair,
ledger_path,
..
} = TestValidator::run_with_options(TestValidatorOptions {
fees: 1,
bootstrap_validator_lamports: 42_000,
..TestValidatorOptions::default()
});
} = TestValidator::run_with_fees(1);
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
@ -252,17 +249,14 @@ fn test_transfer() {
#[test]
fn test_transfer_multisession_signing() {
solana_logger::setup();
let TestValidator {
server,
leader_data,
alice: mint_keypair,
ledger_path,
..
} = TestValidator::run_with_options(TestValidatorOptions {
fees: 1,
bootstrap_validator_lamports: 42_000,
..TestValidatorOptions::default()
});
} = TestValidator::run_with_fees(1);
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
@ -382,17 +376,14 @@ fn test_transfer_multisession_signing() {
#[test]
fn test_transfer_all() {
solana_logger::setup();
let TestValidator {
server,
leader_data,
alice: mint_keypair,
ledger_path,
..
} = TestValidator::run_with_options(TestValidatorOptions {
fees: 1,
bootstrap_validator_lamports: 42_000,
..TestValidatorOptions::default()
});
} = TestValidator::run_with_fees(1);
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);

View File

@ -12,7 +12,6 @@ use solana_faucet::faucet::run_local_faucet;
use solana_sdk::{
account_utils::StateMut,
commitment_config::CommitmentConfig,
pubkey::Pubkey,
signature::{Keypair, Signer},
};
use solana_vote_program::vote_state::{VoteAuthorize, VoteState, VoteStateVersions};
@ -110,7 +109,7 @@ fn test_vote_authorize_and_withdraw() {
assert_eq!(authorized_withdrawer, withdraw_authority.pubkey());
// Withdraw from vote account
let destination_account = Pubkey::new_rand(); // Send withdrawal to new account to make balance check easy
let destination_account = solana_sdk::pubkey::new_rand(); // Send withdrawal to new account to make balance check easy
config.signers = vec![&default_signer, &withdraw_authority];
config.command = CliCommand::WithdrawFromVoteAccount {
vote_account_pubkey,

View File

@ -1,6 +1,6 @@
[package]
name = "solana-client"
version = "1.4.0"
version = "1.4.21"
description = "Solana Client"
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
repository = "https://github.com/solana-labs/solana"
@ -16,17 +16,20 @@ clap = "2.33.0"
indicatif = "0.15.0"
jsonrpc-core = "15.0.0"
log = "0.4.8"
net2 = "0.2.37"
rayon = "1.4.0"
reqwest = { version = "0.10.6", default-features = false, features = ["blocking", "rustls-tls", "json"] }
reqwest = { version = "0.10.8", default-features = false, features = ["blocking", "rustls-tls", "json"] }
semver = "0.11.0"
serde = "1.0.112"
serde_derive = "1.0.103"
serde_json = "1.0.56"
solana-account-decoder = { path = "../account-decoder", version = "1.4.0" }
solana-clap-utils = { path = "../clap-utils", version = "1.4.0" }
solana-net-utils = { path = "../net-utils", version = "1.4.0" }
solana-sdk = { path = "../sdk", version = "1.4.0" }
solana-transaction-status = { path = "../transaction-status", version = "1.4.0" }
solana-vote-program = { path = "../programs/vote", version = "1.4.0" }
solana-account-decoder = { path = "../account-decoder", version = "1.4.21" }
solana-clap-utils = { path = "../clap-utils", version = "1.4.21" }
solana-net-utils = { path = "../net-utils", version = "1.4.21" }
solana-sdk = { path = "../sdk", version = "1.4.21" }
solana-transaction-status = { path = "../transaction-status", version = "1.4.21" }
solana-version = { path = "../version", version = "1.4.21" }
solana-vote-program = { path = "../programs/vote", version = "1.4.21" }
thiserror = "1.0"
tungstenite = "0.10.1"
url = "2.1.1"
@ -35,7 +38,7 @@ url = "2.1.1"
assert_matches = "1.3.0"
jsonrpc-core = "15.0.0"
jsonrpc-http-server = "15.0.0"
solana-logger = { path = "../logger", version = "1.4.0" }
solana-logger = { path = "../logger", version = "1.4.21" }
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

View File

@ -5,6 +5,8 @@ use solana_sdk::{
use std::io;
use thiserror::Error;
pub use reqwest; // export `reqwest` for clients
#[derive(Error, Debug)]
pub enum ClientErrorKind {
#[error(transparent)]
@ -50,10 +52,10 @@ impl Into<TransportError> for ClientErrorKind {
#[derive(Error, Debug)]
#[error("{kind}")]
pub struct ClientError {
request: Option<rpc_request::RpcRequest>,
pub request: Option<rpc_request::RpcRequest>,
#[source]
kind: ClientErrorKind,
pub kind: ClientErrorKind,
}
impl ClientError {

View File

@ -1,6 +1,8 @@
use crate::{
client_error::Result,
rpc_request::{RpcError, RpcRequest},
rpc_custom_error,
rpc_request::{RpcError, RpcRequest, RpcResponseErrorData},
rpc_response::RpcSimulateTransactionResult,
rpc_sender::RpcSender,
};
use log::*;
@ -27,6 +29,13 @@ impl HttpSender {
}
}
#[derive(Deserialize, Debug)]
struct RpcErrorObject {
code: i64,
message: String,
data: serde_json::Value,
}
impl RpcSender for HttpSender {
fn send(&self, request: RpcRequest, params: serde_json::Value) -> Result<serde_json::Value> {
// Concurrent requests are not supported so reuse the same request id for all requests
@ -63,11 +72,36 @@ impl RpcSender for HttpSender {
let json: serde_json::Value = serde_json::from_str(&response.text()?)?;
if json["error"].is_object() {
return Err(RpcError::RpcRequestError(format!(
"RPC Error response: {}",
serde_json::to_string(&json["error"]).unwrap()
))
.into());
return match serde_json::from_value::<RpcErrorObject>(json["error"].clone())
{
Ok(rpc_error_object) => {
let data = match rpc_error_object.code {
rpc_custom_error::JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE => {
match serde_json::from_value::<RpcSimulateTransactionResult>(json["error"]["data"].clone()) {
Ok(data) => RpcResponseErrorData::SendTransactionPreflightFailure(data),
Err(err) => {
debug!("Failed to deserialize RpcSimulateTransactionResult: {:?}", err);
RpcResponseErrorData::Empty
}
}
},
_ => RpcResponseErrorData::Empty
};
Err(RpcError::RpcResponseError {
code: rpc_error_object.code,
message: rpc_error_object.message,
data,
}
.into())
}
Err(err) => Err(RpcError::RpcRequestError(format!(
"Failed to deserialize RPC error response: {} [{}]",
serde_json::to_string(&json["error"]).unwrap(),
err
))
.into()),
};
}
return Ok(json["result"].clone());
}

View File

@ -10,6 +10,7 @@ pub mod perf_utils;
pub mod pubsub_client;
pub mod rpc_client;
pub mod rpc_config;
pub mod rpc_custom_error;
pub mod rpc_filter;
pub mod rpc_request;
pub mod rpc_response;

View File

@ -1,17 +1,19 @@
use crate::{
client_error::Result,
rpc_request::RpcRequest,
rpc_response::{Response, RpcResponseContext},
rpc_response::{Response, RpcResponseContext, RpcVersionInfo},
rpc_sender::RpcSender,
};
use serde_json::{Number, Value};
use serde_json::{json, Number, Value};
use solana_sdk::{
epoch_info::EpochInfo,
fee_calculator::{FeeCalculator, FeeRateGovernor},
instruction::InstructionError,
signature::Signature,
transaction::{self, Transaction, TransactionError},
};
use solana_transaction_status::TransactionStatus;
use solana_version::Version;
use std::{collections::HashMap, sync::RwLock};
pub const PUBKEY: &str = "7RoSF9fUmdphVCpabEoefH81WwrW7orsWonXWqTXkKV8";
@ -46,6 +48,10 @@ impl RpcSender for MockSender {
return Ok(Value::Null);
}
let val = match request {
RpcRequest::GetAccountInfo => serde_json::to_value(Response {
context: RpcResponseContext { slot: 1 },
value: Value::Null,
})?,
RpcRequest::GetBalance => serde_json::to_value(Response {
context: RpcResponseContext { slot: 1 },
value: Value::Number(Number::from(50)),
@ -57,6 +63,14 @@ impl RpcSender for MockSender {
serde_json::to_value(FeeCalculator::default()).unwrap(),
),
})?,
RpcRequest::GetEpochInfo => serde_json::to_value(EpochInfo {
epoch: 1,
slot_index: 2,
slots_in_epoch: 32,
absolute_slot: 34,
block_height: 34,
transaction_count: Some(123),
})?,
RpcRequest::GetFeeCalculatorForBlockhash => {
let value = if self.url == "blockhash_expired" {
Value::Null
@ -112,13 +126,20 @@ impl RpcSender for MockSender {
Signature::new(&[8; 64]).to_string()
} else {
let tx_str = params.as_array().unwrap()[0].as_str().unwrap().to_string();
let data = bs58::decode(tx_str).into_vec().unwrap();
let data = base64::decode(tx_str).unwrap();
let tx: Transaction = bincode::deserialize(&data).unwrap();
tx.signatures[0].to_string()
};
Value::String(signature)
}
RpcRequest::GetMinimumBalanceForRentExemption => Value::Number(Number::from(20)),
RpcRequest::GetVersion => {
let version = Version::default();
json!(RpcVersionInfo {
solana_core: version.to_string(),
feature_set: Some(version.feature_set),
})
}
_ => Value::Null,
};
Ok(val)

View File

@ -1,4 +1,7 @@
use crate::rpc_response::{Response as RpcResponse, RpcSignatureResult, SlotInfo};
use crate::{
rpc_config::{RpcSignatureSubscribeConfig, RpcTransactionLogsConfig, RpcTransactionLogsFilter},
rpc_response::{Response as RpcResponse, RpcLogsResponse, RpcSignatureResult, SlotInfo},
};
use log::*;
use serde::de::DeserializeOwned;
use serde_json::{
@ -20,8 +23,6 @@ use thiserror::Error;
use tungstenite::{client::AutoStream, connect, Message, WebSocket};
use url::{ParseError, Url};
type PubsubSignatureResponse = PubsubClientSubscription<RpcResponse<RpcSignatureResult>>;
#[derive(Debug, Error)]
pub enum PubsubClientError {
#[error("url parse error")]
@ -33,8 +34,8 @@ pub enum PubsubClientError {
#[error("json parse error")]
JsonParseError(#[from] serde_json::error::Error),
#[error("unexpected message format")]
UnexpectedMessageError,
#[error("unexpected message format: {0}")]
UnexpectedMessageError(String),
}
pub struct PubsubClientSubscription<T>
@ -89,8 +90,11 @@ where
return Ok(x);
}
}
Err(PubsubClientError::UnexpectedMessageError)
// TODO: Add proper JSON RPC response/error handling...
Err(PubsubClientError::UnexpectedMessageError(format!(
"{:?}",
json_msg
)))
}
pub fn send_unsubscribe(&self) -> Result<(), PubsubClientError> {
@ -114,14 +118,18 @@ where
let message_text = &message.into_text().unwrap();
let json_msg: Map<String, Value> = serde_json::from_str(message_text)?;
if let Some(Object(value_1)) = json_msg.get("params") {
if let Some(value_2) = value_1.get("result") {
let x: T = serde_json::from_value::<T>(value_2.clone()).unwrap();
if let Some(Object(params)) = json_msg.get("params") {
if let Some(result) = params.get("result") {
let x: T = serde_json::from_value::<T>(result.clone()).unwrap();
return Ok(x);
}
}
Err(PubsubClientError::UnexpectedMessageError)
// TODO: Add proper JSON RPC response/error handling...
Err(PubsubClientError::UnexpectedMessageError(format!(
"{:?}",
json_msg
)))
}
pub fn shutdown(&mut self) -> std::thread::Result<()> {
@ -138,15 +146,79 @@ where
}
}
const SLOT_OPERATION: &str = "slot";
const SIGNATURE_OPERATION: &str = "signature";
pub type LogsSubscription = (
PubsubClientSubscription<RpcResponse<RpcLogsResponse>>,
Receiver<RpcResponse<RpcLogsResponse>>,
);
pub type SlotsSubscription = (PubsubClientSubscription<SlotInfo>, Receiver<SlotInfo>);
pub type SignatureSubscription = (
PubsubClientSubscription<RpcResponse<RpcSignatureResult>>,
Receiver<RpcResponse<RpcSignatureResult>>,
);
pub struct PubsubClient {}
impl PubsubClient {
pub fn slot_subscribe(
pub fn logs_subscribe(
url: &str,
) -> Result<(PubsubClientSubscription<SlotInfo>, Receiver<SlotInfo>), PubsubClientError> {
filter: RpcTransactionLogsFilter,
config: RpcTransactionLogsConfig,
) -> Result<LogsSubscription, PubsubClientError> {
let url = Url::parse(url)?;
let (socket, _response) = connect(url)?;
let (sender, receiver) = channel();
let socket = Arc::new(RwLock::new(socket));
let socket_clone = socket.clone();
let exit = Arc::new(AtomicBool::new(false));
let exit_clone = exit.clone();
let subscription_id =
PubsubClientSubscription::<RpcResponse<RpcLogsResponse>>::send_subscribe(
&socket_clone,
json!({
"jsonrpc":"2.0","id":1,"method":"logsSubscribe","params":[filter, config]
})
.to_string(),
)?;
let t_cleanup = std::thread::spawn(move || {
loop {
if exit_clone.load(Ordering::Relaxed) {
break;
}
match PubsubClientSubscription::read_message(&socket_clone) {
Ok(message) => match sender.send(message) {
Ok(_) => (),
Err(err) => {
info!("receive error: {:?}", err);
break;
}
},
Err(err) => {
info!("receive error: {:?}", err);
break;
}
}
}
info!("websocket - exited receive loop");
});
let result = PubsubClientSubscription {
message_type: PhantomData,
operation: "logs",
socket,
subscription_id,
t_cleanup: Some(t_cleanup),
exit,
};
Ok((result, receiver))
}
pub fn slot_subscribe(url: &str) -> Result<SlotsSubscription, PubsubClientError> {
let url = Url::parse(url)?;
let (socket, _response) = connect(url)?;
let (sender, receiver) = channel::<SlotInfo>();
@ -158,41 +230,37 @@ impl PubsubClient {
let subscription_id = PubsubClientSubscription::<SlotInfo>::send_subscribe(
&socket_clone,
json!({
"jsonrpc":"2.0","id":1,"method":format!("{}Subscribe", SLOT_OPERATION),"params":[]
"jsonrpc":"2.0","id":1,"method":"slotSubscribe","params":[]
})
.to_string(),
)
.unwrap();
)?;
let t_cleanup = std::thread::spawn(move || {
loop {
if exit_clone.load(Ordering::Relaxed) {
break;
}
let message: Result<SlotInfo, PubsubClientError> =
PubsubClientSubscription::read_message(&socket_clone);
if let Ok(msg) = message {
match sender.send(msg) {
match PubsubClientSubscription::read_message(&socket_clone) {
Ok(message) => match sender.send(message) {
Ok(_) => (),
Err(err) => {
info!("receive error: {:?}", err);
break;
}
},
Err(err) => {
info!("receive error: {:?}", err);
break;
}
} else {
info!("receive error: {:?}", message);
break;
}
}
info!("websocket - exited receive loop");
});
let result: PubsubClientSubscription<SlotInfo> = PubsubClientSubscription {
let result = PubsubClientSubscription {
message_type: PhantomData,
operation: SLOT_OPERATION,
operation: "slot",
socket,
subscription_id,
t_cleanup: Some(t_cleanup),
@ -205,16 +273,11 @@ impl PubsubClient {
pub fn signature_subscribe(
url: &str,
signature: &Signature,
) -> Result<
(
PubsubSignatureResponse,
Receiver<RpcResponse<RpcSignatureResult>>,
),
PubsubClientError,
> {
config: Option<RpcSignatureSubscribeConfig>,
) -> Result<SignatureSubscription, PubsubClientError> {
let url = Url::parse(url)?;
let (socket, _response) = connect(url)?;
let (sender, receiver) = channel::<RpcResponse<RpcSignatureResult>>();
let (sender, receiver) = channel();
let socket = Arc::new(RwLock::new(socket));
let socket_clone = socket.clone();
@ -223,10 +286,10 @@ impl PubsubClient {
let body = json!({
"jsonrpc":"2.0",
"id":1,
"method":format!("{}Subscribe", SIGNATURE_OPERATION),
"method":"signatureSubscribe",
"params":[
signature.to_string(),
{"enableReceivedNotification": true }
config
]
})
.to_string();
@ -234,8 +297,7 @@ impl PubsubClient {
PubsubClientSubscription::<RpcResponse<RpcSignatureResult>>::send_subscribe(
&socket_clone,
body,
)
.unwrap();
)?;
let t_cleanup = std::thread::spawn(move || {
loop {
@ -263,15 +325,14 @@ impl PubsubClient {
info!("websocket - exited receive loop");
});
let result: PubsubClientSubscription<RpcResponse<RpcSignatureResult>> =
PubsubClientSubscription {
message_type: PhantomData,
operation: SIGNATURE_OPERATION,
socket,
subscription_id,
t_cleanup: Some(t_cleanup),
exit,
};
let result = PubsubClientSubscription {
message_type: PhantomData,
operation: "signature",
socket,
subscription_id,
t_cleanup: Some(t_cleanup),
exit,
};
Ok((result, receiver))
}

View File

@ -8,7 +8,7 @@ use crate::{
RpcProgramAccountsConfig, RpcSendTransactionConfig, RpcSimulateTransactionConfig,
RpcTokenAccountsFilter,
},
rpc_request::{RpcError, RpcRequest, TokenAccountsFilter},
rpc_request::{RpcError, RpcRequest, RpcResponseErrorData, TokenAccountsFilter},
rpc_response::*,
rpc_sender::RpcSender,
};
@ -41,12 +41,15 @@ use solana_transaction_status::{
use solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY;
use std::{
net::SocketAddr,
sync::RwLock,
thread::sleep,
time::{Duration, Instant},
};
pub struct RpcClient {
sender: Box<dyn RpcSender + Send + Sync + 'static>,
commitment_config: CommitmentConfig,
default_cluster_transaction_encoding: RwLock<Option<UiTransactionEncoding>>,
}
fn serialize_encode_transaction(
@ -70,26 +73,41 @@ fn serialize_encode_transaction(
}
impl RpcClient {
pub fn new_sender<T: RpcSender + Send + Sync + 'static>(sender: T) -> Self {
fn new_sender<T: RpcSender + Send + Sync + 'static>(
sender: T,
commitment_config: CommitmentConfig,
) -> Self {
Self {
sender: Box::new(sender),
default_cluster_transaction_encoding: RwLock::new(None),
commitment_config,
}
}
pub fn new(url: String) -> Self {
Self::new_sender(HttpSender::new(url))
Self::new_with_commitment(url, CommitmentConfig::default())
}
pub fn new_with_commitment(url: String, commitment_config: CommitmentConfig) -> Self {
Self::new_sender(HttpSender::new(url), commitment_config)
}
pub fn new_with_timeout(url: String, timeout: Duration) -> Self {
Self::new_sender(HttpSender::new_with_timeout(url, timeout))
Self::new_sender(
HttpSender::new_with_timeout(url, timeout),
CommitmentConfig::default(),
)
}
pub fn new_mock(url: String) -> Self {
Self::new_sender(MockSender::new(url))
Self::new_sender(MockSender::new(url), CommitmentConfig::default())
}
pub fn new_mock_with_mocks(url: String, mocks: Mocks) -> Self {
Self::new_sender(MockSender::new_with_mocks(url, mocks))
Self::new_sender(
MockSender::new_with_mocks(url, mocks),
CommitmentConfig::default(),
)
}
pub fn new_socket(addr: SocketAddr) -> Self {
@ -103,10 +121,14 @@ impl RpcClient {
pub fn confirm_transaction(&self, signature: &Signature) -> ClientResult<bool> {
Ok(self
.confirm_transaction_with_commitment(signature, CommitmentConfig::default())?
.confirm_transaction_with_commitment(signature, self.commitment_config)?
.value)
}
pub fn commitment(&self) -> CommitmentConfig {
self.commitment_config
}
pub fn confirm_transaction_with_commitment(
&self,
signature: &Signature,
@ -125,7 +147,38 @@ impl RpcClient {
}
pub fn send_transaction(&self, transaction: &Transaction) -> ClientResult<Signature> {
self.send_transaction_with_config(transaction, RpcSendTransactionConfig::default())
self.send_transaction_with_config(
transaction,
RpcSendTransactionConfig {
preflight_commitment: Some(self.commitment_config.commitment),
..RpcSendTransactionConfig::default()
},
)
}
fn default_cluster_transaction_encoding(&self) -> Result<UiTransactionEncoding, RpcError> {
let default_cluster_transaction_encoding =
self.default_cluster_transaction_encoding.read().unwrap();
if let Some(encoding) = *default_cluster_transaction_encoding {
Ok(encoding)
} else {
drop(default_cluster_transaction_encoding);
let cluster_version = self.get_version().map_err(|e| {
RpcError::RpcRequestError(format!("cluster version query failed: {}", e))
})?;
let cluster_version =
semver::Version::parse(&cluster_version.solana_core).map_err(|e| {
RpcError::RpcRequestError(format!("failed to parse cluster version: {}", e))
})?;
// Prefer base64 since 1.3.16
let encoding = if cluster_version < semver::Version::new(1, 3, 16) {
UiTransactionEncoding::Base58
} else {
UiTransactionEncoding::Base64
};
*self.default_cluster_transaction_encoding.write().unwrap() = Some(encoding);
Ok(encoding)
}
}
pub fn send_transaction_with_config(
@ -133,12 +186,43 @@ impl RpcClient {
transaction: &Transaction,
config: RpcSendTransactionConfig,
) -> ClientResult<Signature> {
let encoding = config.encoding.unwrap_or(UiTransactionEncoding::Base58);
let encoding = if let Some(encoding) = config.encoding {
encoding
} else {
self.default_cluster_transaction_encoding()?
};
let config = RpcSendTransactionConfig {
encoding: Some(encoding),
..config
};
let serialized_encoded = serialize_encode_transaction(transaction, encoding)?;
let signature_base58_str: String = self.send(
let signature_base58_str: String = match self.send(
RpcRequest::SendTransaction,
json!([serialized_encoded, config]),
)?;
) {
Ok(signature_base58_str) => signature_base58_str,
Err(err) => {
if let ClientErrorKind::RpcError(RpcError::RpcResponseError {
code,
message,
data,
}) = &err.kind
{
debug!("{} {}", code, message);
if let RpcResponseErrorData::SendTransactionPreflightFailure(
RpcSimulateTransactionResult {
logs: Some(logs), ..
},
) = data
{
for (i, log) in logs.iter().enumerate() {
debug!("{:>3}: {}", i + 1, log);
}
}
}
return Err(err);
}
};
let signature = signature_base58_str
.parse::<Signature>()
@ -161,26 +245,34 @@ impl RpcClient {
pub fn simulate_transaction(
&self,
transaction: &Transaction,
sig_verify: bool,
) -> RpcResult<RpcSimulateTransactionResult> {
self.simulate_transaction_with_config(
transaction,
sig_verify,
RpcSimulateTransactionConfig::default(),
RpcSimulateTransactionConfig {
commitment: Some(self.commitment_config),
..RpcSimulateTransactionConfig::default()
},
)
}
pub fn simulate_transaction_with_config(
&self,
transaction: &Transaction,
sig_verify: bool,
config: RpcSimulateTransactionConfig,
) -> RpcResult<RpcSimulateTransactionResult> {
let encoding = config.encoding.unwrap_or(UiTransactionEncoding::Base58);
let encoding = if let Some(encoding) = config.encoding {
encoding
} else {
self.default_cluster_transaction_encoding()?
};
let config = RpcSimulateTransactionConfig {
encoding: Some(encoding),
..config
};
let serialized_encoded = serialize_encode_transaction(transaction, encoding)?;
self.send(
RpcRequest::SimulateTransaction,
json!([serialized_encoded, { "sigVerify": sig_verify }]),
json!([serialized_encoded, config]),
)
}
@ -188,7 +280,7 @@ impl RpcClient {
&self,
signature: &Signature,
) -> ClientResult<Option<transaction::Result<()>>> {
self.get_signature_status_with_commitment(signature, CommitmentConfig::default())
self.get_signature_status_with_commitment(signature, self.commitment_config)
}
pub fn get_signature_statuses(
@ -246,7 +338,7 @@ impl RpcClient {
}
pub fn get_slot(&self) -> ClientResult<Slot> {
self.get_slot_with_commitment(CommitmentConfig::default())
self.get_slot_with_commitment(self.commitment_config)
}
pub fn get_slot_with_commitment(
@ -264,7 +356,7 @@ impl RpcClient {
}
pub fn total_supply(&self) -> ClientResult<u64> {
self.total_supply_with_commitment(CommitmentConfig::default())
self.total_supply_with_commitment(self.commitment_config)
}
pub fn total_supply_with_commitment(
@ -282,7 +374,7 @@ impl RpcClient {
}
pub fn get_vote_accounts(&self) -> ClientResult<RpcVoteAccountStatus> {
self.get_vote_accounts_with_commitment(CommitmentConfig::default())
self.get_vote_accounts_with_commitment(self.commitment_config)
}
pub fn get_vote_accounts_with_commitment(
@ -292,6 +384,38 @@ impl RpcClient {
self.send(RpcRequest::GetVoteAccounts, json!([commitment_config]))
}
pub fn wait_for_max_stake(
&self,
commitment: CommitmentConfig,
max_stake_percent: f32,
) -> ClientResult<()> {
let mut current_percent;
loop {
let vote_accounts = self.get_vote_accounts_with_commitment(commitment)?;
let mut max = 0;
let total_active_stake = vote_accounts
.current
.iter()
.chain(vote_accounts.delinquent.iter())
.map(|vote_account| {
max = std::cmp::max(max, vote_account.activated_stake);
vote_account.activated_stake
})
.sum::<u64>();
current_percent = 100f32 * max as f32 / total_active_stake as f32;
if current_percent < max_stake_percent {
break;
}
info!(
"Waiting for stake to drop below {} current: {:.1}",
max_stake_percent, current_percent
);
sleep(Duration::from_secs(10));
}
Ok(())
}
pub fn get_cluster_nodes(&self) -> ClientResult<Vec<RpcContactInfo>> {
self.send(RpcRequest::GetClusterNodes, Value::Null)
}
@ -410,7 +534,7 @@ impl RpcClient {
}
pub fn get_epoch_info(&self) -> ClientResult<EpochInfo> {
self.get_epoch_info_with_commitment(CommitmentConfig::default())
self.get_epoch_info_with_commitment(self.commitment_config)
}
pub fn get_epoch_info_with_commitment(
@ -424,7 +548,7 @@ impl RpcClient {
&self,
slot: Option<Slot>,
) -> ClientResult<Option<RpcLeaderSchedule>> {
self.get_leader_schedule_with_commitment(slot, CommitmentConfig::default())
self.get_leader_schedule_with_commitment(slot, self.commitment_config)
}
pub fn get_leader_schedule_with_commitment(
@ -518,8 +642,10 @@ impl RpcClient {
}
}
/// Note that `get_account` returns `Err(..)` if the account does not exist whereas
/// `get_account_with_commitment` returns `Ok(None)` if the account does not exist.
pub fn get_account(&self, pubkey: &Pubkey) -> ClientResult<Account> {
self.get_account_with_commitment(pubkey, CommitmentConfig::default())?
self.get_account_with_commitment(pubkey, self.commitment_config)?
.value
.ok_or_else(|| RpcError::ForUser(format!("AccountNotFound: pubkey={}", pubkey)).into())
}
@ -567,7 +693,7 @@ impl RpcClient {
pub fn get_multiple_accounts(&self, pubkeys: &[Pubkey]) -> ClientResult<Vec<Option<Account>>> {
Ok(self
.get_multiple_accounts_with_commitment(pubkeys, CommitmentConfig::default())?
.get_multiple_accounts_with_commitment(pubkeys, self.commitment_config)?
.value)
}
@ -621,7 +747,7 @@ impl RpcClient {
/// Request the balance of the account `pubkey`.
pub fn get_balance(&self, pubkey: &Pubkey) -> ClientResult<u64> {
Ok(self
.get_balance_with_commitment(pubkey, CommitmentConfig::default())?
.get_balance_with_commitment(pubkey, self.commitment_config)?
.value)
}
@ -663,7 +789,7 @@ impl RpcClient {
/// Request the transaction count.
pub fn get_transaction_count(&self) -> ClientResult<u64> {
self.get_transaction_count_with_commitment(CommitmentConfig::default())
self.get_transaction_count_with_commitment(self.commitment_config)
}
pub fn get_transaction_count_with_commitment(
@ -675,7 +801,7 @@ impl RpcClient {
pub fn get_recent_blockhash(&self) -> ClientResult<(Hash, FeeCalculator)> {
let (blockhash, fee_calculator, _last_valid_slot) = self
.get_recent_blockhash_with_commitment(CommitmentConfig::default())?
.get_recent_blockhash_with_commitment(self.commitment_config)?
.value;
Ok((blockhash, fee_calculator))
}
@ -732,10 +858,7 @@ impl RpcClient {
blockhash: &Hash,
) -> ClientResult<Option<FeeCalculator>> {
Ok(self
.get_fee_calculator_for_blockhash_with_commitment(
blockhash,
CommitmentConfig::default(),
)?
.get_fee_calculator_for_blockhash_with_commitment(blockhash, self.commitment_config)?
.value)
}
@ -811,7 +934,7 @@ impl RpcClient {
pub fn get_token_account(&self, pubkey: &Pubkey) -> ClientResult<Option<UiTokenAccount>> {
Ok(self
.get_token_account_with_commitment(pubkey, CommitmentConfig::default())?
.get_token_account_with_commitment(pubkey, self.commitment_config)?
.value)
}
@ -872,7 +995,7 @@ impl RpcClient {
pub fn get_token_account_balance(&self, pubkey: &Pubkey) -> ClientResult<UiTokenAmount> {
Ok(self
.get_token_account_balance_with_commitment(pubkey, CommitmentConfig::default())?
.get_token_account_balance_with_commitment(pubkey, self.commitment_config)?
.value)
}
@ -896,7 +1019,7 @@ impl RpcClient {
.get_token_accounts_by_delegate_with_commitment(
delegate,
token_account_filter,
CommitmentConfig::default(),
self.commitment_config,
)?
.value)
}
@ -935,7 +1058,7 @@ impl RpcClient {
.get_token_accounts_by_owner_with_commitment(
owner,
token_account_filter,
CommitmentConfig::default(),
self.commitment_config,
)?
.value)
}
@ -967,7 +1090,7 @@ impl RpcClient {
pub fn get_token_supply(&self, mint: &Pubkey) -> ClientResult<UiTokenAmount> {
Ok(self
.get_token_supply_with_commitment(mint, CommitmentConfig::default())?
.get_token_supply_with_commitment(mint, self.commitment_config)?
.value)
}
@ -1048,7 +1171,7 @@ impl RpcClient {
/// Poll the server to confirm a transaction.
pub fn poll_for_signature(&self, signature: &Signature) -> ClientResult<()> {
self.poll_for_signature_with_commitment(signature, CommitmentConfig::default())
self.poll_for_signature_with_commitment(signature, self.commitment_config)
}
/// Poll the server to confirm a transaction.
@ -1156,10 +1279,9 @@ impl RpcClient {
&self,
transaction: &Transaction,
) -> ClientResult<Signature> {
self.send_and_confirm_transaction_with_spinner_and_config(
self.send_and_confirm_transaction_with_spinner_and_commitment(
transaction,
CommitmentConfig::default(),
RpcSendTransactionConfig::default(),
self.commitment_config,
)
}
@ -1171,7 +1293,10 @@ impl RpcClient {
self.send_and_confirm_transaction_with_spinner_and_config(
transaction,
commitment,
RpcSendTransactionConfig::default(),
RpcSendTransactionConfig {
preflight_commitment: Some(commitment.commitment),
..RpcSendTransactionConfig::default()
},
)
}
@ -1418,7 +1543,7 @@ mod tests {
let rpc_client = RpcClient::new_mock("succeeds".to_string());
let key = Keypair::new();
let to = Pubkey::new_rand();
let to = solana_sdk::pubkey::new_rand();
let blockhash = Hash::default();
let tx = system_transaction::transfer(&key, &to, 50, blockhash);
@ -1471,7 +1596,7 @@ mod tests {
let rpc_client = RpcClient::new_mock("succeeds".to_string());
let key = Keypair::new();
let to = Pubkey::new_rand();
let to = solana_sdk::pubkey::new_rand();
let blockhash = Hash::default();
let tx = system_transaction::transfer(&key, &to, 50, blockhash);
let result = rpc_client.send_and_confirm_transaction(&tx);

View File

@ -71,6 +71,21 @@ pub struct RpcProgramAccountsConfig {
pub account_config: RpcAccountInfoConfig,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum RpcTransactionLogsFilter {
All,
AllWithVotes,
Mentions(Vec<String>), // base58-encoded list of addresses
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RpcTransactionLogsConfig {
#[serde(flatten)]
pub commitment: Option<CommitmentConfig>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum RpcTokenAccountsFilter {

View File

@ -1,13 +1,16 @@
//! Implementation defined RPC server errors
use crate::rpc_response::RpcSimulateTransactionResult;
use jsonrpc_core::{Error, ErrorCode};
use solana_client::rpc_response::RpcSimulateTransactionResult;
use solana_sdk::clock::Slot;
const JSON_RPC_SERVER_ERROR_1: i64 = -32001;
const JSON_RPC_SERVER_ERROR_2: i64 = -32002;
const JSON_RPC_SERVER_ERROR_3: i64 = -32003;
const JSON_RPC_SERVER_ERROR_4: i64 = -32004;
const JSON_RPC_SERVER_ERROR_5: i64 = -32005;
const JSON_RPC_SERVER_ERROR_6: i64 = -32006;
pub const JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: i64 = -32001;
pub const JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: i64 = -32002;
pub const JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: i64 = -32003;
pub const JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: i64 = -32004;
pub const JSON_RPC_SERVER_ERROR_NODE_UNHEALTHLY: i64 = -32005;
pub const JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: i64 = -32006;
pub const JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: i64 = -32007;
pub enum RpcCustomError {
BlockCleanedUp {
@ -24,6 +27,9 @@ pub enum RpcCustomError {
},
RpcNodeUnhealthy,
TransactionPrecompileVerificationFailure(solana_sdk::transaction::TransactionError),
SlotSkipped {
slot: Slot,
},
}
impl From<RpcCustomError> for Error {
@ -33,7 +39,7 @@ impl From<RpcCustomError> for Error {
slot,
first_available_block,
} => Self {
code: ErrorCode::ServerError(JSON_RPC_SERVER_ERROR_1),
code: ErrorCode::ServerError(JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP),
message: format!(
"Block {} cleaned up, does not exist on node. First available block: {}",
slot, first_available_block,
@ -41,30 +47,44 @@ impl From<RpcCustomError> for Error {
data: None,
},
RpcCustomError::SendTransactionPreflightFailure { message, result } => Self {
code: ErrorCode::ServerError(JSON_RPC_SERVER_ERROR_2),
code: ErrorCode::ServerError(
JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE,
),
message,
data: Some(serde_json::json!(result)),
},
RpcCustomError::TransactionSignatureVerificationFailure => Self {
code: ErrorCode::ServerError(JSON_RPC_SERVER_ERROR_3),
code: ErrorCode::ServerError(
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE,
),
message: "Transaction signature verification failure".to_string(),
data: None,
},
RpcCustomError::BlockNotAvailable { slot } => Self {
code: ErrorCode::ServerError(JSON_RPC_SERVER_ERROR_4),
code: ErrorCode::ServerError(JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE),
message: format!("Block not available for slot {}", slot),
data: None,
},
RpcCustomError::RpcNodeUnhealthy => Self {
code: ErrorCode::ServerError(JSON_RPC_SERVER_ERROR_5),
code: ErrorCode::ServerError(JSON_RPC_SERVER_ERROR_NODE_UNHEALTHLY),
message: "RPC node is unhealthy".to_string(),
data: None,
},
RpcCustomError::TransactionPrecompileVerificationFailure(e) => Self {
code: ErrorCode::ServerError(JSON_RPC_SERVER_ERROR_6),
code: ErrorCode::ServerError(
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE,
),
message: format!("Transaction precompile verification failure {:?}", e),
data: None,
},
RpcCustomError::SlotSkipped { slot } => Self {
code: ErrorCode::ServerError(JSON_RPC_SERVER_ERROR_SLOT_SKIPPED),
message: format!(
"Slot {} was skipped, or missing due to ledger jump to recent snapshot",
slot
),
data: None,
},
}
}
}

View File

@ -1,3 +1,4 @@
use crate::rpc_response::RpcSimulateTransactionResult;
use serde_json::{json, Value};
use solana_sdk::pubkey::Pubkey;
use std::fmt;
@ -138,10 +139,42 @@ impl RpcRequest {
}
}
#[derive(Debug)]
pub enum RpcResponseErrorData {
Empty,
SendTransactionPreflightFailure(RpcSimulateTransactionResult),
}
impl fmt::Display for RpcResponseErrorData {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
RpcResponseErrorData::SendTransactionPreflightFailure(
RpcSimulateTransactionResult {
logs: Some(logs), ..
},
) => {
if logs.is_empty() {
Ok(())
} else {
// Give the user a hint that there is more useful logging information available...
write!(f, "[{} log messages]", logs.len())
}
}
_ => Ok(()),
}
}
}
#[derive(Debug, Error)]
pub enum RpcError {
#[error("rpc request error: {0}")]
#[error("RPC request error: {0}")]
RpcRequestError(String),
#[error("RPC response error {code}: {message} {data}")]
RpcResponseError {
code: i64,
message: String,
data: RpcResponseErrorData,
},
#[error("parse error: expected {0}")]
ParseError(String), /* "expected" */
// Anything in a `ForUser` needs to die. The caller should be
@ -226,7 +259,7 @@ mod tests {
// Test request with CommitmentConfig and params
let test_request = RpcRequest::GetTokenAccountsByOwner;
let mint = Pubkey::new_rand();
let mint = solana_sdk::pubkey::new_rand();
let token_account_filter = RpcTokenAccountsFilter::Mint(mint.to_string());
let request = test_request
.build_request_json(1, json!([addr, token_account_filter, commitment_config]));

View File

@ -108,6 +108,14 @@ pub enum RpcSignatureResult {
ReceivedSignature(ReceivedSignatureResult),
}
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct RpcLogsResponse {
pub signature: String, // Signature as base58 string
pub err: Option<TransactionError>,
pub logs: Vec<String>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct ProcessedSignatureResult {

View File

@ -3,7 +3,7 @@
//! messages to the network directly. The binary encoding of its messages are
//! unstable and may change in future releases.
use crate::{rpc_client::RpcClient, rpc_response::Response};
use crate::{rpc_client::RpcClient, rpc_config::RpcProgramAccountsConfig, rpc_response::Response};
use bincode::{serialize_into, serialized_size};
use log::*;
use solana_sdk::{
@ -276,6 +276,16 @@ impl ThinClient {
)
}
pub fn get_program_accounts_with_config(
&self,
pubkey: &Pubkey,
config: RpcProgramAccountsConfig,
) -> TransportResult<Vec<(Pubkey, Account)>> {
self.rpc_client()
.get_program_accounts_with_config(pubkey, config)
.map_err(|e| e.into())
}
pub fn wait_for_balance_with_commitment(
&self,
pubkey: &Pubkey,
@ -389,6 +399,12 @@ impl SyncClient for ThinClient {
.map(|r| r.value)
}
fn get_minimum_balance_for_rent_exemption(&self, data_len: usize) -> TransportResult<u64> {
self.rpc_client()
.get_minimum_balance_for_rent_exemption(data_len)
.map_err(|e| e.into())
}
fn get_recent_blockhash(&self) -> TransportResult<(Hash, FeeCalculator)> {
let (blockhash, fee_calculator, _last_valid_slot) =
self.get_recent_blockhash_with_commitment(CommitmentConfig::default())?;

View File

@ -1,7 +1,7 @@
[package]
name = "solana-core"
description = "Blockchain, Rebuilt for Scale"
version = "1.4.0"
version = "1.4.21"
documentation = "https://docs.rs/solana"
homepage = "https://solana.com/"
readme = "../README.md"
@ -14,6 +14,7 @@ edition = "2018"
codecov = { repository = "solana-labs/solana", branch = "master", service = "github" }
[dependencies]
ahash = "0.6.1"
base64 = "0.12.3"
bincode = "1.3.1"
bv = { version = "0.11.1", features = ["serde"] }
@ -34,53 +35,58 @@ jsonrpc-http-server = "15.0.0"
jsonrpc-pubsub = "15.0.0"
jsonrpc-ws-server = "15.0.0"
log = "0.4.8"
lru = "0.6.0"
miow = "0.2.2"
net2 = "0.2.37"
num_cpus = "1.13.0"
num-traits = "0.2"
rand = "0.7.0"
rand_chacha = "0.2.2"
raptorq = "1.4.2"
rayon = "1.4.0"
rayon = "1.4.1"
regex = "1.3.9"
serde = "1.0.112"
serde_derive = "1.0.103"
serde_json = "1.0.56"
solana-account-decoder = { path = "../account-decoder", version = "1.4.0" }
solana-banks-server = { path = "../banks-server", version = "1.4.0" }
solana-bpf-loader-program = { path = "../programs/bpf_loader", version = "1.4.0" }
solana-clap-utils = { path = "../clap-utils", version = "1.4.0" }
solana-client = { path = "../client", version = "1.4.0" }
solana-faucet = { path = "../faucet", version = "1.4.0" }
solana-ledger = { path = "../ledger", version = "1.4.0" }
solana-logger = { path = "../logger", version = "1.4.0" }
solana-merkle-tree = { path = "../merkle-tree", version = "1.4.0" }
solana-metrics = { path = "../metrics", version = "1.4.0" }
solana-measure = { path = "../measure", version = "1.4.0" }
solana-net-utils = { path = "../net-utils", version = "1.4.0" }
solana-perf = { path = "../perf", version = "1.4.0" }
solana-runtime = { path = "../runtime", version = "1.4.0" }
solana-sdk = { path = "../sdk", version = "1.4.0" }
solana-sdk-macro-frozen-abi = { path = "../sdk/macro-frozen-abi", version = "1.4.0" }
solana-stake-program = { path = "../programs/stake", version = "1.4.0" }
solana-storage-bigtable = { path = "../storage-bigtable", version = "1.4.0" }
solana-streamer = { path = "../streamer", version = "1.4.0" }
solana-sys-tuner = { path = "../sys-tuner", version = "1.4.0" }
solana-transaction-status = { path = "../transaction-status", version = "1.4.0" }
solana-version = { path = "../version", version = "1.4.0" }
solana-vote-program = { path = "../programs/vote", version = "1.4.0" }
solana-vote-signer = { path = "../vote-signer", version = "1.4.0" }
spl-token-v2-0 = { package = "spl-token", version = "=2.0.6", features = ["skip-no-mangle"] }
solana-account-decoder = { path = "../account-decoder", version = "1.4.21" }
solana-banks-server = { path = "../banks-server", version = "1.4.21" }
solana-clap-utils = { path = "../clap-utils", version = "1.4.21" }
solana-client = { path = "../client", version = "1.4.21" }
solana-faucet = { path = "../faucet", version = "1.4.21" }
solana-frozen-abi = { path = "../frozen-abi", version = "1.4.21" }
solana-frozen-abi-macro = { path = "../frozen-abi/macro", version = "1.4.21" }
solana-ledger = { path = "../ledger", version = "1.4.21" }
solana-logger = { path = "../logger", version = "1.4.21" }
solana-merkle-tree = { path = "../merkle-tree", version = "1.4.21" }
solana-metrics = { path = "../metrics", version = "1.4.21" }
solana-measure = { path = "../measure", version = "1.4.21" }
solana-net-utils = { path = "../net-utils", version = "1.4.21" }
solana-perf = { path = "../perf", version = "1.4.21" }
solana-runtime = { path = "../runtime", version = "1.4.21" }
solana-sdk = { path = "../sdk", version = "1.4.21" }
solana-stake-program = { path = "../programs/stake", version = "1.4.21" }
solana-storage-bigtable = { path = "../storage-bigtable", version = "1.4.21" }
solana-streamer = { path = "../streamer", version = "1.4.21" }
solana-sys-tuner = { path = "../sys-tuner", version = "1.4.21" }
solana-transaction-status = { path = "../transaction-status", version = "1.4.21" }
solana-version = { path = "../version", version = "1.4.21" }
solana-vote-program = { path = "../programs/vote", version = "1.4.21" }
solana-vote-signer = { path = "../vote-signer", version = "1.4.21" }
spl-token-v2-0 = { package = "spl-token", version = "=3.0.1", features = ["no-entrypoint"] }
tempfile = "3.1.0"
thiserror = "1.0"
tokio = { version = "0.2.22", features = ["full"] }
tokio = { version = "0.2", features = ["full"] }
tokio_01 = { version = "0.1", package = "tokio" }
tokio_01_bytes = { version = "0.4.7", package = "bytes" }
tokio_fs_01 = { version = "0.1", package = "tokio-fs" }
tokio_io_01 = { version = "0.1", package = "tokio-io" }
solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "1.4.0" }
tokio_codec_01 = { version = "0.1", package = "tokio-codec" }
solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "1.4.21" }
trees = "0.2.1"
[dev-dependencies]
matches = "0.1.6"
reqwest = { version = "0.10.6", default-features = false, features = ["blocking", "rustls-tls", "json"] }
reqwest = { version = "0.10.8", default-features = false, features = ["blocking", "rustls-tls", "json"] }
serial_test = "0.4.0"
serial_test_derive = "0.4.0"
systemstat = "0.1.5"
@ -94,6 +100,9 @@ name = "banking_stage"
[[bench]]
name = "blockstore"
[[bench]]
name = "crds"
[[bench]]
name = "crds_gossip_pull"

View File

@ -20,7 +20,7 @@ use solana_runtime::bank::Bank;
use solana_sdk::genesis_config::GenesisConfig;
use solana_sdk::hash::Hash;
use solana_sdk::message::Message;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::pubkey;
use solana_sdk::signature::Keypair;
use solana_sdk::signature::Signature;
use solana_sdk::signature::Signer;
@ -56,7 +56,7 @@ fn bench_consume_buffered(bencher: &mut Bencher) {
let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(100_000);
let bank = Arc::new(Bank::new(&genesis_config));
let ledger_path = get_tmp_ledger_path!();
let my_pubkey = Pubkey::new_rand();
let my_pubkey = pubkey::new_rand();
{
let blockstore = Arc::new(
Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"),
@ -94,15 +94,15 @@ fn bench_consume_buffered(bencher: &mut Bencher) {
}
fn make_accounts_txs(txes: usize, mint_keypair: &Keypair, hash: Hash) -> Vec<Transaction> {
let to_pubkey = Pubkey::new_rand();
let to_pubkey = pubkey::new_rand();
let dummy = system_transaction::transfer(mint_keypair, &to_pubkey, 1, hash);
(0..txes)
.into_par_iter()
.map(|_| {
let mut new = dummy.clone();
let sig: Vec<u8> = (0..64).map(|_| thread_rng().gen()).collect();
new.message.account_keys[0] = Pubkey::new_rand();
new.message.account_keys[1] = Pubkey::new_rand();
new.message.account_keys[0] = pubkey::new_rand();
new.message.account_keys[1] = pubkey::new_rand();
new.signatures = vec![Signature::new(&sig[0..64])];
new
})
@ -117,7 +117,7 @@ fn make_programs_txs(txes: usize, hash: Hash) -> Vec<Transaction> {
let mut instructions = vec![];
let from_key = Keypair::new();
for _ in 1..progs {
let to_key = Pubkey::new_rand();
let to_key = pubkey::new_rand();
instructions.push(system_instruction::transfer(&from_key.pubkey(), &to_key, 1));
}
let message = Message::new(&instructions, Some(&from_key.pubkey()));

View File

@ -8,7 +8,7 @@ use solana_core::broadcast_stage::{broadcast_shreds, get_broadcast_peers};
use solana_core::cluster_info::{ClusterInfo, Node};
use solana_core::contact_info::ContactInfo;
use solana_ledger::shred::Shred;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::pubkey;
use solana_sdk::timing::timestamp;
use std::{
collections::HashMap,
@ -20,7 +20,7 @@ use test::Bencher;
#[bench]
fn broadcast_shreds_bench(bencher: &mut Bencher) {
solana_logger::setup();
let leader_pubkey = Pubkey::new_rand();
let leader_pubkey = pubkey::new_rand();
let leader_info = Node::new_localhost_with_pubkey(&leader_pubkey);
let cluster_info = ClusterInfo::new_with_invalid_keypair(leader_info.info);
let socket = UdpSocket::bind("0.0.0.0:0").unwrap();
@ -30,7 +30,7 @@ fn broadcast_shreds_bench(bencher: &mut Bencher) {
let mut stakes = HashMap::new();
const NUM_PEERS: usize = 200;
for _ in 0..NUM_PEERS {
let id = Pubkey::new_rand();
let id = pubkey::new_rand();
let contact_info = ContactInfo::new_localhost(&id, timestamp());
cluster_info.insert_info(contact_info);
stakes.insert(id, thread_rng().gen_range(1, NUM_PEERS) as u64);

31
core/benches/crds.rs Normal file
View File

@ -0,0 +1,31 @@
#![feature(test)]
extern crate test;
use rand::{thread_rng, Rng};
use rayon::ThreadPoolBuilder;
use solana_core::crds::Crds;
use solana_core::crds_gossip_pull::CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS;
use solana_core::crds_value::CrdsValue;
use solana_sdk::pubkey::Pubkey;
use std::collections::HashMap;
use test::Bencher;
#[bench]
fn bench_find_old_labels(bencher: &mut Bencher) {
let thread_pool = ThreadPoolBuilder::new().build().unwrap();
let mut rng = thread_rng();
let mut crds = Crds::default();
let now = CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS + CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS / 1000;
std::iter::repeat_with(|| (CrdsValue::new_rand(&mut rng, None), rng.gen_range(0, now)))
.take(50_000)
.for_each(|(v, ts)| assert!(crds.insert(v, ts).is_ok()));
let mut timeouts = HashMap::new();
timeouts.insert(Pubkey::default(), CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS);
bencher.iter(|| {
let out = crds.find_old_labels(&thread_pool, now, &timeouts);
assert!(out.len() > 10);
assert!(out.len() < 250);
out
});
}

View File

@ -8,13 +8,13 @@ use solana_core::cluster_info::MAX_BLOOM_SIZE;
use solana_core::crds::Crds;
use solana_core::crds_gossip_pull::{CrdsFilter, CrdsGossipPull};
use solana_core::crds_value::CrdsValue;
use solana_sdk::hash::Hash;
use solana_sdk::hash;
use test::Bencher;
#[bench]
fn bench_hash_as_u64(bencher: &mut Bencher) {
let mut rng = thread_rng();
let hashes: Vec<_> = std::iter::repeat_with(|| Hash::new_rand(&mut rng))
let hashes: Vec<_> = std::iter::repeat_with(|| hash::new_rand(&mut rng))
.take(1000)
.collect();
bencher.iter(|| {
@ -34,12 +34,12 @@ fn bench_build_crds_filters(bencher: &mut Bencher) {
for _ in 0..50_000 {
crds_gossip_pull
.purged_values
.push_back((Hash::new_rand(&mut rng), rng.gen()));
.push_back((solana_sdk::hash::new_rand(&mut rng), rng.gen()));
}
let mut num_inserts = 0;
for _ in 0..90_000 {
if crds
.insert(CrdsValue::new_rand(&mut rng), rng.gen())
.insert(CrdsValue::new_rand(&mut rng, None), rng.gen())
.is_ok()
{
num_inserts += 1;

View File

@ -7,14 +7,14 @@ use solana_core::contact_info::ContactInfo;
use solana_core::crds::VersionedCrdsValue;
use solana_core::crds_shards::CrdsShards;
use solana_core::crds_value::{CrdsData, CrdsValue};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::pubkey;
use solana_sdk::timing::timestamp;
use test::Bencher;
const CRDS_SHARDS_BITS: u32 = 8;
fn new_test_crds_value() -> VersionedCrdsValue {
let data = CrdsData::ContactInfo(ContactInfo::new_localhost(&Pubkey::new_rand(), timestamp()));
let data = CrdsData::ContactInfo(ContactInfo::new_localhost(&pubkey::new_rand(), timestamp()));
VersionedCrdsValue::new(timestamp(), CrdsValue::new_unsigned(data))
}

View File

@ -7,14 +7,18 @@ use log::*;
use solana_core::cluster_info::{ClusterInfo, Node};
use solana_core::contact_info::ContactInfo;
use solana_core::retransmit_stage::retransmitter;
use solana_ledger::entry::Entry;
use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};
use solana_ledger::leader_schedule_cache::LeaderScheduleCache;
use solana_ledger::shred::Shredder;
use solana_measure::measure::Measure;
use solana_perf::packet::to_packets_chunked;
use solana_perf::test_tx::test_tx;
use solana_perf::packet::{Packet, Packets};
use solana_runtime::bank::Bank;
use solana_runtime::bank_forks::BankForks;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::hash::Hash;
use solana_sdk::pubkey;
use solana_sdk::signature::{Keypair, Signer};
use solana_sdk::system_transaction;
use solana_sdk::timing::timestamp;
use std::net::UdpSocket;
use std::sync::atomic::{AtomicUsize, Ordering};
@ -34,7 +38,7 @@ fn bench_retransmitter(bencher: &mut Bencher) {
const NUM_PEERS: usize = 4;
let mut peer_sockets = Vec::new();
for _ in 0..NUM_PEERS {
let id = Pubkey::new_rand();
let id = pubkey::new_rand();
let socket = UdpSocket::bind("0.0.0.0:0").unwrap();
let mut contact_info = ContactInfo::new_localhost(&id, timestamp());
contact_info.tvu = socket.local_addr().unwrap();
@ -63,14 +67,24 @@ fn bench_retransmitter(bencher: &mut Bencher) {
let leader_schedule_cache = Arc::new(LeaderScheduleCache::new_from_bank(&bank));
// To work reliably with higher values, this needs larger udp rmem size
let tx = test_tx();
const NUM_PACKETS: usize = 50;
let chunk_size = NUM_PACKETS / (4 * NUM_THREADS);
let batches = to_packets_chunked(
&std::iter::repeat(tx).take(NUM_PACKETS).collect::<Vec<_>>(),
chunk_size,
);
info!("batches: {}", batches.len());
let entries: Vec<_> = (0..5)
.map(|_| {
let keypair0 = Keypair::new();
let keypair1 = Keypair::new();
let tx0 =
system_transaction::transfer(&keypair0, &keypair1.pubkey(), 1, Hash::default());
Entry::new(&Hash::default(), 1, vec![tx0])
})
.collect();
let keypair = Arc::new(Keypair::new());
let slot = 0;
let parent = 0;
let shredder =
Shredder::new(slot, parent, 0.0, keypair, 0, 0).expect("Failed to create entry shredder");
let mut data_shreds = shredder.entries_to_shreds(&entries, true, 0).0;
let num_packets = data_shreds.len();
let retransmitter_handles = retransmitter(
Arc::new(sockets),
@ -80,6 +94,8 @@ fn bench_retransmitter(bencher: &mut Bencher) {
packet_receiver,
);
let mut index = 0;
let mut slot = 0;
let total = Arc::new(AtomicUsize::new(0));
bencher.iter(move || {
let peer_sockets1 = peer_sockets.clone();
@ -96,7 +112,7 @@ fn bench_retransmitter(bencher: &mut Bencher) {
while peer_sockets2[p].recv(&mut buf).is_ok() {
total2.fetch_add(1, Ordering::Relaxed);
}
if total2.load(Ordering::Relaxed) >= NUM_PACKETS {
if total2.load(Ordering::Relaxed) >= num_packets {
break;
}
info!("{} recv", total2.load(Ordering::Relaxed));
@ -107,9 +123,17 @@ fn bench_retransmitter(bencher: &mut Bencher) {
})
.collect();
for packets in batches.clone() {
packet_sender.send(packets).unwrap();
for shred in data_shreds.iter_mut() {
shred.set_slot(slot);
shred.set_index(index);
index += 1;
index %= 200;
let mut p = Packet::default();
shred.copy_to_packet(&mut p);
let _ = packet_sender.send(Packets::new(vec![p]));
}
slot += 1;
info!("sent...");
let mut join_time = Measure::start("join");

View File

@ -123,8 +123,14 @@ fn bench_shredder_coding(bencher: &mut Bencher) {
let symbol_count = MAX_DATA_SHREDS_PER_FEC_BLOCK as usize;
let data_shreds = make_shreds(symbol_count);
bencher.iter(|| {
Shredder::generate_coding_shreds(0, RECOMMENDED_FEC_RATE, &data_shreds[..symbol_count], 0)
.len();
Shredder::generate_coding_shreds(
0,
RECOMMENDED_FEC_RATE,
&data_shreds[..symbol_count],
0,
symbol_count,
)
.len();
})
}
@ -132,8 +138,13 @@ fn bench_shredder_coding(bencher: &mut Bencher) {
fn bench_shredder_decoding(bencher: &mut Bencher) {
let symbol_count = MAX_DATA_SHREDS_PER_FEC_BLOCK as usize;
let data_shreds = make_shreds(symbol_count);
let coding_shreds =
Shredder::generate_coding_shreds(0, RECOMMENDED_FEC_RATE, &data_shreds[..symbol_count], 0);
let coding_shreds = Shredder::generate_coding_shreds(
0,
RECOMMENDED_FEC_RATE,
&data_shreds[..symbol_count],
0,
symbol_count,
);
bencher.iter(|| {
Shredder::try_recovery(
coding_shreds[..].to_vec(),

View File

@ -1 +1 @@
../sdk/build.rs
../frozen-abi/build.rs

View File

@ -204,6 +204,7 @@ mod tests {
{
let message = make_accounts_hashes_message(&validator1, vec![(0, hash1)]).unwrap();
cluster_info.push_message(message);
cluster_info.flush_push_queue();
}
slot_to_hash.insert(0, hash2);
trusted_validators.insert(validator1.pubkey());
@ -253,7 +254,11 @@ mod tests {
0,
100,
);
// sleep for 1ms to create a newer timestmap for gossip entry
// otherwise the timestamp won't be newer.
std::thread::sleep(Duration::from_millis(1));
}
cluster_info.flush_push_queue();
let cluster_hashes = cluster_info
.get_accounts_hash_for_node(&keypair.pubkey(), |c| c.clone())
.unwrap();

View File

@ -1,151 +0,0 @@
use crate::{
consensus::{ComputedBankState, Tower},
fork_choice::ForkChoice,
progress_map::{ForkStats, ProgressMap},
};
use solana_runtime::{bank::Bank, bank_forks::BankForks};
use solana_sdk::timing;
use std::time::Instant;
use std::{
collections::{HashMap, HashSet},
sync::{Arc, RwLock},
};
#[derive(Default)]
pub struct BankWeightForkChoice {}
impl ForkChoice for BankWeightForkChoice {
fn compute_bank_stats(
&mut self,
bank: &Bank,
_tower: &Tower,
progress: &mut ProgressMap,
computed_bank_state: &ComputedBankState,
) {
let bank_slot = bank.slot();
// Only time progress map should be missing a bank slot
// is if this node was the leader for this slot as those banks
// are not replayed in replay_active_banks()
let parent_weight = bank
.parent()
.and_then(|b| progress.get(&b.slot()))
.map(|x| x.fork_stats.fork_weight)
.unwrap_or(0);
let stats = progress
.get_fork_stats_mut(bank_slot)
.expect("All frozen banks must exist in the Progress map");
let ComputedBankState { bank_weight, .. } = computed_bank_state;
stats.weight = *bank_weight;
stats.fork_weight = stats.weight + parent_weight;
}
// Returns:
// 1) The heaviest overall bank
// 2) The heaviest bank on the same fork as the last vote (doesn't require a
// switching proof to vote for)
fn select_forks(
&self,
frozen_banks: &[Arc<Bank>],
tower: &Tower,
progress: &ProgressMap,
ancestors: &HashMap<u64, HashSet<u64>>,
_bank_forks: &RwLock<BankForks>,
) -> (Arc<Bank>, Option<Arc<Bank>>) {
let tower_start = Instant::now();
assert!(!frozen_banks.is_empty());
let num_frozen_banks = frozen_banks.len();
trace!("frozen_banks {}", frozen_banks.len());
let num_old_banks = frozen_banks
.iter()
.filter(|b| b.slot() < tower.root().unwrap_or(0))
.count();
let last_voted_slot = tower.last_voted_slot();
let mut heaviest_bank_on_same_fork = None;
let mut heaviest_same_fork_weight = 0;
let stats: Vec<&ForkStats> = frozen_banks
.iter()
.map(|bank| {
// Only time progress map should be missing a bank slot
// is if this node was the leader for this slot as those banks
// are not replayed in replay_active_banks()
let stats = progress
.get_fork_stats(bank.slot())
.expect("All frozen banks must exist in the Progress map");
if let Some(last_voted_slot) = last_voted_slot {
if ancestors
.get(&bank.slot())
.expect("Entry in frozen banks must exist in ancestors")
.contains(&last_voted_slot)
{
// Descendant of last vote cannot be locked out
assert!(!stats.is_locked_out);
// ancestors(slot) should not contain the slot itself,
// so we should never get the same bank as the last vote
assert_ne!(bank.slot(), last_voted_slot);
// highest weight, lowest slot first. frozen_banks is sorted
// from least slot to greatest slot, so if two banks have
// the same fork weight, the lower slot will be picked
if stats.fork_weight > heaviest_same_fork_weight {
heaviest_bank_on_same_fork = Some(bank.clone());
heaviest_same_fork_weight = stats.fork_weight;
}
}
}
stats
})
.collect();
let num_not_recent = stats.iter().filter(|s| !s.is_recent).count();
let num_has_voted = stats.iter().filter(|s| s.has_voted).count();
let num_empty = stats.iter().filter(|s| s.is_empty).count();
let num_threshold_failure = stats.iter().filter(|s| !s.vote_threshold).count();
let num_votable_threshold_failure = stats
.iter()
.filter(|s| s.is_recent && !s.has_voted && !s.vote_threshold)
.count();
let mut candidates: Vec<_> = frozen_banks.iter().zip(stats.iter()).collect();
//highest weight, lowest slot first
candidates.sort_by_key(|b| (b.1.fork_weight, 0i64 - b.0.slot() as i64));
let rv = candidates
.last()
.expect("frozen banks was nonempty so candidates must also be nonempty");
let ms = timing::duration_as_ms(&tower_start.elapsed());
let weights: Vec<(u128, u64, u64)> = candidates
.iter()
.map(|x| (x.1.weight, x.0.slot(), x.1.block_height))
.collect();
debug!(
"@{:?} tower duration: {:?} len: {}/{} weights: {:?}",
timing::timestamp(),
ms,
candidates.len(),
stats.iter().filter(|s| !s.has_voted).count(),
weights,
);
datapoint_debug!(
"replay_stage-select_forks",
("frozen_banks", num_frozen_banks as i64, i64),
("not_recent", num_not_recent as i64, i64),
("has_voted", num_has_voted as i64, i64),
("old_banks", num_old_banks as i64, i64),
("empty_banks", num_empty as i64, i64),
("threshold_failure", num_threshold_failure as i64, i64),
(
"votable_threshold_failure",
num_votable_threshold_failure as i64,
i64
),
("tower_duration", ms as i64, i64),
);
(rv.0.clone(), heaviest_bank_on_same_fork)
}
}

View File

@ -4,7 +4,7 @@
use crate::{
cluster_info::ClusterInfo,
poh_recorder::{PohRecorder, PohRecorderError, WorkingBankEntry},
poh_service::PohService,
poh_service::{self, PohService},
};
use crossbeam_channel::{Receiver as CrossbeamReceiver, RecvTimeoutError};
use itertools::Itertools;
@ -23,7 +23,7 @@ use solana_perf::{
};
use solana_runtime::{
accounts_db::ErrorCounters,
bank::{Bank, TransactionBalancesSet, TransactionProcessResult},
bank::{Bank, TransactionBalancesSet, TransactionCheckResult, TransactionExecutionResult},
bank_utils,
transaction_batch::TransactionBatch,
vote_sender_types::ReplayVoteSender,
@ -53,7 +53,7 @@ type PacketsAndOffsets = (Packets, Vec<usize>);
pub type UnprocessedPackets = Vec<PacketsAndOffsets>;
/// Transaction forwarding
pub const FORWARD_TRANSACTIONS_TO_LEADER_AT_SLOT_OFFSET: u64 = 1;
pub const FORWARD_TRANSACTIONS_TO_LEADER_AT_SLOT_OFFSET: u64 = 2;
// Fixed thread size seems to be fastest on GCP setup
pub const NUM_THREADS: u32 = 4;
@ -460,7 +460,7 @@ impl BankingStage {
fn record_transactions(
bank_slot: Slot,
txs: &[Transaction],
results: &[TransactionProcessResult],
results: &[TransactionExecutionResult],
poh: &Arc<Mutex<PohRecorder>>,
) -> (Result<usize, PohRecorderError>, Vec<usize>) {
let mut processed_generation = Measure::start("record::process_generation");
@ -534,13 +534,14 @@ impl BankingStage {
mut loaded_accounts,
results,
inner_instructions,
transaction_logs,
mut retryable_txs,
tx_count,
signature_count,
) = bank.load_and_execute_transactions(
batch,
MAX_PROCESSING_AGE,
None,
transaction_status_sender.is_some(),
transaction_status_sender.is_some(),
);
load_execute_time.stop();
@ -577,9 +578,10 @@ impl BankingStage {
bank.clone(),
batch.transactions(),
batch.iteration_order_vec(),
tx_results.processing_results,
tx_results.execution_results,
TransactionBalancesSet::new(pre_balances, post_balances),
inner_instructions,
transaction_logs,
sender,
);
}
@ -717,7 +719,7 @@ impl BankingStage {
// This function returns a vector containing index of all valid transactions. A valid
// transaction has result Ok() as the value
fn filter_valid_transaction_indexes(
valid_txs: &[TransactionProcessResult],
valid_txs: &[TransactionCheckResult],
transaction_indexes: &[usize],
) -> Vec<usize> {
let valid_transactions = valid_txs
@ -1070,7 +1072,13 @@ pub fn create_test_recorder(
poh_recorder.set_bank(&bank);
let poh_recorder = Arc::new(Mutex::new(poh_recorder));
let poh_service = PohService::new(poh_recorder.clone(), &poh_config, &exit);
let poh_service = PohService::new(
poh_recorder.clone(),
&poh_config,
&exit,
bank.ticks_per_slot(),
poh_service::DEFAULT_PINNED_CPU_CORE,
);
(exit, poh_recorder, poh_service, entry_receiver)
}
@ -1091,7 +1099,6 @@ mod tests {
get_tmp_ledger_path,
};
use solana_perf::packet::to_packets;
use solana_runtime::bank::HashAgeKind;
use solana_sdk::{
instruction::InstructionError,
signature::{Keypair, Signer},
@ -1244,16 +1251,16 @@ mod tests {
bank.process_transaction(&fund_tx).unwrap();
// good tx
let to = Pubkey::new_rand();
let to = solana_sdk::pubkey::new_rand();
let tx = system_transaction::transfer(&mint_keypair, &to, 1, start_hash);
// good tx, but no verify
let to2 = Pubkey::new_rand();
let to2 = solana_sdk::pubkey::new_rand();
let tx_no_ver = system_transaction::transfer(&keypair, &to2, 2, start_hash);
// bad tx, AccountNotFound
let keypair = Keypair::new();
let to3 = Pubkey::new_rand();
let to3 = solana_sdk::pubkey::new_rand();
let tx_anf = system_transaction::transfer(&keypair, &to3, 1, start_hash);
// send 'em over
@ -1446,19 +1453,16 @@ mod tests {
let poh_recorder = Arc::new(Mutex::new(poh_recorder));
poh_recorder.lock().unwrap().set_working_bank(working_bank);
let pubkey = Pubkey::new_rand();
let pubkey = solana_sdk::pubkey::new_rand();
let keypair2 = Keypair::new();
let pubkey2 = Pubkey::new_rand();
let pubkey2 = solana_sdk::pubkey::new_rand();
let transactions = vec![
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_config.hash()),
system_transaction::transfer(&keypair2, &pubkey2, 1, genesis_config.hash()),
];
let mut results = vec![
(Ok(()), Some(HashAgeKind::Extant)),
(Ok(()), Some(HashAgeKind::Extant)),
];
let mut results = vec![(Ok(()), None), (Ok(()), None)];
let _ = BankingStage::record_transactions(
bank.slot(),
&transactions,
@ -1474,7 +1478,7 @@ mod tests {
1,
SystemError::ResultWithNegativeLamports.into(),
)),
Some(HashAgeKind::Extant),
None,
);
let (res, retryable) = BankingStage::record_transactions(
bank.slot(),
@ -1526,7 +1530,7 @@ mod tests {
mint_keypair,
..
} = create_genesis_config(10_000);
let pubkey = Pubkey::new_rand();
let pubkey = solana_sdk::pubkey::new_rand();
let transactions = vec![
None,
@ -1607,7 +1611,7 @@ mod tests {
mint_keypair,
..
} = create_genesis_config(10_000);
let pubkey = Pubkey::new_rand();
let pubkey = solana_sdk::pubkey::new_rand();
let transactions = vec![
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_config.hash()),
@ -1650,10 +1654,10 @@ mod tests {
&[
(Err(TransactionError::BlockhashNotFound), None),
(Err(TransactionError::BlockhashNotFound), None),
(Ok(()), Some(HashAgeKind::Extant)),
(Ok(()), None),
(Err(TransactionError::BlockhashNotFound), None),
(Ok(()), Some(HashAgeKind::Extant)),
(Ok(()), Some(HashAgeKind::Extant)),
(Ok(()), None),
(Ok(()), None),
],
&[2, 4, 5, 9, 11, 13]
),
@ -1663,12 +1667,12 @@ mod tests {
assert_eq!(
BankingStage::filter_valid_transaction_indexes(
&[
(Ok(()), Some(HashAgeKind::Extant)),
(Ok(()), None),
(Err(TransactionError::BlockhashNotFound), None),
(Err(TransactionError::BlockhashNotFound), None),
(Ok(()), Some(HashAgeKind::Extant)),
(Ok(()), Some(HashAgeKind::Extant)),
(Ok(()), Some(HashAgeKind::Extant)),
(Ok(()), None),
(Ok(()), None),
(Ok(()), None),
],
&[1, 6, 7, 9, 31, 43]
),
@ -1678,8 +1682,8 @@ mod tests {
#[test]
fn test_should_process_or_forward_packets() {
let my_pubkey = Pubkey::new_rand();
let my_pubkey1 = Pubkey::new_rand();
let my_pubkey = solana_sdk::pubkey::new_rand();
let my_pubkey1 = solana_sdk::pubkey::new_rand();
assert_eq!(
BankingStage::consume_or_forward_packets(&my_pubkey, None, true, false,),
@ -1725,7 +1729,7 @@ mod tests {
..
} = create_genesis_config(10_000);
let bank = Arc::new(Bank::new(&genesis_config));
let pubkey = Pubkey::new_rand();
let pubkey = solana_sdk::pubkey::new_rand();
let transactions = vec![system_transaction::transfer(
&mint_keypair,
@ -1822,8 +1826,8 @@ mod tests {
..
} = create_genesis_config(10_000);
let bank = Arc::new(Bank::new(&genesis_config));
let pubkey = Pubkey::new_rand();
let pubkey1 = Pubkey::new_rand();
let pubkey = solana_sdk::pubkey::new_rand();
let pubkey1 = solana_sdk::pubkey::new_rand();
let transactions = vec![
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_config.hash()),
@ -1918,7 +1922,7 @@ mod tests {
} = create_genesis_config(10_000);
let bank = Arc::new(Bank::new(&genesis_config));
let pubkey = Pubkey::new_rand();
let pubkey = solana_sdk::pubkey::new_rand();
let transactions =
vec![
@ -1936,7 +1940,7 @@ mod tests {
bank.slot(),
Some((4, 4)),
bank.ticks_per_slot(),
&Pubkey::new_rand(),
&solana_sdk::pubkey::new_rand(),
&Arc::new(blockstore),
&Arc::new(LeaderScheduleCache::new_from_bank(&bank)),
&Arc::new(PohConfig::default()),
@ -1976,8 +1980,8 @@ mod tests {
..
} = create_genesis_config(10_000);
let bank = Arc::new(Bank::new(&genesis_config));
let pubkey = Pubkey::new_rand();
let pubkey1 = Pubkey::new_rand();
let pubkey = solana_sdk::pubkey::new_rand();
let pubkey1 = solana_sdk::pubkey::new_rand();
let keypair1 = Keypair::new();
let success_tx =

View File

@ -140,13 +140,12 @@ impl BroadcastRun for BroadcastFakeShredsRun {
mod tests {
use super::*;
use crate::contact_info::ContactInfo;
use solana_sdk::pubkey::Pubkey;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
#[test]
fn test_tvu_peers_ordering() {
let cluster = ClusterInfo::new_with_invalid_keypair(ContactInfo::new_localhost(
&Pubkey::new_rand(),
&solana_sdk::pubkey::new_rand(),
0,
));
cluster.insert_info(ContactInfo::new_with_socketaddr(&SocketAddr::new(

View File

@ -92,7 +92,7 @@ mod tests {
let bank0 = Arc::new(Bank::new(&genesis_config));
let tx = system_transaction::transfer(
&mint_keypair,
&Pubkey::new_rand(),
&solana_sdk::pubkey::new_rand(),
1,
genesis_config.hash(),
);

View File

@ -1,44 +0,0 @@
use solana_runtime::{
bank::{Builtin, Builtins, Entrypoint},
feature_set,
};
use solana_sdk::{genesis_config::ClusterType, pubkey::Pubkey};
/// Builtin programs that are always available
fn genesis_builtins(cluster_type: ClusterType) -> Vec<Builtin> {
let builtins = if cluster_type != ClusterType::MainnetBeta {
vec![
solana_bpf_loader_deprecated_program!(),
solana_bpf_loader_program!(),
]
} else {
// Remove this `else` block and the `cluster_type` argument to this function once
// `feature_set::bpf_loader2_program::id()` is active on Mainnet Beta
vec![solana_bpf_loader_deprecated_program!()]
};
builtins
.into_iter()
.map(|b| Builtin::new(&b.0, b.1, Entrypoint::Loader(b.2)))
.collect()
}
/// Builtin programs activated dynamically by feature
fn feature_builtins() -> Vec<(Builtin, Pubkey)> {
let builtins = vec![(
solana_bpf_loader_program!(),
feature_set::bpf_loader2_program::id(),
)];
builtins
.into_iter()
.map(|(b, p)| (Builtin::new(&b.0, b.1, Entrypoint::Loader(b.2)), p))
.collect()
}
pub(crate) fn get(cluster_type: ClusterType) -> Builtins {
Builtins {
genesis_builtins: genesis_builtins(cluster_type),
feature_builtins: feature_builtins(),
}
}

View File

@ -2,7 +2,7 @@ use crossbeam_channel::{Receiver, RecvTimeoutError, Sender};
use solana_ledger::blockstore::Blockstore;
use solana_measure::measure::Measure;
use solana_runtime::bank::Bank;
use solana_sdk::timing::slot_duration_from_slots_per_year;
use solana_sdk::{feature_set, timing::slot_duration_from_slots_per_year};
use std::{
collections::HashMap,
sync::{
@ -60,13 +60,24 @@ impl CacheBlockTimeService {
}
fn cache_block_time(bank: Arc<Bank>, blockstore: &Arc<Blockstore>) {
let slot_duration = slot_duration_from_slots_per_year(bank.slots_per_year());
let epoch = bank.epoch_schedule().get_epoch(bank.slot());
let stakes = HashMap::new();
let stakes = bank.epoch_vote_accounts(epoch).unwrap_or(&stakes);
if bank
.feature_set
.is_active(&feature_set::timestamp_correction::id())
{
if let Err(e) = blockstore.cache_block_time(bank.slot(), bank.clock().unix_timestamp) {
error!("cache_block_time failed: slot {:?} {:?}", bank.slot(), e);
}
} else {
let slot_duration = slot_duration_from_slots_per_year(bank.slots_per_year());
let epoch = bank.epoch_schedule().get_epoch(bank.slot());
let stakes = HashMap::new();
let stakes = bank.epoch_vote_accounts(epoch).unwrap_or(&stakes);
if let Err(e) = blockstore.cache_block_time(bank.slot(), slot_duration, stakes) {
error!("cache_block_time failed: slot {:?} {:?}", bank.slot(), e);
if let Err(e) =
blockstore.cache_block_time_from_slot_entries(bank.slot(), slot_duration, stakes)
{
error!("cache_block_time failed: slot {:?} {:?}", bank.slot(), e);
}
}
}

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More