Merge branch 'groovie/v1.17.25-with-patches' into v1.17.28_optimized_gPA

This commit is contained in:
steve-gg 2024-04-09 11:04:12 +02:00
commit b1d8e4181f
No known key found for this signature in database
GPG Key ID: 5B6EB831A5CD2015
7 changed files with 40 additions and 30 deletions

8
Cargo.lock generated
View File

@ -2089,6 +2089,12 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "fd_bs58"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdaac1b30ff95de4562a79ae990f91ac7bf2062d7313cc25c58987762c8e8160"
[[package]]
name = "feature-probe"
version = "0.1.1"
@ -6594,13 +6600,13 @@ dependencies = [
"blake3",
"borsh 0.10.3",
"borsh 0.9.3",
"bs58",
"bv",
"bytemuck",
"cc",
"console_error_panic_hook",
"console_log",
"curve25519-dalek",
"fd_bs58",
"getrandom 0.2.10",
"itertools",
"js-sys",

View File

@ -335,6 +335,14 @@ fn bank_forks_from_snapshot(
);
process::exit(1);
});
// If the node crashes before taking the next bank snapshot, the next startup will attempt
// to load from the same bank snapshot again. And if `shrink` has run, the account storage
// files that are hard linked in bank snapshot will be *different* than what the bank
// snapshot expects. This would cause the node to crash again. To prevent that, purge all
// the bank snapshots here. In the above scenario, this will cause the node to load from a
// snapshot archive next time, which is safe.
snapshot_utils::purge_old_bank_snapshots(&snapshot_config.bank_snapshots_dir, 0, None);
bank
};

View File

@ -16,7 +16,7 @@ bincode = { workspace = true }
blake3 = { workspace = true, features = ["digest", "traits-preview"] }
borsh = { workspace = true }
borsh0-9 = { package = "borsh", version = "0.9.3" }
bs58 = { workspace = true }
fd_bs58 = "0.1.0"
bv = { workspace = true, features = ["serde"] }
bytemuck = { workspace = true, features = ["derive"] }
itertools = { workspace = true }

View File

@ -63,13 +63,13 @@ impl AsRef<[u8]> for Hash {
impl fmt::Debug for Hash {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", bs58::encode(self.0).into_string())
write!(f, "{}", fd_bs58::encode_32(self.0))
}
}
impl fmt::Display for Hash {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", bs58::encode(self.0).into_string())
write!(f, "{}", fd_bs58::encode_32(self.0))
}
}
@ -88,8 +88,7 @@ impl FromStr for Hash {
if s.len() > MAX_BASE58_LEN {
return Err(ParseHashError::WrongSize);
}
let bytes = bs58::decode(s)
.into_vec()
let bytes = fd_bs58::decode_32(s)
.map_err(|_| ParseHashError::Invalid)?;
if bytes.len() != mem::size_of::<Hash>() {
Err(ParseHashError::WrongSize)
@ -174,11 +173,11 @@ mod tests {
fn test_hash_fromstr() {
let hash = hash(&[1u8]);
let mut hash_base58_str = bs58::encode(hash).into_string();
let mut hash_base58_str = fd_bs58::encode_32(hash);
assert_eq!(hash_base58_str.parse::<Hash>(), Ok(hash));
hash_base58_str.push_str(&bs58::encode(hash.0).into_string());
hash_base58_str.push_str(&fd_bs58::encode_32(hash.0));
assert_eq!(
hash_base58_str.parse::<Hash>(),
Err(ParseHashError::WrongSize)
@ -193,14 +192,14 @@ mod tests {
Err(ParseHashError::WrongSize)
);
let input_too_big = bs58::encode(&[0xffu8; HASH_BYTES + 1]).into_string();
let input_too_big = fd_bs58::encode_32(&[0xffu8; HASH_BYTES + 1]);
assert!(input_too_big.len() > MAX_BASE58_LEN);
assert_eq!(
input_too_big.parse::<Hash>(),
Err(ParseHashError::WrongSize)
);
let mut hash_base58_str = bs58::encode(hash.0).into_string();
let mut hash_base58_str = fd_bs58::encode_32(hash.0);
assert_eq!(hash_base58_str.parse::<Hash>(), Ok(hash));
// throw some non-base58 stuff in there

View File

@ -84,13 +84,13 @@ impl AsRef<[u8]> for Hash {
impl fmt::Debug for Hash {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", bs58::encode(self.0).into_string())
write!(f, "{}", fd_bs58::encode_32(self.0))
}
}
impl fmt::Display for Hash {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", bs58::encode(self.0).into_string())
write!(f, "{}", fd_bs58::encode_32(self.0))
}
}
@ -109,8 +109,7 @@ impl FromStr for Hash {
if s.len() > MAX_BASE58_LEN {
return Err(ParseHashError::WrongSize);
}
let bytes = bs58::decode(s)
.into_vec()
let bytes = fd_bs58::decode_32(s)
.map_err(|_| ParseHashError::Invalid)?;
if bytes.len() != mem::size_of::<Hash>() {
Err(ParseHashError::WrongSize)
@ -195,11 +194,11 @@ mod tests {
fn test_hash_fromstr() {
let hash = hash(&[1u8]);
let mut hash_base58_str = bs58::encode(hash).into_string();
let mut hash_base58_str = fd_bs58::encode_32(hash);
assert_eq!(hash_base58_str.parse::<Hash>(), Ok(hash));
hash_base58_str.push_str(&bs58::encode(hash.0).into_string());
hash_base58_str.push_str(&fd_bs58::encode_32(hash.0));
assert_eq!(
hash_base58_str.parse::<Hash>(),
Err(ParseHashError::WrongSize)
@ -214,14 +213,14 @@ mod tests {
Err(ParseHashError::WrongSize)
);
let input_too_big = bs58::encode(&[0xffu8; HASH_BYTES + 1]).into_string();
let input_too_big = fd_bs58::encode_32(&[0xffu8; HASH_BYTES + 1]);
assert!(input_too_big.len() > MAX_BASE58_LEN);
assert_eq!(
input_too_big.parse::<Hash>(),
Err(ParseHashError::WrongSize)
);
let mut hash_base58_str = bs58::encode(hash.0).into_string();
let mut hash_base58_str = fd_bs58::encode_32(hash.0);
assert_eq!(hash_base58_str.parse::<Hash>(), Ok(hash));
// throw some non-base58 stuff in there

View File

@ -63,13 +63,13 @@ impl AsRef<[u8]> for Hash {
impl fmt::Debug for Hash {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", bs58::encode(self.0).into_string())
write!(f, "{}", fd_bs58::encode_32(self.0))
}
}
impl fmt::Display for Hash {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", bs58::encode(self.0).into_string())
write!(f, "{}", fd_bs58::encode_32(self.0))
}
}
@ -88,8 +88,7 @@ impl FromStr for Hash {
if s.len() > MAX_BASE58_LEN {
return Err(ParseHashError::WrongSize);
}
let bytes = bs58::decode(s)
.into_vec()
let bytes = fd_bs58::decode_32(s)
.map_err(|_| ParseHashError::Invalid)?;
if bytes.len() != mem::size_of::<Hash>() {
Err(ParseHashError::WrongSize)

View File

@ -115,8 +115,7 @@ impl FromStr for Pubkey {
if s.len() > MAX_BASE58_LEN {
return Err(ParsePubkeyError::WrongSize);
}
let pubkey_vec = bs58::decode(s)
.into_vec()
let pubkey_vec = fd_bs58::decode_32(s)
.map_err(|_| ParsePubkeyError::Invalid)?;
if pubkey_vec.len() != mem::size_of::<Pubkey>() {
Err(ParsePubkeyError::WrongSize)
@ -658,13 +657,13 @@ impl AsMut<[u8]> for Pubkey {
impl fmt::Debug for Pubkey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", bs58::encode(self.0).into_string())
write!(f, "{}", fd_bs58::encode_32(self.0))
}
}
impl fmt::Display for Pubkey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", bs58::encode(self.0).into_string())
write!(f, "{}", fd_bs58::encode_32(self.0))
}
}
@ -722,11 +721,11 @@ mod tests {
#[test]
fn pubkey_fromstr() {
let pubkey = Pubkey::new_unique();
let mut pubkey_base58_str = bs58::encode(pubkey.0).into_string();
let mut pubkey_base58_str = fd_bs58::encode_32(pubkey.0);
assert_eq!(pubkey_base58_str.parse::<Pubkey>(), Ok(pubkey));
pubkey_base58_str.push_str(&bs58::encode(pubkey.0).into_string());
pubkey_base58_str.push_str(&fd_bs58::encode_32(pubkey.0));
assert_eq!(
pubkey_base58_str.parse::<Pubkey>(),
Err(ParsePubkeyError::WrongSize)
@ -741,7 +740,7 @@ mod tests {
Err(ParsePubkeyError::WrongSize)
);
let mut pubkey_base58_str = bs58::encode(pubkey.0).into_string();
let mut pubkey_base58_str = fd_bs58::encode_32(pubkey.0);
assert_eq!(pubkey_base58_str.parse::<Pubkey>(), Ok(pubkey));
// throw some non-base58 stuff in there
@ -753,7 +752,7 @@ mod tests {
// too long input string
// longest valid encoding
let mut too_long = bs58::encode(&[255u8; PUBKEY_BYTES]).into_string();
let mut too_long = fd_bs58::encode_32(&[255u8; PUBKEY_BYTES]);
// and one to grow on
too_long.push('1');
assert_eq!(too_long.parse::<Pubkey>(), Err(ParsePubkeyError::WrongSize));