Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Bumps base64 from 0.13.1 to 0.21.0. (#31522)
Browse files Browse the repository at this point in the history
Changes:

  marshallpierce/rust-base64@v0.13.1...v0.21.0

`base64::{encode,decode}` are now deprecated in favor of an API that
explicitly selects an `Engine`.  Migrated all calls to the new API.
  • Loading branch information
ilya-bobyr authored May 11, 2023
1 parent 76d1c38 commit 43c0f05
Show file tree
Hide file tree
Showing 21 changed files with 137 additions and 92 deletions.
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ async-mutex = "1.4.0"
async-trait = "0.1.68"
atty = "0.2.11"
backoff = "0.4.0"
base64 = "0.13.1"
base64 = "0.21.0"
bincode = "1.3.3"
bitflags = "1.3.1"
blake3 = "1.3.3"
Expand Down
29 changes: 17 additions & 12 deletions account-decoder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub mod validator_info;

use {
crate::parse_account_data::{parse_account_data, AccountAdditionalData, ParsedAccount},
base64::{prelude::BASE64_STANDARD, Engine},
solana_sdk::{
account::{ReadableAccount, WritableAccount},
clock::Epoch,
Expand Down Expand Up @@ -95,7 +96,7 @@ impl UiAccount {
UiAccountData::Binary(data, encoding)
}
UiAccountEncoding::Base64 => UiAccountData::Binary(
base64::encode(slice_data(account.data(), data_slice_config)),
BASE64_STANDARD.encode(slice_data(account.data(), data_slice_config)),
encoding,
),
UiAccountEncoding::Base64Zstd => {
Expand All @@ -104,9 +105,11 @@ impl UiAccount {
.write_all(slice_data(account.data(), data_slice_config))
.and_then(|()| encoder.finish())
{
Ok(zstd_data) => UiAccountData::Binary(base64::encode(zstd_data), encoding),
Ok(zstd_data) => {
UiAccountData::Binary(BASE64_STANDARD.encode(zstd_data), encoding)
}
Err(_) => UiAccountData::Binary(
base64::encode(slice_data(account.data(), data_slice_config)),
BASE64_STANDARD.encode(slice_data(account.data(), data_slice_config)),
UiAccountEncoding::Base64,
),
}
Expand All @@ -118,7 +121,7 @@ impl UiAccount {
UiAccountData::Json(parsed_data)
} else {
UiAccountData::Binary(
base64::encode(slice_data(account.data(), data_slice_config)),
BASE64_STANDARD.encode(slice_data(account.data(), data_slice_config)),
UiAccountEncoding::Base64,
)
}
Expand All @@ -140,14 +143,16 @@ impl UiAccount {
UiAccountData::LegacyBinary(blob) => bs58::decode(blob).into_vec().ok(),
UiAccountData::Binary(blob, encoding) => match encoding {
UiAccountEncoding::Base58 => bs58::decode(blob).into_vec().ok(),
UiAccountEncoding::Base64 => base64::decode(blob).ok(),
UiAccountEncoding::Base64Zstd => base64::decode(blob).ok().and_then(|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()
}),
UiAccountEncoding::Base64 => BASE64_STANDARD.decode(blob).ok(),
UiAccountEncoding::Base64Zstd => {
BASE64_STANDARD.decode(blob).ok().and_then(|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()
})
}
UiAccountEncoding::Binary | UiAccountEncoding::JsonParsed => None,
},
}?;
Expand Down
25 changes: 19 additions & 6 deletions account-decoder/src/parse_bpf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use {
parse_account_data::{ParsableAccount, ParseAccountError},
UiAccountData, UiAccountEncoding,
},
base64::{prelude::BASE64_STANDARD, Engine},
bincode::{deserialize, serialized_size},
solana_sdk::{bpf_loader_upgradeable::UpgradeableLoaderState, pubkey::Pubkey},
};
Expand All @@ -27,7 +28,7 @@ pub fn parse_bpf_upgradeable_loader(
BpfUpgradeableLoaderAccountType::Buffer(UiBuffer {
authority: authority_address.map(|pubkey| pubkey.to_string()),
data: UiAccountData::Binary(
base64::encode(&data[offset..]),
BASE64_STANDARD.encode(&data[offset..]),
UiAccountEncoding::Base64,
),
})
Expand All @@ -51,7 +52,7 @@ pub fn parse_bpf_upgradeable_loader(
slot,
authority: upgrade_authority_address.map(|pubkey| pubkey.to_string()),
data: UiAccountData::Binary(
base64::encode(&data[offset..]),
BASE64_STANDARD.encode(&data[offset..]),
UiAccountEncoding::Base64,
),
})
Expand Down Expand Up @@ -115,7 +116,10 @@ mod test {
parse_bpf_upgradeable_loader(&account_data).unwrap(),
BpfUpgradeableLoaderAccountType::Buffer(UiBuffer {
authority: Some(authority.to_string()),
data: UiAccountData::Binary(base64::encode(&program), UiAccountEncoding::Base64),
data: UiAccountData::Binary(
BASE64_STANDARD.encode(&program),
UiAccountEncoding::Base64
),
})
);

Expand All @@ -130,7 +134,10 @@ mod test {
parse_bpf_upgradeable_loader(&account_data).unwrap(),
BpfUpgradeableLoaderAccountType::Buffer(UiBuffer {
authority: None,
data: UiAccountData::Binary(base64::encode(&program), UiAccountEncoding::Base64),
data: UiAccountData::Binary(
BASE64_STANDARD.encode(&program),
UiAccountEncoding::Base64
),
})
);

Expand Down Expand Up @@ -159,7 +166,10 @@ mod test {
BpfUpgradeableLoaderAccountType::ProgramData(UiProgramData {
slot,
authority: Some(authority.to_string()),
data: UiAccountData::Binary(base64::encode(&program), UiAccountEncoding::Base64),
data: UiAccountData::Binary(
BASE64_STANDARD.encode(&program),
UiAccountEncoding::Base64
),
})
);

Expand All @@ -174,7 +184,10 @@ mod test {
BpfUpgradeableLoaderAccountType::ProgramData(UiProgramData {
slot,
authority: None,
data: UiAccountData::Binary(base64::encode(&program), UiAccountEncoding::Base64),
data: UiAccountData::Binary(
BASE64_STANDARD.encode(&program),
UiAccountEncoding::Base64
),
})
);
}
Expand Down
3 changes: 2 additions & 1 deletion cli-output/src/cli_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use {
},
QuietDisplay, VerboseDisplay,
},
base64::{prelude::BASE64_STANDARD, Engine},
chrono::{Local, TimeZone},
clap::ArgMatches,
console::{style, Emoji},
Expand Down Expand Up @@ -2400,7 +2401,7 @@ pub fn return_signers_data(tx: &Transaction, config: &ReturnSignersConfig) -> Cl
});
let message = if config.dump_transaction_message {
let message_data = tx.message_data();
Some(base64::encode(message_data))
Some(BASE64_STANDARD.encode(message_data))
} else {
None
};
Expand Down
3 changes: 2 additions & 1 deletion cli-output/src/display.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use {
crate::cli_output::CliSignatureVerificationStatus,
base64::{prelude::BASE64_STANDARD, Engine},
chrono::{DateTime, Local, NaiveDateTime, SecondsFormat, TimeZone, Utc},
console::style,
indicatif::{ProgressBar, ProgressStyle},
Expand Down Expand Up @@ -602,7 +603,7 @@ fn write_return_data<W: io::Write>(
if let Some(return_data) = return_data {
let (data, encoding) = &return_data.data;
let raw_return_data = match encoding {
UiReturnDataEncoding::Base64 => base64::decode(data).map_err(|err| {
UiReturnDataEncoding::Base64 => BASE64_STANDARD.decode(data).map_err(|err| {
io::Error::new(
io::ErrorKind::Other,
format!("could not parse data as {encoding:?}: {err:?}"),
Expand Down
23 changes: 13 additions & 10 deletions genesis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![allow(clippy::integer_arithmetic)]

use {
base64::{prelude::BASE64_STANDARD, Engine},
clap::{crate_description, crate_name, value_t, value_t_or_exit, App, Arg, ArgMatches},
itertools::Itertools,
solana_clap_utils::{
Expand Down Expand Up @@ -87,12 +88,14 @@ pub fn load_genesis_accounts(file: &str, genesis_config: &mut GenesisConfig) ->
let mut account = AccountSharedData::new(account_details.balance, 0, &owner_program_id);
if account_details.data != "~" {
account.set_data(
base64::decode(account_details.data.as_str()).map_err(|err| {
io::Error::new(
io::ErrorKind::Other,
format!("Invalid account data: {}: {:?}", account_details.data, err),
)
})?,
BASE64_STANDARD
.decode(account_details.data.as_str())
.map_err(|err| {
io::Error::new(
io::ErrorKind::Other,
format!("Invalid account data: {}: {:?}", account_details.data, err),
)
})?,
);
}
account.set_executable(account_details.executable);
Expand Down Expand Up @@ -784,7 +787,7 @@ mod tests {

assert_eq!(
b64_account.data,
base64::encode(&genesis_config.accounts[&pubkey].data)
BASE64_STANDARD.encode(&genesis_config.accounts[&pubkey].data)
);
}
}
Expand Down Expand Up @@ -868,7 +871,7 @@ mod tests {

assert_eq!(
b64_account.data,
base64::encode(&genesis_config.accounts[&pubkey].data),
BASE64_STANDARD.encode(&genesis_config.accounts[&pubkey].data),
);
}

Expand Down Expand Up @@ -952,7 +955,7 @@ mod tests {

assert_eq!(
b64_account.data,
base64::encode(&genesis_config.accounts[&pubkey].data),
BASE64_STANDARD.encode(&genesis_config.accounts[&pubkey].data),
);
}

Expand All @@ -977,7 +980,7 @@ mod tests {

assert_eq!(
genesis_accounts2[&keypair_str].data,
base64::encode(&genesis_config.accounts[&pubkey].data),
BASE64_STANDARD.encode(&genesis_config.accounts[&pubkey].data),
);
});
}
Expand Down
5 changes: 3 additions & 2 deletions program-runtime/src/stable_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! of program logging
use {
crate::{ic_logger_msg, log_collector::LogCollector},
base64::{prelude::BASE64_STANDARD, Engine},
itertools::Itertools,
solana_sdk::pubkey::Pubkey,
std::{cell::RefCell, rc::Rc},
Expand Down Expand Up @@ -55,7 +56,7 @@ pub fn program_data(log_collector: &Option<Rc<RefCell<LogCollector>>>, data: &[&
ic_logger_msg!(
log_collector,
"Program data: {}",
data.iter().map(base64::encode).join(" ")
data.iter().map(|v| BASE64_STANDARD.encode(v)).join(" ")
);
}

Expand All @@ -78,7 +79,7 @@ pub fn program_return(
log_collector,
"Program return: {} {}",
program_id,
base64::encode(data)
BASE64_STANDARD.encode(data)
);
}

Expand Down
Loading

0 comments on commit 43c0f05

Please sign in to comment.