Compare commits
464 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f55e637796 | ||
|
7e57c5cefe | ||
|
f7a87291c3 | ||
|
20613d66f0 | ||
|
90faffdb92 | ||
|
8c989da683 | ||
|
b5305587ea | ||
|
a61d24bfa9 | ||
|
c162ac27dd | ||
|
2b22ef1650 | ||
|
456e300244 | ||
|
27948563f5 | ||
|
af91768a24 | ||
|
94102f4501 | ||
|
f53e0af159 | ||
|
227804c306 | ||
|
4fd298abd5 | ||
|
7a33ef1547 | ||
|
f4a2045876 | ||
|
dfabe35b27 | ||
|
75fec798bc | ||
|
0c4743df03 | ||
|
29f9c1e1f2 | ||
|
c4609d0b6d | ||
|
3b70849885 | ||
|
5979005454 | ||
|
27c8e7b905 | ||
|
3612964a58 | ||
|
495e237935 | ||
|
1757cb85a1 | ||
|
b10fb46a4b | ||
|
7045aa9760 | ||
|
e371681f53 | ||
|
e972db03bd | ||
|
a8f7a0c648 | ||
|
687254497c | ||
|
b8932ad0c8 | ||
|
1d4dbe0090 | ||
|
1f8e9c2364 | ||
|
ac07fb392d | ||
|
a492357964 | ||
|
e0bb26d9db | ||
|
d687dd9f13 | ||
|
4b649a71df | ||
|
388a285517 | ||
|
45c368d670 | ||
|
bf5609b4fc | ||
|
d8c0633f0f | ||
|
aebb8187a8 | ||
|
159722a960 | ||
|
c5b36cf18c | ||
|
fae90ff397 | ||
|
a91a106319 | ||
|
7c8debd14a | ||
|
9c64e5e3b1 | ||
|
e48ce1e682 | ||
|
2c239904cc | ||
|
9e459f0093 | ||
|
166251fccd | ||
|
ebbb106fb7 | ||
|
a018d78056 | ||
|
67daa6f01e | ||
|
d5aa648947 | ||
|
acfd72d7c4 | ||
|
096d9ce5c7 | ||
|
a8e522702c | ||
|
e3753186af | ||
|
82d9624736 | ||
|
6101c1d690 | ||
|
7b7b7be99c | ||
|
2b4af48537 | ||
|
2a842408bd | ||
|
755ccbc253 | ||
|
cf0de48dc0 | ||
|
d44058edc3 | ||
|
5496d52097 | ||
|
b4da705f97 | ||
|
75d334147c | ||
|
006d36dd95 | ||
|
8c9e17bbab | ||
|
42017ebe69 | ||
|
b34f179546 | ||
|
1afd1db4fc | ||
|
daba428a3d | ||
|
11f4443a7b | ||
|
a8eea4f42d | ||
|
18e7112608 | ||
|
857e44c147 | ||
|
bd0536c80f | ||
|
184e4253c7 | ||
|
5828d2cff7 | ||
|
eeb7503fb6 | ||
|
7e1aa02ce4 | ||
|
734e669581 | ||
|
81db361d77 | ||
|
97c3ff8a4f | ||
|
5f85ecd457 | ||
|
fb1985fe5e | ||
|
3296c13ef2 | ||
|
b8cc10749a | ||
|
c1f9a9a021 | ||
|
f88b0c4827 | ||
|
c3564203e9 | ||
|
de4e548105 | ||
|
8d67204123 | ||
|
99a01abfd7 | ||
|
973b00debb | ||
|
900139da3e | ||
|
d94ad7523b | ||
|
4e0dbd6a73 | ||
|
9ee69017dc | ||
|
7c956a87e5 | ||
|
0beb443d44 | ||
|
5d8ae9628c | ||
|
de76df0cbb | ||
|
a0190b4105 | ||
|
5255a6ebd2 | ||
|
8575514235 | ||
|
2a1946436b | ||
|
80649a9c3d | ||
|
ad74ba0eb0 | ||
|
fd41ad5d8f | ||
|
63855d5c2a | ||
|
00251f710e | ||
|
14bc623989 | ||
|
fb90fb3feb | ||
|
d6ca879d39 | ||
|
2dcde5281d | ||
|
e2626dad83 | ||
|
070fbeb69a | ||
|
497ec24754 | ||
|
1bda09bf0e | ||
|
7ca7f8604d | ||
|
e2b5f2dd9c | ||
|
3652bd57a9 | ||
|
5077d6bfb3 | ||
|
f0ee3e9deb | ||
|
babad39846 | ||
|
c15aa4a968 | ||
|
3124a88284 | ||
|
e76a2065e3 | ||
|
45f8e453a9 | ||
|
20f9c12855 | ||
|
4218414c87 | ||
|
60c91d386f | ||
|
e477501687 | ||
|
20463e141e | ||
|
e699462ed3 | ||
|
8b345f3258 | ||
|
56436a6271 | ||
|
805ea6f469 | ||
|
1db1d173fc | ||
|
11476038cd | ||
|
a669ef3abb | ||
|
dbbdfa1dbb | ||
|
768c6b4bef | ||
|
8bcc04c275 | ||
|
2fd822887f | ||
|
e2c8aa0847 | ||
|
9b049402c9 | ||
|
d0e1779893 | ||
|
929ffc5a4e | ||
|
1f63fb06f1 | ||
|
b49aa125c9 | ||
|
55836d133e | ||
|
277e402d55 | ||
|
0ab8312b23 | ||
|
bc4c5c5a97 | ||
|
1a9aa78129 | ||
|
798a6db915 | ||
|
0a4a3fd37e | ||
|
66242eab41 | ||
|
7f0d4f0656 | ||
|
acba8d6026 | ||
|
1ff9555099 | ||
|
72a13e2a72 | ||
|
74cdfc2213 | ||
|
7b8e5a9f47 | ||
|
80525ac862 | ||
|
c14f98c6fc | ||
|
c6edfc3944 | ||
|
b95c493d66 | ||
|
5871462241 | ||
|
53bb826375 | ||
|
c769bcc418 | ||
|
f06a4c7861 | ||
|
0cae099d12 | ||
|
4bc3653906 | ||
|
3e7050983a | ||
|
9f1bb75445 | ||
|
139bb32dba | ||
|
158f6f3725 | ||
|
e33f9ea6b5 | ||
|
473037db86 | ||
|
b0e14ea83c | ||
|
782a549613 | ||
|
c805f7dc4e | ||
|
782829152e | ||
|
da6f09afb8 | ||
|
004b1b9c3f | ||
|
2f8d0f88d6 | ||
|
177d241160 | ||
|
5323622842 | ||
|
c852923347 | ||
|
5dc4410d58 | ||
|
da4642d634 | ||
|
a264be1791 | ||
|
9aff121949 | ||
|
a7f4d1487a | ||
|
11e43e1654 | ||
|
82be47bc18 | ||
|
6498e4fbf6 | ||
|
9978971bd9 | ||
|
e28ac2c377 | ||
|
ef296aa7db | ||
|
43e7107f65 | ||
|
752fa29390 | ||
|
7bb7b42356 | ||
|
2a7fc744f9 | ||
|
90e3da0389 | ||
|
1a62bcee42 | ||
|
b83a4cae90 | ||
|
05ef21cd3b | ||
|
dfa27b04d7 | ||
|
880b04906e | ||
|
1fe0b1e516 | ||
|
f9fd4bd24c | ||
|
c55a11d160 | ||
|
92118de0e1 | ||
|
0d9802a2cd | ||
|
f6beede01b | ||
|
ff48ea20de | ||
|
dd9cb18d65 | ||
|
71932aed0a | ||
|
24dc6680e1 | ||
|
61d9d40e48 | ||
|
e9b40db319 | ||
|
316356861d | ||
|
e07c00710a | ||
|
bc47c80610 | ||
|
14baa511f0 | ||
|
e773faeb24 | ||
|
42847516a2 | ||
|
47e9a1ae4f | ||
|
549a154394 | ||
|
dca00d1bde | ||
|
45ce1b4f96 | ||
|
a9232c0633 | ||
|
3da254c745 | ||
|
9ba3ee9683 | ||
|
b0addba2a9 | ||
|
bb59525ff8 | ||
|
acd25124d4 | ||
|
d718ab2491 | ||
|
1860aacd1f | ||
|
d4bbb7f516 | ||
|
d1c0f4b4f1 | ||
|
b72b837ba2 | ||
|
fde85c96c0 | ||
|
121418dad2 | ||
|
f44f94fe23 | ||
|
55a4481022 | ||
|
e859ad37a8 | ||
|
1a28c7fc12 | ||
|
c706a07764 | ||
|
59568e5776 | ||
|
33ca8fa72a | ||
|
4bb66a81fb | ||
|
468c14b14f | ||
|
03e505897a | ||
|
5205eb382e | ||
|
b07b6e56fa | ||
|
bcc890e705 | ||
|
07d14f6f07 | ||
|
03b213e296 | ||
|
1bfce24c9f | ||
|
94b2565969 | ||
|
2896fdb603 | ||
|
50970bc8f9 | ||
|
10df45b173 | ||
|
d3b8129593 | ||
|
f7fb5aebac | ||
|
9311a6e356 | ||
|
8c706892df | ||
|
7f2b11756c | ||
|
f324547600 | ||
|
36e8977f1d | ||
|
b88db2689e | ||
|
1584ec220c | ||
|
fb366a7236 | ||
|
b903158543 | ||
|
9dad9c6333 | ||
|
a6658b9d75 | ||
|
a97feedcc1 | ||
|
8021bce41f | ||
|
d8fa19336c | ||
|
191483cf9f | ||
|
1eb8314d42 | ||
|
88eeb817e4 | ||
|
b777126bd2 | ||
|
89d78dcfcf | ||
|
1cf142c193 | ||
|
3e29325410 | ||
|
4dc98c3dbd | ||
|
9caad645e2 | ||
|
6cb76ac326 | ||
|
0001e5c0a1 | ||
|
ab32d13da1 | ||
|
cefe46e981 | ||
|
f4d70e78b6 | ||
|
d130adf582 | ||
|
1e6285e64e | ||
|
e3c90c3807 | ||
|
85750307aa | ||
|
0ee4a5e799 | ||
|
55cb9cf681 | ||
|
d3af7e0653 | ||
|
729a24d557 | ||
|
55b92c16da | ||
|
835bacce4f | ||
|
ccb7b1a698 | ||
|
85dbdeb4c3 | ||
|
397f9f11c5 | ||
|
a11986ad1d | ||
|
a4d373f0af | ||
|
52eea215ce | ||
|
6f48aafd3a | ||
|
2d94c09aee | ||
|
9699b61679 | ||
|
8865bfbd59 | ||
|
5f80c1d37d | ||
|
f616f5dec6 | ||
|
db1003b5f8 | ||
|
f52ff777b7 | ||
|
4314a29953 | ||
|
e560fff840 | ||
|
5ac747ea7d | ||
|
f522dc1e18 | ||
|
486812bf54 | ||
|
7df8f76df1 | ||
|
bbe4990e80 | ||
|
a5baaf790d | ||
|
0a36ed1b8c | ||
|
b7ad240375 | ||
|
2cc71f2d55 | ||
|
3125c74681 | ||
|
d5b1dee8d6 | ||
|
4b33a2a1b8 | ||
|
58e6a5c281 | ||
|
7eb61074ab | ||
|
9b2edbaa9b | ||
|
e8659b45c7 | ||
|
a9553cb401 | ||
|
800c409698 | ||
|
b6f484ddee | ||
|
3c39fee5a8 | ||
|
560f34d1f6 | ||
|
dbda50941a | ||
|
f1e68ac25c | ||
|
95029b9b05 | ||
|
a789bf4761 | ||
|
d2e7ffa8b9 | ||
|
0914519f6a | ||
|
43cd5f3730 | ||
|
d396a5f45a | ||
|
76a7071dba | ||
|
133baa8ce6 | ||
|
5df3510fde | ||
|
357339273f | ||
|
2500881e0b | ||
|
0013bfff4e | ||
|
f13498b428 | ||
|
b567138170 | ||
|
653982cae5 | ||
|
605f4906ba | ||
|
d27f24e312 | ||
|
c9c1cb5c9c | ||
|
1cc6493ccf | ||
|
ae47862be2 | ||
|
8590184df7 | ||
|
d840bbab08 | ||
|
63314de516 | ||
|
c47a6e12c7 | ||
|
7937c45ba4 | ||
|
813b11ac56 | ||
|
ad6883b66a | ||
|
a8f4c4e297 | ||
|
6d68e94e4e | ||
|
5dd40d7d88 | ||
|
3f58177670 | ||
|
edfd65b115 | ||
|
51da66ec84 | ||
|
ba36308d69 | ||
|
ee450b2dd0 | ||
|
84b28fb261 | ||
|
1586b86797 | ||
|
8f065e487e | ||
|
953eadd983 | ||
|
a4a792facd | ||
|
055f808f98 | ||
|
0404878445 | ||
|
053907f8a4 | ||
|
f76dcc1f05 | ||
|
823bc138cd | ||
|
18f746b025 | ||
|
c81adaf901 | ||
|
2d12ddd0f6 | ||
|
bee36cc8d0 | ||
|
f7aee67023 | ||
|
c021727009 | ||
|
6653136e1d | ||
|
06c40c807c | ||
|
9b262b4915 | ||
|
cc2d3ecfd7 | ||
|
92743499bf | ||
|
aa6a00a03e | ||
|
bd19f7c4cb | ||
|
988bf65ba4 | ||
|
d5b03bd824 | ||
|
6a72dab111 | ||
|
56e8319a6d | ||
|
aed1e51ef1 | ||
|
f4278d61df | ||
|
a5c3ae3cef | ||
|
05c052e212 | ||
|
dc05bb648a | ||
|
800b65b2f6 | ||
|
ae1a0f57c5 | ||
|
df7c44bd0c | ||
|
3e29cfd712 | ||
|
202031538f | ||
|
29ff1b925d | ||
|
5a91db6e62 | ||
|
94ba700e58 | ||
|
1964c6ec29 | ||
|
4dd6591bfd | ||
|
163217815b | ||
|
37c182cd5d | ||
|
0c68f27ac3 | ||
|
5fb8da9b35 | ||
|
74d9fd1e4f | ||
|
e71206c578 | ||
|
0141c80238 | ||
|
ed928cfdf7 | ||
|
2fd319ab7a | ||
|
7813a1decd | ||
|
93e4ed1f75 | ||
|
a70f31b3da | ||
|
2d25227d0a | ||
|
fc7bfd0f67 | ||
|
2996291b37 | ||
|
3e80b9231c | ||
|
78231a8682 | ||
|
ace711e7f1 | ||
|
c9cbc39ec9 | ||
|
606a392d50 | ||
|
c67596ceb4 | ||
|
9a42cc7555 | ||
|
2e5ef2a802 | ||
|
8c8e2c4b2b | ||
|
0578801f99 | ||
|
6141e1410a | ||
|
4fc86807ff | ||
|
d2a2eba69e |
9
.buildkite/env/secrets.ejson
vendored
9
.buildkite/env/secrets.ejson
vendored
@@ -1,7 +1,12 @@
|
|||||||
{
|
{
|
||||||
"_public_key": "ae29f4f7ad2fc92de70d470e411c8426d5d48db8817c9e3dae574b122192335f",
|
"_public_key": "ae29f4f7ad2fc92de70d470e411c8426d5d48db8817c9e3dae574b122192335f",
|
||||||
"_comment": "These credentials are encrypted and pose no risk",
|
|
||||||
"environment": {
|
"environment": {
|
||||||
"CODECOV_TOKEN": "EJ[1:Z7OneT3RdJJ0DipCHQ7rC84snQ+FPbgHwZADQiz54wk=:3K68mE38LJ2RB98VWmjuNLFBNn1XTGR4:cR4r05/TOZQKmEZp1v4CSgUJtC6QJiOaL85QjXW0qZ061fMnsBA8AtAPMDoDq4WCGOZM1A==]"
|
"CODECOV_TOKEN": "EJ[1:Z7OneT3RdJJ0DipCHQ7rC84snQ+FPbgHwZADQiz54wk=:3K68mE38LJ2RB98VWmjuNLFBNn1XTGR4:cR4r05/TOZQKmEZp1v4CSgUJtC6QJiOaL85QjXW0qZ061fMnsBA8AtAPMDoDq4WCGOZM1A==]",
|
||||||
|
"CRATES_IO_TOKEN": "EJ[1:Z7OneT3RdJJ0DipCHQ7rC84snQ+FPbgHwZADQiz54wk=:GGRTYDjMXksevzR6kq4Jx+FaIQZz50RU:xkbwDxcgoCyU+aT2tiI9mymigrEl6YiOr3axe3aX70ELIBKbCdPGilXP/wixvKi94g2u]",
|
||||||
|
"GEOLOCATION_API_KEY": "EJ[1:Z7OneT3RdJJ0DipCHQ7rC84snQ+FPbgHwZADQiz54wk=:U2PZLi5MU3Ru/zK1SilianEeizcMvxml:AJKf2OAtDHmJh0KyXrBnNnistItZvVVP3cZ7ZLtrVupjmWN/PzmKwSsXeCNObWS+]",
|
||||||
|
"GITHUB_TOKEN": "EJ[1:Z7OneT3RdJJ0DipCHQ7rC84snQ+FPbgHwZADQiz54wk=:0NJNlpD/O19mvOakCGBYDhIDfySxWFSC:Dz4NXv9x6ncRQ1u9sVoWOcqmkg0sI09qmefghB0GXZgPcFGgn6T0mw7ynNnbUvjyH8dLruKHauk=]",
|
||||||
|
"INFLUX_DATABASE": "EJ[1:Z7OneT3RdJJ0DipCHQ7rC84snQ+FPbgHwZADQiz54wk=:SzwHIeOVpmbTcGQOGngoFgYumsLZJUGq:t7Rpk49njsWvoM+ztv5Uwuiz]",
|
||||||
|
"INFLUX_PASSWORD": "EJ[1:Z7OneT3RdJJ0DipCHQ7rC84snQ+FPbgHwZADQiz54wk=:/MUs+q7pdGrUjzwcq+6pgIFxur4hxdqu:am22z2E2dtmw1f1J1Mq5JLcUHZsrEjQAJ0pp21M4AZeJbNO6bVb44d9zSkHj7xdN6U+GNlCk+wU=]",
|
||||||
|
"INFLUX_USERNAME": "EJ[1:Z7OneT3RdJJ0DipCHQ7rC84snQ+FPbgHwZADQiz54wk=:XjghH20xGVWro9B+epGlJaJcW8Wze0Bi:ZIdOtXudTY5TqKseDU7gVvQXfmXV99Xh]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,9 +31,4 @@ export CARGO_TARGET_CACHE=$HOME/cargo-target-cache/"$CHANNEL"-"$BUILDKITE_LABEL"
|
|||||||
|
|
||||||
mkdir -p "$CARGO_TARGET_CACHE"/target
|
mkdir -p "$CARGO_TARGET_CACHE"/target
|
||||||
rsync -a --delete --link-dest="$CARGO_TARGET_CACHE" "$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
|
|
||||||
)
|
)
|
||||||
|
@@ -9,10 +9,23 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
cd "$(dirname "$0")"/..
|
cd "$(dirname "$0")"/..
|
||||||
source ci/_
|
|
||||||
|
|
||||||
_ ci/buildkite-pipeline.sh pipeline.yml
|
if [[ -n $BUILDKITE_TAG ]]; then
|
||||||
echo +++ pipeline
|
buildkite-agent annotate --style info --context release-tag \
|
||||||
cat pipeline.yml
|
"https://github.com/solana-labs/solana/releases/$BUILDKITE_TAG"
|
||||||
|
buildkite-agent pipeline upload ci/buildkite-release.yml
|
||||||
|
else
|
||||||
|
if [[ $BUILDKITE_BRANCH =~ ^pull ]]; then
|
||||||
|
# Add helpful link back to the corresponding Github Pull Request
|
||||||
|
buildkite-agent annotate --style info --context pr-backlink \
|
||||||
|
"Github Pull Request: https://github.com/solana-labs/solana/$BUILDKITE_BRANCH"
|
||||||
|
fi
|
||||||
|
|
||||||
_ buildkite-agent pipeline upload pipeline.yml
|
if [[ $BUILDKITE_MESSAGE =~ GitBook: ]]; then
|
||||||
|
buildkite-agent annotate --style info --context gitbook-ci-skip \
|
||||||
|
"GitBook commit detected, CI skipped"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
buildkite-agent pipeline upload ci/buildkite.yml
|
||||||
|
fi
|
||||||
|
41
.github/dependabot.yml
vendored
41
.github/dependabot.yml
vendored
@@ -1,41 +0,0 @@
|
|||||||
# To get started with Dependabot version updates, you'll need to specify which
|
|
||||||
# package ecosystems to update and where the package manifests are located.
|
|
||||||
# Please see the documentation for all configuration options:
|
|
||||||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
||||||
|
|
||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: cargo
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: daily
|
|
||||||
time: "01:00"
|
|
||||||
timezone: America/Los_Angeles
|
|
||||||
#labels:
|
|
||||||
# - "automerge"
|
|
||||||
open-pull-requests-limit: 3
|
|
||||||
|
|
||||||
- package-ecosystem: npm
|
|
||||||
directory: "/web3.js"
|
|
||||||
schedule:
|
|
||||||
interval: daily
|
|
||||||
time: "01:00"
|
|
||||||
timezone: America/Los_Angeles
|
|
||||||
labels:
|
|
||||||
- "automerge"
|
|
||||||
commit-message:
|
|
||||||
prefix: "chore:"
|
|
||||||
open-pull-requests-limit: 3
|
|
||||||
|
|
||||||
- package-ecosystem: npm
|
|
||||||
directory: "/explorer"
|
|
||||||
schedule:
|
|
||||||
interval: daily
|
|
||||||
time: "01:00"
|
|
||||||
timezone: America/Los_Angeles
|
|
||||||
labels:
|
|
||||||
- "automerge"
|
|
||||||
commit-message:
|
|
||||||
prefix: "chore:"
|
|
||||||
include: "scope"
|
|
||||||
open-pull-requests-limit: 3
|
|
47
.github/stale.yml
vendored
47
.github/stale.yml
vendored
@@ -1,39 +1,24 @@
|
|||||||
|
only: pulls
|
||||||
|
|
||||||
|
# Number of days of inactivity before a pull request becomes stale
|
||||||
|
daysUntilStale: 7
|
||||||
|
|
||||||
|
# Number of days of inactivity before a stale pull request is closed
|
||||||
|
daysUntilClose: 7
|
||||||
|
|
||||||
# Issues with these labels will never be considered stale
|
# Issues with these labels will never be considered stale
|
||||||
exemptLabels:
|
exemptLabels:
|
||||||
- security
|
- security
|
||||||
- blocked
|
|
||||||
|
|
||||||
# Label to use when marking a pull request as stale
|
# Label to use when marking a pull request as stale
|
||||||
staleLabel: stale
|
staleLabel: stale
|
||||||
|
|
||||||
pulls:
|
# Comment to post when marking a pull request as stale. Set to `false` to disable
|
||||||
# Number of days of inactivity before a pull request becomes stale
|
markComment: >
|
||||||
daysUntilStale: 7
|
This pull request has been automatically marked as stale because it has not had
|
||||||
|
recent activity. It will be closed if no further activity occurs.
|
||||||
|
|
||||||
# Number of days of inactivity before a stale pull request is closed
|
# Comment to post when closing a stale pull request. Set to `false` to disable
|
||||||
daysUntilClose: 7
|
closeComment: >
|
||||||
# Comment to post when marking a pull request as stale. Set to `false` to disable
|
This stale pull request has been automatically closed.
|
||||||
markComment: >
|
Thank you for your contributions.
|
||||||
This pull request has been automatically marked as stale because it has not had
|
|
||||||
recent activity. It will be closed if no further activity occurs.
|
|
||||||
|
|
||||||
# Comment to post when closing a stale pull request. Set to `false` to disable
|
|
||||||
closeComment: >
|
|
||||||
This stale pull request has been automatically closed.
|
|
||||||
Thank you for your contributions.
|
|
||||||
|
|
||||||
issues:
|
|
||||||
# Number of days of inactivity before a issue becomes stale
|
|
||||||
daysUntilStale: 365
|
|
||||||
|
|
||||||
# Number of days of inactivity before a stale issue is closed
|
|
||||||
daysUntilClose: 7
|
|
||||||
# Comment to post when marking a issue as stale. Set to `false` to disable
|
|
||||||
markComment: >
|
|
||||||
This issue has been automatically marked as stale because it has not had
|
|
||||||
recent activity. It will be closed if no further activity occurs.
|
|
||||||
|
|
||||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
|
||||||
closeComment: >
|
|
||||||
This stale issue has been automatically closed.
|
|
||||||
Thank you for your contributions.
|
|
||||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
/config/
|
/config/
|
||||||
|
|
||||||
.cache
|
|
||||||
|
|
||||||
# log files
|
# log files
|
||||||
*.log
|
*.log
|
||||||
log-*.txt
|
log-*.txt
|
||||||
@@ -29,5 +27,3 @@ log-*/
|
|||||||
# fetch-spl.sh artifacts
|
# fetch-spl.sh artifacts
|
||||||
/spl-genesis-args.sh
|
/spl-genesis-args.sh
|
||||||
/spl_*.so
|
/spl_*.so
|
||||||
|
|
||||||
.DS_Store
|
|
||||||
|
30
.mergify.yml
30
.mergify.yml
@@ -7,7 +7,7 @@ pull_request_rules:
|
|||||||
- name: automatic merge (squash) on CI success
|
- name: automatic merge (squash) on CI success
|
||||||
conditions:
|
conditions:
|
||||||
- status-success=buildkite/solana
|
- status-success=buildkite/solana
|
||||||
- status-success=Travis CI - Pull Request
|
#- status-success=Travis CI - Pull Request
|
||||||
- status-success=ci-gate
|
- status-success=ci-gate
|
||||||
- label=automerge
|
- label=automerge
|
||||||
- author≠@dont-squash-my-commits
|
- author≠@dont-squash-my-commits
|
||||||
@@ -18,7 +18,7 @@ pull_request_rules:
|
|||||||
- name: automatic merge (rebase) on CI success
|
- name: automatic merge (rebase) on CI success
|
||||||
conditions:
|
conditions:
|
||||||
- status-success=buildkite/solana
|
- status-success=buildkite/solana
|
||||||
- status-success=Travis CI - Pull Request
|
#- status-success=Travis CI - Pull Request
|
||||||
- status-success=ci-gate
|
- status-success=ci-gate
|
||||||
- label=automerge
|
- label=automerge
|
||||||
- author=@dont-squash-my-commits
|
- author=@dont-squash-my-commits
|
||||||
@@ -50,35 +50,27 @@ pull_request_rules:
|
|||||||
label:
|
label:
|
||||||
add:
|
add:
|
||||||
- automerge
|
- automerge
|
||||||
- name: v1.3 backport
|
- name: v1.0 backport
|
||||||
conditions:
|
conditions:
|
||||||
- label=v1.3
|
- label=v1.0
|
||||||
actions:
|
actions:
|
||||||
backport:
|
backport:
|
||||||
ignore_conflicts: true
|
ignore_conflicts: true
|
||||||
branches:
|
branches:
|
||||||
- v1.3
|
- v1.0
|
||||||
- name: v1.4 backport
|
- name: v1.1 backport
|
||||||
conditions:
|
conditions:
|
||||||
- label=v1.4
|
- label=v1.1
|
||||||
actions:
|
actions:
|
||||||
backport:
|
backport:
|
||||||
ignore_conflicts: true
|
ignore_conflicts: true
|
||||||
branches:
|
branches:
|
||||||
- v1.4
|
- v1.1
|
||||||
- name: v1.5 backport
|
- name: v1.2 backport
|
||||||
conditions:
|
conditions:
|
||||||
- label=v1.5
|
- label=v1.2
|
||||||
actions:
|
actions:
|
||||||
backport:
|
backport:
|
||||||
ignore_conflicts: true
|
ignore_conflicts: true
|
||||||
branches:
|
branches:
|
||||||
- v1.5
|
- v1.2
|
||||||
- name: v1.6 backport
|
|
||||||
conditions:
|
|
||||||
- label=v1.6
|
|
||||||
actions:
|
|
||||||
backport:
|
|
||||||
ignore_conflicts: true
|
|
||||||
branches:
|
|
||||||
- v1.6
|
|
||||||
|
67
.travis.yml
67
.travis.yml
@@ -4,10 +4,8 @@ branches:
|
|||||||
- /^v\d+\.\d+/
|
- /^v\d+\.\d+/
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
|
||||||
slack:
|
slack:
|
||||||
on_success: change
|
on_success: change
|
||||||
if: NOT type = pull_request
|
|
||||||
secure: F4IjOE05MyaMOdPRL+r8qhs7jBvv4yDM3RmFKE1zNXnfUOqV4X38oQM1EI+YVsgpMQLj/pxnEB7wcTE4Bf86N6moLssEULCpvAuMVoXj4QbWdomLX+01WbFa6fLVeNQIg45NHrz2XzVBhoKOrMNnl+QI5mbR2AlS5oqsudHsXDnyLzZtd4Y5SDMdYG1zVWM01+oNNjgNfjcCGmOE/K0CnOMl6GPi3X9C34tJ19P2XT7MTDsz1/IfEF7fro2Q8DHEYL9dchJMoisXSkem5z7IDQkGzXsWdWT4NnndUvmd1MlTCE9qgoXDqRf95Qh8sB1Dz08HtvgfaosP2XjtNTfDI9BBYS15Ibw9y7PchAJE1luteNjF35EOy6OgmCLw/YpnweqfuNViBZz+yOPWXVC0kxnPIXKZ1wyH9ibeH6E4hr7a8o9SV/6SiWIlbYF+IR9jPXyTCLP/cc3sYljPWxDnhWFwFdRVIi3PbVAhVu7uWtVUO17Oc9gtGPgs/GrhOMkJfwQPXaudRJDpVZowxTX4x9kefNotlMAMRgq+Drbmgt4eEBiCNp0ITWgh17BiE1U09WS3myuduhoct85+FoVeaUkp1sxzHVtGsNQH0hcz7WcpZyOM+AwistJA/qzeEDQao5zi1eKWPbO2xAhi2rV1bDH6bPf/4lDBwLRqSiwvlWU=
|
secure: F4IjOE05MyaMOdPRL+r8qhs7jBvv4yDM3RmFKE1zNXnfUOqV4X38oQM1EI+YVsgpMQLj/pxnEB7wcTE4Bf86N6moLssEULCpvAuMVoXj4QbWdomLX+01WbFa6fLVeNQIg45NHrz2XzVBhoKOrMNnl+QI5mbR2AlS5oqsudHsXDnyLzZtd4Y5SDMdYG1zVWM01+oNNjgNfjcCGmOE/K0CnOMl6GPi3X9C34tJ19P2XT7MTDsz1/IfEF7fro2Q8DHEYL9dchJMoisXSkem5z7IDQkGzXsWdWT4NnndUvmd1MlTCE9qgoXDqRf95Qh8sB1Dz08HtvgfaosP2XjtNTfDI9BBYS15Ibw9y7PchAJE1luteNjF35EOy6OgmCLw/YpnweqfuNViBZz+yOPWXVC0kxnPIXKZ1wyH9ibeH6E4hr7a8o9SV/6SiWIlbYF+IR9jPXyTCLP/cc3sYljPWxDnhWFwFdRVIi3PbVAhVu7uWtVUO17Oc9gtGPgs/GrhOMkJfwQPXaudRJDpVZowxTX4x9kefNotlMAMRgq+Drbmgt4eEBiCNp0ITWgh17BiE1U09WS3myuduhoct85+FoVeaUkp1sxzHVtGsNQH0hcz7WcpZyOM+AwistJA/qzeEDQao5zi1eKWPbO2xAhi2rV1bDH6bPf/4lDBwLRqSiwvlWU=
|
||||||
|
|
||||||
os: linux
|
os: linux
|
||||||
@@ -16,17 +14,8 @@ language: minimal
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
include:
|
include:
|
||||||
- name: "Export Github Repositories"
|
|
||||||
if: type IN (push, cron) AND branch = master
|
|
||||||
language: python
|
|
||||||
git:
|
|
||||||
depth: false
|
|
||||||
script:
|
|
||||||
- .travis/export-github-repo.sh web3.js/ solana-web3.js
|
|
||||||
- .travis/export-github-repo.sh explorer/ explorer
|
|
||||||
|
|
||||||
- &release-artifacts
|
- &release-artifacts
|
||||||
if: type IN (api, cron) OR tag IS present
|
if: type = push
|
||||||
name: "macOS release artifacts"
|
name: "macOS release artifacts"
|
||||||
os: osx
|
os: osx
|
||||||
language: rust
|
language: rust
|
||||||
@@ -34,8 +23,6 @@ jobs:
|
|||||||
- stable
|
- stable
|
||||||
install:
|
install:
|
||||||
- source ci/rust-version.sh
|
- source ci/rust-version.sh
|
||||||
- PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
|
|
||||||
- readlink -f .
|
|
||||||
script:
|
script:
|
||||||
- source ci/env.sh
|
- source ci/env.sh
|
||||||
- ci/publish-tarball.sh
|
- ci/publish-tarball.sh
|
||||||
@@ -60,58 +47,8 @@ jobs:
|
|||||||
- <<: *release-artifacts
|
- <<: *release-artifacts
|
||||||
name: "Windows release artifacts"
|
name: "Windows release artifacts"
|
||||||
os: windows
|
os: windows
|
||||||
# Linux release artifacts are still built by ci/buildkite-secondary.yml
|
|
||||||
#- <<: *release-artifacts
|
|
||||||
# name: "Linux release artifacts"
|
|
||||||
# os: linux
|
|
||||||
# before_install:
|
|
||||||
# - sudo apt-get install libssl-dev libudev-dev
|
|
||||||
|
|
||||||
# explorer pull request
|
# docs pull request or commit
|
||||||
- name: "explorer"
|
|
||||||
if: type = pull_request AND branch = master
|
|
||||||
|
|
||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- "node"
|
|
||||||
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- ~/.npm
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- .travis/affects.sh explorer/ .travis || travis_terminate 0
|
|
||||||
- cd explorer
|
|
||||||
|
|
||||||
script:
|
|
||||||
- npm run build
|
|
||||||
- npm run format
|
|
||||||
|
|
||||||
# web3.js pull request
|
|
||||||
- name: "web3.js"
|
|
||||||
if: type = pull_request AND branch = master
|
|
||||||
|
|
||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- "lts/*"
|
|
||||||
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- ~/.npm
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- .travis/affects.sh web3.js/ .travis || travis_terminate 0
|
|
||||||
- cd web3.js/
|
|
||||||
- source .travis/before_install.sh
|
|
||||||
|
|
||||||
script:
|
|
||||||
- ../.travis/commitlint.sh
|
|
||||||
- source .travis/script.sh
|
|
||||||
|
|
||||||
# docs pull request
|
|
||||||
- name: "docs"
|
- name: "docs"
|
||||||
if: type IN (push, pull_request) OR tag IS present
|
if: type IN (push, pull_request) OR tag IS present
|
||||||
language: node_js
|
language: node_js
|
||||||
|
@@ -1,12 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# Only proceed if we are on one of the channels passed in, or a tag build
|
# Only proceed if we are on one of the channels passed in when calling this file
|
||||||
#
|
#
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
[[ -n $CI_TAG ]] && exit 0
|
|
||||||
|
|
||||||
eval "$(ci/channel-info.sh)"
|
eval "$(ci/channel-info.sh)"
|
||||||
|
|
||||||
for acceptable_channel in "$@"; do
|
for acceptable_channel in "$@"; do
|
||||||
|
@@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# Runs commitlint in the provided subdirectory
|
|
||||||
#
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
basedir=$1
|
|
||||||
if [[ -z "$basedir" ]]; then
|
|
||||||
basedir=.
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -d "$basedir" ]]; then
|
|
||||||
echo "Error: not a directory: $basedir"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -f "$basedir"/commitlint.config.js ]]; then
|
|
||||||
echo "Error: No commitlint configuration found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z $TRAVIS_COMMIT_RANGE ]]; then
|
|
||||||
echo "Error: TRAVIS_COMMIT_RANGE not defined"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "$basedir"
|
|
||||||
echo "Checking commits in TRAVIS_COMMIT_RANGE: $TRAVIS_COMMIT_RANGE"
|
|
||||||
while IFS= read -r line; do
|
|
||||||
echo "$line" | npx commitlint
|
|
||||||
done < <(git log "$TRAVIS_COMMIT_RANGE" --format=%s -- .)
|
|
@@ -1,34 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# Exports a subdirectory into another github repository
|
|
||||||
#
|
|
||||||
|
|
||||||
set -e
|
|
||||||
if [[ -z $GITHUB_TOKEN ]]; then
|
|
||||||
echo GITHUB_TOKEN not defined
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "$(dirname "$0")/.."
|
|
||||||
|
|
||||||
pip3 install git-filter-repo
|
|
||||||
|
|
||||||
declare subdir=$1
|
|
||||||
declare repo_name=$2
|
|
||||||
|
|
||||||
[[ -n "$subdir" ]] || {
|
|
||||||
echo "Error: subdir not specified"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
[[ -n "$repo_name" ]] || {
|
|
||||||
echo "Error: repo_name not specified"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Exporting $subdir"
|
|
||||||
|
|
||||||
set -x
|
|
||||||
rm -rf .github_export/"$repo_name"
|
|
||||||
git clone https://"$GITHUB_TOKEN"@github.com/solana-labs/"$repo_name" .github_export/"$repo_name"
|
|
||||||
git filter-repo --subdirectory-filter "$subdir" --target .github_export/"$repo_name"
|
|
||||||
git -C .github_export/"$repo_name" push https://"$GITHUB_TOKEN"@github.com/solana-labs/"$repo_name"
|
|
@@ -232,7 +232,7 @@ confused with 3-letter acronyms.
|
|||||||
Solana's architecture is described by docs generated from markdown files in
|
Solana's architecture is described by docs generated from markdown files in
|
||||||
the `docs/src/` directory, maintained by an *editor* (currently @garious). To
|
the `docs/src/` directory, maintained by an *editor* (currently @garious). To
|
||||||
add a design proposal, you'll need to include it in the
|
add a design proposal, you'll need to include it in the
|
||||||
[Accepted Design Proposals](https://docs.solana.com/proposals/accepted-design-proposals)
|
[Accepted Design Proposals](https://docs.solana.com/proposals)
|
||||||
section of the Solana docs. Here's the full process:
|
section of the Solana docs. Here's the full process:
|
||||||
|
|
||||||
1. Propose a design by creating a PR that adds a markdown document to the
|
1. Propose a design by creating a PR that adds a markdown document to the
|
||||||
|
2497
Cargo.lock
generated
2497
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
16
Cargo.toml
16
Cargo.toml
@@ -5,10 +5,6 @@ members = [
|
|||||||
"bench-tps",
|
"bench-tps",
|
||||||
"accounts-bench",
|
"accounts-bench",
|
||||||
"banking-bench",
|
"banking-bench",
|
||||||
"banks-client",
|
|
||||||
"banks-interface",
|
|
||||||
"banks-server",
|
|
||||||
"clap-utils",
|
|
||||||
"cli-config",
|
"cli-config",
|
||||||
"cli-output",
|
"cli-output",
|
||||||
"client",
|
"client",
|
||||||
@@ -16,10 +12,10 @@ members = [
|
|||||||
"dos",
|
"dos",
|
||||||
"download-utils",
|
"download-utils",
|
||||||
"faucet",
|
"faucet",
|
||||||
"frozen-abi",
|
|
||||||
"perf",
|
"perf",
|
||||||
"validator",
|
"validator",
|
||||||
"genesis",
|
"genesis",
|
||||||
|
"genesis-programs",
|
||||||
"gossip",
|
"gossip",
|
||||||
"install",
|
"install",
|
||||||
"keygen",
|
"keygen",
|
||||||
@@ -31,17 +27,15 @@ members = [
|
|||||||
"merkle-tree",
|
"merkle-tree",
|
||||||
"stake-o-matic",
|
"stake-o-matic",
|
||||||
"storage-bigtable",
|
"storage-bigtable",
|
||||||
"storage-proto",
|
|
||||||
"streamer",
|
"streamer",
|
||||||
"measure",
|
"measure",
|
||||||
"metrics",
|
"metrics",
|
||||||
"net-shaper",
|
"net-shaper",
|
||||||
"notifier",
|
"notifier",
|
||||||
"poh-bench",
|
|
||||||
"program-test",
|
|
||||||
"programs/secp256k1",
|
|
||||||
"programs/bpf_loader",
|
"programs/bpf_loader",
|
||||||
"programs/budget",
|
"programs/budget",
|
||||||
|
"programs/btc_spv",
|
||||||
|
"programs/btc_spv_bin",
|
||||||
"programs/config",
|
"programs/config",
|
||||||
"programs/exchange",
|
"programs/exchange",
|
||||||
"programs/failure",
|
"programs/failure",
|
||||||
@@ -53,10 +47,7 @@ members = [
|
|||||||
"remote-wallet",
|
"remote-wallet",
|
||||||
"ramp-tps",
|
"ramp-tps",
|
||||||
"runtime",
|
"runtime",
|
||||||
"runtime/store-tool",
|
|
||||||
"sdk",
|
"sdk",
|
||||||
"sdk/cargo-build-bpf",
|
|
||||||
"sdk/cargo-test-bpf",
|
|
||||||
"scripts",
|
"scripts",
|
||||||
"stake-accounts",
|
"stake-accounts",
|
||||||
"stake-monitor",
|
"stake-monitor",
|
||||||
@@ -67,6 +58,7 @@ members = [
|
|||||||
"upload-perf",
|
"upload-perf",
|
||||||
"net-utils",
|
"net-utils",
|
||||||
"version",
|
"version",
|
||||||
|
"vote-signer",
|
||||||
"cli",
|
"cli",
|
||||||
"rayon-threadlimit",
|
"rayon-threadlimit",
|
||||||
"watchtower",
|
"watchtower",
|
||||||
|
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
|||||||
Copyright 2020 Solana Foundation.
|
Copyright 2018 Solana Labs, Inc.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
13
README.md
13
README.md
@@ -19,7 +19,7 @@ $ source $HOME/.cargo/env
|
|||||||
$ rustup component add rustfmt
|
$ rustup component add rustfmt
|
||||||
```
|
```
|
||||||
|
|
||||||
Please sure you are always using the latest stable rust version by running:
|
If your rustc version is lower than 1.39.0, please update it:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ rustup update
|
$ rustup update
|
||||||
@@ -29,7 +29,7 @@ On Linux systems you may need to install libssl-dev, pkg-config, zlib1g-dev, etc
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ sudo apt-get update
|
$ sudo apt-get update
|
||||||
$ sudo apt-get install libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang make
|
$ sudo apt-get install libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang
|
||||||
```
|
```
|
||||||
|
|
||||||
## **2. Download the source code.**
|
## **2. Download the source code.**
|
||||||
@@ -59,11 +59,10 @@ $ cargo test
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Starting a local testnet
|
### Starting a local testnet
|
||||||
Start your own testnet locally, instructions are in the [online docs](https://docs.solana.com/cluster/bench-tps).
|
Start your own testnet locally, instructions are in the [online docs](https://docs.solana.com/bench-tps).
|
||||||
|
|
||||||
### Accessing the remote development cluster
|
### Accessing the remote testnet
|
||||||
* `devnet` - stable public cluster for development accessible via
|
* `testnet` - public stable testnet accessible via devnet.solana.com. Runs 24/7
|
||||||
devnet.solana.com. Runs 24/7. Learn more about the [public clusters](https://docs.solana.com/clusters)
|
|
||||||
|
|
||||||
# Benchmarking
|
# Benchmarking
|
||||||
|
|
||||||
@@ -108,5 +107,3 @@ send us that patch!
|
|||||||
# Disclaimer
|
# Disclaimer
|
||||||
|
|
||||||
All claims, content, designs, algorithms, estimates, roadmaps, specifications, and performance measurements described in this project are done with the author's best effort. It is up to the reader to check and validate their accuracy and truthfulness. Furthermore nothing in this project constitutes a solicitation for investment.
|
All claims, content, designs, algorithms, estimates, roadmaps, specifications, and performance measurements described in this project are done with the author's best effort. It is up to the reader to check and validate their accuracy and truthfulness. Furthermore nothing in this project constitutes a solicitation for investment.
|
||||||
|
|
||||||
Any content produced by Solana, or developer resources that Solana provides, are for educational and inspiration purposes only. Solana does not encourage, induce or sanction the deployment of any such applications in violation of applicable laws or regulations.
|
|
||||||
|
106
RELEASE.md
106
RELEASE.md
@@ -76,20 +76,21 @@ There are three release channels that map to branches as follows:
|
|||||||
git push -u origin <branchname>
|
git push -u origin <branchname>
|
||||||
```
|
```
|
||||||
|
|
||||||
Alternatively use the Github UI.
|
### Update master branch with the next version
|
||||||
|
|
||||||
### Update master branch to the next release minor version
|
|
||||||
|
|
||||||
1. After the new branch has been created and pushed, update the Cargo.toml files on **master** to the next semantic version (e.g. 0.9.0 -> 0.10.0) with:
|
1. After the new branch has been created and pushed, update the Cargo.toml files on **master** to the next semantic version (e.g. 0.9.0 -> 0.10.0) with:
|
||||||
```
|
```
|
||||||
$ scripts/increment-cargo-version.sh minor
|
scripts/increment-cargo-version.sh minor
|
||||||
$ ./scripts/cargo-for-all-lock-files.sh update
|
|
||||||
```
|
```
|
||||||
|
1. Rebuild to get an updated version of `Cargo.lock`:
|
||||||
|
```
|
||||||
|
cargo build
|
||||||
|
```
|
||||||
1. Push all the changed Cargo.toml and Cargo.lock files to the `master` branch with something like:
|
1. Push all the changed Cargo.toml and Cargo.lock files to the `master` branch with something like:
|
||||||
```
|
```
|
||||||
git co -b version_update
|
git co -b version_update
|
||||||
git ls-files -m | xargs git add
|
git ls-files -m | xargs git add
|
||||||
git commit -m 'Bump version to X.Y+1.0'
|
git commit -m 'Update Cargo.toml versions from X.Y to X.Y+1'
|
||||||
git push -u origin version_update
|
git push -u origin version_update
|
||||||
```
|
```
|
||||||
1. Confirm that your freshly cut release branch is shown as `BETA_CHANNEL` and the previous release branch as `STABLE_CHANNEL`:
|
1. Confirm that your freshly cut release branch is shown as `BETA_CHANNEL` and the previous release branch as `STABLE_CHANNEL`:
|
||||||
@@ -101,22 +102,15 @@ Alternatively use the Github UI.
|
|||||||
|
|
||||||
### Create the Release Tag on GitHub
|
### Create the Release Tag on GitHub
|
||||||
|
|
||||||
1. Go to [GitHub Releases](https://github.com/solana-labs/solana/releases) for tagging a release.
|
1. Go to [GitHub's Releases UI](https://github.com/solana-labs/solana/releases) for tagging a release.
|
||||||
1. Click "Draft new release". The release tag must exactly match the `version`
|
1. Click "Draft new release". The release tag must exactly match the `version`
|
||||||
field in `/Cargo.toml` prefixed by `v`.
|
field in `/Cargo.toml` prefixed by `v`.
|
||||||
1. If the Cargo.toml version field is **0.12.3**, then the release tag must be **v0.12.3**
|
1. If the Cargo.toml verion field is **0.12.3**, then the release tag must be **v0.12.3**
|
||||||
1. Make sure the Target Branch field matches the branch you want to make a release on.
|
1. Make sure the Target Branch field matches the branch you want to make a release on.
|
||||||
1. If you want to release v0.12.0, the target branch must be v0.12
|
1. If you want to release v0.12.0, the target branch must be v0.12
|
||||||
1. Fill the release notes.
|
1. If this is the first release on the branch (e.g. v0.13.**0**), paste in [this
|
||||||
1. If this is the first release on the branch (e.g. v0.13.**0**), paste in [this
|
|
||||||
template](https://raw.githubusercontent.com/solana-labs/solana/master/.github/RELEASE_TEMPLATE.md). Engineering Lead can provide summary contents for release notes if needed.
|
template](https://raw.githubusercontent.com/solana-labs/solana/master/.github/RELEASE_TEMPLATE.md). Engineering Lead can provide summary contents for release notes if needed.
|
||||||
1. If this is a patch release, review all the commits since the previous release on this branch and add details as needed.
|
1. Click "Save Draft", then confirm the release notes look good and the tag name and branch are correct. Go back into edit the release and click "Publish release" when ready.
|
||||||
1. Click "Save Draft", then confirm the release notes look good and the tag name and branch are correct.
|
|
||||||
1. Ensure all desired commits (usually backports) are landed on the branch by now.
|
|
||||||
1. Ensure the release is marked **"This is a pre-release"**. This flag will need to be be removed manually after confirming the the Linux binary artifacts appear at a later step.
|
|
||||||
1. Go back into edit the release and click "Publish release" while being marked as a pre-release.
|
|
||||||
1. Confirm there is new git tag with intended version number at the intended revision after running `git fetch` locally.
|
|
||||||
|
|
||||||
|
|
||||||
### Update release branch with the next patch version
|
### Update release branch with the next patch version
|
||||||
|
|
||||||
@@ -125,32 +119,68 @@ Alternatively use the Github UI.
|
|||||||
$ scripts/increment-cargo-version.sh patch
|
$ scripts/increment-cargo-version.sh patch
|
||||||
$ ./scripts/cargo-for-all-lock-files.sh tree
|
$ ./scripts/cargo-for-all-lock-files.sh tree
|
||||||
```
|
```
|
||||||
|
1. Rebuild to get an updated version of `Cargo.lock`:
|
||||||
|
```
|
||||||
|
cargo build
|
||||||
|
```
|
||||||
1. Push all the changed Cargo.toml and Cargo.lock files to the **release branch** with something like:
|
1. Push all the changed Cargo.toml and Cargo.lock files to the **release branch** with something like:
|
||||||
```
|
```
|
||||||
git co -b version_update origin/vX.Y
|
git co -b version_update
|
||||||
git add -u
|
git ls-files -m | xargs git add
|
||||||
git commit -m 'Bump version to X.Y.Z+1'
|
git commit -m 'Update Cargo.toml versions from X.Y.Z to X.Y.Z+1'
|
||||||
git push -u <user-remote> version_update
|
git push -u origin version_update
|
||||||
```
|
```
|
||||||
1. Open a PR against origin/vX.Y and then merge the PR after passing CI.
|
|
||||||
|
|
||||||
### Prepare for the next release
|
|
||||||
1. Go to [GitHub Releases](https://github.com/solana-labs/solana/releases) and create a new draft release for `X.Y.Z+1` with empty release notes. This allows people to incrementally add new release notes until it's time for the next release
|
|
||||||
1. Also, point the branch field to the same branch and mark the relese as **"This is a pre-release"**.
|
|
||||||
1. Go to the [Github Milestones](https://github.com/solana-labs/solana/milestones). Create a new milestone for the `X.Y.Z+1`, move over
|
|
||||||
unresolved issues still in the `X.Y.Z` milestone, then close the `X.Y.Z` milestone.
|
|
||||||
|
|
||||||
### Verify release automation success
|
### Verify release automation success
|
||||||
Go to [Solana Releases](https://github.com/solana-labs/solana/releases) and click on the latest release that you just published.
|
1. Go to [Solana Releases](https://github.com/solana-labs/solana/releases) and click on the latest release that you just published. Verify that all of the build artifacts are present. This can take up to 90 minutes after creating the tag.
|
||||||
Verify that all of the build artifacts are present, then the uncheck **"This is a pre-release"** for the release.
|
1. The `solana-secondary` Buildkite pipeline handles creating the binary tarballs and updated crates. Look for a job under the tag name of the release: https://buildkite.com/solana-labs/solana-secondary
|
||||||
|
1. [Crates.io](https://crates.io/crates/solana) should have an updated Solana version.
|
||||||
|
|
||||||
Build artifacts can take up to 60 minutes after creating the tag before
|
### Update documentation
|
||||||
appearing. To check for progress:
|
TODO: Documentation update procedure is WIP as we move to gitbook
|
||||||
* The `solana-secondary` Buildkite pipeline handles creating the Linux release artifacts and updated crates. Look for a job under the tag name of the release: https://buildkite.com/solana-labs/solana-secondary.
|
|
||||||
* The macOS and Windows release artifacts are produced by Travis CI: https://travis-ci.com/github/solana-labs/solana/branches
|
|
||||||
|
|
||||||
[Crates.io](https://crates.io/crates/solana) should have an updated Solana version. This can take 2-3 hours, and sometimes fails in the `solana-secondary` job.
|
Document the new recommended version by updating `docs/src/running-archiver.md` and `docs/src/validator-testnet.md` on the release (beta) branch to point at the `solana-install` for the upcoming release version.
|
||||||
If this happens and the error is non-fatal, click "Retry" on the "publish crate" job
|
|
||||||
|
|
||||||
### Update software on devnet.solana.com/testnet.solana.com/mainnet-beta.solana.com
|
### Update software on devnet.solana.com
|
||||||
See the documentation at https://github.com/solana-labs/cluster-ops/
|
|
||||||
|
The testnet running on devnet.solana.com is set to use a fixed release tag
|
||||||
|
which is set in the Buildkite testnet-management pipeline.
|
||||||
|
This tag needs to be updated and the testnet restarted after a new release
|
||||||
|
tag is created.
|
||||||
|
|
||||||
|
#### Update testnet schedules
|
||||||
|
|
||||||
|
Go to https://buildkite.com/solana-labs and click through: Pipelines ->
|
||||||
|
testnet-management -> Pipeline Settings -> Schedules
|
||||||
|
Or just click here:
|
||||||
|
https://buildkite.com/solana-labs/testnet-management/settings/schedules
|
||||||
|
|
||||||
|
There are two scheduled jobs for testnet: a daily restart and an hourly sanity-or-restart. \
|
||||||
|
https://buildkite.com/solana-labs/testnet-management/settings/schedules/0efd7856-7143-4713-8817-47e6bdb05387
|
||||||
|
https://buildkite.com/solana-labs/testnet-management/settings/schedules/2a926646-d972-42b5-aeb9-bb6759592a53
|
||||||
|
|
||||||
|
On each schedule:
|
||||||
|
1. Set TESTNET_TAG environment variable to the desired release tag.
|
||||||
|
1. Example, TESTNET_TAG=v0.13.2
|
||||||
|
1. Set the Build Branch to the branch that TESTNET_TAG is from.
|
||||||
|
1. Example: v0.13
|
||||||
|
|
||||||
|
#### Restart the testnet
|
||||||
|
|
||||||
|
Trigger a TESTNET_OP=create-and-start to refresh the cluster with the new version
|
||||||
|
|
||||||
|
1. Go to https://buildkite.com/solana-labs/testnet-management
|
||||||
|
2. Click "New Build" and use the following settings, then click "Create Build"
|
||||||
|
1. Commit: HEAD
|
||||||
|
1. Branch: [channel branch as set in the schedules]
|
||||||
|
1. Environment Variables:
|
||||||
|
```
|
||||||
|
TESTNET=testnet
|
||||||
|
TESTNET_TAG=[same value as used in TESTNET_TAG in the schedules]
|
||||||
|
TESTNET_OP=create-and-start
|
||||||
|
```
|
||||||
|
|
||||||
|
### Alert the community
|
||||||
|
|
||||||
|
Notify Discord users on #validator-support that a new release for
|
||||||
|
devnet.solana.com is available
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "solana-account-decoder"
|
name = "solana-account-decoder"
|
||||||
version = "1.5.3"
|
version = "1.2.33"
|
||||||
description = "Solana account decoder"
|
description = "Solana account decoder"
|
||||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
||||||
repository = "https://github.com/solana-labs/solana"
|
repository = "https://github.com/solana-labs/solana"
|
||||||
@@ -9,22 +9,21 @@ license = "Apache-2.0"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
base64 = "0.12.3"
|
|
||||||
bincode = "1.3.1"
|
bincode = "1.3.1"
|
||||||
|
base64 = "0.12.3"
|
||||||
bs58 = "0.3.1"
|
bs58 = "0.3.1"
|
||||||
bv = "0.11.1"
|
bv = "0.11.1"
|
||||||
Inflector = "0.11.4"
|
Inflector = "0.11.4"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
serde = "1.0.112"
|
serde = "1.0.112"
|
||||||
serde_derive = "1.0.103"
|
serde_derive = "1.0.103"
|
||||||
serde_json = "1.0.56"
|
serde_json = "1.0.54"
|
||||||
solana-config-program = { path = "../programs/config", version = "1.5.3" }
|
solana-config-program = { path = "../programs/config", version = "1.2.33" }
|
||||||
solana-sdk = { path = "../sdk", version = "1.5.3" }
|
solana-sdk = { path = "../sdk", version = "1.2.33" }
|
||||||
solana-stake-program = { path = "../programs/stake", version = "1.5.3" }
|
solana-stake-program = { path = "../programs/stake", version = "1.2.33" }
|
||||||
solana-vote-program = { path = "../programs/vote", version = "1.5.3" }
|
solana-vote-program = { path = "../programs/vote", version = "1.2.33" }
|
||||||
spl-token-v2-0 = { package = "spl-token", version = "=3.0.1", features = ["no-entrypoint"] }
|
spl-token-v2-0 = { package = "spl-token", version = "2.0.6", features = ["skip-no-mangle"] }
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
zstd = "0.5.1"
|
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
@@ -12,14 +12,9 @@ pub mod parse_token;
|
|||||||
pub mod parse_vote;
|
pub mod parse_vote;
|
||||||
pub mod validator_info;
|
pub mod validator_info;
|
||||||
|
|
||||||
use {
|
use crate::parse_account_data::{parse_account_data, AccountAdditionalData, ParsedAccount};
|
||||||
crate::parse_account_data::{parse_account_data, AccountAdditionalData, ParsedAccount},
|
use solana_sdk::{account::Account, clock::Epoch, fee_calculator::FeeCalculator, pubkey::Pubkey};
|
||||||
solana_sdk::{account::Account, clock::Epoch, fee_calculator::FeeCalculator, pubkey::Pubkey},
|
use std::str::FromStr;
|
||||||
std::{
|
|
||||||
io::{Read, Write},
|
|
||||||
str::FromStr,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub type StringAmount = String;
|
pub type StringAmount = String;
|
||||||
|
|
||||||
@@ -49,8 +44,6 @@ pub enum UiAccountEncoding {
|
|||||||
Base58,
|
Base58,
|
||||||
Base64,
|
Base64,
|
||||||
JsonParsed,
|
JsonParsed,
|
||||||
#[serde(rename = "base64+zstd")]
|
|
||||||
Base64Zstd,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UiAccount {
|
impl UiAccount {
|
||||||
@@ -73,19 +66,6 @@ impl UiAccount {
|
|||||||
base64::encode(slice_data(&account.data, data_slice_config)),
|
base64::encode(slice_data(&account.data, data_slice_config)),
|
||||||
encoding,
|
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 => {
|
UiAccountEncoding::JsonParsed => {
|
||||||
if let Ok(parsed_data) =
|
if let Ok(parsed_data) =
|
||||||
parse_account_data(pubkey, &account.owner, &account.data, additional_data)
|
parse_account_data(pubkey, &account.owner, &account.data, additional_data)
|
||||||
@@ -112,16 +92,6 @@ impl UiAccount {
|
|||||||
UiAccountData::Binary(blob, encoding) => match encoding {
|
UiAccountData::Binary(blob, encoding) => match encoding {
|
||||||
UiAccountEncoding::Base58 => bs58::decode(blob).into_vec().ok(),
|
UiAccountEncoding::Base58 => bs58::decode(blob).into_vec().ok(),
|
||||||
UiAccountEncoding::Base64 => base64::decode(blob).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,
|
UiAccountEncoding::Binary | UiAccountEncoding::JsonParsed => None,
|
||||||
},
|
},
|
||||||
}?;
|
}?;
|
||||||
@@ -209,25 +179,4 @@ mod test {
|
|||||||
});
|
});
|
||||||
assert_eq!(slice_data(&data, slice_config), &[] as &[u8]);
|
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]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -81,7 +81,7 @@ pub fn parse_account_data(
|
|||||||
) -> Result<ParsedAccount, ParseAccountError> {
|
) -> Result<ParsedAccount, ParseAccountError> {
|
||||||
let program_name = PARSABLE_PROGRAM_IDS
|
let program_name = PARSABLE_PROGRAM_IDS
|
||||||
.get(program_id)
|
.get(program_id)
|
||||||
.ok_or(ParseAccountError::ProgramNotParsable)?;
|
.ok_or_else(|| ParseAccountError::ProgramNotParsable)?;
|
||||||
let additional_data = additional_data.unwrap_or_default();
|
let additional_data = additional_data.unwrap_or_default();
|
||||||
let parsed_json = match program_name {
|
let parsed_json = match program_name {
|
||||||
ParsableAccount::Config => serde_json::to_value(parse_config(data, pubkey)?)?,
|
ParsableAccount::Config => serde_json::to_value(parse_config(data, pubkey)?)?,
|
||||||
@@ -111,14 +111,14 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_account_data() {
|
fn test_parse_account_data() {
|
||||||
let account_pubkey = solana_sdk::pubkey::new_rand();
|
let account_pubkey = Pubkey::new_rand();
|
||||||
let other_program = solana_sdk::pubkey::new_rand();
|
let other_program = Pubkey::new_rand();
|
||||||
let data = vec![0; 4];
|
let data = vec![0; 4];
|
||||||
assert!(parse_account_data(&account_pubkey, &other_program, &data, None).is_err());
|
assert!(parse_account_data(&account_pubkey, &other_program, &data, None).is_err());
|
||||||
|
|
||||||
let vote_state = VoteState::default();
|
let vote_state = VoteState::default();
|
||||||
let mut vote_account_data: Vec<u8> = vec![0; VoteState::size_of()];
|
let mut vote_account_data: Vec<u8> = vec![0; VoteState::size_of()];
|
||||||
let versioned = VoteStateVersions::new_current(vote_state);
|
let versioned = VoteStateVersions::Current(Box::new(vote_state));
|
||||||
VoteState::serialize(&versioned, &mut vote_account_data).unwrap();
|
VoteState::serialize(&versioned, &mut vote_account_data).unwrap();
|
||||||
let parsed = parse_account_data(
|
let parsed = parse_account_data(
|
||||||
&account_pubkey,
|
&account_pubkey,
|
||||||
|
@@ -117,7 +117,7 @@ mod test {
|
|||||||
}))
|
}))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
};
|
};
|
||||||
let info_pubkey = solana_sdk::pubkey::new_rand();
|
let info_pubkey = Pubkey::new_rand();
|
||||||
let validator_info_config_account = create_config_account(
|
let validator_info_config_account = create_config_account(
|
||||||
vec![(validator_info::id(), false), (info_pubkey, true)],
|
vec![(validator_info::id(), false), (info_pubkey, true)],
|
||||||
&validator_info,
|
&validator_info,
|
||||||
|
@@ -26,6 +26,7 @@ pub fn parse_stake(data: &[u8]) -> Result<StakeAccountType, ParseAccountError> {
|
|||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, PartialEq)]
|
#[derive(Debug, Serialize, Deserialize, PartialEq)]
|
||||||
#[serde(rename_all = "camelCase", tag = "type", content = "info")]
|
#[serde(rename_all = "camelCase", tag = "type", content = "info")]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum StakeAccountType {
|
pub enum StakeAccountType {
|
||||||
Uninitialized,
|
Uninitialized,
|
||||||
Initialized(UiStakeAccount),
|
Initialized(UiStakeAccount),
|
||||||
@@ -134,6 +135,7 @@ impl From<Delegation> for UiDelegation {
|
|||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use bincode::serialize;
|
use bincode::serialize;
|
||||||
|
use solana_sdk::pubkey::Pubkey;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_stake() {
|
fn test_parse_stake() {
|
||||||
@@ -144,8 +146,8 @@ mod test {
|
|||||||
StakeAccountType::Uninitialized
|
StakeAccountType::Uninitialized
|
||||||
);
|
);
|
||||||
|
|
||||||
let pubkey = solana_sdk::pubkey::new_rand();
|
let pubkey = Pubkey::new_rand();
|
||||||
let custodian = solana_sdk::pubkey::new_rand();
|
let custodian = Pubkey::new_rand();
|
||||||
let authorized = Authorized::auto(&pubkey);
|
let authorized = Authorized::auto(&pubkey);
|
||||||
let lockup = Lockup {
|
let lockup = Lockup {
|
||||||
unix_timestamp: 0,
|
unix_timestamp: 0,
|
||||||
@@ -179,7 +181,7 @@ mod test {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
let voter_pubkey = solana_sdk::pubkey::new_rand();
|
let voter_pubkey = Pubkey::new_rand();
|
||||||
let stake = Stake {
|
let stake = Stake {
|
||||||
delegation: Delegation {
|
delegation: Delegation {
|
||||||
voter_pubkey,
|
voter_pubkey,
|
||||||
|
@@ -105,7 +105,6 @@ pub enum SysvarAccountType {
|
|||||||
pub struct UiClock {
|
pub struct UiClock {
|
||||||
pub slot: Slot,
|
pub slot: Slot,
|
||||||
pub epoch: Epoch,
|
pub epoch: Epoch,
|
||||||
pub epoch_start_timestamp: UnixTimestamp,
|
|
||||||
pub leader_schedule_epoch: Epoch,
|
pub leader_schedule_epoch: Epoch,
|
||||||
pub unix_timestamp: UnixTimestamp,
|
pub unix_timestamp: UnixTimestamp,
|
||||||
}
|
}
|
||||||
@@ -115,7 +114,6 @@ impl From<Clock> for UiClock {
|
|||||||
Self {
|
Self {
|
||||||
slot: clock.slot,
|
slot: clock.slot,
|
||||||
epoch: clock.epoch,
|
epoch: clock.epoch,
|
||||||
epoch_start_timestamp: clock.epoch_start_timestamp,
|
|
||||||
leader_schedule_epoch: clock.leader_schedule_epoch,
|
leader_schedule_epoch: clock.leader_schedule_epoch,
|
||||||
unix_timestamp: clock.unix_timestamp,
|
unix_timestamp: clock.unix_timestamp,
|
||||||
}
|
}
|
||||||
@@ -214,13 +212,15 @@ pub struct UiStakeHistoryEntry {
|
|||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::create_account, fee_calculator::FeeCalculator, hash::Hash,
|
fee_calculator::FeeCalculator,
|
||||||
sysvar::recent_blockhashes::IterItem,
|
hash::Hash,
|
||||||
|
sysvar::{recent_blockhashes::IterItem, Sysvar},
|
||||||
};
|
};
|
||||||
|
use std::iter::FromIterator;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_sysvars() {
|
fn test_parse_sysvars() {
|
||||||
let clock_sysvar = create_account(&Clock::default(), 1);
|
let clock_sysvar = Clock::default().create_account(1);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_sysvar(&clock_sysvar.data, &sysvar::clock::id()).unwrap(),
|
parse_sysvar(&clock_sysvar.data, &sysvar::clock::id()).unwrap(),
|
||||||
SysvarAccountType::Clock(UiClock::default()),
|
SysvarAccountType::Clock(UiClock::default()),
|
||||||
@@ -233,13 +233,13 @@ mod test {
|
|||||||
first_normal_epoch: 1,
|
first_normal_epoch: 1,
|
||||||
first_normal_slot: 12,
|
first_normal_slot: 12,
|
||||||
};
|
};
|
||||||
let epoch_schedule_sysvar = create_account(&epoch_schedule, 1);
|
let epoch_schedule_sysvar = epoch_schedule.create_account(1);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_sysvar(&epoch_schedule_sysvar.data, &sysvar::epoch_schedule::id()).unwrap(),
|
parse_sysvar(&epoch_schedule_sysvar.data, &sysvar::epoch_schedule::id()).unwrap(),
|
||||||
SysvarAccountType::EpochSchedule(epoch_schedule),
|
SysvarAccountType::EpochSchedule(epoch_schedule),
|
||||||
);
|
);
|
||||||
|
|
||||||
let fees_sysvar = create_account(&Fees::default(), 1);
|
let fees_sysvar = Fees::default().create_account(1);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_sysvar(&fees_sysvar.data, &sysvar::fees::id()).unwrap(),
|
parse_sysvar(&fees_sysvar.data, &sysvar::fees::id()).unwrap(),
|
||||||
SysvarAccountType::Fees(UiFees::default()),
|
SysvarAccountType::Fees(UiFees::default()),
|
||||||
@@ -249,10 +249,9 @@ mod test {
|
|||||||
let fee_calculator = FeeCalculator {
|
let fee_calculator = FeeCalculator {
|
||||||
lamports_per_signature: 10,
|
lamports_per_signature: 10,
|
||||||
};
|
};
|
||||||
let recent_blockhashes: RecentBlockhashes = vec![IterItem(0, &hash, &fee_calculator)]
|
let recent_blockhashes =
|
||||||
.into_iter()
|
RecentBlockhashes::from_iter(vec![IterItem(0, &hash, &fee_calculator)].into_iter());
|
||||||
.collect();
|
let recent_blockhashes_sysvar = recent_blockhashes.create_account(1);
|
||||||
let recent_blockhashes_sysvar = create_account(&recent_blockhashes, 1);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_sysvar(
|
parse_sysvar(
|
||||||
&recent_blockhashes_sysvar.data,
|
&recent_blockhashes_sysvar.data,
|
||||||
@@ -270,13 +269,13 @@ mod test {
|
|||||||
exemption_threshold: 2.0,
|
exemption_threshold: 2.0,
|
||||||
burn_percent: 5,
|
burn_percent: 5,
|
||||||
};
|
};
|
||||||
let rent_sysvar = create_account(&rent, 1);
|
let rent_sysvar = rent.create_account(1);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_sysvar(&rent_sysvar.data, &sysvar::rent::id()).unwrap(),
|
parse_sysvar(&rent_sysvar.data, &sysvar::rent::id()).unwrap(),
|
||||||
SysvarAccountType::Rent(rent.into()),
|
SysvarAccountType::Rent(rent.into()),
|
||||||
);
|
);
|
||||||
|
|
||||||
let rewards_sysvar = create_account(&Rewards::default(), 1);
|
let rewards_sysvar = Rewards::default().create_account(1);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_sysvar(&rewards_sysvar.data, &sysvar::rewards::id()).unwrap(),
|
parse_sysvar(&rewards_sysvar.data, &sysvar::rewards::id()).unwrap(),
|
||||||
SysvarAccountType::Rewards(UiRewards::default()),
|
SysvarAccountType::Rewards(UiRewards::default()),
|
||||||
@@ -284,7 +283,7 @@ mod test {
|
|||||||
|
|
||||||
let mut slot_hashes = SlotHashes::default();
|
let mut slot_hashes = SlotHashes::default();
|
||||||
slot_hashes.add(1, hash);
|
slot_hashes.add(1, hash);
|
||||||
let slot_hashes_sysvar = create_account(&slot_hashes, 1);
|
let slot_hashes_sysvar = slot_hashes.create_account(1);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_sysvar(&slot_hashes_sysvar.data, &sysvar::slot_hashes::id()).unwrap(),
|
parse_sysvar(&slot_hashes_sysvar.data, &sysvar::slot_hashes::id()).unwrap(),
|
||||||
SysvarAccountType::SlotHashes(vec![UiSlotHashEntry {
|
SysvarAccountType::SlotHashes(vec![UiSlotHashEntry {
|
||||||
@@ -295,7 +294,7 @@ mod test {
|
|||||||
|
|
||||||
let mut slot_history = SlotHistory::default();
|
let mut slot_history = SlotHistory::default();
|
||||||
slot_history.add(42);
|
slot_history.add(42);
|
||||||
let slot_history_sysvar = create_account(&slot_history, 1);
|
let slot_history_sysvar = slot_history.create_account(1);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_sysvar(&slot_history_sysvar.data, &sysvar::slot_history::id()).unwrap(),
|
parse_sysvar(&slot_history_sysvar.data, &sysvar::slot_history::id()).unwrap(),
|
||||||
SysvarAccountType::SlotHistory(UiSlotHistory {
|
SysvarAccountType::SlotHistory(UiSlotHistory {
|
||||||
@@ -311,7 +310,7 @@ mod test {
|
|||||||
deactivating: 3,
|
deactivating: 3,
|
||||||
};
|
};
|
||||||
stake_history.add(1, stake_history_entry.clone());
|
stake_history.add(1, stake_history_entry.clone());
|
||||||
let stake_history_sysvar = create_account(&stake_history, 1);
|
let stake_history_sysvar = stake_history.create_account(1);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_sysvar(&stake_history_sysvar.data, &sysvar::stake_history::id()).unwrap(),
|
parse_sysvar(&stake_history_sysvar.data, &sysvar::stake_history::id()).unwrap(),
|
||||||
SysvarAccountType::StakeHistory(vec![UiStakeHistoryEntry {
|
SysvarAccountType::StakeHistory(vec![UiStakeHistoryEntry {
|
||||||
@@ -320,7 +319,7 @@ mod test {
|
|||||||
}]),
|
}]),
|
||||||
);
|
);
|
||||||
|
|
||||||
let bad_pubkey = solana_sdk::pubkey::new_rand();
|
let bad_pubkey = Pubkey::new_rand();
|
||||||
assert!(parse_sysvar(&stake_history_sysvar.data, &bad_pubkey).is_err());
|
assert!(parse_sysvar(&stake_history_sysvar.data, &bad_pubkey).is_err());
|
||||||
|
|
||||||
let bad_data = vec![0; 4];
|
let bad_data = vec![0; 4];
|
||||||
|
@@ -4,9 +4,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use solana_sdk::pubkey::Pubkey;
|
||||||
use spl_token_v2_0::{
|
use spl_token_v2_0::{
|
||||||
solana_program::{
|
solana_sdk::{program_option::COption, program_pack::Pack, pubkey::Pubkey as SplTokenPubkey},
|
||||||
program_option::COption, program_pack::Pack, pubkey::Pubkey as SplTokenPubkey,
|
|
||||||
},
|
|
||||||
state::{Account, AccountState, Mint, Multisig},
|
state::{Account, AccountState, Mint, Multisig},
|
||||||
};
|
};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
@@ -23,16 +21,6 @@ pub fn spl_token_v2_0_native_mint() -> Pubkey {
|
|||||||
Pubkey::from_str(&spl_token_v2_0::native_mint::id().to_string()).unwrap()
|
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(
|
pub fn parse_token(
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
mint_decimals: Option<u8>,
|
mint_decimals: Option<u8>,
|
||||||
@@ -166,31 +154,6 @@ pub struct UiTokenAmount {
|
|||||||
pub amount: StringAmount,
|
pub amount: StringAmount,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UiTokenAmount {
|
|
||||||
pub fn real_number_string(&self) -> String {
|
|
||||||
let decimals = self.decimals as usize;
|
|
||||||
if decimals > 0 {
|
|
||||||
let amount = u64::from_str(&self.amount).unwrap_or(0);
|
|
||||||
|
|
||||||
// Left-pad zeros to decimals + 1, so we at least have an integer zero
|
|
||||||
let mut s = format!("{:01$}", amount, decimals + 1);
|
|
||||||
|
|
||||||
// Add the decimal point (Sorry, "," locales!)
|
|
||||||
s.insert(s.len() - decimals, '.');
|
|
||||||
s
|
|
||||||
} else {
|
|
||||||
self.amount.clone()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn real_number_string_trimmed(&self) -> String {
|
|
||||||
let s = self.real_number_string();
|
|
||||||
let zeros_trimmed = s.trim_end_matches('0');
|
|
||||||
let decimal_trimmed = zeros_trimmed.trim_end_matches('.');
|
|
||||||
decimal_trimmed.to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn token_amount_to_ui_amount(amount: u64, decimals: u8) -> UiTokenAmount {
|
pub fn token_amount_to_ui_amount(amount: u64, decimals: u8) -> UiTokenAmount {
|
||||||
// Use `amount_to_ui_amount()` once spl_token is bumped to a version that supports it: https://github.com/solana-labs/solana-program-library/pull/211
|
// Use `amount_to_ui_amount()` once spl_token is bumped to a version that supports it: https://github.com/solana-labs/solana-program-library/pull/211
|
||||||
let amount_decimals = amount as f64 / 10_usize.pow(decimals as u32) as f64;
|
let amount_decimals = amount as f64 / 10_usize.pow(decimals as u32) as f64;
|
||||||
@@ -333,20 +296,4 @@ mod test {
|
|||||||
Some(expected_mint_pubkey)
|
Some(expected_mint_pubkey)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_ui_token_amount_real_string() {
|
|
||||||
let token_amount = token_amount_to_ui_amount(1, 0);
|
|
||||||
assert_eq!(&token_amount.real_number_string(), "1");
|
|
||||||
assert_eq!(&token_amount.real_number_string_trimmed(), "1");
|
|
||||||
let token_amount = token_amount_to_ui_amount(1, 9);
|
|
||||||
assert_eq!(&token_amount.real_number_string(), "0.000000001");
|
|
||||||
assert_eq!(&token_amount.real_number_string_trimmed(), "0.000000001");
|
|
||||||
let token_amount = token_amount_to_ui_amount(1_000_000_000, 9);
|
|
||||||
assert_eq!(&token_amount.real_number_string(), "1.000000000");
|
|
||||||
assert_eq!(&token_amount.real_number_string_trimmed(), "1");
|
|
||||||
let token_amount = token_amount_to_ui_amount(1_234_567_890, 3);
|
|
||||||
assert_eq!(&token_amount.real_number_string(), "1234567.890");
|
|
||||||
assert_eq!(&token_amount.real_number_string_trimmed(), "1234567.89");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -128,13 +128,11 @@ mod test {
|
|||||||
fn test_parse_vote() {
|
fn test_parse_vote() {
|
||||||
let vote_state = VoteState::default();
|
let vote_state = VoteState::default();
|
||||||
let mut vote_account_data: Vec<u8> = vec![0; VoteState::size_of()];
|
let mut vote_account_data: Vec<u8> = vec![0; VoteState::size_of()];
|
||||||
let versioned = VoteStateVersions::new_current(vote_state);
|
let versioned = VoteStateVersions::Current(Box::new(vote_state));
|
||||||
VoteState::serialize(&versioned, &mut vote_account_data).unwrap();
|
VoteState::serialize(&versioned, &mut vote_account_data).unwrap();
|
||||||
let expected_vote_state = UiVoteState {
|
let mut expected_vote_state = UiVoteState::default();
|
||||||
node_pubkey: Pubkey::default().to_string(),
|
expected_vote_state.node_pubkey = Pubkey::default().to_string();
|
||||||
authorized_withdrawer: Pubkey::default().to_string(),
|
expected_vote_state.authorized_withdrawer = Pubkey::default().to_string();
|
||||||
..UiVoteState::default()
|
|
||||||
};
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_vote(&vote_account_data).unwrap(),
|
parse_vote(&vote_account_data).unwrap(),
|
||||||
VoteAccountType::Vote(expected_vote_state)
|
VoteAccountType::Vote(expected_vote_state)
|
||||||
|
@@ -1,21 +1,19 @@
|
|||||||
[package]
|
[package]
|
||||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
name = "solana-accounts-bench"
|
name = "solana-accounts-bench"
|
||||||
version = "1.5.3"
|
version = "1.2.33"
|
||||||
repository = "https://github.com/solana-labs/solana"
|
repository = "https://github.com/solana-labs/solana"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
homepage = "https://solana.com/"
|
homepage = "https://solana.com/"
|
||||||
publish = false
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.4.11"
|
log = "0.4.6"
|
||||||
rayon = "1.4.0"
|
rayon = "1.4.0"
|
||||||
solana-logger = { path = "../logger", version = "1.5.3" }
|
solana-logger = { path = "../logger", version = "1.2.33" }
|
||||||
solana-runtime = { path = "../runtime", version = "1.5.3" }
|
solana-runtime = { path = "../runtime", version = "1.2.33" }
|
||||||
solana-measure = { path = "../measure", version = "1.5.3" }
|
solana-measure = { path = "../measure", version = "1.2.33" }
|
||||||
solana-sdk = { path = "../sdk", version = "1.5.3" }
|
solana-sdk = { path = "../sdk", version = "1.2.33" }
|
||||||
solana-version = { path = "../version", version = "1.5.3" }
|
|
||||||
rand = "0.7.0"
|
rand = "0.7.0"
|
||||||
clap = "2.33.1"
|
clap = "2.33.1"
|
||||||
crossbeam-channel = "0.4"
|
crossbeam-channel = "0.4"
|
||||||
|
@@ -1,19 +1,20 @@
|
|||||||
use clap::{crate_description, crate_name, value_t, App, Arg};
|
use clap::{value_t, App, Arg};
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use solana_measure::measure::Measure;
|
use solana_measure::measure::Measure;
|
||||||
use solana_runtime::{
|
use solana_runtime::{
|
||||||
accounts::{create_test_accounts, update_accounts_bench, Accounts},
|
accounts::{create_test_accounts, update_accounts, Accounts},
|
||||||
accounts_index::Ancestors,
|
accounts_index::Ancestors,
|
||||||
};
|
};
|
||||||
use solana_sdk::{genesis_config::ClusterType, pubkey::Pubkey};
|
use solana_sdk::{genesis_config::OperatingMode, pubkey::Pubkey};
|
||||||
use std::{collections::HashSet, env, fs, path::PathBuf};
|
use std::fs;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
|
|
||||||
let matches = App::new(crate_name!())
|
let matches = App::new("crate")
|
||||||
.about(crate_description!())
|
.about("about")
|
||||||
.version(solana_version::version!())
|
.version("version")
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("num_slots")
|
Arg::with_name("num_slots")
|
||||||
.long("num_slots")
|
.long("num_slots")
|
||||||
@@ -49,13 +50,11 @@ fn main() {
|
|||||||
let clean = matches.is_present("clean");
|
let clean = matches.is_present("clean");
|
||||||
println!("clean: {:?}", clean);
|
println!("clean: {:?}", clean);
|
||||||
|
|
||||||
let path = PathBuf::from(env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_owned()))
|
let path = PathBuf::from("farf/accounts-bench");
|
||||||
.join("accounts-bench");
|
|
||||||
if fs::remove_dir_all(path.clone()).is_err() {
|
if fs::remove_dir_all(path.clone()).is_err() {
|
||||||
println!("Warning: Couldn't remove {:?}", path);
|
println!("Warning: Couldn't remove {:?}", path);
|
||||||
}
|
}
|
||||||
let accounts =
|
let accounts = Accounts::new(vec![path], OperatingMode::Preview);
|
||||||
Accounts::new_with_config(vec![path], &ClusterType::Testnet, HashSet::new(), false);
|
|
||||||
println!("Creating {} accounts", num_accounts);
|
println!("Creating {} accounts", num_accounts);
|
||||||
let mut create_time = Measure::start("create accounts");
|
let mut create_time = Measure::start("create accounts");
|
||||||
let pubkeys: Vec<_> = (0..num_slots)
|
let pubkeys: Vec<_> = (0..num_slots)
|
||||||
@@ -87,20 +86,17 @@ fn main() {
|
|||||||
for x in 0..iterations {
|
for x in 0..iterations {
|
||||||
if clean {
|
if clean {
|
||||||
let mut time = Measure::start("clean");
|
let mut time = Measure::start("clean");
|
||||||
accounts.accounts_db.clean_accounts(None);
|
accounts.accounts_db.clean_accounts();
|
||||||
time.stop();
|
time.stop();
|
||||||
println!("{}", time);
|
println!("{}", time);
|
||||||
for slot in 0..num_slots {
|
for slot in 0..num_slots {
|
||||||
update_accounts_bench(&accounts, &pubkeys, ((x + 1) * num_slots + slot) as u64);
|
update_accounts(&accounts, &pubkeys, ((x + 1) * num_slots + slot) as u64);
|
||||||
accounts.add_root((x * num_slots + slot) as u64);
|
accounts.add_root((x * num_slots + slot) as u64);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let mut pubkeys: Vec<Pubkey> = vec![];
|
let mut pubkeys: Vec<Pubkey> = vec![];
|
||||||
let mut time = Measure::start("hash");
|
let mut time = Measure::start("hash");
|
||||||
let hash = accounts
|
let hash = accounts.accounts_db.update_accounts_hash(0, &ancestors);
|
||||||
.accounts_db
|
|
||||||
.update_accounts_hash(0, &ancestors, true)
|
|
||||||
.0;
|
|
||||||
time.stop();
|
time.stop();
|
||||||
println!("hash: {} {}", hash, time);
|
println!("hash: {} {}", hash, time);
|
||||||
create_test_accounts(&accounts, &mut pubkeys, 1, 0);
|
create_test_accounts(&accounts, &mut pubkeys, 1, 0);
|
||||||
|
@@ -1,29 +1,28 @@
|
|||||||
[package]
|
[package]
|
||||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
name = "solana-banking-bench"
|
name = "solana-banking-bench"
|
||||||
version = "1.5.3"
|
version = "1.2.33"
|
||||||
repository = "https://github.com/solana-labs/solana"
|
repository = "https://github.com/solana-labs/solana"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
homepage = "https://solana.com/"
|
homepage = "https://solana.com/"
|
||||||
publish = false
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.33.1"
|
clap = "2.33.1"
|
||||||
crossbeam-channel = "0.4"
|
crossbeam-channel = "0.4"
|
||||||
log = "0.4.11"
|
log = "0.4.6"
|
||||||
rand = "0.7.0"
|
rand = "0.7.0"
|
||||||
rayon = "1.4.0"
|
rayon = "1.4.0"
|
||||||
solana-core = { path = "../core", version = "1.5.3" }
|
solana-core = { path = "../core", version = "1.2.33" }
|
||||||
solana-clap-utils = { path = "../clap-utils", version = "1.5.3" }
|
solana-clap-utils = { path = "../clap-utils", version = "1.2.33" }
|
||||||
solana-streamer = { path = "../streamer", version = "1.5.3" }
|
solana-streamer = { path = "../streamer", version = "1.2.33" }
|
||||||
solana-perf = { path = "../perf", version = "1.5.3" }
|
solana-perf = { path = "../perf", version = "1.2.33" }
|
||||||
solana-ledger = { path = "../ledger", version = "1.5.3" }
|
solana-ledger = { path = "../ledger", version = "1.2.33" }
|
||||||
solana-logger = { path = "../logger", version = "1.5.3" }
|
solana-logger = { path = "../logger", version = "1.2.33" }
|
||||||
solana-runtime = { path = "../runtime", version = "1.5.3" }
|
solana-runtime = { path = "../runtime", version = "1.2.33" }
|
||||||
solana-measure = { path = "../measure", version = "1.5.3" }
|
solana-measure = { path = "../measure", version = "1.2.33" }
|
||||||
solana-sdk = { path = "../sdk", version = "1.5.3" }
|
solana-sdk = { path = "../sdk", version = "1.2.33" }
|
||||||
solana-version = { path = "../version", version = "1.5.3" }
|
solana-version = { path = "../version", version = "1.2.33" }
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
@@ -11,17 +11,17 @@ use solana_core::{
|
|||||||
poh_recorder::WorkingBankEntry,
|
poh_recorder::WorkingBankEntry,
|
||||||
};
|
};
|
||||||
use solana_ledger::{
|
use solana_ledger::{
|
||||||
|
bank_forks::BankForks,
|
||||||
blockstore::Blockstore,
|
blockstore::Blockstore,
|
||||||
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
||||||
get_tmp_ledger_path,
|
get_tmp_ledger_path,
|
||||||
};
|
};
|
||||||
use solana_measure::measure::Measure;
|
use solana_measure::measure::Measure;
|
||||||
use solana_perf::packet::to_packets_chunked;
|
use solana_perf::packet::to_packets_chunked;
|
||||||
use solana_runtime::{
|
use solana_runtime::bank::Bank;
|
||||||
accounts_background_service::ABSRequestSender, bank::Bank, bank_forks::BankForks,
|
|
||||||
};
|
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
|
pubkey::Pubkey,
|
||||||
signature::Keypair,
|
signature::Keypair,
|
||||||
signature::Signature,
|
signature::Signature,
|
||||||
system_transaction,
|
system_transaction,
|
||||||
@@ -70,7 +70,7 @@ fn make_accounts_txs(
|
|||||||
hash: Hash,
|
hash: Hash,
|
||||||
same_payer: bool,
|
same_payer: bool,
|
||||||
) -> Vec<Transaction> {
|
) -> Vec<Transaction> {
|
||||||
let to_pubkey = solana_sdk::pubkey::new_rand();
|
let to_pubkey = Pubkey::new_rand();
|
||||||
let payer_key = Keypair::new();
|
let payer_key = Keypair::new();
|
||||||
let dummy = system_transaction::transfer(&payer_key, &to_pubkey, 1, hash);
|
let dummy = system_transaction::transfer(&payer_key, &to_pubkey, 1, hash);
|
||||||
(0..total_num_transactions)
|
(0..total_num_transactions)
|
||||||
@@ -79,9 +79,9 @@ fn make_accounts_txs(
|
|||||||
let mut new = dummy.clone();
|
let mut new = dummy.clone();
|
||||||
let sig: Vec<u8> = (0..64).map(|_| thread_rng().gen()).collect();
|
let sig: Vec<u8> = (0..64).map(|_| thread_rng().gen()).collect();
|
||||||
if !same_payer {
|
if !same_payer {
|
||||||
new.message.account_keys[0] = solana_sdk::pubkey::new_rand();
|
new.message.account_keys[0] = Pubkey::new_rand();
|
||||||
}
|
}
|
||||||
new.message.account_keys[1] = solana_sdk::pubkey::new_rand();
|
new.message.account_keys[1] = Pubkey::new_rand();
|
||||||
new.signatures = vec![Signature::new(&sig[0..64])];
|
new.signatures = vec![Signature::new(&sig[0..64])];
|
||||||
new
|
new
|
||||||
})
|
})
|
||||||
@@ -168,7 +168,6 @@ fn main() {
|
|||||||
|
|
||||||
let (verified_sender, verified_receiver) = unbounded();
|
let (verified_sender, verified_receiver) = unbounded();
|
||||||
let (vote_sender, vote_receiver) = unbounded();
|
let (vote_sender, vote_receiver) = unbounded();
|
||||||
let (replay_vote_sender, _replay_vote_receiver) = unbounded();
|
|
||||||
let bank0 = Bank::new(&genesis_config);
|
let bank0 = Bank::new(&genesis_config);
|
||||||
let mut bank_forks = BankForks::new(bank0);
|
let mut bank_forks = BankForks::new(bank0);
|
||||||
let mut bank = bank_forks.working_bank();
|
let mut bank = bank_forks.working_bank();
|
||||||
@@ -210,7 +209,7 @@ fn main() {
|
|||||||
bank.clear_signatures();
|
bank.clear_signatures();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut verified: Vec<_> = to_packets_chunked(&transactions, packets_per_chunk);
|
let mut verified: Vec<_> = to_packets_chunked(&transactions.clone(), packets_per_chunk);
|
||||||
let ledger_path = get_tmp_ledger_path!();
|
let ledger_path = get_tmp_ledger_path!();
|
||||||
{
|
{
|
||||||
let blockstore = Arc::new(
|
let blockstore = Arc::new(
|
||||||
@@ -226,7 +225,6 @@ fn main() {
|
|||||||
verified_receiver,
|
verified_receiver,
|
||||||
vote_receiver,
|
vote_receiver,
|
||||||
None,
|
None,
|
||||||
replay_vote_sender,
|
|
||||||
);
|
);
|
||||||
poh_recorder.lock().unwrap().set_bank(&bank);
|
poh_recorder.lock().unwrap().set_bank(&bank);
|
||||||
|
|
||||||
@@ -242,7 +240,7 @@ fn main() {
|
|||||||
let base_tx_count = bank.transaction_count();
|
let base_tx_count = bank.transaction_count();
|
||||||
let mut txs_processed = 0;
|
let mut txs_processed = 0;
|
||||||
let mut root = 1;
|
let mut root = 1;
|
||||||
let collector = solana_sdk::pubkey::new_rand();
|
let collector = Pubkey::new_rand();
|
||||||
let config = Config {
|
let config = Config {
|
||||||
packets_per_batch: packets_per_chunk,
|
packets_per_batch: packets_per_chunk,
|
||||||
chunk_len,
|
chunk_len,
|
||||||
@@ -325,7 +323,7 @@ fn main() {
|
|||||||
poh_recorder.lock().unwrap().set_bank(&bank);
|
poh_recorder.lock().unwrap().set_bank(&bank);
|
||||||
assert!(poh_recorder.lock().unwrap().bank().is_some());
|
assert!(poh_recorder.lock().unwrap().bank().is_some());
|
||||||
if bank.slot() > 32 {
|
if bank.slot() > 32 {
|
||||||
bank_forks.set_root(root, &ABSRequestSender::default(), None);
|
bank_forks.set_root(root, &None, None);
|
||||||
root += 1;
|
root += 1;
|
||||||
}
|
}
|
||||||
debug!(
|
debug!(
|
||||||
|
@@ -1,30 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "solana-banks-client"
|
|
||||||
version = "1.5.3"
|
|
||||||
description = "Solana banks client"
|
|
||||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
|
||||||
repository = "https://github.com/solana-labs/solana"
|
|
||||||
license = "Apache-2.0"
|
|
||||||
homepage = "https://solana.com/"
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
bincode = "1.3.1"
|
|
||||||
futures = "0.3"
|
|
||||||
mio = "0.7.6"
|
|
||||||
solana-banks-interface = { path = "../banks-interface", version = "1.5.3" }
|
|
||||||
solana-sdk = { path = "../sdk", version = "1.5.3" }
|
|
||||||
tarpc = { version = "0.23.0", features = ["full"] }
|
|
||||||
tokio = { version = "0.3.5", features = ["full"] }
|
|
||||||
tokio-serde = { version = "0.6", features = ["bincode"] }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
solana-runtime = { path = "../runtime", version = "1.5.3" }
|
|
||||||
solana-banks-server = { path = "../banks-server", version = "1.5.3" }
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["lib"]
|
|
||||||
name = "solana_banks_client"
|
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
|
@@ -1,371 +0,0 @@
|
|||||||
//! A client for the ledger state, from the perspective of an arbitrary validator.
|
|
||||||
//!
|
|
||||||
//! Use start_tcp_client() to create a client and then import BanksClientExt to
|
|
||||||
//! access its methods. Additional "*_with_context" methods are also available,
|
|
||||||
//! but they are undocumented, may change over time, and are generally more
|
|
||||||
//! cumbersome to use.
|
|
||||||
|
|
||||||
use futures::{future::join_all, Future, FutureExt};
|
|
||||||
pub use solana_banks_interface::{BanksClient as TarpcClient, TransactionStatus};
|
|
||||||
use solana_banks_interface::{BanksRequest, BanksResponse};
|
|
||||||
use solana_sdk::{
|
|
||||||
account::{from_account, Account},
|
|
||||||
clock::Slot,
|
|
||||||
commitment_config::CommitmentLevel,
|
|
||||||
fee_calculator::FeeCalculator,
|
|
||||||
hash::Hash,
|
|
||||||
pubkey::Pubkey,
|
|
||||||
rent::Rent,
|
|
||||||
signature::Signature,
|
|
||||||
sysvar,
|
|
||||||
transaction::{self, Transaction},
|
|
||||||
transport,
|
|
||||||
};
|
|
||||||
use std::io::{self, Error, ErrorKind};
|
|
||||||
use tarpc::{
|
|
||||||
client::{self, channel::RequestDispatch, NewClient},
|
|
||||||
context::{self, Context},
|
|
||||||
rpc::{ClientMessage, Response},
|
|
||||||
serde_transport::tcp,
|
|
||||||
Transport,
|
|
||||||
};
|
|
||||||
use tokio::{net::ToSocketAddrs, time::Duration};
|
|
||||||
use tokio_serde::formats::Bincode;
|
|
||||||
|
|
||||||
// This exists only for backward compatibility
|
|
||||||
pub trait BanksClientExt {}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct BanksClient {
|
|
||||||
inner: TarpcClient,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BanksClient {
|
|
||||||
#[allow(clippy::new_ret_no_self)]
|
|
||||||
pub fn new<C>(
|
|
||||||
config: client::Config,
|
|
||||||
transport: C,
|
|
||||||
) -> NewClient<TarpcClient, RequestDispatch<BanksRequest, BanksResponse, C>>
|
|
||||||
where
|
|
||||||
C: Transport<ClientMessage<BanksRequest>, Response<BanksResponse>>,
|
|
||||||
{
|
|
||||||
TarpcClient::new(config, transport)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn send_transaction_with_context(
|
|
||||||
&mut self,
|
|
||||||
ctx: Context,
|
|
||||||
transaction: Transaction,
|
|
||||||
) -> impl Future<Output = io::Result<()>> + '_ {
|
|
||||||
self.inner.send_transaction_with_context(ctx, transaction)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_fees_with_commitment_and_context(
|
|
||||||
&mut self,
|
|
||||||
ctx: Context,
|
|
||||||
commitment: CommitmentLevel,
|
|
||||||
) -> impl Future<Output = io::Result<(FeeCalculator, Hash, Slot)>> + '_ {
|
|
||||||
self.inner
|
|
||||||
.get_fees_with_commitment_and_context(ctx, commitment)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_transaction_status_with_context(
|
|
||||||
&mut self,
|
|
||||||
ctx: Context,
|
|
||||||
signature: Signature,
|
|
||||||
) -> impl Future<Output = io::Result<Option<TransactionStatus>>> + '_ {
|
|
||||||
self.inner
|
|
||||||
.get_transaction_status_with_context(ctx, signature)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_slot_with_context(
|
|
||||||
&mut self,
|
|
||||||
ctx: Context,
|
|
||||||
commitment: CommitmentLevel,
|
|
||||||
) -> impl Future<Output = io::Result<Slot>> + '_ {
|
|
||||||
self.inner.get_slot_with_context(ctx, commitment)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn process_transaction_with_commitment_and_context(
|
|
||||||
&mut self,
|
|
||||||
ctx: Context,
|
|
||||||
transaction: Transaction,
|
|
||||||
commitment: CommitmentLevel,
|
|
||||||
) -> impl Future<Output = io::Result<Option<transaction::Result<()>>>> + '_ {
|
|
||||||
self.inner
|
|
||||||
.process_transaction_with_commitment_and_context(ctx, transaction, commitment)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_account_with_commitment_and_context(
|
|
||||||
&mut self,
|
|
||||||
ctx: Context,
|
|
||||||
address: Pubkey,
|
|
||||||
commitment: CommitmentLevel,
|
|
||||||
) -> impl Future<Output = io::Result<Option<Account>>> + '_ {
|
|
||||||
self.inner
|
|
||||||
.get_account_with_commitment_and_context(ctx, address, commitment)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Send a transaction and return immediately. The server will resend the
|
|
||||||
/// transaction until either it is accepted by the cluster or the transaction's
|
|
||||||
/// blockhash expires.
|
|
||||||
pub fn send_transaction(
|
|
||||||
&mut self,
|
|
||||||
transaction: Transaction,
|
|
||||||
) -> impl Future<Output = io::Result<()>> + '_ {
|
|
||||||
self.send_transaction_with_context(context::current(), transaction)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the fee parameters associated with a recent, rooted blockhash. The cluster
|
|
||||||
/// will use the transaction's blockhash to look up these same fee parameters and
|
|
||||||
/// use them to calculate the transaction fee.
|
|
||||||
pub fn get_fees(
|
|
||||||
&mut self,
|
|
||||||
) -> impl Future<Output = io::Result<(FeeCalculator, Hash, Slot)>> + '_ {
|
|
||||||
self.get_fees_with_commitment_and_context(context::current(), CommitmentLevel::Root)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the cluster rent
|
|
||||||
pub fn get_rent(&mut self) -> impl Future<Output = io::Result<Rent>> + '_ {
|
|
||||||
self.get_account(sysvar::rent::id()).map(|result| {
|
|
||||||
let rent_sysvar = result?
|
|
||||||
.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")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return a recent, rooted blockhash from the server. The cluster will only accept
|
|
||||||
/// transactions with a blockhash that has not yet expired. Use the `get_fees`
|
|
||||||
/// method to get both a blockhash and the blockhash's last valid slot.
|
|
||||||
pub fn get_recent_blockhash(&mut self) -> impl Future<Output = io::Result<Hash>> + '_ {
|
|
||||||
self.get_fees().map(|result| Ok(result?.1))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Send a transaction and return after the transaction has been rejected or
|
|
||||||
/// reached the given level of commitment.
|
|
||||||
pub fn process_transaction_with_commitment(
|
|
||||||
&mut self,
|
|
||||||
transaction: Transaction,
|
|
||||||
commitment: CommitmentLevel,
|
|
||||||
) -> impl Future<Output = transport::Result<()>> + '_ {
|
|
||||||
let mut ctx = context::current();
|
|
||||||
ctx.deadline += Duration::from_secs(50);
|
|
||||||
self.process_transaction_with_commitment_and_context(ctx, transaction, commitment)
|
|
||||||
.map(|result| match result? {
|
|
||||||
None => {
|
|
||||||
Err(Error::new(ErrorKind::TimedOut, "invalid blockhash or fee-payer").into())
|
|
||||||
}
|
|
||||||
Some(transaction_result) => Ok(transaction_result?),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Send a transaction and return until the transaction has been finalized or rejected.
|
|
||||||
pub fn process_transaction(
|
|
||||||
&mut self,
|
|
||||||
transaction: Transaction,
|
|
||||||
) -> impl Future<Output = transport::Result<()>> + '_ {
|
|
||||||
self.process_transaction_with_commitment(transaction, CommitmentLevel::default())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn process_transactions_with_commitment(
|
|
||||||
&mut self,
|
|
||||||
transactions: Vec<Transaction>,
|
|
||||||
commitment: CommitmentLevel,
|
|
||||||
) -> transport::Result<()> {
|
|
||||||
let mut clients: Vec<_> = transactions.iter().map(|_| self.clone()).collect();
|
|
||||||
let futures = clients
|
|
||||||
.iter_mut()
|
|
||||||
.zip(transactions)
|
|
||||||
.map(|(client, transaction)| {
|
|
||||||
client.process_transaction_with_commitment(transaction, commitment)
|
|
||||||
});
|
|
||||||
let statuses = join_all(futures).await;
|
|
||||||
statuses.into_iter().collect() // Convert Vec<Result<_, _>> to Result<Vec<_>>
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Send transactions and return until the transaction has been finalized or rejected.
|
|
||||||
pub fn process_transactions(
|
|
||||||
&mut self,
|
|
||||||
transactions: Vec<Transaction>,
|
|
||||||
) -> impl Future<Output = transport::Result<()>> + '_ {
|
|
||||||
self.process_transactions_with_commitment(transactions, CommitmentLevel::default())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the most recent rooted slot height. All transactions at or below this height
|
|
||||||
/// are said to be finalized. The cluster will not fork to a higher slot height.
|
|
||||||
pub fn get_root_slot(&mut self) -> impl Future<Output = io::Result<Slot>> + '_ {
|
|
||||||
self.get_slot_with_context(context::current(), CommitmentLevel::Root)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the account at the given address at the slot corresponding to the given
|
|
||||||
/// commitment level. If the account is not found, None is returned.
|
|
||||||
pub fn get_account_with_commitment(
|
|
||||||
&mut self,
|
|
||||||
address: Pubkey,
|
|
||||||
commitment: CommitmentLevel,
|
|
||||||
) -> impl Future<Output = io::Result<Option<Account>>> + '_ {
|
|
||||||
self.get_account_with_commitment_and_context(context::current(), address, commitment)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the account at the given address at the time of the most recent root slot.
|
|
||||||
/// If the account is not found, None is returned.
|
|
||||||
pub fn get_account(
|
|
||||||
&mut self,
|
|
||||||
address: Pubkey,
|
|
||||||
) -> impl Future<Output = io::Result<Option<Account>>> + '_ {
|
|
||||||
self.get_account_with_commitment(address, CommitmentLevel::default())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the balance in lamports of an account at the given address at the slot
|
|
||||||
/// corresponding to the given commitment level.
|
|
||||||
pub fn get_balance_with_commitment(
|
|
||||||
&mut self,
|
|
||||||
address: Pubkey,
|
|
||||||
commitment: CommitmentLevel,
|
|
||||||
) -> impl Future<Output = io::Result<u64>> + '_ {
|
|
||||||
self.get_account_with_commitment_and_context(context::current(), address, commitment)
|
|
||||||
.map(|result| Ok(result?.map(|x| x.lamports).unwrap_or(0)))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the balance in lamports of an account at the given address at the time
|
|
||||||
/// of the most recent root slot.
|
|
||||||
pub fn get_balance(&mut self, address: Pubkey) -> impl Future<Output = io::Result<u64>> + '_ {
|
|
||||||
self.get_balance_with_commitment(address, CommitmentLevel::default())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the status of a transaction with a signature matching the transaction's first
|
|
||||||
/// signature. Return None if the transaction is not found, which may be because the
|
|
||||||
/// blockhash was expired or the fee-paying account had insufficient funds to pay the
|
|
||||||
/// transaction fee. Note that servers rarely store the full transaction history. This
|
|
||||||
/// method may return None if the transaction status has been discarded.
|
|
||||||
pub fn get_transaction_status(
|
|
||||||
&mut self,
|
|
||||||
signature: Signature,
|
|
||||||
) -> impl Future<Output = io::Result<Option<TransactionStatus>>> + '_ {
|
|
||||||
self.get_transaction_status_with_context(context::current(), signature)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Same as get_transaction_status, but for multiple transactions.
|
|
||||||
pub async fn get_transaction_statuses(
|
|
||||||
&mut self,
|
|
||||||
signatures: Vec<Signature>,
|
|
||||||
) -> io::Result<Vec<Option<TransactionStatus>>> {
|
|
||||||
// tarpc futures oddly hold a mutable reference back to the client so clone the client upfront
|
|
||||||
let mut clients_and_signatures: Vec<_> = signatures
|
|
||||||
.into_iter()
|
|
||||||
.map(|signature| (self.clone(), signature))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let futs = clients_and_signatures
|
|
||||||
.iter_mut()
|
|
||||||
.map(|(client, signature)| client.get_transaction_status(*signature));
|
|
||||||
|
|
||||||
let statuses = join_all(futs).await;
|
|
||||||
|
|
||||||
// Convert Vec<Result<_, _>> to Result<Vec<_>>
|
|
||||||
statuses.into_iter().collect()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn start_client<C>(transport: C) -> io::Result<BanksClient>
|
|
||||||
where
|
|
||||||
C: Transport<ClientMessage<BanksRequest>, Response<BanksResponse>> + Send + 'static,
|
|
||||||
{
|
|
||||||
Ok(BanksClient {
|
|
||||||
inner: TarpcClient::new(client::Config::default(), transport).spawn()?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn start_tcp_client<T: ToSocketAddrs>(addr: T) -> io::Result<BanksClient> {
|
|
||||||
let transport = tcp::connect(addr, Bincode::default).await?;
|
|
||||||
Ok(BanksClient {
|
|
||||||
inner: TarpcClient::new(client::Config::default(), transport).spawn()?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
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, signature::Signer, system_instruction};
|
|
||||||
use std::sync::{Arc, RwLock};
|
|
||||||
use tarpc::transport;
|
|
||||||
use tokio::{runtime::Runtime, time::sleep};
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_banks_client_new() {
|
|
||||||
let (client_transport, _server_transport) = transport::channel::unbounded();
|
|
||||||
BanksClient::new(client::Config::default(), client_transport);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_banks_server_transfer_via_server() -> io::Result<()> {
|
|
||||||
// This test shows the preferred way to interact with BanksServer.
|
|
||||||
// It creates a runtime explicitly (no globals via tokio macros) and calls
|
|
||||||
// `runtime.block_on()` just once, to run all the async code.
|
|
||||||
|
|
||||||
let genesis = create_genesis_config(10);
|
|
||||||
let bank_forks = Arc::new(RwLock::new(BankForks::new(Bank::new(
|
|
||||||
&genesis.genesis_config,
|
|
||||||
))));
|
|
||||||
|
|
||||||
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));
|
|
||||||
|
|
||||||
Runtime::new()?.block_on(async {
|
|
||||||
let client_transport = start_local_server(&bank_forks).await;
|
|
||||||
let mut banks_client = start_client(client_transport).await?;
|
|
||||||
|
|
||||||
let recent_blockhash = banks_client.get_recent_blockhash().await?;
|
|
||||||
let transaction = Transaction::new(&[&genesis.mint_keypair], message, recent_blockhash);
|
|
||||||
banks_client.process_transaction(transaction).await.unwrap();
|
|
||||||
assert_eq!(banks_client.get_balance(bob_pubkey).await?, 1);
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_banks_server_transfer_via_client() -> io::Result<()> {
|
|
||||||
// The caller may not want to hold the connection open until the transaction
|
|
||||||
// is processed (or blockhash expires). In this test, we verify the
|
|
||||||
// server-side functionality is available to the client.
|
|
||||||
|
|
||||||
let genesis = create_genesis_config(10);
|
|
||||||
let bank_forks = Arc::new(RwLock::new(BankForks::new(Bank::new(
|
|
||||||
&genesis.genesis_config,
|
|
||||||
))));
|
|
||||||
|
|
||||||
let mint_pubkey = &genesis.mint_keypair.pubkey();
|
|
||||||
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));
|
|
||||||
|
|
||||||
Runtime::new()?.block_on(async {
|
|
||||||
let client_transport = start_local_server(&bank_forks).await;
|
|
||||||
let mut banks_client = start_client(client_transport).await?;
|
|
||||||
let (_, recent_blockhash, last_valid_slot) = banks_client.get_fees().await?;
|
|
||||||
let transaction = Transaction::new(&[&genesis.mint_keypair], message, recent_blockhash);
|
|
||||||
let signature = transaction.signatures[0];
|
|
||||||
banks_client.send_transaction(transaction).await?;
|
|
||||||
|
|
||||||
let mut status = banks_client.get_transaction_status(signature).await?;
|
|
||||||
|
|
||||||
while status.is_none() {
|
|
||||||
let root_slot = banks_client.get_root_slot().await?;
|
|
||||||
if root_slot > last_valid_slot {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
sleep(Duration::from_millis(100)).await;
|
|
||||||
status = banks_client.get_transaction_status(signature).await?;
|
|
||||||
}
|
|
||||||
assert!(status.unwrap().err.is_none());
|
|
||||||
assert_eq!(banks_client.get_balance(bob_pubkey).await?, 1);
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,25 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "solana-banks-interface"
|
|
||||||
version = "1.5.3"
|
|
||||||
description = "Solana banks RPC interface"
|
|
||||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
|
||||||
repository = "https://github.com/solana-labs/solana"
|
|
||||||
license = "Apache-2.0"
|
|
||||||
homepage = "https://solana.com/"
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
mio = "0.7.6"
|
|
||||||
serde = { version = "1.0.112", features = ["derive"] }
|
|
||||||
solana-sdk = { path = "../sdk", version = "1.5.3" }
|
|
||||||
tarpc = { version = "0.23.0", features = ["full"] }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
tokio = { version = "0.3.5", features = ["full"] }
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["lib"]
|
|
||||||
name = "solana_banks_interface"
|
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
|
@@ -1,49 +0,0 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use solana_sdk::{
|
|
||||||
account::Account,
|
|
||||||
clock::Slot,
|
|
||||||
commitment_config::CommitmentLevel,
|
|
||||||
fee_calculator::FeeCalculator,
|
|
||||||
hash::Hash,
|
|
||||||
pubkey::Pubkey,
|
|
||||||
signature::Signature,
|
|
||||||
transaction::{self, Transaction, TransactionError},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
||||||
pub struct TransactionStatus {
|
|
||||||
pub slot: Slot,
|
|
||||||
pub confirmations: Option<usize>, // None = rooted
|
|
||||||
pub err: Option<TransactionError>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tarpc::service]
|
|
||||||
pub trait Banks {
|
|
||||||
async fn send_transaction_with_context(transaction: Transaction);
|
|
||||||
async fn get_fees_with_commitment_and_context(
|
|
||||||
commitment: CommitmentLevel,
|
|
||||||
) -> (FeeCalculator, Hash, Slot);
|
|
||||||
async fn get_transaction_status_with_context(signature: Signature)
|
|
||||||
-> Option<TransactionStatus>;
|
|
||||||
async fn get_slot_with_context(commitment: CommitmentLevel) -> Slot;
|
|
||||||
async fn process_transaction_with_commitment_and_context(
|
|
||||||
transaction: Transaction,
|
|
||||||
commitment: CommitmentLevel,
|
|
||||||
) -> Option<transaction::Result<()>>;
|
|
||||||
async fn get_account_with_commitment_and_context(
|
|
||||||
address: Pubkey,
|
|
||||||
commitment: CommitmentLevel,
|
|
||||||
) -> Option<Account>;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
use tarpc::{client, transport};
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_banks_client_new() {
|
|
||||||
let (client_transport, _server_transport) = transport::channel::unbounded();
|
|
||||||
BanksClient::new(client::Config::default(), client_transport);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,29 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "solana-banks-server"
|
|
||||||
version = "1.5.3"
|
|
||||||
description = "Solana banks server"
|
|
||||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
|
||||||
repository = "https://github.com/solana-labs/solana"
|
|
||||||
license = "Apache-2.0"
|
|
||||||
homepage = "https://solana.com/"
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
bincode = "1.3.1"
|
|
||||||
futures = "0.3"
|
|
||||||
log = "0.4.11"
|
|
||||||
mio = "0.7.6"
|
|
||||||
solana-banks-interface = { path = "../banks-interface", version = "1.5.3" }
|
|
||||||
solana-runtime = { path = "../runtime", version = "1.5.3" }
|
|
||||||
solana-sdk = { path = "../sdk", version = "1.5.3" }
|
|
||||||
solana-metrics = { path = "../metrics", version = "1.5.3" }
|
|
||||||
tarpc = { version = "0.23.0", features = ["full"] }
|
|
||||||
tokio = { version = "0.3", features = ["full"] }
|
|
||||||
tokio-serde = { version = "0.6", features = ["bincode"] }
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["lib"]
|
|
||||||
name = "solana_banks_server"
|
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
|
@@ -1,275 +0,0 @@
|
|||||||
use crate::send_transaction_service::{SendTransactionService, TransactionInfo};
|
|
||||||
use bincode::{deserialize, serialize};
|
|
||||||
use futures::{
|
|
||||||
future,
|
|
||||||
prelude::stream::{self, StreamExt},
|
|
||||||
};
|
|
||||||
use solana_banks_interface::{Banks, BanksRequest, BanksResponse, TransactionStatus};
|
|
||||||
use solana_runtime::{bank::Bank, bank_forks::BankForks, commitment::BlockCommitmentCache};
|
|
||||||
use solana_sdk::{
|
|
||||||
account::Account,
|
|
||||||
clock::Slot,
|
|
||||||
commitment_config::CommitmentLevel,
|
|
||||||
fee_calculator::FeeCalculator,
|
|
||||||
hash::Hash,
|
|
||||||
pubkey::Pubkey,
|
|
||||||
signature::Signature,
|
|
||||||
transaction::{self, Transaction},
|
|
||||||
};
|
|
||||||
use std::{
|
|
||||||
io,
|
|
||||||
net::{Ipv4Addr, SocketAddr},
|
|
||||||
sync::{
|
|
||||||
mpsc::{channel, Receiver, Sender},
|
|
||||||
Arc, RwLock,
|
|
||||||
},
|
|
||||||
thread::Builder,
|
|
||||||
time::Duration,
|
|
||||||
};
|
|
||||||
use tarpc::{
|
|
||||||
context::Context,
|
|
||||||
rpc::{transport::channel::UnboundedChannel, ClientMessage, Response},
|
|
||||||
serde_transport::tcp,
|
|
||||||
server::{self, Channel, Handler},
|
|
||||||
transport,
|
|
||||||
};
|
|
||||||
use tokio::time::sleep;
|
|
||||||
use tokio_serde::formats::Bincode;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
struct BanksServer {
|
|
||||||
bank_forks: Arc<RwLock<BankForks>>,
|
|
||||||
block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>,
|
|
||||||
transaction_sender: Sender<TransactionInfo>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BanksServer {
|
|
||||||
/// Return a BanksServer that forwards transactions to the
|
|
||||||
/// given sender. If unit-testing, those transactions can go to
|
|
||||||
/// a bank in the given BankForks. Otherwise, the receiver should
|
|
||||||
/// forward them to a validator in the leader schedule.
|
|
||||||
fn new(
|
|
||||||
bank_forks: Arc<RwLock<BankForks>>,
|
|
||||||
block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>,
|
|
||||||
transaction_sender: Sender<TransactionInfo>,
|
|
||||||
) -> Self {
|
|
||||||
Self {
|
|
||||||
bank_forks,
|
|
||||||
block_commitment_cache,
|
|
||||||
transaction_sender,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run(bank: &Bank, transaction_receiver: Receiver<TransactionInfo>) {
|
|
||||||
while let Ok(info) = transaction_receiver.recv() {
|
|
||||||
let mut transaction_infos = vec![info];
|
|
||||||
while let Ok(info) = transaction_receiver.try_recv() {
|
|
||||||
transaction_infos.push(info);
|
|
||||||
}
|
|
||||||
let transactions: Vec<_> = transaction_infos
|
|
||||||
.into_iter()
|
|
||||||
.map(|info| deserialize(&info.wire_transaction).unwrap())
|
|
||||||
.collect();
|
|
||||||
let _ = bank.process_transactions(&transactions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Useful for unit-testing
|
|
||||||
fn new_loopback(bank_forks: Arc<RwLock<BankForks>>) -> Self {
|
|
||||||
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_for_tests_with_slots(slot, slot),
|
|
||||||
));
|
|
||||||
Builder::new()
|
|
||||||
.name("solana-bank-forks-client".to_string())
|
|
||||||
.spawn(move || Self::run(&bank, transaction_receiver))
|
|
||||||
.unwrap();
|
|
||||||
Self::new(bank_forks, block_commitment_cache, transaction_sender)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn slot(&self, commitment: CommitmentLevel) -> Slot {
|
|
||||||
self.block_commitment_cache
|
|
||||||
.read()
|
|
||||||
.unwrap()
|
|
||||||
.slot_with_commitment(commitment)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn bank(&self, commitment: CommitmentLevel) -> Arc<Bank> {
|
|
||||||
self.bank_forks.read().unwrap()[self.slot(commitment)].clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn poll_signature_status(
|
|
||||||
self,
|
|
||||||
signature: &Signature,
|
|
||||||
blockhash: &Hash,
|
|
||||||
last_valid_slot: Slot,
|
|
||||||
commitment: CommitmentLevel,
|
|
||||||
) -> Option<transaction::Result<()>> {
|
|
||||||
let mut status = self
|
|
||||||
.bank(commitment)
|
|
||||||
.get_signature_status_with_blockhash(signature, blockhash);
|
|
||||||
while status.is_none() {
|
|
||||||
sleep(Duration::from_millis(200)).await;
|
|
||||||
let bank = self.bank(commitment);
|
|
||||||
if bank.slot() > last_valid_slot {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
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) {
|
|
||||||
let blockhash = &transaction.message.recent_blockhash;
|
|
||||||
let last_valid_slot = self
|
|
||||||
.bank_forks
|
|
||||||
.read()
|
|
||||||
.unwrap()
|
|
||||||
.root_bank()
|
|
||||||
.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();
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_fees_with_commitment_and_context(
|
|
||||||
self,
|
|
||||||
_: Context,
|
|
||||||
commitment: CommitmentLevel,
|
|
||||||
) -> (FeeCalculator, Hash, Slot) {
|
|
||||||
let bank = self.bank(commitment);
|
|
||||||
let (blockhash, fee_calculator) = bank.last_blockhash_with_fee_calculator();
|
|
||||||
let last_valid_slot = bank.get_blockhash_last_valid_slot(&blockhash).unwrap();
|
|
||||||
(fee_calculator, blockhash, last_valid_slot)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_transaction_status_with_context(
|
|
||||||
self,
|
|
||||||
_: Context,
|
|
||||||
signature: Signature,
|
|
||||||
) -> Option<TransactionStatus> {
|
|
||||||
let bank = self.bank(CommitmentLevel::Recent);
|
|
||||||
let (slot, status) = bank.get_signature_status_slot(&signature)?;
|
|
||||||
let r_block_commitment_cache = self.block_commitment_cache.read().unwrap();
|
|
||||||
|
|
||||||
let confirmations = if r_block_commitment_cache.root() >= slot {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
r_block_commitment_cache
|
|
||||||
.get_confirmation_count(slot)
|
|
||||||
.or(Some(0))
|
|
||||||
};
|
|
||||||
Some(TransactionStatus {
|
|
||||||
slot,
|
|
||||||
confirmations,
|
|
||||||
err: status.err(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_slot_with_context(self, _: Context, commitment: CommitmentLevel) -> Slot {
|
|
||||||
self.slot(commitment)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn process_transaction_with_commitment_and_context(
|
|
||||||
self,
|
|
||||||
_: Context,
|
|
||||||
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)
|
|
||||||
.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, blockhash, last_valid_slot, commitment)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_account_with_commitment_and_context(
|
|
||||||
self,
|
|
||||||
_: Context,
|
|
||||||
address: Pubkey,
|
|
||||||
commitment: CommitmentLevel,
|
|
||||||
) -> Option<Account> {
|
|
||||||
let bank = self.bank(commitment);
|
|
||||||
bank.get_account(&address)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn start_local_server(
|
|
||||||
bank_forks: &Arc<RwLock<BankForks>>,
|
|
||||||
) -> UnboundedChannel<Response<BanksResponse>, ClientMessage<BanksRequest>> {
|
|
||||||
let banks_server = BanksServer::new_loopback(bank_forks.clone());
|
|
||||||
let (client_transport, server_transport) = transport::channel::unbounded();
|
|
||||||
let server = server::new(server::Config::default())
|
|
||||||
.incoming(stream::once(future::ready(server_transport)))
|
|
||||||
.respond_with(banks_server.serve());
|
|
||||||
tokio::spawn(server);
|
|
||||||
client_transport
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn start_tcp_server(
|
|
||||||
listen_addr: SocketAddr,
|
|
||||||
tpu_addr: SocketAddr,
|
|
||||||
bank_forks: Arc<RwLock<BankForks>>,
|
|
||||||
block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>,
|
|
||||||
) -> io::Result<()> {
|
|
||||||
// Note: These settings are copied straight from the tarpc example.
|
|
||||||
let server = tcp::listen(listen_addr, Bincode::default)
|
|
||||||
.await?
|
|
||||||
// Ignore accept errors.
|
|
||||||
.filter_map(|r| future::ready(r.ok()))
|
|
||||||
.map(server::BaseChannel::with_defaults)
|
|
||||||
// Limit channels to 1 per IP.
|
|
||||||
.max_channels_per_key(1, |t| {
|
|
||||||
t.as_ref()
|
|
||||||
.peer_addr()
|
|
||||||
.map(|x| x.ip())
|
|
||||||
.unwrap_or_else(|_| Ipv4Addr::new(0, 0, 0, 0).into())
|
|
||||||
})
|
|
||||||
// serve is generated by the service attribute. It takes as input any type implementing
|
|
||||||
// the generated Banks trait.
|
|
||||||
.map(move |chan| {
|
|
||||||
let (sender, receiver) = channel();
|
|
||||||
|
|
||||||
SendTransactionService::new(tpu_addr, &bank_forks, receiver);
|
|
||||||
|
|
||||||
let server =
|
|
||||||
BanksServer::new(bank_forks.clone(), block_commitment_cache.clone(), sender);
|
|
||||||
chan.respond_with(server.serve()).execute()
|
|
||||||
})
|
|
||||||
// Max 10 channels.
|
|
||||||
.buffer_unordered(10)
|
|
||||||
.for_each(|_| async {});
|
|
||||||
|
|
||||||
server.await;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
@@ -1,6 +0,0 @@
|
|||||||
pub mod banks_server;
|
|
||||||
pub mod rpc_banks_service;
|
|
||||||
pub mod send_transaction_service;
|
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate solana_metrics;
|
|
@@ -1,116 +0,0 @@
|
|||||||
//! The `rpc_banks_service` module implements the Solana Banks RPC API.
|
|
||||||
|
|
||||||
use crate::banks_server::start_tcp_server;
|
|
||||||
use futures::{future::FutureExt, pin_mut, prelude::stream::StreamExt, select};
|
|
||||||
use solana_runtime::{bank_forks::BankForks, commitment::BlockCommitmentCache};
|
|
||||||
use std::{
|
|
||||||
net::SocketAddr,
|
|
||||||
sync::{
|
|
||||||
atomic::{AtomicBool, Ordering},
|
|
||||||
Arc, RwLock,
|
|
||||||
},
|
|
||||||
thread::{self, Builder, JoinHandle},
|
|
||||||
};
|
|
||||||
use tokio::{
|
|
||||||
runtime::Runtime,
|
|
||||||
time::{self, Duration},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub struct RpcBanksService {
|
|
||||||
thread_hdl: JoinHandle<()>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Run the TCP service until `exit` is set to true
|
|
||||||
async fn start_abortable_tcp_server(
|
|
||||||
listen_addr: SocketAddr,
|
|
||||||
tpu_addr: SocketAddr,
|
|
||||||
bank_forks: Arc<RwLock<BankForks>>,
|
|
||||||
block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>,
|
|
||||||
exit: Arc<AtomicBool>,
|
|
||||||
) {
|
|
||||||
let server = start_tcp_server(
|
|
||||||
listen_addr,
|
|
||||||
tpu_addr,
|
|
||||||
bank_forks.clone(),
|
|
||||||
block_commitment_cache.clone(),
|
|
||||||
)
|
|
||||||
.fuse();
|
|
||||||
let interval = time::interval(Duration::from_millis(100)).fuse();
|
|
||||||
pin_mut!(server, interval);
|
|
||||||
loop {
|
|
||||||
select! {
|
|
||||||
_ = server => {},
|
|
||||||
_ = interval.select_next_some() => {
|
|
||||||
if exit.load(Ordering::Relaxed) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RpcBanksService {
|
|
||||||
fn run(
|
|
||||||
listen_addr: SocketAddr,
|
|
||||||
tpu_addr: SocketAddr,
|
|
||||||
bank_forks: Arc<RwLock<BankForks>>,
|
|
||||||
block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>,
|
|
||||||
exit: Arc<AtomicBool>,
|
|
||||||
) {
|
|
||||||
let server = start_abortable_tcp_server(
|
|
||||||
listen_addr,
|
|
||||||
tpu_addr,
|
|
||||||
bank_forks,
|
|
||||||
block_commitment_cache,
|
|
||||||
exit,
|
|
||||||
);
|
|
||||||
Runtime::new().unwrap().block_on(server);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new(
|
|
||||||
listen_addr: SocketAddr,
|
|
||||||
tpu_addr: SocketAddr,
|
|
||||||
bank_forks: &Arc<RwLock<BankForks>>,
|
|
||||||
block_commitment_cache: &Arc<RwLock<BlockCommitmentCache>>,
|
|
||||||
exit: &Arc<AtomicBool>,
|
|
||||||
) -> Self {
|
|
||||||
let bank_forks = bank_forks.clone();
|
|
||||||
let block_commitment_cache = block_commitment_cache.clone();
|
|
||||||
let exit = exit.clone();
|
|
||||||
let thread_hdl = Builder::new()
|
|
||||||
.name("solana-rpc-banks".to_string())
|
|
||||||
.spawn(move || {
|
|
||||||
Self::run(
|
|
||||||
listen_addr,
|
|
||||||
tpu_addr,
|
|
||||||
bank_forks,
|
|
||||||
block_commitment_cache,
|
|
||||||
exit,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
Self { thread_hdl }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn join(self) -> thread::Result<()> {
|
|
||||||
self.thread_hdl.join()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
use solana_runtime::bank::Bank;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_rpc_banks_server_exit() {
|
|
||||||
let bank_forks = Arc::new(RwLock::new(BankForks::new(Bank::default())));
|
|
||||||
let block_commitment_cache = Arc::new(RwLock::new(BlockCommitmentCache::default()));
|
|
||||||
let exit = Arc::new(AtomicBool::new(false));
|
|
||||||
let addr = "127.0.0.1:0".parse().unwrap();
|
|
||||||
let service = RpcBanksService::new(addr, addr, &bank_forks, &block_commitment_cache, &exit);
|
|
||||||
exit.store(true, Ordering::Relaxed);
|
|
||||||
service.join().unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,343 +0,0 @@
|
|||||||
// TODO: Merge this implementation with the one at `core/src/send_transaction_service.rs`
|
|
||||||
use log::*;
|
|
||||||
use solana_metrics::{datapoint_warn, inc_new_counter_info};
|
|
||||||
use solana_runtime::{bank::Bank, bank_forks::BankForks};
|
|
||||||
use solana_sdk::{clock::Slot, signature::Signature};
|
|
||||||
use std::{
|
|
||||||
collections::HashMap,
|
|
||||||
net::{SocketAddr, UdpSocket},
|
|
||||||
sync::{
|
|
||||||
mpsc::{Receiver, RecvTimeoutError},
|
|
||||||
Arc, RwLock,
|
|
||||||
},
|
|
||||||
thread::{self, Builder, JoinHandle},
|
|
||||||
time::{Duration, Instant},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Maximum size of the transaction queue
|
|
||||||
const MAX_TRANSACTION_QUEUE_SIZE: usize = 10_000; // This seems like a lot but maybe it needs to be bigger one day
|
|
||||||
|
|
||||||
pub struct SendTransactionService {
|
|
||||||
thread: JoinHandle<()>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct TransactionInfo {
|
|
||||||
pub signature: Signature,
|
|
||||||
pub wire_transaction: Vec<u8>,
|
|
||||||
pub last_valid_slot: Slot,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TransactionInfo {
|
|
||||||
pub fn new(signature: Signature, wire_transaction: Vec<u8>, last_valid_slot: Slot) -> Self {
|
|
||||||
Self {
|
|
||||||
signature,
|
|
||||||
wire_transaction,
|
|
||||||
last_valid_slot,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Debug, PartialEq)]
|
|
||||||
struct ProcessTransactionsResult {
|
|
||||||
rooted: u64,
|
|
||||||
expired: u64,
|
|
||||||
retried: u64,
|
|
||||||
failed: u64,
|
|
||||||
retained: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SendTransactionService {
|
|
||||||
pub fn new(
|
|
||||||
tpu_address: SocketAddr,
|
|
||||||
bank_forks: &Arc<RwLock<BankForks>>,
|
|
||||||
receiver: Receiver<TransactionInfo>,
|
|
||||||
) -> Self {
|
|
||||||
let thread = Self::retry_thread(receiver, bank_forks.clone(), tpu_address);
|
|
||||||
Self { thread }
|
|
||||||
}
|
|
||||||
|
|
||||||
fn retry_thread(
|
|
||||||
receiver: Receiver<TransactionInfo>,
|
|
||||||
bank_forks: Arc<RwLock<BankForks>>,
|
|
||||||
tpu_address: SocketAddr,
|
|
||||||
) -> JoinHandle<()> {
|
|
||||||
let mut last_status_check = Instant::now();
|
|
||||||
let mut transactions = HashMap::new();
|
|
||||||
let send_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
|
||||||
|
|
||||||
Builder::new()
|
|
||||||
.name("send-tx-svc".to_string())
|
|
||||||
.spawn(move || loop {
|
|
||||||
match receiver.recv_timeout(Duration::from_secs(1)) {
|
|
||||||
Err(RecvTimeoutError::Disconnected) => break,
|
|
||||||
Err(RecvTimeoutError::Timeout) => {}
|
|
||||||
Ok(transaction_info) => {
|
|
||||||
Self::send_transaction(
|
|
||||||
&send_socket,
|
|
||||||
&tpu_address,
|
|
||||||
&transaction_info.wire_transaction,
|
|
||||||
);
|
|
||||||
if transactions.len() < MAX_TRANSACTION_QUEUE_SIZE {
|
|
||||||
transactions.insert(transaction_info.signature, transaction_info);
|
|
||||||
} else {
|
|
||||||
datapoint_warn!("send_transaction_service-queue-overflow");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if Instant::now().duration_since(last_status_check).as_secs() >= 5 {
|
|
||||||
if !transactions.is_empty() {
|
|
||||||
datapoint_info!(
|
|
||||||
"send_transaction_service-queue-size",
|
|
||||||
("len", transactions.len(), i64)
|
|
||||||
);
|
|
||||||
let bank_forks = bank_forks.read().unwrap();
|
|
||||||
let root_bank = bank_forks.root_bank();
|
|
||||||
let working_bank = bank_forks.working_bank();
|
|
||||||
|
|
||||||
let _result = Self::process_transactions(
|
|
||||||
&working_bank,
|
|
||||||
&root_bank,
|
|
||||||
&send_socket,
|
|
||||||
&tpu_address,
|
|
||||||
&mut transactions,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
last_status_check = Instant::now();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn process_transactions(
|
|
||||||
working_bank: &Arc<Bank>,
|
|
||||||
root_bank: &Arc<Bank>,
|
|
||||||
send_socket: &UdpSocket,
|
|
||||||
tpu_address: &SocketAddr,
|
|
||||||
transactions: &mut HashMap<Signature, TransactionInfo>,
|
|
||||||
) -> ProcessTransactionsResult {
|
|
||||||
let mut result = ProcessTransactionsResult::default();
|
|
||||||
|
|
||||||
transactions.retain(|signature, transaction_info| {
|
|
||||||
if root_bank.has_signature(signature) {
|
|
||||||
info!("Transaction is rooted: {}", signature);
|
|
||||||
result.rooted += 1;
|
|
||||||
inc_new_counter_info!("send_transaction_service-rooted", 1);
|
|
||||||
false
|
|
||||||
} else if transaction_info.last_valid_slot < root_bank.slot() {
|
|
||||||
info!("Dropping expired transaction: {}", signature);
|
|
||||||
result.expired += 1;
|
|
||||||
inc_new_counter_info!("send_transaction_service-expired", 1);
|
|
||||||
false
|
|
||||||
} else {
|
|
||||||
match working_bank.get_signature_status_slot(signature) {
|
|
||||||
None => {
|
|
||||||
// Transaction is unknown to the working bank, it might have been
|
|
||||||
// dropped or landed in another fork. Re-send it
|
|
||||||
info!("Retrying transaction: {}", signature);
|
|
||||||
result.retried += 1;
|
|
||||||
inc_new_counter_info!("send_transaction_service-retry", 1);
|
|
||||||
Self::send_transaction(
|
|
||||||
&send_socket,
|
|
||||||
&tpu_address,
|
|
||||||
&transaction_info.wire_transaction,
|
|
||||||
);
|
|
||||||
true
|
|
||||||
}
|
|
||||||
Some((_slot, status)) => {
|
|
||||||
if status.is_err() {
|
|
||||||
info!("Dropping failed transaction: {}", signature);
|
|
||||||
result.failed += 1;
|
|
||||||
inc_new_counter_info!("send_transaction_service-failed", 1);
|
|
||||||
false
|
|
||||||
} else {
|
|
||||||
result.retained += 1;
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|
||||||
fn send_transaction(
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn join(self) -> thread::Result<()> {
|
|
||||||
self.thread.join()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod test {
|
|
||||||
use super::*;
|
|
||||||
use solana_sdk::{
|
|
||||||
genesis_config::create_genesis_config, pubkey::Pubkey, signature::Signer,
|
|
||||||
system_transaction,
|
|
||||||
};
|
|
||||||
use std::sync::mpsc::channel;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn service_exit() {
|
|
||||||
let tpu_address = "127.0.0.1:0".parse().unwrap();
|
|
||||||
let bank = Bank::default();
|
|
||||||
let bank_forks = Arc::new(RwLock::new(BankForks::new(bank)));
|
|
||||||
let (sender, receiver) = channel();
|
|
||||||
|
|
||||||
let send_tranaction_service =
|
|
||||||
SendTransactionService::new(tpu_address, &bank_forks, receiver);
|
|
||||||
|
|
||||||
drop(sender);
|
|
||||||
send_tranaction_service.join().unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn process_transactions() {
|
|
||||||
let (genesis_config, mint_keypair) = create_genesis_config(4);
|
|
||||||
let bank = Bank::new(&genesis_config);
|
|
||||||
let bank_forks = Arc::new(RwLock::new(BankForks::new(bank)));
|
|
||||||
let send_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
|
||||||
let tpu_address = "127.0.0.1:0".parse().unwrap();
|
|
||||||
|
|
||||||
let root_bank = Arc::new(Bank::new_from_parent(
|
|
||||||
&bank_forks.read().unwrap().working_bank(),
|
|
||||||
&Pubkey::default(),
|
|
||||||
1,
|
|
||||||
));
|
|
||||||
let rooted_signature = root_bank
|
|
||||||
.transfer(1, &mint_keypair, &mint_keypair.pubkey())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let working_bank = Arc::new(Bank::new_from_parent(&root_bank, &Pubkey::default(), 2));
|
|
||||||
|
|
||||||
let non_rooted_signature = working_bank
|
|
||||||
.transfer(2, &mint_keypair, &mint_keypair.pubkey())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let failed_signature = {
|
|
||||||
let blockhash = working_bank.last_blockhash();
|
|
||||||
let transaction =
|
|
||||||
system_transaction::transfer(&mint_keypair, &Pubkey::default(), 1, blockhash);
|
|
||||||
let signature = transaction.signatures[0];
|
|
||||||
working_bank.process_transaction(&transaction).unwrap_err();
|
|
||||||
signature
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut transactions = HashMap::new();
|
|
||||||
|
|
||||||
info!("Expired transactions are dropped..");
|
|
||||||
transactions.insert(
|
|
||||||
Signature::default(),
|
|
||||||
TransactionInfo::new(Signature::default(), vec![], root_bank.slot() - 1),
|
|
||||||
);
|
|
||||||
let result = SendTransactionService::process_transactions(
|
|
||||||
&working_bank,
|
|
||||||
&root_bank,
|
|
||||||
&send_socket,
|
|
||||||
&tpu_address,
|
|
||||||
&mut transactions,
|
|
||||||
);
|
|
||||||
assert!(transactions.is_empty());
|
|
||||||
assert_eq!(
|
|
||||||
result,
|
|
||||||
ProcessTransactionsResult {
|
|
||||||
expired: 1,
|
|
||||||
..ProcessTransactionsResult::default()
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
info!("Rooted transactions are dropped...");
|
|
||||||
transactions.insert(
|
|
||||||
rooted_signature,
|
|
||||||
TransactionInfo::new(rooted_signature, vec![], working_bank.slot()),
|
|
||||||
);
|
|
||||||
let result = SendTransactionService::process_transactions(
|
|
||||||
&working_bank,
|
|
||||||
&root_bank,
|
|
||||||
&send_socket,
|
|
||||||
&tpu_address,
|
|
||||||
&mut transactions,
|
|
||||||
);
|
|
||||||
assert!(transactions.is_empty());
|
|
||||||
assert_eq!(
|
|
||||||
result,
|
|
||||||
ProcessTransactionsResult {
|
|
||||||
rooted: 1,
|
|
||||||
..ProcessTransactionsResult::default()
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
info!("Failed transactions are dropped...");
|
|
||||||
transactions.insert(
|
|
||||||
failed_signature,
|
|
||||||
TransactionInfo::new(failed_signature, vec![], working_bank.slot()),
|
|
||||||
);
|
|
||||||
let result = SendTransactionService::process_transactions(
|
|
||||||
&working_bank,
|
|
||||||
&root_bank,
|
|
||||||
&send_socket,
|
|
||||||
&tpu_address,
|
|
||||||
&mut transactions,
|
|
||||||
);
|
|
||||||
assert!(transactions.is_empty());
|
|
||||||
assert_eq!(
|
|
||||||
result,
|
|
||||||
ProcessTransactionsResult {
|
|
||||||
failed: 1,
|
|
||||||
..ProcessTransactionsResult::default()
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
info!("Non-rooted transactions are kept...");
|
|
||||||
transactions.insert(
|
|
||||||
non_rooted_signature,
|
|
||||||
TransactionInfo::new(non_rooted_signature, vec![], working_bank.slot()),
|
|
||||||
);
|
|
||||||
let result = SendTransactionService::process_transactions(
|
|
||||||
&working_bank,
|
|
||||||
&root_bank,
|
|
||||||
&send_socket,
|
|
||||||
&tpu_address,
|
|
||||||
&mut transactions,
|
|
||||||
);
|
|
||||||
assert_eq!(transactions.len(), 1);
|
|
||||||
assert_eq!(
|
|
||||||
result,
|
|
||||||
ProcessTransactionsResult {
|
|
||||||
retained: 1,
|
|
||||||
..ProcessTransactionsResult::default()
|
|
||||||
}
|
|
||||||
);
|
|
||||||
transactions.clear();
|
|
||||||
|
|
||||||
info!("Unknown transactions are retried...");
|
|
||||||
transactions.insert(
|
|
||||||
Signature::default(),
|
|
||||||
TransactionInfo::new(Signature::default(), vec![], working_bank.slot()),
|
|
||||||
);
|
|
||||||
let result = SendTransactionService::process_transactions(
|
|
||||||
&working_bank,
|
|
||||||
&root_bank,
|
|
||||||
&send_socket,
|
|
||||||
&tpu_address,
|
|
||||||
&mut transactions,
|
|
||||||
);
|
|
||||||
assert_eq!(transactions.len(), 1);
|
|
||||||
assert_eq!(
|
|
||||||
result,
|
|
||||||
ProcessTransactionsResult {
|
|
||||||
retried: 1,
|
|
||||||
..ProcessTransactionsResult::default()
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,8 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
name = "solana-bench-exchange"
|
name = "solana-bench-exchange"
|
||||||
version = "1.5.3"
|
version = "1.2.33"
|
||||||
repository = "https://github.com/solana-labs/solana"
|
repository = "https://github.com/solana-labs/solana"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
homepage = "https://solana.com/"
|
homepage = "https://solana.com/"
|
||||||
@@ -11,28 +11,28 @@ publish = false
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.33.1"
|
clap = "2.33.1"
|
||||||
itertools = "0.9.0"
|
itertools = "0.9.0"
|
||||||
log = "0.4.11"
|
log = "0.4.8"
|
||||||
num-derive = "0.3"
|
num-derive = "0.3"
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
rand = "0.7.0"
|
rand = "0.7.0"
|
||||||
rayon = "1.4.0"
|
rayon = "1.4.0"
|
||||||
serde_json = "1.0.56"
|
serde_json = "1.0.53"
|
||||||
serde_yaml = "0.8.13"
|
serde_yaml = "0.8.12"
|
||||||
solana-clap-utils = { path = "../clap-utils", version = "1.5.3" }
|
solana-clap-utils = { path = "../clap-utils", version = "1.2.33" }
|
||||||
solana-core = { path = "../core", version = "1.5.3" }
|
solana-core = { path = "../core", version = "1.2.33" }
|
||||||
solana-genesis = { path = "../genesis", version = "1.5.3" }
|
solana-genesis = { path = "../genesis", version = "1.2.33" }
|
||||||
solana-client = { path = "../client", version = "1.5.3" }
|
solana-client = { path = "../client", version = "1.2.33" }
|
||||||
solana-faucet = { path = "../faucet", version = "1.5.3" }
|
solana-faucet = { path = "../faucet", version = "1.2.33" }
|
||||||
solana-exchange-program = { path = "../programs/exchange", version = "1.5.3" }
|
solana-exchange-program = { path = "../programs/exchange", version = "1.2.33" }
|
||||||
solana-logger = { path = "../logger", version = "1.5.3" }
|
solana-logger = { path = "../logger", version = "1.2.33" }
|
||||||
solana-metrics = { path = "../metrics", version = "1.5.3" }
|
solana-metrics = { path = "../metrics", version = "1.2.33" }
|
||||||
solana-net-utils = { path = "../net-utils", version = "1.5.3" }
|
solana-net-utils = { path = "../net-utils", version = "1.2.33" }
|
||||||
solana-runtime = { path = "../runtime", version = "1.5.3" }
|
solana-runtime = { path = "../runtime", version = "1.2.33" }
|
||||||
solana-sdk = { path = "../sdk", version = "1.5.3" }
|
solana-sdk = { path = "../sdk", version = "1.2.33" }
|
||||||
solana-version = { path = "../version", version = "1.5.3" }
|
solana-version = { path = "../version", version = "1.2.33" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
solana-local-cluster = { path = "../local-cluster", version = "1.5.3" }
|
solana-local-cluster = { path = "../local-cluster", version = "1.2.33" }
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
@@ -179,13 +179,19 @@ where
|
|||||||
|
|
||||||
info!("Generating {:?} account keys", total_keys);
|
info!("Generating {:?} account keys", total_keys);
|
||||||
let mut account_keypairs = generate_keypairs(total_keys);
|
let mut account_keypairs = generate_keypairs(total_keys);
|
||||||
let src_keypairs: Vec<_> = account_keypairs.drain(0..accounts_in_groups).collect();
|
let src_keypairs: Vec<_> = account_keypairs
|
||||||
|
.drain(0..accounts_in_groups)
|
||||||
|
.map(|keypair| keypair)
|
||||||
|
.collect();
|
||||||
let src_pubkeys: Vec<Pubkey> = src_keypairs
|
let src_pubkeys: Vec<Pubkey> = src_keypairs
|
||||||
.iter()
|
.iter()
|
||||||
.map(|keypair| keypair.pubkey())
|
.map(|keypair| keypair.pubkey())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let profit_keypairs: Vec<_> = account_keypairs.drain(0..accounts_in_groups).collect();
|
let profit_keypairs: Vec<_> = account_keypairs
|
||||||
|
.drain(0..accounts_in_groups)
|
||||||
|
.map(|keypair| keypair)
|
||||||
|
.collect();
|
||||||
let profit_pubkeys: Vec<Pubkey> = profit_keypairs
|
let profit_pubkeys: Vec<Pubkey> = profit_keypairs
|
||||||
.iter()
|
.iter()
|
||||||
.map(|keypair| keypair.pubkey())
|
.map(|keypair| keypair.pubkey())
|
||||||
|
@@ -163,8 +163,7 @@ pub fn build_args<'a, 'b>(version: &'b str) -> App<'a, 'b> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::field_reassign_with_default)]
|
pub fn extract_args<'a>(matches: &ArgMatches<'a>) -> Config {
|
||||||
pub fn extract_args(matches: &ArgMatches) -> Config {
|
|
||||||
let mut args = Config::default();
|
let mut args = Config::default();
|
||||||
|
|
||||||
args.entrypoint_addr = solana_net_utils::parse_host_port(
|
args.entrypoint_addr = solana_net_utils::parse_host_port(
|
||||||
|
@@ -22,17 +22,15 @@ fn test_exchange_local_cluster() {
|
|||||||
|
|
||||||
const NUM_NODES: usize = 1;
|
const NUM_NODES: usize = 1;
|
||||||
|
|
||||||
let config = Config {
|
let mut config = Config::default();
|
||||||
identity: Keypair::new(),
|
config.identity = Keypair::new();
|
||||||
duration: Duration::from_secs(1),
|
config.duration = Duration::from_secs(1);
|
||||||
fund_amount: 100_000,
|
config.fund_amount = 100_000;
|
||||||
threads: 1,
|
config.threads = 1;
|
||||||
transfer_delay: 20, // 15
|
config.transfer_delay = 20; // 15
|
||||||
batch_size: 100, // 1000
|
config.batch_size = 100; // 1000;
|
||||||
chunk_size: 10, // 200
|
config.chunk_size = 10; // 200;
|
||||||
account_groups: 1, // 10
|
config.account_groups = 1; // 10;
|
||||||
..Config::default()
|
|
||||||
};
|
|
||||||
let Config {
|
let Config {
|
||||||
fund_amount,
|
fund_amount,
|
||||||
batch_size,
|
batch_size,
|
||||||
@@ -41,7 +39,7 @@ fn test_exchange_local_cluster() {
|
|||||||
} = config;
|
} = config;
|
||||||
let accounts_in_groups = batch_size * account_groups;
|
let accounts_in_groups = batch_size * account_groups;
|
||||||
|
|
||||||
let cluster = LocalCluster::new(&mut ClusterConfig {
|
let cluster = LocalCluster::new(&ClusterConfig {
|
||||||
node_stakes: vec![100_000; NUM_NODES],
|
node_stakes: vec![100_000; NUM_NODES],
|
||||||
cluster_lamports: 100_000_000_000_000,
|
cluster_lamports: 100_000_000_000_000,
|
||||||
validator_configs: vec![ValidatorConfig::default(); NUM_NODES],
|
validator_configs: vec![ValidatorConfig::default(); NUM_NODES],
|
||||||
@@ -88,21 +86,18 @@ fn test_exchange_bank_client() {
|
|||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
let (genesis_config, identity) = create_genesis_config(100_000_000_000_000);
|
let (genesis_config, identity) = create_genesis_config(100_000_000_000_000);
|
||||||
let mut bank = Bank::new(&genesis_config);
|
let mut bank = Bank::new(&genesis_config);
|
||||||
bank.add_builtin("exchange_program", id(), process_instruction);
|
bank.add_builtin_program("exchange_program", id(), process_instruction);
|
||||||
let clients = vec![BankClient::new(bank)];
|
let clients = vec![BankClient::new(bank)];
|
||||||
|
|
||||||
do_bench_exchange(
|
let mut config = Config::default();
|
||||||
clients,
|
config.identity = identity;
|
||||||
Config {
|
config.duration = Duration::from_secs(1);
|
||||||
identity,
|
config.fund_amount = 100_000;
|
||||||
duration: Duration::from_secs(1),
|
config.threads = 1;
|
||||||
fund_amount: 100_000,
|
config.transfer_delay = 20; // 0;
|
||||||
threads: 1,
|
config.batch_size = 100; // 1500;
|
||||||
transfer_delay: 20, // 0;
|
config.chunk_size = 10; // 1500;
|
||||||
batch_size: 100, // 1500;
|
config.account_groups = 1; // 50;
|
||||||
chunk_size: 10, // 1500;
|
|
||||||
account_groups: 1, // 50;
|
do_bench_exchange(clients, config);
|
||||||
..Config::default()
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@@ -1,20 +1,19 @@
|
|||||||
[package]
|
[package]
|
||||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
name = "solana-bench-streamer"
|
name = "solana-bench-streamer"
|
||||||
version = "1.5.3"
|
version = "1.2.33"
|
||||||
repository = "https://github.com/solana-labs/solana"
|
repository = "https://github.com/solana-labs/solana"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
homepage = "https://solana.com/"
|
homepage = "https://solana.com/"
|
||||||
publish = false
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.33.1"
|
clap = "2.33.1"
|
||||||
solana-clap-utils = { path = "../clap-utils", version = "1.5.3" }
|
solana-clap-utils = { path = "../clap-utils", version = "1.2.33" }
|
||||||
solana-streamer = { path = "../streamer", version = "1.5.3" }
|
solana-streamer = { path = "../streamer", version = "1.2.33" }
|
||||||
solana-logger = { path = "../logger", version = "1.5.3" }
|
solana-logger = { path = "../logger", version = "1.2.33" }
|
||||||
solana-net-utils = { path = "../net-utils", version = "1.5.3" }
|
solana-net-utils = { path = "../net-utils", version = "1.2.33" }
|
||||||
solana-version = { path = "../version", version = "1.5.3" }
|
solana-version = { path = "../version", version = "1.2.33" }
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
@@ -1,37 +1,36 @@
|
|||||||
[package]
|
[package]
|
||||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
name = "solana-bench-tps"
|
name = "solana-bench-tps"
|
||||||
version = "1.5.3"
|
version = "1.2.33"
|
||||||
repository = "https://github.com/solana-labs/solana"
|
repository = "https://github.com/solana-labs/solana"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
homepage = "https://solana.com/"
|
homepage = "https://solana.com/"
|
||||||
publish = false
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bincode = "1.3.1"
|
bincode = "1.3.1"
|
||||||
clap = "2.33.1"
|
clap = "2.33.1"
|
||||||
log = "0.4.11"
|
log = "0.4.8"
|
||||||
rayon = "1.4.0"
|
rayon = "1.4.0"
|
||||||
serde_json = "1.0.56"
|
serde_json = "1.0.53"
|
||||||
serde_yaml = "0.8.13"
|
serde_yaml = "0.8.12"
|
||||||
solana-clap-utils = { path = "../clap-utils", version = "1.5.3" }
|
solana-clap-utils = { path = "../clap-utils", version = "1.2.33" }
|
||||||
solana-core = { path = "../core", version = "1.5.3" }
|
solana-core = { path = "../core", version = "1.2.33" }
|
||||||
solana-genesis = { path = "../genesis", version = "1.5.3" }
|
solana-genesis = { path = "../genesis", version = "1.2.33" }
|
||||||
solana-client = { path = "../client", version = "1.5.3" }
|
solana-client = { path = "../client", version = "1.2.33" }
|
||||||
solana-faucet = { path = "../faucet", version = "1.5.3" }
|
solana-faucet = { path = "../faucet", version = "1.2.33" }
|
||||||
solana-logger = { path = "../logger", version = "1.5.3" }
|
solana-logger = { path = "../logger", version = "1.2.33" }
|
||||||
solana-metrics = { path = "../metrics", version = "1.5.3" }
|
solana-metrics = { path = "../metrics", version = "1.2.33" }
|
||||||
solana-measure = { path = "../measure", version = "1.5.3" }
|
solana-measure = { path = "../measure", version = "1.2.33" }
|
||||||
solana-net-utils = { path = "../net-utils", version = "1.5.3" }
|
solana-net-utils = { path = "../net-utils", version = "1.2.33" }
|
||||||
solana-runtime = { path = "../runtime", version = "1.5.3" }
|
solana-runtime = { path = "../runtime", version = "1.2.33" }
|
||||||
solana-sdk = { path = "../sdk", version = "1.5.3" }
|
solana-sdk = { path = "../sdk", version = "1.2.33" }
|
||||||
solana-version = { path = "../version", version = "1.5.3" }
|
solana-version = { path = "../version", version = "1.2.33" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serial_test = "0.4.0"
|
serial_test = "0.4.0"
|
||||||
serial_test_derive = "0.4.0"
|
serial_test_derive = "0.4.0"
|
||||||
solana-local-cluster = { path = "../local-cluster", version = "1.5.3" }
|
solana-local-cluster = { path = "../local-cluster", version = "1.2.33" }
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
@@ -938,12 +938,10 @@ mod tests {
|
|||||||
let bank = Bank::new(&genesis_config);
|
let bank = Bank::new(&genesis_config);
|
||||||
let client = Arc::new(BankClient::new(bank));
|
let client = Arc::new(BankClient::new(bank));
|
||||||
|
|
||||||
let config = Config {
|
let mut config = Config::default();
|
||||||
id,
|
config.id = id;
|
||||||
tx_count: 10,
|
config.tx_count = 10;
|
||||||
duration: Duration::from_secs(5),
|
config.duration = Duration::from_secs(5);
|
||||||
..Config::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
let keypair_count = config.tx_count * config.keypair_multiplier;
|
let keypair_count = config.tx_count * config.keypair_multiplier;
|
||||||
let keypairs =
|
let keypairs =
|
||||||
|
@@ -1,10 +1,7 @@
|
|||||||
use clap::{crate_description, crate_name, App, Arg, ArgMatches};
|
use clap::{crate_description, crate_name, App, Arg, ArgMatches};
|
||||||
use solana_faucet::faucet::FAUCET_PORT;
|
use solana_faucet::faucet::FAUCET_PORT;
|
||||||
use solana_sdk::fee_calculator::FeeRateGovernor;
|
use solana_sdk::fee_calculator::FeeRateGovernor;
|
||||||
use solana_sdk::{
|
use solana_sdk::signature::{read_keypair_file, Keypair};
|
||||||
pubkey::Pubkey,
|
|
||||||
signature::{read_keypair_file, Keypair},
|
|
||||||
};
|
|
||||||
use std::{net::SocketAddr, process::exit, time::Duration};
|
use std::{net::SocketAddr, process::exit, time::Duration};
|
||||||
|
|
||||||
const NUM_LAMPORTS_PER_ACCOUNT_DEFAULT: u64 = solana_sdk::native_token::LAMPORTS_PER_SOL;
|
const NUM_LAMPORTS_PER_ACCOUNT_DEFAULT: u64 = solana_sdk::native_token::LAMPORTS_PER_SOL;
|
||||||
@@ -28,7 +25,6 @@ pub struct Config {
|
|||||||
pub multi_client: bool,
|
pub multi_client: bool,
|
||||||
pub num_lamports_per_account: u64,
|
pub num_lamports_per_account: u64,
|
||||||
pub target_slots_per_epoch: u64,
|
pub target_slots_per_epoch: u64,
|
||||||
pub target_node: Option<Pubkey>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
@@ -51,7 +47,6 @@ impl Default for Config {
|
|||||||
multi_client: true,
|
multi_client: true,
|
||||||
num_lamports_per_account: NUM_LAMPORTS_PER_ACCOUNT_DEFAULT,
|
num_lamports_per_account: NUM_LAMPORTS_PER_ACCOUNT_DEFAULT,
|
||||||
target_slots_per_epoch: 0,
|
target_slots_per_epoch: 0,
|
||||||
target_node: None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,14 +112,6 @@ pub fn build_args<'a, 'b>(version: &'b str) -> App<'a, 'b> {
|
|||||||
.long("no-multi-client")
|
.long("no-multi-client")
|
||||||
.help("Disable multi-client support, only transact with the entrypoint."),
|
.help("Disable multi-client support, only transact with the entrypoint."),
|
||||||
)
|
)
|
||||||
.arg(
|
|
||||||
Arg::with_name("target_node")
|
|
||||||
.long("target-node")
|
|
||||||
.requires("no-multi-client")
|
|
||||||
.takes_value(true)
|
|
||||||
.value_name("PUBKEY")
|
|
||||||
.help("Specify an exact node to send transactions to."),
|
|
||||||
)
|
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("tx_count")
|
Arg::with_name("tx_count")
|
||||||
.long("tx_count")
|
.long("tx_count")
|
||||||
@@ -196,7 +183,7 @@ pub fn build_args<'a, 'b>(version: &'b str) -> App<'a, 'b> {
|
|||||||
/// * `matches` - command line arguments parsed by clap
|
/// * `matches` - command line arguments parsed by clap
|
||||||
/// # Panics
|
/// # Panics
|
||||||
/// Panics if there is trouble parsing any of the arguments
|
/// Panics if there is trouble parsing any of the arguments
|
||||||
pub fn extract_args(matches: &ArgMatches) -> Config {
|
pub fn extract_args<'a>(matches: &ArgMatches<'a>) -> Config {
|
||||||
let mut args = Config::default();
|
let mut args = Config::default();
|
||||||
|
|
||||||
if let Some(addr) = matches.value_of("entrypoint") {
|
if let Some(addr) = matches.value_of("entrypoint") {
|
||||||
@@ -270,9 +257,6 @@ pub fn extract_args(matches: &ArgMatches) -> Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args.multi_client = !matches.is_present("no-multi-client");
|
args.multi_client = !matches.is_present("no-multi-client");
|
||||||
args.target_node = matches
|
|
||||||
.value_of("target_node")
|
|
||||||
.map(|target_str| target_str.parse().unwrap());
|
|
||||||
|
|
||||||
if let Some(v) = matches.value_of("num_lamports_per_account") {
|
if let Some(v) = matches.value_of("num_lamports_per_account") {
|
||||||
args.num_lamports_per_account = v.to_string().parse().expect("can't parse lamports");
|
args.num_lamports_per_account = v.to_string().parse().expect("can't parse lamports");
|
||||||
|
@@ -31,7 +31,6 @@ fn main() {
|
|||||||
target_lamports_per_signature,
|
target_lamports_per_signature,
|
||||||
multi_client,
|
multi_client,
|
||||||
num_lamports_per_account,
|
num_lamports_per_account,
|
||||||
target_node,
|
|
||||||
..
|
..
|
||||||
} = &cli_config;
|
} = &cli_config;
|
||||||
|
|
||||||
@@ -82,19 +81,6 @@ fn main() {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
Arc::new(client)
|
Arc::new(client)
|
||||||
} else if let Some(target_node) = target_node {
|
|
||||||
info!("Searching for target_node: {:?}", target_node);
|
|
||||||
let mut target_client = None;
|
|
||||||
for node in nodes {
|
|
||||||
if node.id == *target_node {
|
|
||||||
target_client = Some(Arc::new(get_client(&[node])));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
target_client.unwrap_or_else(|| {
|
|
||||||
eprintln!("Target node {} not found", target_node);
|
|
||||||
exit(1);
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
Arc::new(get_client(&nodes))
|
Arc::new(get_client(&nodes))
|
||||||
};
|
};
|
||||||
|
@@ -15,7 +15,7 @@ fn test_bench_tps_local_cluster(config: Config) {
|
|||||||
|
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
const NUM_NODES: usize = 1;
|
const NUM_NODES: usize = 1;
|
||||||
let cluster = LocalCluster::new(&mut ClusterConfig {
|
let cluster = LocalCluster::new(&ClusterConfig {
|
||||||
node_stakes: vec![999_990; NUM_NODES],
|
node_stakes: vec![999_990; NUM_NODES],
|
||||||
cluster_lamports: 200_000_000,
|
cluster_lamports: 200_000_000,
|
||||||
validator_configs: vec![ValidatorConfig::default(); NUM_NODES],
|
validator_configs: vec![ValidatorConfig::default(); NUM_NODES],
|
||||||
@@ -60,9 +60,9 @@ fn test_bench_tps_local_cluster(config: Config) {
|
|||||||
#[test]
|
#[test]
|
||||||
#[serial]
|
#[serial]
|
||||||
fn test_bench_tps_local_cluster_solana() {
|
fn test_bench_tps_local_cluster_solana() {
|
||||||
test_bench_tps_local_cluster(Config {
|
let mut config = Config::default();
|
||||||
tx_count: 100,
|
config.tx_count = 100;
|
||||||
duration: Duration::from_secs(10),
|
config.duration = Duration::from_secs(10);
|
||||||
..Config::default()
|
|
||||||
});
|
test_bench_tps_local_cluster(config);
|
||||||
}
|
}
|
||||||
|
31
cargo
31
cargo
@@ -1,31 +0,0 @@
|
|||||||
#!/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}" "${@}"
|
|
@@ -1,13 +0,0 @@
|
|||||||
#!/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 "$@"
|
|
@@ -1,14 +0,0 @@
|
|||||||
#!/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 "$@"
|
|
@@ -47,8 +47,6 @@ sudo ./setup-new-buildkite-agent/setup-buildkite.sh
|
|||||||
```
|
```
|
||||||
- Copy the pubkey contents from `~buildkite-agent/.ssh/id_ecdsa.pub` and
|
- Copy the pubkey contents from `~buildkite-agent/.ssh/id_ecdsa.pub` and
|
||||||
add the pubkey as an authorized SSH key on github.
|
add the pubkey as an authorized SSH key on github.
|
||||||
- In net/scripts/solana-user-authorized_keys.sh
|
|
||||||
- Bug mvines to add it to the "solana-grimes" github user
|
|
||||||
- Edit `/etc/buildkite-agent/buildkite-agent.cfg` and/or `/etc/systemd/system/buildkite-agent@*` to the desired configuration of the agent(s)
|
- Edit `/etc/buildkite-agent/buildkite-agent.cfg` and/or `/etc/systemd/system/buildkite-agent@*` to the desired configuration of the agent(s)
|
||||||
- Copy `ejson` keys from another CI node at `/opt/ejson/keys/`
|
- Copy `ejson` keys from another CI node at `/opt/ejson/keys/`
|
||||||
to the same location on the new node.
|
to the same location on the new node.
|
||||||
|
43
ci/affects-files.sh
Executable file
43
ci/affects-files.sh
Executable file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Checks if a CI build affects one or more path patterns. Each command-line
|
||||||
|
# argument is checked in series.
|
||||||
|
#
|
||||||
|
# Bash regular expressions are permitted in the pattern:
|
||||||
|
# ./affects-files.sh .rs$ -- any file or directory ending in .rs
|
||||||
|
# ./affects-files.sh .rs -- also matches foo.rs.bar
|
||||||
|
# ./affects-files.sh ^snap/ -- anything under the snap/ subdirectory
|
||||||
|
# ./affects-files.sh snap/ -- also matches foo/snap/
|
||||||
|
# Any pattern starting with the ! character will be negated:
|
||||||
|
# ./affects-files.sh !^docs/ -- anything *not* under the docs/ subdirectory
|
||||||
|
#
|
||||||
|
set -e
|
||||||
|
cd "$(dirname "$0")"/..
|
||||||
|
|
||||||
|
if [[ -n $CI_PULL_REQUEST ]]; then
|
||||||
|
affectedFiles="$(buildkite-agent meta-data get affected_files)"
|
||||||
|
echo "Affected files in this PR: $affectedFiles"
|
||||||
|
|
||||||
|
IFS=':' read -ra files <<< "$affectedFiles"
|
||||||
|
for pattern in "$@"; do
|
||||||
|
if [[ ${pattern:0:1} = "!" ]]; then
|
||||||
|
for file in "${files[@]}"; do
|
||||||
|
if [[ ! $file =~ ${pattern:1} ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
for file in "${files[@]}"; do
|
||||||
|
if [[ $file =~ $pattern ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# affected_files metadata is not currently available for non-PR builds, so assume
|
||||||
|
# the worse (affected)
|
||||||
|
exit 0
|
@@ -175,30 +175,6 @@ EOF
|
|||||||
"Stable-perf skipped as no relevant files were modified"
|
"Stable-perf skipped as no relevant files were modified"
|
||||||
fi
|
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...
|
# Benches...
|
||||||
if affects \
|
if affects \
|
||||||
.rs$ \
|
.rs$ \
|
||||||
@@ -231,7 +207,7 @@ pull_or_push_steps() {
|
|||||||
|
|
||||||
# Run the full test suite by default, skipping only if modifications are local
|
# Run the full test suite by default, skipping only if modifications are local
|
||||||
# to some particular areas of the tree
|
# to some particular areas of the tree
|
||||||
if affects_other_than ^.buildkite ^.mergify .md$ ^docs/ ^web3.js/ ^explorer/ ^.gitbook; then
|
if affects_other_than ^.buildkite ^.travis .md$ ^docs/ ^web3.js/ ^explorer/ ^.gitbook; then
|
||||||
all_test_steps
|
all_test_steps
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -263,7 +239,7 @@ if [[ $BUILDKITE_BRANCH =~ ^pull ]]; then
|
|||||||
annotate --style info --context pr-backlink \
|
annotate --style info --context pr-backlink \
|
||||||
"Github Pull Request: https://github.com/solana-labs/solana/$BUILDKITE_BRANCH"
|
"Github Pull Request: https://github.com/solana-labs/solana/$BUILDKITE_BRANCH"
|
||||||
|
|
||||||
if [[ $GITHUB_USER = "dependabot[bot]" ]]; then
|
if [[ $GITHUB_USER = "dependabot-preview[bot]" ]]; then
|
||||||
command_step dependabot "ci/dependabot-pr.sh" 5
|
command_step dependabot "ci/dependabot-pr.sh" 5
|
||||||
wait_step
|
wait_step
|
||||||
fi
|
fi
|
||||||
|
15
ci/buildkite-release.yml
Normal file
15
ci/buildkite-release.yml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Build steps that run on a release tag
|
||||||
|
#
|
||||||
|
# All the steps in `buildkite.yml` are skipped and we jump directly to the
|
||||||
|
# secondary build steps since it's assumed the commit that was tagged is known
|
||||||
|
# to be good so there's no need to rebuild and retest it.
|
||||||
|
steps:
|
||||||
|
- trigger: "solana-secondary"
|
||||||
|
branches: "!pull/*"
|
||||||
|
async: true
|
||||||
|
build:
|
||||||
|
message: "${BUILDKITE_MESSAGE}"
|
||||||
|
commit: "${BUILDKITE_COMMIT}"
|
||||||
|
branch: "${BUILDKITE_BRANCH}"
|
||||||
|
env:
|
||||||
|
TRIGGERED_BUILDKITE_TAG: "${BUILDKITE_TAG}"
|
26
ci/buildkite-tests.yml
Normal file
26
ci/buildkite-tests.yml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# These steps are conditionally triggered by ci/buildkite.yml when files
|
||||||
|
# other than those in docs/ are modified
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- command: ". ci/rust-version.sh; ci/docker-run.sh $$rust_nightly_docker_image ci/test-coverage.sh"
|
||||||
|
name: "coverage"
|
||||||
|
timeout_in_minutes: 30
|
||||||
|
- wait
|
||||||
|
- command: ". ci/rust-version.sh; ci/docker-run.sh $$rust_stable_docker_image ci/test-stable.sh"
|
||||||
|
name: "stable"
|
||||||
|
timeout_in_minutes: 60
|
||||||
|
artifact_paths: "log-*.txt"
|
||||||
|
- wait
|
||||||
|
- command: "ci/test-stable-perf.sh"
|
||||||
|
name: "stable-perf"
|
||||||
|
timeout_in_minutes: 40
|
||||||
|
artifact_paths: "log-*.txt"
|
||||||
|
agents:
|
||||||
|
- "queue=cuda"
|
||||||
|
- command: "ci/test-bench.sh"
|
||||||
|
name: "bench"
|
||||||
|
timeout_in_minutes: 30
|
||||||
|
- command: ". ci/rust-version.sh; ci/docker-run.sh $$rust_stable_docker_image ci/test-local-cluster.sh"
|
||||||
|
name: "local-cluster"
|
||||||
|
timeout_in_minutes: 45
|
||||||
|
artifact_paths: "log-*.txt"
|
47
ci/buildkite.yml
Normal file
47
ci/buildkite.yml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# Build steps that run on pushes and pull requests.
|
||||||
|
# If files other than those in docs/ were modified, this will be followed up by
|
||||||
|
# ci/buildkite-tests.yml
|
||||||
|
#
|
||||||
|
# Release tags use buildkite-release.yml instead
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- command: "ci/test-sanity.sh"
|
||||||
|
name: "sanity"
|
||||||
|
timeout_in_minutes: 5
|
||||||
|
- command: "ci/dependabot-pr.sh"
|
||||||
|
name: "dependabot"
|
||||||
|
timeout_in_minutes: 5
|
||||||
|
if: build.env("GITHUB_USER") == "dependabot-preview[bot]"
|
||||||
|
|
||||||
|
- wait
|
||||||
|
|
||||||
|
- command: ". ci/rust-version.sh; ci/docker-run.sh $$rust_audit_docker_image ci/test-audit.sh"
|
||||||
|
name: "audit"
|
||||||
|
timeout_in_minutes: 20
|
||||||
|
|
||||||
|
- wait
|
||||||
|
|
||||||
|
- command: ". ci/rust-version.sh; ci/docker-run.sh $$rust_nightly_docker_image ci/test-checks.sh"
|
||||||
|
name: "checks"
|
||||||
|
timeout_in_minutes: 20
|
||||||
|
- command: "ci/shellcheck.sh"
|
||||||
|
name: "shellcheck"
|
||||||
|
timeout_in_minutes: 5
|
||||||
|
|
||||||
|
- wait
|
||||||
|
|
||||||
|
- command: "ci/maybe-trigger-tests.sh"
|
||||||
|
name: "maybe-trigger-tests"
|
||||||
|
timeout_in_minutes: 2
|
||||||
|
|
||||||
|
- wait
|
||||||
|
|
||||||
|
- trigger: "solana-secondary"
|
||||||
|
branches: "!pull/*"
|
||||||
|
async: true
|
||||||
|
build:
|
||||||
|
message: "${BUILDKITE_MESSAGE}"
|
||||||
|
commit: "${BUILDKITE_COMMIT}"
|
||||||
|
branch: "${BUILDKITE_BRANCH}"
|
||||||
|
env:
|
||||||
|
TRIGGERED_BUILDKITE_TAG: "${BUILDKITE_TAG}"
|
@@ -95,14 +95,12 @@ elif [[ -n $CI_BRANCH ]]; then
|
|||||||
BRANCH="$CI_BRANCH"
|
BRANCH="$CI_BRANCH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$CHANNEL" ]]; then
|
if [[ $BRANCH = "$STABLE_CHANNEL" ]]; then
|
||||||
if [[ $BRANCH = "$STABLE_CHANNEL" ]]; then
|
CHANNEL=stable
|
||||||
CHANNEL=stable
|
elif [[ $BRANCH = "$EDGE_CHANNEL" ]]; then
|
||||||
elif [[ $BRANCH = "$EDGE_CHANNEL" ]]; then
|
CHANNEL=edge
|
||||||
CHANNEL=edge
|
elif [[ $BRANCH = "$BETA_CHANNEL" ]]; then
|
||||||
elif [[ $BRANCH = "$BETA_CHANNEL" ]]; then
|
CHANNEL=beta
|
||||||
CHANNEL=beta
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo EDGE_CHANNEL="$EDGE_CHANNEL"
|
echo EDGE_CHANNEL="$EDGE_CHANNEL"
|
||||||
|
@@ -6,15 +6,15 @@ source ci/_
|
|||||||
|
|
||||||
commit_range="$(git merge-base HEAD origin/master)..HEAD"
|
commit_range="$(git merge-base HEAD origin/master)..HEAD"
|
||||||
parsed_update_args="$(
|
parsed_update_args="$(
|
||||||
git log "$commit_range" --author "dependabot\[bot\]" --oneline -n1 |
|
git log "$commit_range" --author "dependabot-preview" --oneline -n1 |
|
||||||
grep -o '[Bb]ump.*$' |
|
grep -o 'Bump.*$' |
|
||||||
sed -r 's/[Bb]ump ([^ ]+) from ([^ ]+) to ([^ ]+)/-p \1:\2 --precise \3/'
|
sed -r 's/Bump ([^ ]+) from ([^ ]+) to ([^ ]+)/-p \1:\2 --precise \3/'
|
||||||
)"
|
)"
|
||||||
# relaxed_parsed_update_args is temporal measure...
|
# relaxed_parsed_update_args is temporal measure...
|
||||||
relaxed_parsed_update_args="$(
|
relaxed_parsed_update_args="$(
|
||||||
git log "$commit_range" --author "dependabot\[bot\]" --oneline -n1 |
|
git log "$commit_range" --author "dependabot-preview" --oneline -n1 |
|
||||||
grep -o '[Bb]ump.*$' |
|
grep -o 'Bump.*$' |
|
||||||
sed -r 's/[Bb]ump ([^ ]+) from [^ ]+ to ([^ ]+)/-p \1 --precise \2/'
|
sed -r 's/Bump ([^ ]+) from [^ ]+ to ([^ ]+)/-p \1 --precise \2/'
|
||||||
)"
|
)"
|
||||||
package=$(echo "$parsed_update_args" | awk '{print $2}' | grep -o "^[^:]*")
|
package=$(echo "$parsed_update_args" | awk '{print $2}' | grep -o "^[^:]*")
|
||||||
if [[ -n $parsed_update_args ]]; then
|
if [[ -n $parsed_update_args ]]; then
|
||||||
|
@@ -60,12 +60,6 @@ if [[ -z "$SOLANA_DOCKER_RUN_NOSETUID" ]]; then
|
|||||||
ARGS+=(--user "$(id -u):$(id -g)")
|
ARGS+=(--user "$(id -u):$(id -g)")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n $SOLANA_ALLOCATE_TTY ]]; then
|
|
||||||
# Colored output, progress bar and Ctrl-C:
|
|
||||||
# https://stackoverflow.com/a/41099052/10242004
|
|
||||||
ARGS+=(--interactive --tty)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Environment variables to propagate into the container
|
# Environment variables to propagate into the container
|
||||||
ARGS+=(
|
ARGS+=(
|
||||||
--env BUILDKITE
|
--env BUILDKITE
|
||||||
|
@@ -1,10 +1,9 @@
|
|||||||
FROM solanalabs/rust:1.48.0
|
FROM solanalabs/rust:1.43.0
|
||||||
ARG date
|
ARG date
|
||||||
|
|
||||||
RUN set -x \
|
RUN set -x \
|
||||||
&& rustup install nightly-$date \
|
&& rustup install nightly-$date \
|
||||||
&& rustup component add clippy --toolchain=nightly-$date \
|
&& rustup component add clippy --toolchain=nightly-$date \
|
||||||
&& rustup component add rustfmt --toolchain=nightly-$date \
|
|
||||||
&& rustup show \
|
&& rustup show \
|
||||||
&& rustc --version \
|
&& rustc --version \
|
||||||
&& cargo --version \
|
&& cargo --version \
|
||||||
|
@@ -2,27 +2,23 @@ Docker image containing rust nightly and some preinstalled crates used in CI.
|
|||||||
|
|
||||||
This image may be manually updated by running `CI=true ./build.sh` if you are a member
|
This image may be manually updated by running `CI=true ./build.sh` if you are a member
|
||||||
of the [Solana Labs](https://hub.docker.com/u/solanalabs/) Docker Hub
|
of the [Solana Labs](https://hub.docker.com/u/solanalabs/) Docker Hub
|
||||||
organization.
|
organization, but it is also automatically updated periodically by
|
||||||
|
[this automation](https://buildkite.com/solana-labs/solana-ci-docker-rust-nightly).
|
||||||
|
|
||||||
## Moving to a newer nightly
|
## Moving to a newer nightly
|
||||||
|
|
||||||
NOTE: Follow instructions in docker-rust/README.md before this when updating the stable
|
|
||||||
rust version as well.
|
|
||||||
|
|
||||||
We pin the version of nightly (see the `ARG nightly=xyz` line in `Dockerfile`)
|
We pin the version of nightly (see the `ARG nightly=xyz` line in `Dockerfile`)
|
||||||
to avoid the build breaking at unexpected times, as occasionally nightly will
|
to avoid the build breaking at unexpected times, as occasionally nightly will
|
||||||
introduce breaking changes.
|
introduce breaking changes.
|
||||||
|
|
||||||
To update the pinned version:
|
To update the pinned version:
|
||||||
1. Edit `Dockerfile` to match the desired stable rust version to base on if needed.
|
|
||||||
1. Run `ci/docker-rust-nightly/build.sh` to rebuild the nightly image locally,
|
1. Run `ci/docker-rust-nightly/build.sh` to rebuild the nightly image locally,
|
||||||
or potentially `ci/docker-rust-nightly/build.sh YYYY-MM-DD` if there's a
|
or potentially `ci/docker-rust-nightly/build.sh YYYY-MM-DD` if there's a
|
||||||
specific YYYY-MM-DD that is desired (default is today's build).
|
specific YYYY-MM-DD that is desired (default is today's build).
|
||||||
Check https://rust-lang.github.io/rustup-components-history/ for build
|
Check https://rust-lang.github.io/rustup-components-history/ for build
|
||||||
status
|
status
|
||||||
1. Update `ci/rust-version.sh` to reflect the new nightly `YYYY-MM-DD`
|
1. Update `ci/rust-version.sh` to reflect the new nightly `YYY-MM-DD`
|
||||||
1. Run `SOLANA_ALLOCATE_TTY=1 SOLANA_DOCKER_RUN_NOSETUID=1 ci/docker-run.sh --nopull solanalabs/rust-nightly:YYYY-MM-DD ci/test-checks.sh`
|
1. Run `SOLANA_DOCKER_RUN_NOSETUID=1 ci/docker-run.sh --nopull solanalabs/rust-nightly:YYYY-MM-DD ci/test-coverage.sh`
|
||||||
and `SOLANA_ALLOCATE_TTY=1 SOLANA_DOCKER_RUN_NOSETUID=1 ci/docker-run.sh --nopull solanalabs/rust-nightly:YYYY-MM-DD ci/test-coverage.sh [args]...`
|
|
||||||
to confirm the new nightly image builds. Fix any issues as needed
|
to confirm the new nightly image builds. Fix any issues as needed
|
||||||
1. Run `docker login` to enable pushing images to Docker Hub, if you're authorized.
|
1. Run `docker login` to enable pushing images to Docker Hub, if you're authorized.
|
||||||
1. Run `CI=true ci/docker-rust-nightly/build.sh YYYY-MM-DD` to push the new nightly image to dockerhub.com.
|
1. Run `CI=true ci/docker-rust-nightly/build.sh YYYY-MM-DD` to push the new nightly image to dockerhub.com.
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# Note: when the rust version is changed also modify
|
# Note: when the rust version is changed also modify
|
||||||
# ci/rust-version.sh to pick up the new image tag
|
# ci/rust-version.sh to pick up the new image tag
|
||||||
FROM rust:1.48.0
|
FROM rust:1.43.0
|
||||||
|
|
||||||
# Add Google Protocol Buffers for Libra's metrics library.
|
# Add Google Protocol Buffers for Libra's metrics library.
|
||||||
ENV PROTOC_VERSION 3.8.0
|
ENV PROTOC_VERSION 3.8.0
|
||||||
|
@@ -1,11 +1,7 @@
|
|||||||
Docker image containing rust and some preinstalled packages used in CI.
|
Docker image containing rust and some preinstalled packages used in CI.
|
||||||
|
|
||||||
NOTE: Recreate rust-nightly docker image after this when updating the stable rust
|
|
||||||
version! Both of docker images must be updated in tandem.
|
|
||||||
|
|
||||||
This image manually maintained:
|
This image manually maintained:
|
||||||
1. Edit `Dockerfile` to match the desired rust version
|
1. Edit `Dockerfile` to match the desired rust version
|
||||||
1. Run `docker login` to enable pushing images to Docker Hub, if you're authorized.
|
2. Run `./build.sh` to publish the new image, if you are a member of the [Solana
|
||||||
1. Run `./build.sh` to publish the new image, if you are a member of the [Solana
|
|
||||||
Labs](https://hub.docker.com/u/solanalabs/) Docker Hub organization.
|
Labs](https://hub.docker.com/u/solanalabs/) Docker Hub organization.
|
||||||
|
|
||||||
|
21
ci/maybe-trigger-tests.sh
Executable file
21
ci/maybe-trigger-tests.sh
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
|
annotate() {
|
||||||
|
${BUILDKITE:-false} && {
|
||||||
|
buildkite-agent annotate "$@"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Skip if only the docs have been modified
|
||||||
|
ci/affects-files.sh \
|
||||||
|
\!^docs/ \
|
||||||
|
|| {
|
||||||
|
annotate --style info \
|
||||||
|
"Skipping all further tests as only docs/ files were modified"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
annotate --style info "Triggering tests"
|
||||||
|
buildkite-agent pipeline upload ci/buildkite-tests.yml
|
@@ -26,9 +26,6 @@ declare print_free_tree=(
|
|||||||
':runtime/src/**.rs'
|
':runtime/src/**.rs'
|
||||||
':sdk/bpf/rust/rust-utils/**.rs'
|
':sdk/bpf/rust/rust-utils/**.rs'
|
||||||
':sdk/**.rs'
|
':sdk/**.rs'
|
||||||
':^sdk/cargo-build-bpf/**.rs'
|
|
||||||
':^sdk/program/src/program_option.rs'
|
|
||||||
':^sdk/program/src/program_stubs.rs'
|
|
||||||
':programs/**.rs'
|
':programs/**.rs'
|
||||||
':^**bin**.rs'
|
':^**bin**.rs'
|
||||||
':^**bench**.rs'
|
':^**bench**.rs'
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2.7
|
||||||
#
|
#
|
||||||
# This script figures the order in which workspace crates must be published to
|
# This script figures the order in which workspace crates must be published to
|
||||||
# crates.io. Along the way it also ensures there are no circular dependencies
|
# crates.io. Along the way it also ensures there are no circular dependencies
|
||||||
@@ -45,27 +45,21 @@ def get_packages():
|
|||||||
sorted_dependency_graph = []
|
sorted_dependency_graph = []
|
||||||
max_iterations = pow(len(dependency_graph),2)
|
max_iterations = pow(len(dependency_graph),2)
|
||||||
while dependency_graph:
|
while dependency_graph:
|
||||||
deleted_packages = []
|
|
||||||
if max_iterations == 0:
|
if max_iterations == 0:
|
||||||
# One day be more helpful and find the actual cycle for the user...
|
# 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())))
|
sys.exit('Error: Circular dependency suspected between these packages: \n {}\n'.format('\n '.join(dependency_graph.keys())))
|
||||||
|
|
||||||
max_iterations -= 1
|
max_iterations -= 1
|
||||||
|
|
||||||
for package, dependencies in dependency_graph.items():
|
for package, dependencies in dependency_graph.items():
|
||||||
if package in deleted_packages:
|
|
||||||
continue
|
|
||||||
for dependency in dependencies:
|
for dependency in dependencies:
|
||||||
if dependency in dependency_graph:
|
if dependency in dependency_graph:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
deleted_packages.append(package)
|
del dependency_graph[package]
|
||||||
sorted_dependency_graph.append((package, manifest_path[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
|
return sorted_dependency_graph
|
||||||
|
|
||||||
for package, manifest in get_packages():
|
for package, manifest in get_packages():
|
||||||
print(os.path.relpath(manifest))
|
print os.path.relpath(manifest)
|
||||||
|
@@ -16,12 +16,21 @@ fi
|
|||||||
[[ -f bpf-sdk.tar.bz2 ]]
|
[[ -f bpf-sdk.tar.bz2 ]]
|
||||||
)
|
)
|
||||||
|
|
||||||
source ci/upload-ci-artifact.sh
|
|
||||||
echo --- AWS S3 Store
|
echo --- AWS S3 Store
|
||||||
if [[ -z $CHANNEL_OR_TAG ]]; then
|
if [[ -z $CHANNEL_OR_TAG ]]; then
|
||||||
echo Skipped
|
echo Skipped
|
||||||
else
|
else
|
||||||
upload-s3-artifact "/solana/bpf-sdk.tar.bz2" "s3://solana-sdk/$CHANNEL_OR_TAG/bpf-sdk.tar.bz2"
|
(
|
||||||
|
set -x
|
||||||
|
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/bpf-sdk.tar.bz2 \
|
||||||
|
s3://solana-sdk/"$CHANNEL_OR_TAG"/bpf-sdk.tar.bz2
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@@ -4,8 +4,6 @@ cd "$(dirname "$0")/.."
|
|||||||
source ci/semver_bash/semver.sh
|
source ci/semver_bash/semver.sh
|
||||||
source ci/rust-version.sh stable
|
source ci/rust-version.sh stable
|
||||||
|
|
||||||
cargo="$(readlink -f ./cargo)"
|
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
is_crate_version_uploaded() {
|
is_crate_version_uploaded() {
|
||||||
name=$1
|
name=$1
|
||||||
@@ -40,7 +38,7 @@ for Cargo_toml in $Cargo_tomls; do
|
|||||||
crate_name=$(grep -m 1 '^name = ' "$Cargo_toml" | cut -f 3 -d ' ' | tr -d \")
|
crate_name=$(grep -m 1 '^name = ' "$Cargo_toml" | cut -f 3 -d ' ' | tr -d \")
|
||||||
|
|
||||||
if grep -q "^publish = false" "$Cargo_toml"; then
|
if grep -q "^publish = false" "$Cargo_toml"; then
|
||||||
echo "$crate_name is marked as unpublishable"
|
echo "$crate_name is is marked as unpublishable"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -68,11 +66,11 @@ for Cargo_toml in $Cargo_tomls; do
|
|||||||
(
|
(
|
||||||
set -x
|
set -x
|
||||||
rm -rf crate-test
|
rm -rf crate-test
|
||||||
"$cargo" stable init crate-test
|
cargo +"$rust_stable" init crate-test
|
||||||
cd crate-test/
|
cd crate-test/
|
||||||
echo "${crate_name} = \"${expectedCrateVersion}\"" >> Cargo.toml
|
echo "${crate_name} = \"${expectedCrateVersion}\"" >> Cargo.toml
|
||||||
echo "[workspace]" >> Cargo.toml
|
echo "[workspace]" >> Cargo.toml
|
||||||
"$cargo" stable check
|
cargo +"$rust_stable" check
|
||||||
) && really_uploaded=1
|
) && really_uploaded=1
|
||||||
if ((really_uploaded)); then
|
if ((really_uploaded)); then
|
||||||
break;
|
break;
|
||||||
|
@@ -46,15 +46,6 @@ linux)
|
|||||||
;;
|
;;
|
||||||
windows)
|
windows)
|
||||||
TARGET=x86_64-pc-windows-msvc
|
TARGET=x86_64-pc-windows-msvc
|
||||||
# Enable symlinks used by some build.rs files
|
|
||||||
# source: https://stackoverflow.com/a/52097145/10242004
|
|
||||||
(
|
|
||||||
set -x
|
|
||||||
git --version
|
|
||||||
git config core.symlinks true
|
|
||||||
find . -type l -delete
|
|
||||||
git reset --hard
|
|
||||||
)
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo CI_OS_NAME unset
|
echo CI_OS_NAME unset
|
||||||
@@ -62,14 +53,11 @@ windows)
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
RELEASE_BASENAME="${RELEASE_BASENAME:=solana-release}"
|
|
||||||
TARBALL_BASENAME="${TARBALL_BASENAME:="$RELEASE_BASENAME"}"
|
|
||||||
|
|
||||||
echo --- Creating release tarball
|
echo --- Creating release tarball
|
||||||
(
|
(
|
||||||
set -x
|
set -x
|
||||||
rm -rf "${RELEASE_BASENAME:?}"/
|
rm -rf solana-release/
|
||||||
mkdir "${RELEASE_BASENAME}"/
|
mkdir solana-release/
|
||||||
|
|
||||||
COMMIT="$(git rev-parse HEAD)"
|
COMMIT="$(git rev-parse HEAD)"
|
||||||
|
|
||||||
@@ -77,34 +65,36 @@ echo --- Creating release tarball
|
|||||||
echo "channel: $CHANNEL_OR_TAG"
|
echo "channel: $CHANNEL_OR_TAG"
|
||||||
echo "commit: $COMMIT"
|
echo "commit: $COMMIT"
|
||||||
echo "target: $TARGET"
|
echo "target: $TARGET"
|
||||||
) > "${RELEASE_BASENAME}"/version.yml
|
) > solana-release/version.yml
|
||||||
|
|
||||||
# Make CHANNEL available to include in the software version information
|
# Make CHANNEL available to include in the software version information
|
||||||
export CHANNEL
|
export CHANNEL
|
||||||
|
|
||||||
source ci/rust-version.sh stable
|
source ci/rust-version.sh stable
|
||||||
scripts/cargo-install-all.sh +"$rust_stable" "${RELEASE_BASENAME}"
|
scripts/cargo-install-all.sh +"$rust_stable" solana-release
|
||||||
|
|
||||||
tar cvf "${TARBALL_BASENAME}"-$TARGET.tar "${RELEASE_BASENAME}"
|
tar cvf solana-release-$TARGET.tar solana-release
|
||||||
bzip2 "${TARBALL_BASENAME}"-$TARGET.tar
|
bzip2 solana-release-$TARGET.tar
|
||||||
cp "${RELEASE_BASENAME}"/bin/solana-install-init solana-install-init-$TARGET
|
cp solana-release/bin/solana-install-init solana-install-init-$TARGET
|
||||||
cp "${RELEASE_BASENAME}"/version.yml "${TARBALL_BASENAME}"-$TARGET.yml
|
cp solana-release/version.yml solana-release-$TARGET.yml
|
||||||
)
|
)
|
||||||
|
|
||||||
# Maybe tarballs are platform agnostic, only publish them from the Linux build
|
# Metrics tarball is platform agnostic, only publish it from Linux
|
||||||
MAYBE_TARBALLS=
|
MAYBE_TARBALLS=
|
||||||
if [[ "$CI_OS_NAME" = linux ]]; then
|
if [[ "$CI_OS_NAME" = linux ]]; then
|
||||||
|
metrics/create-metrics-tarball.sh
|
||||||
(
|
(
|
||||||
set -x
|
set -x
|
||||||
sdk/bpf/scripts/package.sh
|
sdk/bpf/scripts/package.sh
|
||||||
[[ -f bpf-sdk.tar.bz2 ]]
|
[[ -f bpf-sdk.tar.bz2 ]]
|
||||||
|
|
||||||
)
|
)
|
||||||
MAYBE_TARBALLS="bpf-sdk.tar.bz2"
|
MAYBE_TARBALLS="bpf-sdk.tar.bz2 solana-metrics.tar.bz2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source ci/upload-ci-artifact.sh
|
source ci/upload-ci-artifact.sh
|
||||||
|
|
||||||
for file in "${TARBALL_BASENAME}"-$TARGET.tar.bz2 "${TARBALL_BASENAME}"-$TARGET.yml solana-install-init-"$TARGET"* $MAYBE_TARBALLS; do
|
for file in solana-release-$TARGET.tar.bz2 solana-release-$TARGET.yml solana-install-init-"$TARGET"* $MAYBE_TARBALLS; do
|
||||||
if [[ -n $DO_NOT_PUBLISH_TAR ]]; then
|
if [[ -n $DO_NOT_PUBLISH_TAR ]]; then
|
||||||
upload-ci-artifact "$file"
|
upload-ci-artifact "$file"
|
||||||
echo "Skipped $file due to DO_NOT_PUBLISH_TAR"
|
echo "Skipped $file due to DO_NOT_PUBLISH_TAR"
|
||||||
@@ -113,10 +103,19 @@ for file in "${TARBALL_BASENAME}"-$TARGET.tar.bz2 "${TARBALL_BASENAME}"-$TARGET.
|
|||||||
|
|
||||||
if [[ -n $BUILDKITE ]]; then
|
if [[ -n $BUILDKITE ]]; then
|
||||||
echo --- AWS S3 Store: "$file"
|
echo --- AWS S3 Store: "$file"
|
||||||
upload-s3-artifact "/solana/$file" s3://release.solana.com/"$CHANNEL_OR_TAG"/"$file"
|
(
|
||||||
|
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/"$file" s3://release.solana.com/"$CHANNEL_OR_TAG"/"$file"
|
||||||
|
|
||||||
echo Published to:
|
echo Published to:
|
||||||
$DRYRUN ci/format-url.sh https://release.solana.com/"$CHANNEL_OR_TAG"/"$file"
|
$DRYRUN ci/format-url.sh http://release.solana.com/"$CHANNEL_OR_TAG"/"$file"
|
||||||
|
)
|
||||||
|
|
||||||
if [[ -n $TAG ]]; then
|
if [[ -n $TAG ]]; then
|
||||||
ci/upload-github-release-asset.sh "$file"
|
ci/upload-github-release-asset.sh "$file"
|
||||||
@@ -138,22 +137,4 @@ for file in "${TARBALL_BASENAME}"-$TARGET.tar.bz2 "${TARBALL_BASENAME}"-$TARGET.
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
# Create install wrapper for release.solana.com
|
|
||||||
if [[ -n $DO_NOT_PUBLISH_TAR ]]; then
|
|
||||||
echo "Skipping publishing install wrapper"
|
|
||||||
elif [[ -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"
|
|
||||||
$DRYRUN upload-s3-artifact "/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
|
echo --- ok
|
||||||
|
@@ -18,13 +18,13 @@
|
|||||||
if [[ -n $RUST_STABLE_VERSION ]]; then
|
if [[ -n $RUST_STABLE_VERSION ]]; then
|
||||||
stable_version="$RUST_STABLE_VERSION"
|
stable_version="$RUST_STABLE_VERSION"
|
||||||
else
|
else
|
||||||
stable_version=1.48.0
|
stable_version=1.43.0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n $RUST_NIGHTLY_VERSION ]]; then
|
if [[ -n $RUST_NIGHTLY_VERSION ]]; then
|
||||||
nightly_version="$RUST_NIGHTLY_VERSION"
|
nightly_version="$RUST_NIGHTLY_VERSION"
|
||||||
else
|
else
|
||||||
nightly_version=2020-12-13
|
nightly_version=2020-04-23
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@@ -34,12 +34,14 @@ export rust_stable_docker_image=solanalabs/rust:"$stable_version"
|
|||||||
export rust_nightly=nightly-"$nightly_version"
|
export rust_nightly=nightly-"$nightly_version"
|
||||||
export rust_nightly_docker_image=solanalabs/rust-nightly:"$nightly_version"
|
export rust_nightly_docker_image=solanalabs/rust-nightly:"$nightly_version"
|
||||||
|
|
||||||
|
export rust_audit="1.46.0"
|
||||||
|
export rust_audit_docker_image=solanalabs/rust-nightly:2020-08-17
|
||||||
|
|
||||||
[[ -z $1 ]] || (
|
[[ -z $1 ]] || (
|
||||||
|
|
||||||
rustup_install() {
|
rustup_install() {
|
||||||
declare toolchain=$1
|
declare toolchain=$1
|
||||||
if ! cargo +"$toolchain" -V > /dev/null; then
|
if ! cargo +"$toolchain" -V; then
|
||||||
echo "$0: Missing toolchain? Installing...: $toolchain" >&2
|
|
||||||
rustup install "$toolchain"
|
rustup install "$toolchain"
|
||||||
cargo +"$toolchain" -V
|
cargo +"$toolchain" -V
|
||||||
fi
|
fi
|
||||||
@@ -48,6 +50,9 @@ export rust_nightly_docker_image=solanalabs/rust-nightly:"$nightly_version"
|
|||||||
set -e
|
set -e
|
||||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||||
case $1 in
|
case $1 in
|
||||||
|
audit)
|
||||||
|
rustup_install "$rust_audit"
|
||||||
|
;;
|
||||||
stable)
|
stable)
|
||||||
rustup_install "$rust_stable"
|
rustup_install "$rust_stable"
|
||||||
;;
|
;;
|
||||||
@@ -57,9 +62,10 @@ export rust_nightly_docker_image=solanalabs/rust-nightly:"$nightly_version"
|
|||||||
all)
|
all)
|
||||||
rustup_install "$rust_stable"
|
rustup_install "$rust_stable"
|
||||||
rustup_install "$rust_nightly"
|
rustup_install "$rust_nightly"
|
||||||
|
rustup_install "$rust_audit"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "$0: Note: ignoring unknown argument: $1" >&2
|
echo "Note: ignoring unknown argument: $1"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
)
|
)
|
||||||
|
@@ -27,5 +27,5 @@ Alternatively, you can source it from within a script:
|
|||||||
local PATCH=0
|
local PATCH=0
|
||||||
local SPECIAL=""
|
local SPECIAL=""
|
||||||
|
|
||||||
semverParseInto "1.2.3" MAJOR MINOR PATCH SPECIAL
|
semverParseInto "1.2.33" MAJOR MINOR PATCH SPECIAL
|
||||||
semverParseInto "3.2.1" MAJOR MINOR PATCH SPECIAL
|
semverParseInto "3.2.1" MAJOR MINOR PATCH SPECIAL
|
||||||
|
@@ -7,7 +7,6 @@ SOLANA_ROOT="$HERE"/../..
|
|||||||
source "$HERE"/utils.sh
|
source "$HERE"/utils.sh
|
||||||
|
|
||||||
ensure_env || exit 1
|
ensure_env || exit 1
|
||||||
check_ssh_authorized_keys || exit 1
|
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
|
@@ -6,11 +6,6 @@ HERE="$(dirname "$0")"
|
|||||||
source "$HERE"/utils.sh
|
source "$HERE"/utils.sh
|
||||||
|
|
||||||
ensure_env || exit 1
|
ensure_env || exit 1
|
||||||
# This is a last ditch effort to prevent the caller from locking themselves
|
|
||||||
# out of the machine. Exiting here will likely leave the system in some
|
|
||||||
# half-configured state. To prevent this, duplicate the next line at the top
|
|
||||||
# of the entrypoint script.
|
|
||||||
check_ssh_authorized_keys || exit 1
|
|
||||||
|
|
||||||
set -xe
|
set -xe
|
||||||
# Setup sshd
|
# Setup sshd
|
||||||
|
@@ -14,33 +14,3 @@ ensure_env() {
|
|||||||
$RC
|
$RC
|
||||||
}
|
}
|
||||||
|
|
||||||
# Some scripts disable SSH password logins. If no one hash setup authorized_keys
|
|
||||||
# this will result in the machine being remotely inaccessible. Check that the
|
|
||||||
# user running this script has setup their keys
|
|
||||||
check_ssh_authorized_keys() {
|
|
||||||
declare rc=false
|
|
||||||
declare user_home=
|
|
||||||
if [[ -n "$SUDO_USER" ]]; then
|
|
||||||
declare user uid gid home
|
|
||||||
declare passwd_entry
|
|
||||||
passwd_entry="$(grep "$SUDO_USER:[^:]*:$SUDO_UID:$SUDO_GID" /etc/passwd)"
|
|
||||||
IFS=: read -r user _ uid gid _ home _ <<<"$passwd_entry"
|
|
||||||
if [[ "$user" == "$SUDO_USER" && "$uid" == "$SUDO_UID" && "$gid" == "$SUDO_GID" ]]; then
|
|
||||||
user_home="$home"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
user_home="$HOME"
|
|
||||||
fi
|
|
||||||
declare authorized_keys="${user_home}/.ssh/authorized_keys"
|
|
||||||
if [[ -n "$user_home" ]]; then
|
|
||||||
[[ -s "$authorized_keys" ]] && rc=true
|
|
||||||
fi
|
|
||||||
if ! $rc; then
|
|
||||||
echo "ERROR! This script will disable SSH password logins and you don't"
|
|
||||||
echo "appear to have set up any authorized keys. Please add you SSH"
|
|
||||||
echo "public key to ${authorized_keys} before continuing!"
|
|
||||||
fi
|
|
||||||
$rc
|
|
||||||
}
|
|
||||||
|
|
||||||
check_ssh_authorized_keys
|
|
||||||
|
11
ci/test-audit.sh
Executable file
11
ci/test-audit.sh
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
source ci/_
|
||||||
|
source ci/rust-version.sh audit
|
||||||
|
|
||||||
|
export RUST_BACKTRACE=1
|
||||||
|
export RUSTFLAGS="-D warnings"
|
||||||
|
|
||||||
|
_ cargo +"$rust_audit" audit --version
|
||||||
|
_ scripts/cargo-for-all-lock-files.sh +"$rust_audit" audit --ignore RUSTSEC-2020-0002 --ignore RUSTSEC-2020-0008
|
@@ -2,12 +2,30 @@
|
|||||||
set -e
|
set -e
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
|
annotate() {
|
||||||
|
${BUILDKITE:-false} && {
|
||||||
|
buildkite-agent annotate "$@"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ci/affects-files.sh \
|
||||||
|
.rs$ \
|
||||||
|
Cargo.lock$ \
|
||||||
|
Cargo.toml$ \
|
||||||
|
^ci/rust-version.sh \
|
||||||
|
^ci/test-bench.sh \
|
||||||
|
|| {
|
||||||
|
annotate --style info --context test-bench \
|
||||||
|
"Bench skipped as no .rs files were modified"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
source ci/_
|
source ci/_
|
||||||
source ci/upload-ci-artifact.sh
|
source ci/upload-ci-artifact.sh
|
||||||
|
|
||||||
eval "$(ci/channel-info.sh)"
|
eval "$(ci/channel-info.sh)"
|
||||||
|
source ci/rust-version.sh all
|
||||||
cargo="$(readlink -f "./cargo")"
|
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
export RUST_BACKTRACE=1
|
export RUST_BACKTRACE=1
|
||||||
@@ -28,35 +46,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
|
test -d target/release/bpf && find target/release/bpf -name '*.d' -delete
|
||||||
|
|
||||||
# Ensure all dependencies are built
|
# Ensure all dependencies are built
|
||||||
_ "$cargo" nightly build --release
|
_ cargo +$rust_nightly build --release
|
||||||
|
|
||||||
# Remove "BENCH_FILE", if it exists so that the following commands can append
|
# Remove "BENCH_FILE", if it exists so that the following commands can append
|
||||||
rm -f "$BENCH_FILE"
|
rm -f "$BENCH_FILE"
|
||||||
|
|
||||||
# Run sdk benches
|
# Run sdk benches
|
||||||
_ "$cargo" nightly bench --manifest-path sdk/Cargo.toml ${V:+--verbose} \
|
_ cargo +$rust_nightly bench --manifest-path sdk/Cargo.toml ${V:+--verbose} \
|
||||||
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
|
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
|
||||||
|
|
||||||
# Run runtime benches
|
# Run runtime benches
|
||||||
_ "$cargo" nightly bench --manifest-path runtime/Cargo.toml ${V:+--verbose} \
|
_ cargo +$rust_nightly bench --manifest-path runtime/Cargo.toml ${V:+--verbose} \
|
||||||
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
|
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
|
||||||
|
|
||||||
# Run core benches
|
# Run core benches
|
||||||
_ "$cargo" nightly bench --manifest-path core/Cargo.toml ${V:+--verbose} \
|
_ cargo +$rust_nightly bench --manifest-path core/Cargo.toml ${V:+--verbose} \
|
||||||
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
|
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
|
||||||
|
|
||||||
# Run bpf benches
|
# Run bpf benches
|
||||||
_ "$cargo" nightly bench --manifest-path programs/bpf/Cargo.toml ${V:+--verbose} --features=bpf_c \
|
_ cargo +$rust_nightly bench --manifest-path programs/bpf/Cargo.toml ${V:+--verbose} --features=bpf_c \
|
||||||
-- -Z unstable-options --format=json --nocapture | tee -a "$BENCH_FILE"
|
-- -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.
|
# Run banking/accounts bench. Doesn't require nightly, but use since it is already built.
|
||||||
_ "$cargo" nightly run --release --manifest-path banking-bench/Cargo.toml ${V:+--verbose} | tee -a "$BENCH_FILE"
|
_ cargo +$rust_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"
|
_ cargo +$rust_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
|
# `solana-upload-perf` disabled as it can take over 30 minutes to complete for some
|
||||||
# reason
|
# reason
|
||||||
exit 0
|
exit 0
|
||||||
_ "$cargo" nightly run --release --package solana-upload-perf \
|
_ cargo +$rust_nightly run --release --package solana-upload-perf \
|
||||||
-- "$BENCH_FILE" "$TARGET_BRANCH" "$UPLOAD_METRICS" | tee "$BENCH_ARTIFACT"
|
-- "$BENCH_FILE" "$TARGET_BRANCH" "$UPLOAD_METRICS" | tee "$BENCH_ARTIFACT"
|
||||||
|
|
||||||
upload-ci-artifact "$BENCH_FILE"
|
upload-ci-artifact "$BENCH_FILE"
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
@@ -8,95 +7,42 @@ source ci/_
|
|||||||
source ci/rust-version.sh stable
|
source ci/rust-version.sh stable
|
||||||
source ci/rust-version.sh nightly
|
source ci/rust-version.sh nightly
|
||||||
eval "$(ci/channel-info.sh)"
|
eval "$(ci/channel-info.sh)"
|
||||||
cargo="$(readlink -f "./cargo")"
|
|
||||||
|
|
||||||
scripts/increment-cargo-version.sh check
|
|
||||||
|
|
||||||
echo --- build environment
|
|
||||||
(
|
|
||||||
set -x
|
|
||||||
|
|
||||||
rustup run "$rust_stable" rustc --version --verbose
|
|
||||||
rustup run "$rust_nightly" rustc --version --verbose
|
|
||||||
|
|
||||||
"$cargo" stable --version --verbose
|
|
||||||
"$cargo" nightly --version --verbose
|
|
||||||
|
|
||||||
"$cargo" stable clippy --version --verbose
|
|
||||||
"$cargo" nightly clippy --version --verbose
|
|
||||||
|
|
||||||
# audit is done only with stable
|
|
||||||
"$cargo" stable audit --version
|
|
||||||
)
|
|
||||||
|
|
||||||
export RUST_BACKTRACE=1
|
export RUST_BACKTRACE=1
|
||||||
export RUSTFLAGS="-D warnings -A incomplete_features"
|
export RUSTFLAGS="-D warnings"
|
||||||
|
|
||||||
|
|
||||||
# Only force up-to-date lock files on edge
|
# Only force up-to-date lock files on edge
|
||||||
if [[ $CI_BASE_BRANCH = "$EDGE_CHANNEL" ]]; then
|
if [[ $CI_BASE_BRANCH = "$EDGE_CHANNEL" ]]; then
|
||||||
# Exclude --benches as it's not available in rust stable yet
|
if _ scripts/cargo-for-all-lock-files.sh +"$rust_nightly" check --locked --all-targets; then
|
||||||
if _ scripts/cargo-for-all-lock-files.sh +"$rust_stable" check --locked --tests --bins --examples; then
|
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
check_status=$?
|
check_status=$?
|
||||||
echo "$0: Some Cargo.lock might be outdated; sync them (or just be a compilation error?)" >&2
|
echo "Some Cargo.lock is outdated; please update them as well"
|
||||||
echo "$0: protip: $ ./scripts/cargo-for-all-lock-files.sh [--ignore-exit-code] ... \\" >&2
|
echo "protip: you can use ./scripts/cargo-for-all-lock-files.sh update ..."
|
||||||
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"
|
exit "$check_status"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure nightly and --benches
|
|
||||||
_ scripts/cargo-for-all-lock-files.sh +"$rust_nightly" check --locked --all-targets
|
|
||||||
else
|
else
|
||||||
echo "Note: cargo-for-all-lock-files.sh skipped because $CI_BASE_BRANCH != $EDGE_CHANNEL"
|
echo "Note: cargo-for-all-lock-files.sh skipped because $CI_BASE_BRANCH != $EDGE_CHANNEL"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
_ cargo +"$rust_stable" fmt --all -- --check
|
||||||
|
|
||||||
|
_ cargo +"$rust_stable" clippy --version
|
||||||
|
_ cargo +"$rust_stable" clippy --workspace -- --deny=warnings
|
||||||
|
|
||||||
_ ci/order-crates-for-publishing.py
|
_ ci/order-crates-for-publishing.py
|
||||||
_ "$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" nightly clippy -Zunstable-options --workspace --all-targets -- --deny=warnings
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# difference is unmaintained
|
|
||||||
#
|
|
||||||
# Blocked on predicates v1.0.6 removing its dependency on `difference`
|
|
||||||
--ignore RUSTSEC-2020-0095
|
|
||||||
|
|
||||||
)
|
|
||||||
_ scripts/cargo-for-all-lock-files.sh +"$rust_stable" audit "${cargo_audit_ignores[@]}"
|
|
||||||
|
|
||||||
{
|
{
|
||||||
cd programs/bpf
|
cd programs/bpf
|
||||||
_ "$cargo" stable audit
|
|
||||||
for project in rust/*/ ; do
|
for project in rust/*/ ; do
|
||||||
echo "+++ do_bpf_checks $project"
|
echo "+++ do_bpf_checks $project"
|
||||||
(
|
(
|
||||||
cd "$project"
|
cd "$project"
|
||||||
_ "$cargo" stable fmt -- --check
|
_ cargo +"$rust_stable" fmt -- --check
|
||||||
_ "$cargo" nightly test
|
_ cargo +"$rust_nightly" test
|
||||||
_ "$cargo" nightly clippy -- --deny=warnings --allow=clippy::missing_safety_doc
|
_ cargo +"$rust_nightly" clippy --version
|
||||||
|
_ cargo +"$rust_nightly" clippy -- --deny=warnings --allow=clippy::missing_safety_doc
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@@ -8,14 +8,23 @@ annotate() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ci/affects-files.sh \
|
||||||
|
.rs$ \
|
||||||
|
Cargo.lock$ \
|
||||||
|
Cargo.toml$ \
|
||||||
|
^ci/rust-version.sh \
|
||||||
|
^ci/test-coverage.sh \
|
||||||
|
^scripts/coverage.sh \
|
||||||
|
|| {
|
||||||
|
annotate --style info --context test-coverage \
|
||||||
|
"Coverage skipped as no .rs files were modified"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
source ci/upload-ci-artifact.sh
|
source ci/upload-ci-artifact.sh
|
||||||
source scripts/ulimit-n.sh
|
source scripts/ulimit-n.sh
|
||||||
|
|
||||||
scripts/coverage.sh "$@"
|
scripts/coverage.sh
|
||||||
|
|
||||||
if [[ -z $CI ]]; then
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
report=coverage-"${CI_COMMIT:0:9}".tar.gz
|
report=coverage-"${CI_COMMIT:0:9}".tar.gz
|
||||||
mv target/cov/report.tar.gz "$report"
|
mv target/cov/report.tar.gz "$report"
|
||||||
|
@@ -8,16 +8,10 @@ source ci/_
|
|||||||
(
|
(
|
||||||
echo --- git diff --check
|
echo --- git diff --check
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
if [[ -n $CI_BASE_BRANCH ]]
|
|
||||||
then branch="$CI_BASE_BRANCH"
|
|
||||||
else branch="master"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Look for failed mergify.io backports by searching leftover conflict markers
|
# Look for failed mergify.io backports by searching leftover conflict markers
|
||||||
# Also check for any trailing whitespaces!
|
# Also check for any trailing whitespaces!
|
||||||
git fetch origin "$branch"
|
git fetch origin "$CI_BASE_BRANCH"
|
||||||
git diff "$(git merge-base HEAD "origin/$branch")" --check --oneline
|
git diff "$(git merge-base HEAD "origin/$CI_BASE_BRANCH")..HEAD" --check --oneline
|
||||||
)
|
)
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
@@ -2,8 +2,6 @@
|
|||||||
set -e
|
set -e
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
cargo="$(readlink -f "./cargo")"
|
|
||||||
|
|
||||||
source ci/_
|
source ci/_
|
||||||
|
|
||||||
annotate() {
|
annotate() {
|
||||||
@@ -15,12 +13,24 @@ annotate() {
|
|||||||
# Run the appropriate test based on entrypoint
|
# Run the appropriate test based on entrypoint
|
||||||
testName=$(basename "$0" .sh)
|
testName=$(basename "$0" .sh)
|
||||||
|
|
||||||
|
# Skip if only the docs have been modified
|
||||||
|
ci/affects-files.sh \
|
||||||
|
\!^docs/ \
|
||||||
|
|| {
|
||||||
|
annotate --style info \
|
||||||
|
"Skipped $testName as only docs/ files were modified"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
source ci/rust-version.sh stable
|
source ci/rust-version.sh stable
|
||||||
|
|
||||||
export RUST_BACKTRACE=1
|
export RUST_BACKTRACE=1
|
||||||
export RUSTFLAGS="-D warnings"
|
export RUSTFLAGS="-D warnings"
|
||||||
source scripts/ulimit-n.sh
|
source scripts/ulimit-n.sh
|
||||||
|
|
||||||
|
# Clear cached json keypair files
|
||||||
|
rm -rf "$HOME/.config/solana"
|
||||||
|
|
||||||
# Clear the C dependency files, if dependency moves these files are not regenerated
|
# Clear the C dependency files, if dependency moves these files are not regenerated
|
||||||
test -d target/debug/bpf && find target/debug/bpf -name '*.d' -delete
|
test -d target/debug/bpf && find target/debug/bpf -name '*.d' -delete
|
||||||
test -d target/release/bpf && find target/release/bpf -name '*.d' -delete
|
test -d target/release/bpf && find target/release/bpf -name '*.d' -delete
|
||||||
@@ -36,15 +46,30 @@ NPROC=$((NPROC>14 ? 14 : NPROC))
|
|||||||
echo "Executing $testName"
|
echo "Executing $testName"
|
||||||
case $testName in
|
case $testName in
|
||||||
test-stable)
|
test-stable)
|
||||||
_ "$cargo" stable test --jobs "$NPROC" --all --exclude solana-local-cluster ${V:+--verbose} -- --nocapture
|
_ cargo +"$rust_stable" test --jobs "$NPROC" --all --exclude solana-local-cluster ${V:+--verbose} -- --nocapture
|
||||||
;;
|
;;
|
||||||
test-stable-perf)
|
test-stable-perf)
|
||||||
# BPF solana-sdk legacy compile test
|
ci/affects-files.sh \
|
||||||
./cargo-build-bpf --manifest-path sdk/Cargo.toml
|
.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/ \
|
||||||
|
|| {
|
||||||
|
annotate --style info \
|
||||||
|
"Skipped $testName as no relevant files were modified"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
# BPF program tests
|
# BPF program tests
|
||||||
_ make -C programs/bpf/c tests
|
_ make -C programs/bpf/c tests
|
||||||
_ "$cargo" stable test \
|
_ cargo +"$rust_stable" test \
|
||||||
--manifest-path programs/bpf/Cargo.toml \
|
--manifest-path programs/bpf/Cargo.toml \
|
||||||
--no-default-features --features=bpf_c,bpf_rust -- --nocapture
|
--no-default-features --features=bpf_c,bpf_rust -- --nocapture
|
||||||
|
|
||||||
@@ -64,13 +89,12 @@ test-stable-perf)
|
|||||||
export SOLANA_CUDA=1
|
export SOLANA_CUDA=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_ "$cargo" stable build --bins ${V:+--verbose}
|
_ cargo +"$rust_stable" build --bins ${V:+--verbose}
|
||||||
_ "$cargo" stable test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- --nocapture
|
_ cargo +"$rust_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)
|
test-local-cluster)
|
||||||
_ "$cargo" stable build --release --bins ${V:+--verbose}
|
_ cargo +"$rust_stable" build --release --bins ${V:+--verbose}
|
||||||
_ "$cargo" stable test --release --package solana-local-cluster ${V:+--verbose} -- --nocapture --test-threads=1
|
_ cargo +"$rust_stable" test --release --package solana-local-cluster ${V:+--verbose} -- --nocapture --test-threads=1
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@@ -16,16 +16,3 @@ upload-ci-artifact() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
upload-s3-artifact() {
|
|
||||||
echo "--- artifact: $1 to $2"
|
|
||||||
(
|
|
||||||
set -x
|
|
||||||
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 "$1" "$2"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "solana-clap-utils"
|
name = "solana-clap-utils"
|
||||||
version = "1.5.3"
|
version = "1.2.33"
|
||||||
description = "Solana utilities for the clap"
|
description = "Solana utilities for the clap"
|
||||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||||
repository = "https://github.com/solana-labs/solana"
|
repository = "https://github.com/solana-labs/solana"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
homepage = "https://solana.com/"
|
homepage = "https://solana.com/"
|
||||||
@@ -11,9 +11,9 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.33.0"
|
clap = "2.33.0"
|
||||||
rpassword = "4.0"
|
rpassword = "4.0"
|
||||||
solana-remote-wallet = { path = "../remote-wallet", version = "1.5.3" }
|
solana-remote-wallet = { path = "../remote-wallet", version = "1.2.33" }
|
||||||
solana-sdk = { path = "../sdk", version = "1.5.3" }
|
solana-sdk = { path = "../sdk", version = "1.2.33" }
|
||||||
thiserror = "1.0.21"
|
thiserror = "1.0.11"
|
||||||
tiny-bip39 = "0.7.0"
|
tiny-bip39 = "0.7.0"
|
||||||
url = "2.1.0"
|
url = "2.1.0"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
|
@@ -15,7 +15,7 @@ pub fn commitment_arg_with_default<'a, 'b>(default_value: &'static str) -> Arg<'
|
|||||||
Arg::with_name(COMMITMENT_ARG.name)
|
Arg::with_name(COMMITMENT_ARG.name)
|
||||||
.long(COMMITMENT_ARG.long)
|
.long(COMMITMENT_ARG.long)
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.possible_values(&["recent", "single", "singleGossip", "root", "max"])
|
.possible_values(&["recent", "single", "root", "max"])
|
||||||
.default_value(default_value)
|
.default_value(default_value)
|
||||||
.value_name("COMMITMENT_LEVEL")
|
.value_name("COMMITMENT_LEVEL")
|
||||||
.help(COMMITMENT_ARG.help)
|
.help(COMMITMENT_ARG.help)
|
||||||
|
@@ -8,7 +8,6 @@ use solana_remote_wallet::remote_wallet::RemoteWalletManager;
|
|||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
clock::UnixTimestamp,
|
clock::UnixTimestamp,
|
||||||
commitment_config::CommitmentConfig,
|
commitment_config::CommitmentConfig,
|
||||||
genesis_config::ClusterType,
|
|
||||||
native_token::sol_to_lamports,
|
native_token::sol_to_lamports,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::{read_keypair_file, Keypair, Signature, Signer},
|
signature::{read_keypair_file, Keypair, Signature, Signer},
|
||||||
@@ -179,17 +178,12 @@ pub fn lamports_of_sol(matches: &ArgMatches<'_>, name: &str) -> Option<u64> {
|
|||||||
value_of(matches, name).map(sol_to_lamports)
|
value_of(matches, name).map(sol_to_lamports)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cluster_type_of(matches: &ArgMatches<'_>, name: &str) -> Option<ClusterType> {
|
|
||||||
value_of(matches, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn commitment_of(matches: &ArgMatches<'_>, name: &str) -> Option<CommitmentConfig> {
|
pub fn commitment_of(matches: &ArgMatches<'_>, name: &str) -> Option<CommitmentConfig> {
|
||||||
matches.value_of(name).map(|value| match value {
|
matches.value_of(name).map(|value| match value {
|
||||||
"max" => CommitmentConfig::max(),
|
"max" => CommitmentConfig::max(),
|
||||||
"recent" => CommitmentConfig::recent(),
|
"recent" => CommitmentConfig::recent(),
|
||||||
"root" => CommitmentConfig::root(),
|
"root" => CommitmentConfig::root(),
|
||||||
"single" => CommitmentConfig::single(),
|
"single" => CommitmentConfig::single(),
|
||||||
"singleGossip" => CommitmentConfig::single_gossip(),
|
|
||||||
_ => CommitmentConfig::default(),
|
_ => CommitmentConfig::default(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -229,8 +223,8 @@ mod tests {
|
|||||||
assert_eq!(values_of(&matches, "multiple"), Some(vec![50, 39]));
|
assert_eq!(values_of(&matches, "multiple"), Some(vec![50, 39]));
|
||||||
assert_eq!(values_of::<u64>(&matches, "single"), None);
|
assert_eq!(values_of::<u64>(&matches, "single"), None);
|
||||||
|
|
||||||
let pubkey0 = solana_sdk::pubkey::new_rand();
|
let pubkey0 = Pubkey::new_rand();
|
||||||
let pubkey1 = solana_sdk::pubkey::new_rand();
|
let pubkey1 = Pubkey::new_rand();
|
||||||
let matches = app().clone().get_matches_from(vec![
|
let matches = app().clone().get_matches_from(vec![
|
||||||
"test",
|
"test",
|
||||||
"--multiple",
|
"--multiple",
|
||||||
@@ -252,7 +246,7 @@ mod tests {
|
|||||||
assert_eq!(value_of(&matches, "single"), Some(50));
|
assert_eq!(value_of(&matches, "single"), Some(50));
|
||||||
assert_eq!(value_of::<u64>(&matches, "multiple"), None);
|
assert_eq!(value_of::<u64>(&matches, "multiple"), None);
|
||||||
|
|
||||||
let pubkey = solana_sdk::pubkey::new_rand();
|
let pubkey = Pubkey::new_rand();
|
||||||
let matches = app()
|
let matches = app()
|
||||||
.clone()
|
.clone()
|
||||||
.get_matches_from(vec!["test", "--single", &pubkey.to_string()]);
|
.get_matches_from(vec!["test", "--single", &pubkey.to_string()]);
|
||||||
@@ -332,8 +326,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_pubkeys_sigs_of() {
|
fn test_pubkeys_sigs_of() {
|
||||||
let key1 = solana_sdk::pubkey::new_rand();
|
let key1 = Pubkey::new_rand();
|
||||||
let key2 = solana_sdk::pubkey::new_rand();
|
let key2 = Pubkey::new_rand();
|
||||||
let sig1 = Keypair::new().sign_message(&[0u8]);
|
let sig1 = Keypair::new().sign_message(&[0u8]);
|
||||||
let sig2 = Keypair::new().sign_message(&[1u8]);
|
let sig2 = Keypair::new().sign_message(&[1u8]);
|
||||||
let signer1 = format!("{}={}", key1, sig1);
|
let signer1 = format!("{}={}", key1, sig1);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
use crate::keypair::{parse_keypair_path, KeypairUrl, ASK_KEYWORD};
|
use crate::keypair::{parse_keypair_path, KeypairUrl, ASK_KEYWORD};
|
||||||
use chrono::DateTime;
|
use chrono::DateTime;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
clock::{Epoch, Slot},
|
clock::Slot,
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::{read_keypair_file, Signature},
|
signature::{read_keypair_file, Signature},
|
||||||
@@ -148,40 +148,6 @@ 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>
|
pub fn is_slot<T>(slot: T) -> Result<(), String>
|
||||||
where
|
where
|
||||||
T: AsRef<str> + Display,
|
T: AsRef<str> + Display,
|
||||||
|
@@ -58,15 +58,6 @@ impl CliSignerInfo {
|
|||||||
Some(0)
|
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 {
|
pub struct DefaultSigner {
|
||||||
@@ -163,7 +154,7 @@ pub fn signer_from_path(
|
|||||||
KeypairUrl::Filepath(path) => match read_keypair_file(&path) {
|
KeypairUrl::Filepath(path) => match read_keypair_file(&path) {
|
||||||
Err(e) => Err(std::io::Error::new(
|
Err(e) => Err(std::io::Error::new(
|
||||||
std::io::ErrorKind::Other,
|
std::io::ErrorKind::Other,
|
||||||
format!("could not read keypair file \"{}\". Run \"solana-keygen new\" to create a keypair file: {}", path, e),
|
format!("could not find keypair file: {} error: {}", path, e),
|
||||||
)
|
)
|
||||||
.into()),
|
.into()),
|
||||||
Ok(file) => Ok(Box::new(file)),
|
Ok(file) => Ok(Box::new(file)),
|
||||||
@@ -234,7 +225,7 @@ pub fn resolve_signer_from_path(
|
|||||||
KeypairUrl::Filepath(path) => match read_keypair_file(&path) {
|
KeypairUrl::Filepath(path) => match read_keypair_file(&path) {
|
||||||
Err(e) => Err(std::io::Error::new(
|
Err(e) => Err(std::io::Error::new(
|
||||||
std::io::ErrorKind::Other,
|
std::io::ErrorKind::Other,
|
||||||
format!("could not read keypair file \"{}\". Run \"solana-keygen new\" to create a keypair file: {}", path, e),
|
format!("could not find keypair file: {} error: {}", path, e),
|
||||||
)
|
)
|
||||||
.into()),
|
.into()),
|
||||||
Ok(_) => Ok(Some(path.to_string())),
|
Ok(_) => Ok(Some(path.to_string())),
|
||||||
@@ -307,24 +298,7 @@ pub fn keypair_from_seed_phrase(
|
|||||||
keypair_from_seed_phrase_and_passphrase(&seed_phrase, &passphrase)?
|
keypair_from_seed_phrase_and_passphrase(&seed_phrase, &passphrase)?
|
||||||
} else {
|
} else {
|
||||||
let sanitized = sanitize_seed_phrase(seed_phrase);
|
let sanitized = sanitize_seed_phrase(seed_phrase);
|
||||||
let parse_language_fn = || {
|
let mnemonic = Mnemonic::from_phrase(&sanitized, Language::English)?;
|
||||||
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 passphrase = prompt_passphrase(&passphrase_prompt)?;
|
||||||
let seed = Seed::new(&mnemonic, &passphrase);
|
let seed = Seed::new(&mnemonic, &passphrase);
|
||||||
keypair_from_seed(seed.as_bytes())?
|
keypair_from_seed(seed.as_bytes())?
|
||||||
|
@@ -36,15 +36,12 @@ pub fn nonce_authority_arg<'a, 'b>() -> Arg<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait NonceArgs {
|
pub trait NonceArgs {
|
||||||
fn nonce_args(self, global: bool) -> Self;
|
fn nonce_args(self) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NonceArgs for App<'_, '_> {
|
impl NonceArgs for App<'_, '_> {
|
||||||
fn nonce_args(self, global: bool) -> Self {
|
fn nonce_args(self) -> Self {
|
||||||
self.arg(nonce_arg().global(global)).arg(
|
self.arg(nonce_arg())
|
||||||
nonce_authority_arg()
|
.arg(nonce_authority_arg().requires(NONCE_ARG.name))
|
||||||
.requires(NONCE_ARG.name)
|
|
||||||
.global(global),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -47,32 +47,14 @@ fn signer_arg<'a, 'b>() -> Arg<'a, 'b> {
|
|||||||
.help(SIGNER_ARG.help)
|
.help(SIGNER_ARG.help)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ArgsConfig {
|
|
||||||
fn blockhash_arg<'a, 'b>(&self, arg: Arg<'a, 'b>) -> Arg<'a, 'b> {
|
|
||||||
arg
|
|
||||||
}
|
|
||||||
fn sign_only_arg<'a, 'b>(&self, arg: Arg<'a, 'b>) -> Arg<'a, 'b> {
|
|
||||||
arg
|
|
||||||
}
|
|
||||||
fn signer_arg<'a, 'b>(&self, arg: Arg<'a, 'b>) -> Arg<'a, 'b> {
|
|
||||||
arg
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait OfflineArgs {
|
pub trait OfflineArgs {
|
||||||
fn offline_args(self) -> Self;
|
fn offline_args(self) -> Self;
|
||||||
fn offline_args_config(self, config: &dyn ArgsConfig) -> Self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OfflineArgs for App<'_, '_> {
|
impl OfflineArgs for App<'_, '_> {
|
||||||
fn offline_args_config(self, config: &dyn ArgsConfig) -> Self {
|
|
||||||
self.arg(config.blockhash_arg(blockhash_arg()))
|
|
||||||
.arg(config.sign_only_arg(sign_only_arg()))
|
|
||||||
.arg(config.signer_arg(signer_arg()))
|
|
||||||
}
|
|
||||||
fn offline_args(self) -> Self {
|
fn offline_args(self) -> Self {
|
||||||
struct NullArgsConfig {}
|
self.arg(blockhash_arg())
|
||||||
impl ArgsConfig for NullArgsConfig {}
|
.arg(sign_only_arg())
|
||||||
self.offline_args_config(&NullArgsConfig {})
|
.arg(signer_arg())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,19 +1,19 @@
|
|||||||
[package]
|
[package]
|
||||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
name = "solana-cli-config"
|
name = "solana-cli-config"
|
||||||
description = "Blockchain, Rebuilt for Scale"
|
description = "Blockchain, Rebuilt for Scale"
|
||||||
version = "1.5.3"
|
version = "1.2.33"
|
||||||
repository = "https://github.com/solana-labs/solana"
|
repository = "https://github.com/solana-labs/solana"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
homepage = "https://solana.com/"
|
homepage = "https://solana.com/"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dirs-next = "2.0.0"
|
dirs = "2.0.2"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
serde = "1.0.112"
|
serde = "1.0.110"
|
||||||
serde_derive = "1.0.103"
|
serde_derive = "1.0.103"
|
||||||
serde_yaml = "0.8.13"
|
serde_yaml = "0.8.12"
|
||||||
url = "2.1.1"
|
url = "2.1.1"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
// Wallet settings that can be configured for long-term use
|
// Wallet settings that can be configured for long-term use
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use std::{collections::HashMap, io, path::Path};
|
use std::{collections::HashMap, io};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref CONFIG_FILE: Option<String> = {
|
pub static ref CONFIG_FILE: Option<String> = {
|
||||||
dirs_next::home_dir().map(|mut path| {
|
dirs::home_dir().map(|mut path| {
|
||||||
path.extend(&[".config", "solana", "cli", "config.yml"]);
|
path.extend(&[".config", "solana", "cli", "config.yml"]);
|
||||||
path.to_str().unwrap().to_string()
|
path.to_str().unwrap().to_string()
|
||||||
})
|
})
|
||||||
@@ -17,7 +17,6 @@ pub struct Config {
|
|||||||
pub json_rpc_url: String,
|
pub json_rpc_url: String,
|
||||||
pub websocket_url: String,
|
pub websocket_url: String,
|
||||||
pub keypair_path: String,
|
pub keypair_path: String,
|
||||||
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub address_labels: HashMap<String, String>,
|
pub address_labels: HashMap<String, String>,
|
||||||
}
|
}
|
||||||
@@ -25,7 +24,7 @@ pub struct Config {
|
|||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let keypair_path = {
|
let keypair_path = {
|
||||||
let mut keypair_path = dirs_next::home_dir().expect("home directory");
|
let mut keypair_path = dirs::home_dir().expect("home directory");
|
||||||
keypair_path.extend(&[".config", "solana", "id.json"]);
|
keypair_path.extend(&[".config", "solana", "id.json"]);
|
||||||
keypair_path.to_str().unwrap().to_string()
|
keypair_path.to_str().unwrap().to_string()
|
||||||
};
|
};
|
||||||
@@ -35,17 +34,11 @@ impl Default for Config {
|
|||||||
// `Config::compute_websocket_url(&json_rpc_url)`
|
// `Config::compute_websocket_url(&json_rpc_url)`
|
||||||
let websocket_url = "".to_string();
|
let websocket_url = "".to_string();
|
||||||
|
|
||||||
let mut address_labels = HashMap::new();
|
|
||||||
address_labels.insert(
|
|
||||||
"11111111111111111111111111111111".to_string(),
|
|
||||||
"System Program".to_string(),
|
|
||||||
);
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
json_rpc_url,
|
json_rpc_url,
|
||||||
websocket_url,
|
websocket_url,
|
||||||
keypair_path,
|
keypair_path,
|
||||||
address_labels,
|
address_labels: HashMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,24 +68,6 @@ impl Config {
|
|||||||
}
|
}
|
||||||
ws_url.to_string()
|
ws_url.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn import_address_labels<P>(&mut self, filename: P) -> Result<(), io::Error>
|
|
||||||
where
|
|
||||||
P: AsRef<Path>,
|
|
||||||
{
|
|
||||||
let imports: HashMap<String, String> = crate::load_config_file(filename)?;
|
|
||||||
for (address, label) in imports.into_iter() {
|
|
||||||
self.address_labels.insert(address, label);
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn export_address_labels<P>(&self, filename: P) -> Result<(), io::Error>
|
|
||||||
where
|
|
||||||
P: AsRef<Path>,
|
|
||||||
{
|
|
||||||
crate::save_config_file(&self.address_labels, filename)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@@ -3,27 +3,26 @@ authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
name = "solana-cli-output"
|
name = "solana-cli-output"
|
||||||
description = "Blockchain, Rebuilt for Scale"
|
description = "Blockchain, Rebuilt for Scale"
|
||||||
version = "1.5.3"
|
version = "1.2.33"
|
||||||
repository = "https://github.com/solana-labs/solana"
|
repository = "https://github.com/solana-labs/solana"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
homepage = "https://solana.com/"
|
homepage = "https://solana.com/"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = { version = "0.4.11", features = ["serde"] }
|
chrono = { version = "0.4.11", features = ["serde"] }
|
||||||
console = "0.11.3"
|
console = "0.10.1"
|
||||||
humantime = "2.0.1"
|
humantime = "2.0.0"
|
||||||
Inflector = "0.11.4"
|
Inflector = "0.11.4"
|
||||||
indicatif = "0.15.0"
|
indicatif = "0.14.0"
|
||||||
serde = "1.0.112"
|
serde = "1.0.110"
|
||||||
serde_derive = "1.0.103"
|
serde_derive = "1.0.103"
|
||||||
serde_json = "1.0.56"
|
serde_json = "1.0.53"
|
||||||
solana-account-decoder = { path = "../account-decoder", version = "1.5.3" }
|
solana-clap-utils = { path = "../clap-utils", version = "1.2.33" }
|
||||||
solana-clap-utils = { path = "../clap-utils", version = "1.5.3" }
|
solana-client = { path = "../client", version = "1.2.33" }
|
||||||
solana-client = { path = "../client", version = "1.5.3" }
|
solana-sdk = { path = "../sdk", version = "1.2.33" }
|
||||||
solana-sdk = { path = "../sdk", version = "1.5.3" }
|
solana-stake-program = { path = "../programs/stake", version = "1.2.33" }
|
||||||
solana-stake-program = { path = "../programs/stake", version = "1.5.3" }
|
solana-transaction-status = { path = "../transaction-status", version = "1.2.33" }
|
||||||
solana-transaction-status = { path = "../transaction-status", version = "1.5.3" }
|
solana-vote-program = { path = "../programs/vote", version = "1.2.33" }
|
||||||
solana-vote-program = { path = "../programs/vote", version = "1.5.3" }
|
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
@@ -1,17 +1,12 @@
|
|||||||
use crate::{
|
use crate::display::{build_balance_message, writeln_name_value};
|
||||||
display::{build_balance_message, format_labeled_address, writeln_name_value},
|
|
||||||
QuietDisplay, VerboseDisplay,
|
|
||||||
};
|
|
||||||
use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc};
|
use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc};
|
||||||
use console::{style, Emoji};
|
use console::{style, Emoji};
|
||||||
use inflector::cases::titlecase::to_title_case;
|
use inflector::cases::titlecase::to_title_case;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::{Map, Value};
|
use serde_json::{Map, Value};
|
||||||
use solana_account_decoder::parse_token::UiTokenAccount;
|
|
||||||
use solana_clap_utils::keypair::SignOnly;
|
use solana_clap_utils::keypair::SignOnly;
|
||||||
use solana_client::rpc_response::{
|
use solana_client::rpc_response::{
|
||||||
RpcAccountBalance, RpcInflationGovernor, RpcInflationRate, RpcKeyedAccount, RpcSupply,
|
RpcAccountBalance, RpcKeyedAccount, RpcSupply, RpcVoteAccountInfo,
|
||||||
RpcVoteAccountInfo,
|
|
||||||
};
|
};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
clock::{self, Epoch, Slot, UnixTimestamp},
|
clock::{self, Epoch, Slot, UnixTimestamp},
|
||||||
@@ -28,12 +23,7 @@ use solana_vote_program::{
|
|||||||
authorized_voters::AuthorizedVoters,
|
authorized_voters::AuthorizedVoters,
|
||||||
vote_state::{BlockTimestamp, Lockout},
|
vote_state::{BlockTimestamp, Lockout},
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{collections::BTreeMap, fmt, str::FromStr, time::Duration};
|
||||||
collections::{BTreeMap, HashMap},
|
|
||||||
fmt,
|
|
||||||
str::FromStr,
|
|
||||||
time::Duration,
|
|
||||||
};
|
|
||||||
|
|
||||||
static WARNING: Emoji = Emoji("⚠️", "!");
|
static WARNING: Emoji = Emoji("⚠️", "!");
|
||||||
|
|
||||||
@@ -42,27 +32,15 @@ pub enum OutputFormat {
|
|||||||
Display,
|
Display,
|
||||||
Json,
|
Json,
|
||||||
JsonCompact,
|
JsonCompact,
|
||||||
DisplayQuiet,
|
|
||||||
DisplayVerbose,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OutputFormat {
|
impl OutputFormat {
|
||||||
pub fn formatted_string<T>(&self, item: &T) -> String
|
pub fn formatted_string<T>(&self, item: &T) -> String
|
||||||
where
|
where
|
||||||
T: Serialize + fmt::Display + QuietDisplay + VerboseDisplay,
|
T: Serialize + fmt::Display,
|
||||||
{
|
{
|
||||||
match self {
|
match self {
|
||||||
OutputFormat::Display => format!("{}", item),
|
OutputFormat::Display => format!("{}", item),
|
||||||
OutputFormat::DisplayQuiet => {
|
|
||||||
let mut s = String::new();
|
|
||||||
QuietDisplay::write_str(item, &mut s).unwrap();
|
|
||||||
s
|
|
||||||
}
|
|
||||||
OutputFormat::DisplayVerbose => {
|
|
||||||
let mut s = String::new();
|
|
||||||
VerboseDisplay::write_str(item, &mut s).unwrap();
|
|
||||||
s
|
|
||||||
}
|
|
||||||
OutputFormat::Json => serde_json::to_string_pretty(item).unwrap(),
|
OutputFormat::Json => serde_json::to_string_pretty(item).unwrap(),
|
||||||
OutputFormat::JsonCompact => serde_json::to_value(item).unwrap().to_string(),
|
OutputFormat::JsonCompact => serde_json::to_value(item).unwrap().to_string(),
|
||||||
}
|
}
|
||||||
@@ -77,9 +55,6 @@ pub struct CliAccount {
|
|||||||
pub use_lamports_unit: bool,
|
pub use_lamports_unit: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay for CliAccount {}
|
|
||||||
impl VerboseDisplay for CliAccount {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliAccount {
|
impl fmt::Display for CliAccount {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
writeln!(f)?;
|
writeln!(f)?;
|
||||||
@@ -122,9 +97,6 @@ pub struct CliBlockProduction {
|
|||||||
pub verbose: bool,
|
pub verbose: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay for CliBlockProduction {}
|
|
||||||
impl VerboseDisplay for CliBlockProduction {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliBlockProduction {
|
impl fmt::Display for CliBlockProduction {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
writeln!(f)?;
|
writeln!(f)?;
|
||||||
@@ -133,7 +105,7 @@ impl fmt::Display for CliBlockProduction {
|
|||||||
"{}",
|
"{}",
|
||||||
style(format!(
|
style(format!(
|
||||||
" {:<44} {:>15} {:>15} {:>15} {:>23}",
|
" {:<44} {:>15} {:>15} {:>15} {:>23}",
|
||||||
"Identity",
|
"Identity Pubkey",
|
||||||
"Leader Slots",
|
"Leader Slots",
|
||||||
"Blocks Produced",
|
"Blocks Produced",
|
||||||
"Skipped Slots",
|
"Skipped Slots",
|
||||||
@@ -229,22 +201,11 @@ impl From<EpochInfo> for CliEpochInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay for CliEpochInfo {}
|
|
||||||
impl VerboseDisplay for CliEpochInfo {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliEpochInfo {
|
impl fmt::Display for CliEpochInfo {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
writeln!(f)?;
|
writeln!(f)?;
|
||||||
writeln_name_value(
|
|
||||||
f,
|
|
||||||
"Block height:",
|
|
||||||
&self.epoch_info.block_height.to_string(),
|
|
||||||
)?;
|
|
||||||
writeln_name_value(f, "Slot:", &self.epoch_info.absolute_slot.to_string())?;
|
writeln_name_value(f, "Slot:", &self.epoch_info.absolute_slot.to_string())?;
|
||||||
writeln_name_value(f, "Epoch:", &self.epoch_info.epoch.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 start_slot = self.epoch_info.absolute_slot - self.epoch_info.slot_index;
|
||||||
let end_slot = start_slot + self.epoch_info.slots_in_epoch;
|
let end_slot = start_slot + self.epoch_info.slots_in_epoch;
|
||||||
writeln_name_value(
|
writeln_name_value(
|
||||||
@@ -291,31 +252,18 @@ fn slot_to_human_time(slot: Slot) -> String {
|
|||||||
.to_string()
|
.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Default)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct CliValidatorsStakeByVersion {
|
|
||||||
pub current_validators: usize,
|
|
||||||
pub delinquent_validators: usize,
|
|
||||||
pub current_active_stake: u64,
|
|
||||||
pub delinquent_active_stake: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct CliValidators {
|
pub struct CliValidators {
|
||||||
pub total_active_stake: u64,
|
pub total_active_stake: u64,
|
||||||
pub total_current_stake: u64,
|
pub total_current_stake: u64,
|
||||||
pub total_delinquent_stake: u64,
|
pub total_deliquent_stake: u64,
|
||||||
pub current_validators: Vec<CliValidator>,
|
pub current_validators: Vec<CliValidator>,
|
||||||
pub delinquent_validators: Vec<CliValidator>,
|
pub delinquent_validators: Vec<CliValidator>,
|
||||||
pub stake_by_version: BTreeMap<String, CliValidatorsStakeByVersion>,
|
|
||||||
#[serde(skip_serializing)]
|
#[serde(skip_serializing)]
|
||||||
pub use_lamports_unit: bool,
|
pub use_lamports_unit: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay for CliValidators {}
|
|
||||||
impl VerboseDisplay for CliValidators {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliValidators {
|
impl fmt::Display for CliValidators {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
fn write_vote_account(
|
fn write_vote_account(
|
||||||
@@ -335,7 +283,7 @@ impl fmt::Display for CliValidators {
|
|||||||
|
|
||||||
writeln!(
|
writeln!(
|
||||||
f,
|
f,
|
||||||
"{} {:<44} {:<44} {:>3}% {:>8} {:>10} {:>10} {:>8} {}",
|
"{} {:<44} {:<44} {:>9}% {:>8} {:>10} {:>7} {}",
|
||||||
if delinquent {
|
if delinquent {
|
||||||
WARNING.to_string()
|
WARNING.to_string()
|
||||||
} else {
|
} else {
|
||||||
@@ -347,12 +295,11 @@ impl fmt::Display for CliValidators {
|
|||||||
non_zero_or_dash(validator.last_vote),
|
non_zero_or_dash(validator.last_vote),
|
||||||
non_zero_or_dash(validator.root_slot),
|
non_zero_or_dash(validator.root_slot),
|
||||||
validator.credits,
|
validator.credits,
|
||||||
validator.version,
|
|
||||||
if validator.activated_stake > 0 {
|
if validator.activated_stake > 0 {
|
||||||
format!(
|
format!(
|
||||||
"{} ({:.2}%)",
|
"{} ({:.2}%)",
|
||||||
build_balance_message(validator.activated_stake, use_lamports_unit, true),
|
build_balance_message(validator.activated_stake, use_lamports_unit, true),
|
||||||
100. * validator.activated_stake as f64 / total_active_stake as f64,
|
100. * validator.activated_stake as f64 / total_active_stake as f64
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
"-".into()
|
"-".into()
|
||||||
@@ -364,7 +311,7 @@ impl fmt::Display for CliValidators {
|
|||||||
"Active Stake:",
|
"Active Stake:",
|
||||||
&build_balance_message(self.total_active_stake, self.use_lamports_unit, true),
|
&build_balance_message(self.total_active_stake, self.use_lamports_unit, true),
|
||||||
)?;
|
)?;
|
||||||
if self.total_delinquent_stake > 0 {
|
if self.total_deliquent_stake > 0 {
|
||||||
writeln_name_value(
|
writeln_name_value(
|
||||||
f,
|
f,
|
||||||
"Current Stake:",
|
"Current Stake:",
|
||||||
@@ -380,49 +327,26 @@ impl fmt::Display for CliValidators {
|
|||||||
&format!(
|
&format!(
|
||||||
"{} ({:0.2}%)",
|
"{} ({:0.2}%)",
|
||||||
&build_balance_message(
|
&build_balance_message(
|
||||||
self.total_delinquent_stake,
|
self.total_deliquent_stake,
|
||||||
self.use_lamports_unit,
|
self.use_lamports_unit,
|
||||||
true
|
true
|
||||||
),
|
),
|
||||||
100. * self.total_delinquent_stake as f64 / self.total_active_stake as f64
|
100. * self.total_deliquent_stake as f64 / self.total_active_stake as f64
|
||||||
),
|
),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
writeln!(f)?;
|
|
||||||
writeln!(f, "{}", style("Stake By Version:").bold())?;
|
|
||||||
for (version, info) in self.stake_by_version.iter() {
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
"{:<8} - {:3} current validators ({:>5.2}%){}",
|
|
||||||
version,
|
|
||||||
info.current_validators,
|
|
||||||
100. * info.current_active_stake as f64 / self.total_active_stake as f64,
|
|
||||||
if info.delinquent_validators > 0 {
|
|
||||||
format!(
|
|
||||||
", {:3} delinquent validators ({:>5.2}%)",
|
|
||||||
info.delinquent_validators,
|
|
||||||
100. * info.delinquent_active_stake as f64 / self.total_active_stake as f64
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
"".to_string()
|
|
||||||
},
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
writeln!(f)?;
|
writeln!(f)?;
|
||||||
writeln!(
|
writeln!(
|
||||||
f,
|
f,
|
||||||
"{}",
|
"{}",
|
||||||
style(format!(
|
style(format!(
|
||||||
" {:<44} {:<38} {} {} {} {:>10} {:^8} {}",
|
" {:<44} {:<44} {} {} {} {:>7} {}",
|
||||||
"Identity",
|
"Identity Pubkey",
|
||||||
"Vote Account",
|
"Vote Account Pubkey",
|
||||||
"Commission",
|
"Commission",
|
||||||
"Last Vote",
|
"Last Vote",
|
||||||
"Root Block",
|
"Root Block",
|
||||||
"Credits",
|
"Credits",
|
||||||
"Version",
|
|
||||||
"Active Stake",
|
"Active Stake",
|
||||||
))
|
))
|
||||||
.bold()
|
.bold()
|
||||||
@@ -459,19 +383,13 @@ pub struct CliValidator {
|
|||||||
pub root_slot: u64,
|
pub root_slot: u64,
|
||||||
pub credits: u64,
|
pub credits: u64,
|
||||||
pub activated_stake: u64,
|
pub activated_stake: u64,
|
||||||
pub version: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CliValidator {
|
impl CliValidator {
|
||||||
pub fn new(
|
pub fn new(vote_account: &RpcVoteAccountInfo, current_epoch: Epoch) -> Self {
|
||||||
vote_account: &RpcVoteAccountInfo,
|
|
||||||
current_epoch: Epoch,
|
|
||||||
version: String,
|
|
||||||
address_labels: &HashMap<String, String>,
|
|
||||||
) -> Self {
|
|
||||||
Self {
|
Self {
|
||||||
identity_pubkey: format_labeled_address(&vote_account.node_pubkey, address_labels),
|
identity_pubkey: vote_account.node_pubkey.to_string(),
|
||||||
vote_account_pubkey: format_labeled_address(&vote_account.vote_pubkey, address_labels),
|
vote_account_pubkey: vote_account.vote_pubkey.to_string(),
|
||||||
commission: vote_account.commission,
|
commission: vote_account.commission,
|
||||||
last_vote: vote_account.last_vote,
|
last_vote: vote_account.last_vote,
|
||||||
root_slot: vote_account.root_slot,
|
root_slot: vote_account.root_slot,
|
||||||
@@ -487,7 +405,6 @@ impl CliValidator {
|
|||||||
})
|
})
|
||||||
.unwrap_or(0),
|
.unwrap_or(0),
|
||||||
activated_stake: vote_account.activated_stake,
|
activated_stake: vote_account.activated_stake,
|
||||||
version,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -504,9 +421,6 @@ pub struct CliNonceAccount {
|
|||||||
pub use_lamports_unit: bool,
|
pub use_lamports_unit: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay for CliNonceAccount {}
|
|
||||||
impl VerboseDisplay for CliNonceAccount {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliNonceAccount {
|
impl fmt::Display for CliNonceAccount {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
writeln!(
|
writeln!(
|
||||||
@@ -524,7 +438,7 @@ impl fmt::Display for CliNonceAccount {
|
|||||||
)
|
)
|
||||||
)?;
|
)?;
|
||||||
let nonce = self.nonce.as_deref().unwrap_or("uninitialized");
|
let nonce = self.nonce.as_deref().unwrap_or("uninitialized");
|
||||||
writeln!(f, "Nonce blockhash: {}", nonce)?;
|
writeln!(f, "Nonce: {}", nonce)?;
|
||||||
if let Some(fees) = self.lamports_per_signature {
|
if let Some(fees) = self.lamports_per_signature {
|
||||||
writeln!(f, "Fee: {} lamports per signature", fees)?;
|
writeln!(f, "Fee: {} lamports per signature", fees)?;
|
||||||
} else {
|
} else {
|
||||||
@@ -544,17 +458,6 @@ impl CliStakeVec {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay 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 {
|
impl fmt::Display for CliStakeVec {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
for state in &self.0 {
|
for state in &self.0 {
|
||||||
@@ -573,14 +476,6 @@ pub struct CliKeyedStakeState {
|
|||||||
pub stake_state: CliStakeState,
|
pub stake_state: CliStakeState,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay 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 {
|
impl fmt::Display for CliKeyedStakeState {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
writeln!(f, "Stake Pubkey: {}", self.stake_pubkey)?;
|
writeln!(f, "Stake Pubkey: {}", self.stake_pubkey)?;
|
||||||
@@ -588,98 +483,12 @@ impl fmt::Display for CliKeyedStakeState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct CliEpochReward {
|
|
||||||
pub epoch: Epoch,
|
|
||||||
pub effective_slot: Slot,
|
|
||||||
pub amount: u64, // lamports
|
|
||||||
pub post_balance: u64, // lamports
|
|
||||||
pub percent_change: f64,
|
|
||||||
pub apr: Option<f64>,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn show_votes_and_credits(
|
|
||||||
f: &mut fmt::Formatter,
|
|
||||||
votes: &[CliLockout],
|
|
||||||
epoch_voting_history: &[CliEpochVotingHistory],
|
|
||||||
) -> fmt::Result {
|
|
||||||
if votes.is_empty() {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
writeln!(f, "Recent Votes:")?;
|
|
||||||
for vote in votes {
|
|
||||||
writeln!(f, "- slot: {}", vote.slot)?;
|
|
||||||
writeln!(f, " confirmation count: {}", vote.confirmation_count)?;
|
|
||||||
}
|
|
||||||
writeln!(f, "Epoch Voting History:")?;
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
"* missed credits include slots unavailable to vote on due to delinquent leaders",
|
|
||||||
)?;
|
|
||||||
for entry in epoch_voting_history {
|
|
||||||
writeln!(
|
|
||||||
f, // tame fmt so that this will be folded like following
|
|
||||||
"- epoch: {}",
|
|
||||||
entry.epoch
|
|
||||||
)?;
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
" credits range: [{}..{})",
|
|
||||||
entry.prev_credits, entry.credits
|
|
||||||
)?;
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
" credits/slots: {}/{}",
|
|
||||||
entry.credits_earned, entry.slots_in_epoch
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn show_epoch_rewards(
|
|
||||||
f: &mut fmt::Formatter,
|
|
||||||
epoch_rewards: &Option<Vec<CliEpochReward>>,
|
|
||||||
) -> fmt::Result {
|
|
||||||
if let Some(epoch_rewards) = epoch_rewards {
|
|
||||||
if epoch_rewards.is_empty() {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
writeln!(f, "Epoch Rewards:")?;
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
" {:<6} {:<11} {:<16} {:<16} {:>14} {:>14}",
|
|
||||||
"Epoch", "Reward Slot", "Amount", "New Balance", "Percent Change", "APR"
|
|
||||||
)?;
|
|
||||||
for reward in epoch_rewards {
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
" {:<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
|
|
||||||
.map(|apr| format!("{:>13.2}%", apr))
|
|
||||||
.unwrap_or_default(),
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize)]
|
#[derive(Default, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct CliStakeState {
|
pub struct CliStakeState {
|
||||||
pub stake_type: CliStakeType,
|
pub stake_type: CliStakeType,
|
||||||
pub account_balance: u64,
|
pub account_balance: u64,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub credits_observed: Option<u64>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub delegated_stake: Option<u64>,
|
pub delegated_stake: Option<u64>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub delegated_vote_account_address: Option<String>,
|
pub delegated_vote_account_address: Option<String>,
|
||||||
@@ -703,19 +512,6 @@ pub struct CliStakeState {
|
|||||||
pub activating_stake: Option<u64>,
|
pub activating_stake: Option<u64>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub deactivating_stake: Option<u64>,
|
pub deactivating_stake: Option<u64>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub epoch_rewards: Option<Vec<CliEpochReward>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl QuietDisplay 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 {
|
impl fmt::Display for CliStakeState {
|
||||||
@@ -725,20 +521,19 @@ impl fmt::Display for CliStakeState {
|
|||||||
writeln!(f, "Withdraw Authority: {}", authorized.withdrawer)?;
|
writeln!(f, "Withdraw Authority: {}", authorized.withdrawer)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn show_lockup(f: &mut fmt::Formatter, lockup: Option<&CliLockup>) -> fmt::Result {
|
fn show_lockup(f: &mut fmt::Formatter, lockup: &CliLockup) -> fmt::Result {
|
||||||
if let Some(lockup) = lockup {
|
writeln!(
|
||||||
if lockup.unix_timestamp != UnixTimestamp::default() {
|
f,
|
||||||
writeln!(
|
"Lockup Timestamp: {} (UnixTimestamp: {})",
|
||||||
f,
|
DateTime::<Utc>::from_utc(
|
||||||
"Lockup Timestamp: {}",
|
NaiveDateTime::from_timestamp(lockup.unix_timestamp, 0),
|
||||||
unix_timestamp_to_string(lockup.unix_timestamp)
|
Utc
|
||||||
)?;
|
)
|
||||||
}
|
.to_rfc3339_opts(SecondsFormat::Secs, true),
|
||||||
if lockup.epoch != Epoch::default() {
|
lockup.unix_timestamp
|
||||||
writeln!(f, "Lockup Epoch: {}", lockup.epoch)?;
|
)?;
|
||||||
}
|
writeln!(f, "Lockup Epoch: {}", lockup.epoch)?;
|
||||||
writeln!(f, "Lockup Custodian: {}", lockup.custodian)?;
|
writeln!(f, "Lockup Custodian: {}", lockup.custodian)?;
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -762,7 +557,7 @@ impl fmt::Display for CliStakeState {
|
|||||||
CliStakeType::Initialized => {
|
CliStakeType::Initialized => {
|
||||||
writeln!(f, "Stake account is undelegated")?;
|
writeln!(f, "Stake account is undelegated")?;
|
||||||
show_authorized(f, self.authorized.as_ref().unwrap())?;
|
show_authorized(f, self.authorized.as_ref().unwrap())?;
|
||||||
show_lockup(f, self.lockup.as_ref())?;
|
show_lockup(f, self.lockup.as_ref().unwrap())?;
|
||||||
}
|
}
|
||||||
CliStakeType::Stake => {
|
CliStakeType::Stake => {
|
||||||
let show_delegation = {
|
let show_delegation = {
|
||||||
@@ -860,15 +655,14 @@ impl fmt::Display for CliStakeState {
|
|||||||
writeln!(f, "Stake account is undelegated")?;
|
writeln!(f, "Stake account is undelegated")?;
|
||||||
}
|
}
|
||||||
show_authorized(f, self.authorized.as_ref().unwrap())?;
|
show_authorized(f, self.authorized.as_ref().unwrap())?;
|
||||||
show_lockup(f, self.lockup.as_ref())?;
|
show_lockup(f, self.lockup.as_ref().unwrap())?;
|
||||||
show_epoch_rewards(f, &self.epoch_rewards)?
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub enum CliStakeType {
|
pub enum CliStakeType {
|
||||||
Stake,
|
Stake,
|
||||||
RewardsPool,
|
RewardsPool,
|
||||||
@@ -890,9 +684,6 @@ pub struct CliStakeHistory {
|
|||||||
pub use_lamports_unit: bool,
|
pub use_lamports_unit: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay for CliStakeHistory {}
|
|
||||||
impl VerboseDisplay for CliStakeHistory {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliStakeHistory {
|
impl fmt::Display for CliStakeHistory {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
writeln!(f)?;
|
writeln!(f)?;
|
||||||
@@ -987,9 +778,6 @@ impl CliValidatorInfoVec {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay for CliValidatorInfoVec {}
|
|
||||||
impl VerboseDisplay for CliValidatorInfoVec {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliValidatorInfoVec {
|
impl fmt::Display for CliValidatorInfoVec {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
if self.0.is_empty() {
|
if self.0.is_empty() {
|
||||||
@@ -1011,13 +799,10 @@ pub struct CliValidatorInfo {
|
|||||||
pub info: Map<String, Value>,
|
pub info: Map<String, Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay for CliValidatorInfo {}
|
|
||||||
impl VerboseDisplay for CliValidatorInfo {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliValidatorInfo {
|
impl fmt::Display for CliValidatorInfo {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
writeln_name_value(f, "Validator Identity:", &self.identity_pubkey)?;
|
writeln_name_value(f, "Validator Identity Pubkey:", &self.identity_pubkey)?;
|
||||||
writeln_name_value(f, " Info Address:", &self.info_pubkey)?;
|
writeln_name_value(f, " Info Pubkey:", &self.info_pubkey)?;
|
||||||
for (key, value) in self.info.iter() {
|
for (key, value) in self.info.iter() {
|
||||||
writeln_name_value(
|
writeln_name_value(
|
||||||
f,
|
f,
|
||||||
@@ -1045,13 +830,8 @@ pub struct CliVoteAccount {
|
|||||||
pub epoch_voting_history: Vec<CliEpochVotingHistory>,
|
pub epoch_voting_history: Vec<CliEpochVotingHistory>,
|
||||||
#[serde(skip_serializing)]
|
#[serde(skip_serializing)]
|
||||||
pub use_lamports_unit: bool,
|
pub use_lamports_unit: bool,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub epoch_rewards: Option<Vec<CliEpochReward>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay for CliVoteAccount {}
|
|
||||||
impl VerboseDisplay for CliVoteAccount {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliVoteAccount {
|
impl fmt::Display for CliVoteAccount {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
writeln!(
|
writeln!(
|
||||||
@@ -1072,14 +852,25 @@ impl fmt::Display for CliVoteAccount {
|
|||||||
None => "~".to_string(),
|
None => "~".to_string(),
|
||||||
}
|
}
|
||||||
)?;
|
)?;
|
||||||
writeln!(
|
writeln!(f, "Recent Timestamp: {:?}", self.recent_timestamp)?;
|
||||||
f,
|
if !self.votes.is_empty() {
|
||||||
"Recent Timestamp: {} from slot {}",
|
writeln!(f, "Recent Votes:")?;
|
||||||
unix_timestamp_to_string(self.recent_timestamp.timestamp),
|
for vote in &self.votes {
|
||||||
self.recent_timestamp.slot
|
writeln!(
|
||||||
)?;
|
f,
|
||||||
show_votes_and_credits(f, &self.votes, &self.epoch_voting_history)?;
|
"- slot: {}\n confirmation count: {}",
|
||||||
show_epoch_rewards(f, &self.epoch_rewards)?;
|
vote.slot, vote.confirmation_count
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
writeln!(f, "Epoch Voting History:")?;
|
||||||
|
for epoch_info in &self.epoch_voting_history {
|
||||||
|
writeln!(
|
||||||
|
f,
|
||||||
|
"- epoch: {}\n slots in epoch: {}\n credits earned: {}",
|
||||||
|
epoch_info.epoch, epoch_info.slots_in_epoch, epoch_info.credits_earned,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1090,9 +881,6 @@ pub struct CliAuthorizedVoters {
|
|||||||
authorized_voters: BTreeMap<Epoch, String>,
|
authorized_voters: BTreeMap<Epoch, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay for CliAuthorizedVoters {}
|
|
||||||
impl VerboseDisplay for CliAuthorizedVoters {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliAuthorizedVoters {
|
impl fmt::Display for CliAuthorizedVoters {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "{:?}", self.authorized_voters)
|
write!(f, "{:?}", self.authorized_voters)
|
||||||
@@ -1117,8 +905,6 @@ pub struct CliEpochVotingHistory {
|
|||||||
pub epoch: Epoch,
|
pub epoch: Epoch,
|
||||||
pub slots_in_epoch: u64,
|
pub slots_in_epoch: u64,
|
||||||
pub credits_earned: u64,
|
pub credits_earned: u64,
|
||||||
pub credits: u64,
|
|
||||||
pub prev_credits: u64,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
@@ -1144,122 +930,18 @@ pub struct CliBlockTime {
|
|||||||
pub timestamp: UnixTimestamp,
|
pub timestamp: UnixTimestamp,
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
impl fmt::Display for CliBlockTime {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
writeln_name_value(f, "Block:", &self.slot.to_string())?;
|
writeln_name_value(f, "Block:", &self.slot.to_string())?;
|
||||||
writeln_name_value(f, "Date:", &unix_timestamp_to_string(self.timestamp))
|
writeln_name_value(
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct CliLeaderSchedule {
|
|
||||||
pub epoch: Epoch,
|
|
||||||
pub leader_schedule_entries: Vec<CliLeaderScheduleEntry>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl QuietDisplay for CliLeaderSchedule {}
|
|
||||||
impl VerboseDisplay for CliLeaderSchedule {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliLeaderSchedule {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
for entry in &self.leader_schedule_entries {
|
|
||||||
writeln!(f, " {:<15} {:<44}", entry.slot, entry.leader)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct CliLeaderScheduleEntry {
|
|
||||||
pub slot: Slot,
|
|
||||||
pub leader: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct CliInflation {
|
|
||||||
pub governor: RpcInflationGovernor,
|
|
||||||
pub current_rate: RpcInflationRate,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl QuietDisplay for CliInflation {}
|
|
||||||
impl VerboseDisplay for CliInflation {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliInflation {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
writeln!(f, "{}", style("Inflation Governor:").bold())?;
|
|
||||||
if (self.governor.initial - self.governor.terminal).abs() < f64::EPSILON {
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
"Fixed APR: {:>5.2}%",
|
|
||||||
self.governor.terminal * 100.
|
|
||||||
)?;
|
|
||||||
} else {
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
"Initial APR: {:>5.2}%",
|
|
||||||
self.governor.initial * 100.
|
|
||||||
)?;
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
"Terminal APR: {:>5.2}%",
|
|
||||||
self.governor.terminal * 100.
|
|
||||||
)?;
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
"Rate reduction per year: {:>5.2}%",
|
|
||||||
self.governor.taper * 100.
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
if self.governor.foundation_term > 0. {
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
"Foundation percentage: {:>5.2}%",
|
|
||||||
self.governor.foundation
|
|
||||||
)?;
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
"Foundation term: {:.1} years",
|
|
||||||
self.governor.foundation_term
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
writeln!(
|
|
||||||
f,
|
f,
|
||||||
"\n{}",
|
"Date:",
|
||||||
style(format!("Inflation for Epoch {}:", self.current_rate.epoch)).bold()
|
&format!(
|
||||||
)?;
|
"{} (UnixTimestamp: {})",
|
||||||
writeln!(
|
DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp(self.timestamp, 0), Utc)
|
||||||
f,
|
.to_rfc3339_opts(SecondsFormat::Secs, true),
|
||||||
"Total APR: {:>5.2}%",
|
self.timestamp
|
||||||
self.current_rate.total * 100.
|
),
|
||||||
)?;
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
"Staking APR: {:>5.2}%",
|
|
||||||
self.current_rate.validator * 100.
|
|
||||||
)?;
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
"Foundation APR: {:>5.2}%",
|
|
||||||
self.current_rate.foundation * 100.
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1276,9 +958,6 @@ pub struct CliSignOnlyData {
|
|||||||
pub bad_sig: Vec<String>,
|
pub bad_sig: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay for CliSignOnlyData {}
|
|
||||||
impl VerboseDisplay for CliSignOnlyData {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliSignOnlyData {
|
impl fmt::Display for CliSignOnlyData {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
writeln!(f)?;
|
writeln!(f)?;
|
||||||
@@ -1311,9 +990,6 @@ pub struct CliSignature {
|
|||||||
pub signature: String,
|
pub signature: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay for CliSignature {}
|
|
||||||
impl VerboseDisplay for CliSignature {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliSignature {
|
impl fmt::Display for CliSignature {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
writeln!(f)?;
|
writeln!(f)?;
|
||||||
@@ -1328,9 +1004,6 @@ pub struct CliAccountBalances {
|
|||||||
pub accounts: Vec<RpcAccountBalance>,
|
pub accounts: Vec<RpcAccountBalance>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay for CliAccountBalances {}
|
|
||||||
impl VerboseDisplay for CliAccountBalances {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliAccountBalances {
|
impl fmt::Display for CliAccountBalances {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
writeln!(
|
writeln!(
|
||||||
@@ -1373,9 +1046,6 @@ impl From<RpcSupply> for CliSupply {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay for CliSupply {}
|
|
||||||
impl VerboseDisplay for CliSupply {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliSupply {
|
impl fmt::Display for CliSupply {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
writeln_name_value(f, "Total:", &format!("{} SOL", lamports_to_sol(self.total)))?;
|
writeln_name_value(f, "Total:", &format!("{} SOL", lamports_to_sol(self.total)))?;
|
||||||
@@ -1409,9 +1079,6 @@ pub struct CliFees {
|
|||||||
pub last_valid_slot: Slot,
|
pub last_valid_slot: Slot,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QuietDisplay for CliFees {}
|
|
||||||
impl VerboseDisplay for CliFees {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliFees {
|
impl fmt::Display for CliFees {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
writeln_name_value(f, "Blockhash:", &self.blockhash)?;
|
writeln_name_value(f, "Blockhash:", &self.blockhash)?;
|
||||||
@@ -1425,50 +1092,6 @@ impl fmt::Display for CliFees {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct CliTokenAccount {
|
|
||||||
pub address: String,
|
|
||||||
#[serde(flatten)]
|
|
||||||
pub token_account: UiTokenAccount,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl QuietDisplay for CliTokenAccount {}
|
|
||||||
impl VerboseDisplay for CliTokenAccount {}
|
|
||||||
|
|
||||||
impl fmt::Display for CliTokenAccount {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
writeln!(f)?;
|
|
||||||
writeln_name_value(f, "Address:", &self.address)?;
|
|
||||||
let account = &self.token_account;
|
|
||||||
writeln_name_value(
|
|
||||||
f,
|
|
||||||
"Balance:",
|
|
||||||
&account.token_amount.real_number_string_trimmed(),
|
|
||||||
)?;
|
|
||||||
let mint = format!(
|
|
||||||
"{}{}",
|
|
||||||
account.mint,
|
|
||||||
if account.is_native { " (native)" } else { "" }
|
|
||||||
);
|
|
||||||
writeln_name_value(f, "Mint:", &mint)?;
|
|
||||||
writeln_name_value(f, "Owner:", &account.owner)?;
|
|
||||||
writeln_name_value(f, "State:", &format!("{:?}", account.state))?;
|
|
||||||
if let Some(delegate) = &account.delegate {
|
|
||||||
writeln!(f, "Delegation:")?;
|
|
||||||
writeln_name_value(f, " Delegate:", delegate)?;
|
|
||||||
let allowance = account.delegated_amount.as_ref().unwrap();
|
|
||||||
writeln_name_value(f, " Allowance:", &allowance.real_number_string_trimmed())?;
|
|
||||||
}
|
|
||||||
writeln_name_value(
|
|
||||||
f,
|
|
||||||
"Close authority:",
|
|
||||||
&account.close_authority.as_ref().unwrap_or(&String::new()),
|
|
||||||
)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn return_signers(
|
pub fn return_signers(
|
||||||
tx: &Transaction,
|
tx: &Transaction,
|
||||||
output_format: &OutputFormat,
|
output_format: &OutputFormat,
|
||||||
@@ -1613,51 +1236,4 @@ mod tests {
|
|||||||
assert_eq!(sign_only.absent_signers[0], absent.pubkey());
|
assert_eq!(sign_only.absent_signers[0], absent.pubkey());
|
||||||
assert_eq!(sign_only.bad_signers[0], bad.pubkey());
|
assert_eq!(sign_only.bad_signers[0], bad.pubkey());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_verbose_quiet_output_formats() {
|
|
||||||
#[derive(Deserialize, Serialize)]
|
|
||||||
struct FallbackToDisplay {}
|
|
||||||
impl std::fmt::Display for FallbackToDisplay {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
write!(f, "display")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl QuietDisplay for FallbackToDisplay {}
|
|
||||||
impl VerboseDisplay for FallbackToDisplay {}
|
|
||||||
|
|
||||||
let f = FallbackToDisplay {};
|
|
||||||
assert_eq!(&OutputFormat::Display.formatted_string(&f), "display");
|
|
||||||
assert_eq!(&OutputFormat::DisplayQuiet.formatted_string(&f), "display");
|
|
||||||
assert_eq!(
|
|
||||||
&OutputFormat::DisplayVerbose.formatted_string(&f),
|
|
||||||
"display"
|
|
||||||
);
|
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
|
||||||
struct DiscreteVerbosityDisplay {}
|
|
||||||
impl std::fmt::Display for DiscreteVerbosityDisplay {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
write!(f, "display")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl QuietDisplay for DiscreteVerbosityDisplay {
|
|
||||||
fn write_str(&self, w: &mut dyn std::fmt::Write) -> std::fmt::Result {
|
|
||||||
write!(w, "quiet")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl VerboseDisplay for DiscreteVerbosityDisplay {
|
|
||||||
fn write_str(&self, w: &mut dyn std::fmt::Write) -> std::fmt::Result {
|
|
||||||
write!(w, "verbose")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let f = DiscreteVerbosityDisplay {};
|
|
||||||
assert_eq!(&OutputFormat::Display.formatted_string(&f), "display");
|
|
||||||
assert_eq!(&OutputFormat::DisplayQuiet.formatted_string(&f), "quiet");
|
|
||||||
assert_eq!(
|
|
||||||
&OutputFormat::DisplayVerbose.formatted_string(&f),
|
|
||||||
"verbose"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,7 @@ use solana_sdk::{
|
|||||||
transaction::Transaction,
|
transaction::Transaction,
|
||||||
};
|
};
|
||||||
use solana_transaction_status::UiTransactionStatusMeta;
|
use solana_transaction_status::UiTransactionStatusMeta;
|
||||||
use std::{collections::HashMap, fmt, io};
|
use std::{fmt, io};
|
||||||
|
|
||||||
pub fn build_balance_message(lamports: u64, use_lamports_unit: bool, show_unit: bool) -> String {
|
pub fn build_balance_message(lamports: u64, use_lamports_unit: bool, show_unit: bool) -> String {
|
||||||
if use_lamports_unit {
|
if use_lamports_unit {
|
||||||
@@ -27,7 +27,7 @@ pub fn build_balance_message(lamports: u64, use_lamports_unit: bool, show_unit:
|
|||||||
|
|
||||||
// Pretty print a "name value"
|
// Pretty print a "name value"
|
||||||
pub fn println_name_value(name: &str, value: &str) {
|
pub fn println_name_value(name: &str, value: &str) {
|
||||||
let styled_value = if value.is_empty() {
|
let styled_value = if value == "" {
|
||||||
style("(not set)").italic()
|
style("(not set)").italic()
|
||||||
} else {
|
} else {
|
||||||
style(value)
|
style(value)
|
||||||
@@ -36,7 +36,7 @@ pub fn println_name_value(name: &str, value: &str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn writeln_name_value(f: &mut fmt::Formatter, name: &str, value: &str) -> fmt::Result {
|
pub fn writeln_name_value(f: &mut fmt::Formatter, name: &str, value: &str) -> fmt::Result {
|
||||||
let styled_value = if value.is_empty() {
|
let styled_value = if value == "" {
|
||||||
style("(not set)").italic()
|
style("(not set)").italic()
|
||||||
} else {
|
} else {
|
||||||
style(value)
|
style(value)
|
||||||
@@ -44,19 +44,6 @@ pub fn writeln_name_value(f: &mut fmt::Formatter, name: &str, value: &str) -> fm
|
|||||||
writeln!(f, "{} {}", style(name).bold(), styled_value)
|
writeln!(f, "{} {}", style(name).bold(), styled_value)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn format_labeled_address(pubkey: &str, address_labels: &HashMap<String, String>) -> String {
|
|
||||||
let label = address_labels.get(pubkey);
|
|
||||||
match label {
|
|
||||||
Some(label) => format!(
|
|
||||||
"{:.31} ({:.4}..{})",
|
|
||||||
label,
|
|
||||||
pubkey,
|
|
||||||
pubkey.split_at(pubkey.len() - 4).1
|
|
||||||
),
|
|
||||||
None => pubkey.to_string(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn println_signers(
|
pub fn println_signers(
|
||||||
blockhash: &Hash,
|
blockhash: &Hash,
|
||||||
signers: &[String],
|
signers: &[String],
|
||||||
@@ -164,7 +151,7 @@ pub fn write_transaction<W: io::Write>(
|
|||||||
)?;
|
)?;
|
||||||
writeln!(
|
writeln!(
|
||||||
w,
|
w,
|
||||||
"{} Fee: ◎{}",
|
"{} Fee: {} SOL",
|
||||||
prefix,
|
prefix,
|
||||||
lamports_to_sol(transaction_status.fee)
|
lamports_to_sol(transaction_status.fee)
|
||||||
)?;
|
)?;
|
||||||
@@ -181,7 +168,7 @@ pub fn write_transaction<W: io::Write>(
|
|||||||
if pre == post {
|
if pre == post {
|
||||||
writeln!(
|
writeln!(
|
||||||
w,
|
w,
|
||||||
"{} Account {} balance: ◎{}",
|
"{} Account {} balance: {} SOL",
|
||||||
prefix,
|
prefix,
|
||||||
i,
|
i,
|
||||||
lamports_to_sol(*pre)
|
lamports_to_sol(*pre)
|
||||||
@@ -189,7 +176,7 @@ pub fn write_transaction<W: io::Write>(
|
|||||||
} else {
|
} else {
|
||||||
writeln!(
|
writeln!(
|
||||||
w,
|
w,
|
||||||
"{} Account {} balance: ◎{} -> ◎{}",
|
"{} Account {} balance: {} SOL -> {} SOL",
|
||||||
prefix,
|
prefix,
|
||||||
i,
|
i,
|
||||||
lamports_to_sol(*pre),
|
lamports_to_sol(*pre),
|
||||||
@@ -197,15 +184,6 @@ 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 {
|
} else {
|
||||||
writeln!(w, "{}Status: Unavailable", prefix)?;
|
writeln!(w, "{}Status: Unavailable", prefix)?;
|
||||||
}
|
}
|
||||||
@@ -234,32 +212,3 @@ pub fn new_spinner_progress_bar() -> ProgressBar {
|
|||||||
progress_bar.enable_steady_tick(100);
|
progress_bar.enable_steady_tick(100);
|
||||||
progress_bar
|
progress_bar
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod test {
|
|
||||||
use super::*;
|
|
||||||
use solana_sdk::pubkey::Pubkey;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_format_labeled_address() {
|
|
||||||
let pubkey = Pubkey::default().to_string();
|
|
||||||
let mut address_labels = HashMap::new();
|
|
||||||
|
|
||||||
assert_eq!(format_labeled_address(&pubkey, &address_labels), pubkey);
|
|
||||||
|
|
||||||
address_labels.insert(pubkey.to_string(), "Default Address".to_string());
|
|
||||||
assert_eq!(
|
|
||||||
&format_labeled_address(&pubkey, &address_labels),
|
|
||||||
"Default Address (1111..1111)"
|
|
||||||
);
|
|
||||||
|
|
||||||
address_labels.insert(
|
|
||||||
pubkey.to_string(),
|
|
||||||
"abcdefghijklmnopqrstuvwxyz1234567890".to_string(),
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
&format_labeled_address(&pubkey, &address_labels),
|
|
||||||
"abcdefghijklmnopqrstuvwxyz12345 (1111..1111)"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -1,15 +1,3 @@
|
|||||||
mod cli_output;
|
mod cli_output;
|
||||||
pub mod display;
|
pub mod display;
|
||||||
pub use cli_output::*;
|
pub use cli_output::*;
|
||||||
|
|
||||||
pub trait QuietDisplay: std::fmt::Display {
|
|
||||||
fn write_str(&self, w: &mut dyn std::fmt::Write) -> std::fmt::Result {
|
|
||||||
write!(w, "{}", self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait VerboseDisplay: std::fmt::Display {
|
|
||||||
fn write_str(&self, w: &mut dyn std::fmt::Write) -> std::fmt::Result {
|
|
||||||
write!(w, "{}", self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
name = "solana-cli"
|
name = "solana-cli"
|
||||||
description = "Blockchain, Rebuilt for Scale"
|
description = "Blockchain, Rebuilt for Scale"
|
||||||
version = "1.5.3"
|
version = "1.2.33"
|
||||||
repository = "https://github.com/solana-labs/solana"
|
repository = "https://github.com/solana-labs/solana"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
homepage = "https://solana.com/"
|
homepage = "https://solana.com/"
|
||||||
@@ -14,42 +14,42 @@ bs58 = "0.3.1"
|
|||||||
chrono = { version = "0.4.11", features = ["serde"] }
|
chrono = { version = "0.4.11", features = ["serde"] }
|
||||||
clap = "2.33.1"
|
clap = "2.33.1"
|
||||||
criterion-stats = "0.3.0"
|
criterion-stats = "0.3.0"
|
||||||
ctrlc = { version = "3.1.5", features = ["termination"] }
|
ctrlc = { version = "3.1.4", features = ["termination"] }
|
||||||
console = "0.11.3"
|
console = "0.10.1"
|
||||||
dirs-next = "2.0.0"
|
dirs = "2.0.2"
|
||||||
log = "0.4.11"
|
log = "0.4.8"
|
||||||
Inflector = "0.11.4"
|
Inflector = "0.11.4"
|
||||||
indicatif = "0.15.0"
|
indicatif = "0.14.0"
|
||||||
humantime = "2.0.1"
|
humantime = "2.0.0"
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
pretty-hex = "0.2.1"
|
pretty-hex = "0.1.1"
|
||||||
reqwest = { version = "0.10.8", default-features = false, features = ["blocking", "rustls-tls", "json"] }
|
reqwest = { version = "0.10.4", default-features = false, features = ["blocking", "rustls-tls", "json"] }
|
||||||
serde = "1.0.112"
|
serde = "1.0.110"
|
||||||
serde_derive = "1.0.103"
|
serde_derive = "1.0.103"
|
||||||
serde_json = "1.0.56"
|
serde_json = "1.0.53"
|
||||||
solana-account-decoder = { path = "../account-decoder", version = "1.5.3" }
|
solana-account-decoder = { path = "../account-decoder", version = "1.2.33" }
|
||||||
solana-bpf-loader-program = { path = "../programs/bpf_loader", version = "1.5.3" }
|
solana-budget-program = { path = "../programs/budget", version = "1.2.33" }
|
||||||
solana-clap-utils = { path = "../clap-utils", version = "1.5.3" }
|
solana-clap-utils = { path = "../clap-utils", version = "1.2.33" }
|
||||||
solana-cli-config = { path = "../cli-config", version = "1.5.3" }
|
solana-cli-config = { path = "../cli-config", version = "1.2.33" }
|
||||||
solana-cli-output = { path = "../cli-output", version = "1.5.3" }
|
solana-cli-output = { path = "../cli-output", version = "1.2.33" }
|
||||||
solana-client = { path = "../client", version = "1.5.3" }
|
solana-client = { path = "../client", version = "1.2.33" }
|
||||||
solana-config-program = { path = "../programs/config", version = "1.5.3" }
|
solana-config-program = { path = "../programs/config", version = "1.2.33" }
|
||||||
solana-faucet = { path = "../faucet", version = "1.5.3" }
|
solana-faucet = { path = "../faucet", version = "1.2.33" }
|
||||||
solana-logger = { path = "../logger", version = "1.5.3" }
|
solana-logger = { path = "../logger", version = "1.2.33" }
|
||||||
solana-net-utils = { path = "../net-utils", version = "1.5.3" }
|
solana-net-utils = { path = "../net-utils", version = "1.2.33" }
|
||||||
solana_rbpf = "=0.2.3"
|
solana-remote-wallet = { path = "../remote-wallet", version = "1.2.33" }
|
||||||
solana-remote-wallet = { path = "../remote-wallet", version = "1.5.3" }
|
solana-sdk = { path = "../sdk", version = "1.2.33" }
|
||||||
solana-sdk = { path = "../sdk", version = "1.5.3" }
|
solana-stake-program = { path = "../programs/stake", version = "1.2.33" }
|
||||||
solana-stake-program = { path = "../programs/stake", version = "1.5.3" }
|
solana-transaction-status = { path = "../transaction-status", version = "1.2.33" }
|
||||||
solana-transaction-status = { path = "../transaction-status", version = "1.5.3" }
|
solana-version = { path = "../version", version = "1.2.33" }
|
||||||
solana-version = { path = "../version", version = "1.5.3" }
|
solana-vote-program = { path = "../programs/vote", version = "1.2.33" }
|
||||||
solana-vote-program = { path = "../programs/vote", version = "1.5.3" }
|
solana-vote-signer = { path = "../vote-signer", version = "1.2.33" }
|
||||||
thiserror = "1.0.21"
|
thiserror = "1.0.19"
|
||||||
tiny-bip39 = "0.7.0"
|
|
||||||
url = "2.1.1"
|
url = "2.1.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
solana-core = { path = "../core", version = "1.5.3" }
|
solana-core = { path = "../core", version = "1.2.33" }
|
||||||
|
solana-budget-program = { path = "../programs/budget", version = "1.2.33" }
|
||||||
tempfile = "3.1.0"
|
tempfile = "3.1.0"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
@@ -4,8 +4,7 @@ use solana_client::{
|
|||||||
rpc_client::RpcClient,
|
rpc_client::RpcClient,
|
||||||
};
|
};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
commitment_config::CommitmentConfig, fee_calculator::FeeCalculator, message::Message,
|
fee_calculator::FeeCalculator, message::Message, native_token::lamports_to_sol, pubkey::Pubkey,
|
||||||
native_token::lamports_to_sol, pubkey::Pubkey,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn check_account_for_fee(
|
pub fn check_account_for_fee(
|
||||||
@@ -17,79 +16,17 @@ pub fn check_account_for_fee(
|
|||||||
check_account_for_multiple_fees(rpc_client, account_pubkey, fee_calculator, &[message])
|
check_account_for_multiple_fees(rpc_client, account_pubkey, fee_calculator, &[message])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_account_for_fee_with_commitment(
|
|
||||||
rpc_client: &RpcClient,
|
|
||||||
account_pubkey: &Pubkey,
|
|
||||||
fee_calculator: &FeeCalculator,
|
|
||||||
message: &Message,
|
|
||||||
commitment: CommitmentConfig,
|
|
||||||
) -> Result<(), CliError> {
|
|
||||||
check_account_for_multiple_fees_with_commitment(
|
|
||||||
rpc_client,
|
|
||||||
account_pubkey,
|
|
||||||
fee_calculator,
|
|
||||||
&[message],
|
|
||||||
commitment,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn check_account_for_multiple_fees(
|
pub fn check_account_for_multiple_fees(
|
||||||
rpc_client: &RpcClient,
|
rpc_client: &RpcClient,
|
||||||
account_pubkey: &Pubkey,
|
account_pubkey: &Pubkey,
|
||||||
fee_calculator: &FeeCalculator,
|
fee_calculator: &FeeCalculator,
|
||||||
messages: &[&Message],
|
messages: &[&Message],
|
||||||
) -> Result<(), CliError> {
|
|
||||||
check_account_for_multiple_fees_with_commitment(
|
|
||||||
rpc_client,
|
|
||||||
account_pubkey,
|
|
||||||
fee_calculator,
|
|
||||||
messages,
|
|
||||||
CommitmentConfig::default(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn check_account_for_multiple_fees_with_commitment(
|
|
||||||
rpc_client: &RpcClient,
|
|
||||||
account_pubkey: &Pubkey,
|
|
||||||
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> {
|
) -> Result<(), CliError> {
|
||||||
let fee = calculate_fee(fee_calculator, messages);
|
let fee = calculate_fee(fee_calculator, messages);
|
||||||
if !check_account_for_balance_with_commitment(
|
if !check_account_for_balance(rpc_client, account_pubkey, fee)
|
||||||
rpc_client,
|
.map_err(Into::<ClientError>::into)?
|
||||||
account_pubkey,
|
|
||||||
balance + fee,
|
|
||||||
commitment,
|
|
||||||
)
|
|
||||||
.map_err(Into::<ClientError>::into)?
|
|
||||||
{
|
{
|
||||||
if balance > 0 {
|
return Err(CliError::InsufficientFundsForFee(lamports_to_sol(fee)));
|
||||||
return Err(CliError::InsufficientFundsForSpendAndFee(
|
|
||||||
lamports_to_sol(balance),
|
|
||||||
lamports_to_sol(fee),
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
return Err(CliError::InsufficientFundsForFee(lamports_to_sol(fee)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -106,23 +43,7 @@ pub fn check_account_for_balance(
|
|||||||
account_pubkey: &Pubkey,
|
account_pubkey: &Pubkey,
|
||||||
balance: u64,
|
balance: u64,
|
||||||
) -> ClientResult<bool> {
|
) -> ClientResult<bool> {
|
||||||
check_account_for_balance_with_commitment(
|
let lamports = rpc_client.get_balance(account_pubkey)?;
|
||||||
rpc_client,
|
|
||||||
account_pubkey,
|
|
||||||
balance,
|
|
||||||
CommitmentConfig::default(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn check_account_for_balance_with_commitment(
|
|
||||||
rpc_client: &RpcClient,
|
|
||||||
account_pubkey: &Pubkey,
|
|
||||||
balance: u64,
|
|
||||||
commitment: CommitmentConfig,
|
|
||||||
) -> ClientResult<bool> {
|
|
||||||
let lamports = rpc_client
|
|
||||||
.get_balance_with_commitment(account_pubkey, commitment)?
|
|
||||||
.value;
|
|
||||||
if lamports != 0 && lamports >= balance {
|
if lamports != 0 && lamports >= balance {
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
@@ -161,7 +82,7 @@ mod tests {
|
|||||||
context: RpcResponseContext { slot: 1 },
|
context: RpcResponseContext { slot: 1 },
|
||||||
value: json!(account_balance),
|
value: json!(account_balance),
|
||||||
});
|
});
|
||||||
let pubkey = solana_sdk::pubkey::new_rand();
|
let pubkey = Pubkey::new_rand();
|
||||||
let fee_calculator = FeeCalculator::new(1);
|
let fee_calculator = FeeCalculator::new(1);
|
||||||
|
|
||||||
let pubkey0 = Pubkey::new(&[0; 32]);
|
let pubkey0 = Pubkey::new(&[0; 32]);
|
||||||
@@ -221,7 +142,7 @@ mod tests {
|
|||||||
context: RpcResponseContext { slot: 1 },
|
context: RpcResponseContext { slot: 1 },
|
||||||
value: json!(account_balance),
|
value: json!(account_balance),
|
||||||
});
|
});
|
||||||
let pubkey = solana_sdk::pubkey::new_rand();
|
let pubkey = Pubkey::new_rand();
|
||||||
|
|
||||||
let mut mocks = HashMap::new();
|
let mut mocks = HashMap::new();
|
||||||
mocks.insert(RpcRequest::GetBalance, account_balance_response);
|
mocks.insert(RpcRequest::GetBalance, account_balance_response);
|
||||||
@@ -267,9 +188,9 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_check_unique_pubkeys() {
|
fn test_check_unique_pubkeys() {
|
||||||
let pubkey0 = solana_sdk::pubkey::new_rand();
|
let pubkey0 = Pubkey::new_rand();
|
||||||
let pubkey_clone = pubkey0;
|
let pubkey_clone = pubkey0;
|
||||||
let pubkey1 = solana_sdk::pubkey::new_rand();
|
let pubkey1 = Pubkey::new_rand();
|
||||||
|
|
||||||
check_unique_pubkeys((&pubkey0, "foo".to_string()), (&pubkey1, "bar".to_string()))
|
check_unique_pubkeys((&pubkey0, "foo".to_string()), (&pubkey1, "bar".to_string()))
|
||||||
.expect("unexpected result");
|
.expect("unexpected result");
|
||||||
|
1587
cli/src/cli.rs
1587
cli/src/cli.rs
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,379 +0,0 @@
|
|||||||
use crate::{
|
|
||||||
cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult},
|
|
||||||
spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
|
|
||||||
};
|
|
||||||
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
|
|
||||||
use console::style;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
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_sdk::{
|
|
||||||
clock::Slot,
|
|
||||||
feature::{self, Feature},
|
|
||||||
feature_set::FEATURE_NAMES,
|
|
||||||
message::Message,
|
|
||||||
pubkey::Pubkey,
|
|
||||||
transaction::Transaction,
|
|
||||||
};
|
|
||||||
use std::{collections::HashMap, fmt, sync::Arc};
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
|
||||||
pub enum FeatureCliCommand {
|
|
||||||
Status { features: Vec<Pubkey> },
|
|
||||||
Activate { feature: Pubkey },
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
#[serde(rename_all = "camelCase", tag = "status", content = "sinceSlot")]
|
|
||||||
pub enum CliFeatureStatus {
|
|
||||||
Inactive,
|
|
||||||
Pending,
|
|
||||||
Active(Slot),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct CliFeature {
|
|
||||||
pub id: String,
|
|
||||||
pub description: String,
|
|
||||||
#[serde(flatten)]
|
|
||||||
pub status: CliFeatureStatus,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct CliFeatures {
|
|
||||||
pub features: Vec<CliFeature>,
|
|
||||||
pub feature_activation_allowed: bool,
|
|
||||||
#[serde(skip)]
|
|
||||||
pub inactive: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for CliFeatures {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
if self.features.len() > 1 {
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
"{}",
|
|
||||||
style(format!(
|
|
||||||
"{:<44} {:<40} {}",
|
|
||||||
"Feature", "Description", "Status"
|
|
||||||
))
|
|
||||||
.bold()
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
for feature in &self.features {
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
"{:<44} {:<40} {}",
|
|
||||||
feature.id,
|
|
||||||
feature.description,
|
|
||||||
match feature.status {
|
|
||||||
CliFeatureStatus::Inactive => style("inactive".to_string()).red(),
|
|
||||||
CliFeatureStatus::Pending => style("activation pending".to_string()).yellow(),
|
|
||||||
CliFeatureStatus::Active(activation_slot) =>
|
|
||||||
style(format!("active since slot {}", activation_slot)).green(),
|
|
||||||
}
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
if self.inactive && !self.feature_activation_allowed {
|
|
||||||
writeln!(
|
|
||||||
f,
|
|
||||||
"{}",
|
|
||||||
style("\nFeature activation is not allowed at this time")
|
|
||||||
.bold()
|
|
||||||
.red()
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl QuietDisplay for CliFeatures {}
|
|
||||||
impl VerboseDisplay for CliFeatures {}
|
|
||||||
|
|
||||||
pub trait FeatureSubCommands {
|
|
||||||
fn feature_subcommands(self) -> Self;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FeatureSubCommands for App<'_, '_> {
|
|
||||||
fn feature_subcommands(self) -> Self {
|
|
||||||
self.subcommand(
|
|
||||||
SubCommand::with_name("feature")
|
|
||||||
.about("Runtime feature management")
|
|
||||||
.setting(AppSettings::SubcommandRequiredElseHelp)
|
|
||||||
.subcommand(
|
|
||||||
SubCommand::with_name("status")
|
|
||||||
.about("Query runtime feature status")
|
|
||||||
.arg(
|
|
||||||
Arg::with_name("features")
|
|
||||||
.value_name("ADDRESS")
|
|
||||||
.validator(is_valid_pubkey)
|
|
||||||
.index(1)
|
|
||||||
.multiple(true)
|
|
||||||
.help("Feature status to query [default: all known features]"),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.subcommand(
|
|
||||||
SubCommand::with_name("activate")
|
|
||||||
.about("Activate a runtime feature")
|
|
||||||
.arg(
|
|
||||||
Arg::with_name("feature")
|
|
||||||
.value_name("FEATURE_KEYPAIR")
|
|
||||||
.validator(is_valid_signer)
|
|
||||||
.index(1)
|
|
||||||
.required(true)
|
|
||||||
.help("The signer for the feature to activate"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn known_feature(feature: &Pubkey) -> Result<(), CliError> {
|
|
||||||
if FEATURE_NAMES.contains_key(feature) {
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(CliError::BadParameter(format!(
|
|
||||||
"Unknown feature: {}",
|
|
||||||
feature
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parse_feature_subcommand(
|
|
||||||
matches: &ArgMatches<'_>,
|
|
||||||
default_signer: &DefaultSigner,
|
|
||||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
|
||||||
) -> Result<CliCommandInfo, CliError> {
|
|
||||||
let response = match matches.subcommand() {
|
|
||||||
("activate", Some(matches)) => {
|
|
||||||
let (feature_signer, feature) = signer_of(matches, "feature", wallet_manager)?;
|
|
||||||
let mut signers = vec![default_signer.signer_from_path(matches, wallet_manager)?];
|
|
||||||
signers.push(feature_signer.unwrap());
|
|
||||||
let feature = feature.unwrap();
|
|
||||||
|
|
||||||
known_feature(&feature)?;
|
|
||||||
|
|
||||||
CliCommandInfo {
|
|
||||||
command: CliCommand::Feature(FeatureCliCommand::Activate { feature }),
|
|
||||||
signers,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
("status", Some(matches)) => {
|
|
||||||
let mut features = if let Some(features) = pubkeys_of(matches, "features") {
|
|
||||||
for feature in &features {
|
|
||||||
known_feature(feature)?;
|
|
||||||
}
|
|
||||||
features
|
|
||||||
} else {
|
|
||||||
FEATURE_NAMES.keys().cloned().collect()
|
|
||||||
};
|
|
||||||
features.sort();
|
|
||||||
CliCommandInfo {
|
|
||||||
command: CliCommand::Feature(FeatureCliCommand::Status { features }),
|
|
||||||
signers: vec![],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => unreachable!(),
|
|
||||||
};
|
|
||||||
Ok(response)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn process_feature_subcommand(
|
|
||||||
rpc_client: &RpcClient,
|
|
||||||
config: &CliConfig,
|
|
||||||
feature_subcommand: &FeatureCliCommand,
|
|
||||||
) -> ProcessResult {
|
|
||||||
match feature_subcommand {
|
|
||||||
FeatureCliCommand::Status { features } => process_status(rpc_client, config, features),
|
|
||||||
FeatureCliCommand::Activate { feature } => process_activate(rpc_client, config, *feature),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn active_stake_by_feature_set(rpc_client: &RpcClient) -> Result<HashMap<u32, u64>, ClientError> {
|
|
||||||
// Validator identity -> feature set
|
|
||||||
let feature_set_map = rpc_client
|
|
||||||
.get_cluster_nodes()?
|
|
||||||
.into_iter()
|
|
||||||
.map(|contact_info| (contact_info.pubkey, contact_info.feature_set))
|
|
||||||
.collect::<HashMap<_, _>>();
|
|
||||||
|
|
||||||
let vote_accounts = rpc_client.get_vote_accounts()?;
|
|
||||||
|
|
||||||
let total_active_stake: u64 = vote_accounts
|
|
||||||
.current
|
|
||||||
.iter()
|
|
||||||
.chain(vote_accounts.delinquent.iter())
|
|
||||||
.map(|vote_account| vote_account.activated_stake)
|
|
||||||
.sum();
|
|
||||||
|
|
||||||
// Sum all active stake by feature set
|
|
||||||
let mut active_stake_by_feature_set = HashMap::new();
|
|
||||||
for vote_account in vote_accounts.current {
|
|
||||||
if let Some(Some(feature_set)) = feature_set_map.get(&vote_account.node_pubkey) {
|
|
||||||
*active_stake_by_feature_set.entry(*feature_set).or_default() +=
|
|
||||||
vote_account.activated_stake;
|
|
||||||
} else {
|
|
||||||
*active_stake_by_feature_set
|
|
||||||
.entry(0 /* "unknown" */)
|
|
||||||
.or_default() += vote_account.activated_stake;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert active stake to a percentage so the caller doesn't need `total_active_stake`
|
|
||||||
for (_, val) in active_stake_by_feature_set.iter_mut() {
|
|
||||||
*val = *val * 100 / total_active_stake;
|
|
||||||
}
|
|
||||||
Ok(active_stake_by_feature_set)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Feature activation is only allowed when 95% of the active stake is on the current feature set
|
|
||||||
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)?;
|
|
||||||
|
|
||||||
let feature_activation_allowed = active_stake_by_feature_set
|
|
||||||
.get(&my_feature_set)
|
|
||||||
.map(|percentage| *percentage >= 95)
|
|
||||||
.unwrap_or(false);
|
|
||||||
|
|
||||||
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);
|
|
||||||
} else {
|
|
||||||
println!(
|
|
||||||
"{} - {}% {}",
|
|
||||||
feature_set,
|
|
||||||
percentage,
|
|
||||||
if *feature_set == my_feature_set {
|
|
||||||
" <-- me"
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
println!();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(feature_activation_allowed)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn process_status(
|
|
||||||
rpc_client: &RpcClient,
|
|
||||||
config: &CliConfig,
|
|
||||||
feature_ids: &[Pubkey],
|
|
||||||
) -> ProcessResult {
|
|
||||||
let mut features: Vec<CliFeature> = vec![];
|
|
||||||
let mut inactive = false;
|
|
||||||
for (i, account) in rpc_client
|
|
||||||
.get_multiple_accounts(feature_ids)?
|
|
||||||
.into_iter()
|
|
||||||
.enumerate()
|
|
||||||
{
|
|
||||||
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) {
|
|
||||||
let feature_status = match feature.activated_at {
|
|
||||||
None => CliFeatureStatus::Pending,
|
|
||||||
Some(activation_slot) => CliFeatureStatus::Active(activation_slot),
|
|
||||||
};
|
|
||||||
features.push(CliFeature {
|
|
||||||
id: feature_id.to_string(),
|
|
||||||
description: feature_name.to_string(),
|
|
||||||
status: feature_status,
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inactive = true;
|
|
||||||
features.push(CliFeature {
|
|
||||||
id: feature_id.to_string(),
|
|
||||||
description: feature_name.to_string(),
|
|
||||||
status: CliFeatureStatus::Inactive,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let feature_activation_allowed = feature_activation_allowed(rpc_client, features.len() <= 1)?;
|
|
||||||
let feature_set = CliFeatures {
|
|
||||||
features,
|
|
||||||
feature_activation_allowed,
|
|
||||||
inactive,
|
|
||||||
};
|
|
||||||
Ok(config.output_format.formatted_string(&feature_set))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn process_activate(
|
|
||||||
rpc_client: &RpcClient,
|
|
||||||
config: &CliConfig,
|
|
||||||
feature_id: Pubkey,
|
|
||||||
) -> ProcessResult {
|
|
||||||
let account = rpc_client
|
|
||||||
.get_multiple_accounts(&[feature_id])?
|
|
||||||
.into_iter()
|
|
||||||
.next()
|
|
||||||
.unwrap();
|
|
||||||
if let Some(account) = account {
|
|
||||||
if feature::from_account(&account).is_some() {
|
|
||||||
return Err(format!("{} has already been activated", feature_id).into());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !feature_activation_allowed(rpc_client, false)? {
|
|
||||||
return Err("Feature activation is not allowed at this time".into());
|
|
||||||
}
|
|
||||||
|
|
||||||
let rent = rpc_client.get_minimum_balance_for_rent_exemption(Feature::size_of())?;
|
|
||||||
|
|
||||||
let (blockhash, fee_calculator) = rpc_client.get_recent_blockhash()?;
|
|
||||||
let (message, _) = resolve_spend_tx_and_check_account_balance(
|
|
||||||
rpc_client,
|
|
||||||
false,
|
|
||||||
SpendAmount::Some(rent),
|
|
||||||
&fee_calculator,
|
|
||||||
&config.signers[0].pubkey(),
|
|
||||||
|lamports| {
|
|
||||||
Message::new(
|
|
||||||
&feature::activate_with_lamports(
|
|
||||||
&feature_id,
|
|
||||||
&config.signers[0].pubkey(),
|
|
||||||
lamports,
|
|
||||||
),
|
|
||||||
Some(&config.signers[0].pubkey()),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
config.commitment,
|
|
||||||
)?;
|
|
||||||
let mut transaction = Transaction::new_unsigned(message);
|
|
||||||
transaction.try_sign(&config.signers, blockhash)?;
|
|
||||||
|
|
||||||
println!(
|
|
||||||
"Activating {} ({})",
|
|
||||||
FEATURE_NAMES.get(&feature_id).unwrap(),
|
|
||||||
feature_id
|
|
||||||
);
|
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&transaction)?;
|
|
||||||
Ok("".to_string())
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user