Bumps base64 from 0.13.1 to 0.21.0. (#31522)

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.
This commit is contained in:
Illia Bobyr 2023-05-11 11:34:58 -07:00 committed by GitHub
parent 76d1c38f59
commit 43c0f05ca0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 137 additions and 92 deletions

28
Cargo.lock generated
View File

@ -4943,7 +4943,7 @@ name = "solana-account-decoder"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"bs58", "bs58",
"bv", "bv",
@ -5372,7 +5372,7 @@ name = "solana-cli-output"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"base64 0.13.1", "base64 0.21.0",
"chrono", "chrono",
"clap 2.33.3", "clap 2.33.3",
"console", "console",
@ -5502,7 +5502,7 @@ dependencies = [
name = "solana-core" name = "solana-core"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"bs58", "bs58",
"chrono", "chrono",
@ -5760,7 +5760,7 @@ dependencies = [
name = "solana-genesis" name = "solana-genesis"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"clap 2.33.3", "clap 2.33.3",
"itertools", "itertools",
@ -6338,7 +6338,7 @@ dependencies = [
"ark-serialize 0.4.2", "ark-serialize 0.4.2",
"array-bytes", "array-bytes",
"assert_matches", "assert_matches",
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"bitflags", "bitflags",
"blake3", "blake3",
@ -6388,7 +6388,7 @@ dependencies = [
name = "solana-program-runtime" name = "solana-program-runtime"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"eager", "eager",
"enum-iterator", "enum-iterator",
@ -6417,7 +6417,7 @@ version = "1.16.0"
dependencies = [ dependencies = [
"assert_matches", "assert_matches",
"async-trait", "async-trait",
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"chrono-humanize", "chrono-humanize",
"crossbeam-channel", "crossbeam-channel",
@ -6520,7 +6520,7 @@ dependencies = [
name = "solana-rpc" name = "solana-rpc"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"bs58", "bs58",
"crossbeam-channel", "crossbeam-channel",
@ -6579,7 +6579,7 @@ version = "1.16.0"
dependencies = [ dependencies = [
"assert_matches", "assert_matches",
"async-trait", "async-trait",
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"bs58", "bs58",
"crossbeam-channel", "crossbeam-channel",
@ -6606,7 +6606,7 @@ dependencies = [
name = "solana-rpc-client-api" name = "solana-rpc-client-api"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"base64 0.13.1", "base64 0.21.0",
"bs58", "bs58",
"jsonrpc-core", "jsonrpc-core",
"reqwest", "reqwest",
@ -6799,7 +6799,7 @@ version = "1.16.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"assert_matches", "assert_matches",
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"bitflags", "bitflags",
"borsh", "borsh",
@ -7046,7 +7046,7 @@ dependencies = [
name = "solana-test-validator" name = "solana-test-validator"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"crossbeam-channel", "crossbeam-channel",
"log", "log",
@ -7173,7 +7173,7 @@ name = "solana-transaction-status"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"borsh", "borsh",
"bs58", "bs58",
@ -7392,7 +7392,7 @@ version = "1.16.0"
dependencies = [ dependencies = [
"aes-gcm-siv", "aes-gcm-siv",
"arrayref", "arrayref",
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"bytemuck", "bytemuck",
"byteorder", "byteorder",

View File

@ -138,7 +138,7 @@ async-mutex = "1.4.0"
async-trait = "0.1.68" async-trait = "0.1.68"
atty = "0.2.11" atty = "0.2.11"
backoff = "0.4.0" backoff = "0.4.0"
base64 = "0.13.1" base64 = "0.21.0"
bincode = "1.3.3" bincode = "1.3.3"
bitflags = "1.3.1" bitflags = "1.3.1"
blake3 = "1.3.3" blake3 = "1.3.3"

View File

@ -18,6 +18,7 @@ pub mod validator_info;
use { use {
crate::parse_account_data::{parse_account_data, AccountAdditionalData, ParsedAccount}, crate::parse_account_data::{parse_account_data, AccountAdditionalData, ParsedAccount},
base64::{prelude::BASE64_STANDARD, Engine},
solana_sdk::{ solana_sdk::{
account::{ReadableAccount, WritableAccount}, account::{ReadableAccount, WritableAccount},
clock::Epoch, clock::Epoch,
@ -95,7 +96,7 @@ impl UiAccount {
UiAccountData::Binary(data, encoding) UiAccountData::Binary(data, encoding)
} }
UiAccountEncoding::Base64 => UiAccountData::Binary( UiAccountEncoding::Base64 => UiAccountData::Binary(
base64::encode(slice_data(account.data(), data_slice_config)), BASE64_STANDARD.encode(slice_data(account.data(), data_slice_config)),
encoding, encoding,
), ),
UiAccountEncoding::Base64Zstd => { UiAccountEncoding::Base64Zstd => {
@ -104,9 +105,11 @@ impl UiAccount {
.write_all(slice_data(account.data(), data_slice_config)) .write_all(slice_data(account.data(), data_slice_config))
.and_then(|()| encoder.finish()) .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( Err(_) => UiAccountData::Binary(
base64::encode(slice_data(account.data(), data_slice_config)), BASE64_STANDARD.encode(slice_data(account.data(), data_slice_config)),
UiAccountEncoding::Base64, UiAccountEncoding::Base64,
), ),
} }
@ -118,7 +121,7 @@ impl UiAccount {
UiAccountData::Json(parsed_data) UiAccountData::Json(parsed_data)
} else { } else {
UiAccountData::Binary( UiAccountData::Binary(
base64::encode(slice_data(account.data(), data_slice_config)), BASE64_STANDARD.encode(slice_data(account.data(), data_slice_config)),
UiAccountEncoding::Base64, UiAccountEncoding::Base64,
) )
} }
@ -140,14 +143,16 @@ impl UiAccount {
UiAccountData::LegacyBinary(blob) => bs58::decode(blob).into_vec().ok(), UiAccountData::LegacyBinary(blob) => bs58::decode(blob).into_vec().ok(),
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_STANDARD.decode(blob).ok(),
UiAccountEncoding::Base64Zstd => base64::decode(blob).ok().and_then(|zstd_data| { UiAccountEncoding::Base64Zstd => {
let mut data = vec![]; BASE64_STANDARD.decode(blob).ok().and_then(|zstd_data| {
zstd::stream::read::Decoder::new(zstd_data.as_slice()) let mut data = vec![];
.and_then(|mut reader| reader.read_to_end(&mut data)) zstd::stream::read::Decoder::new(zstd_data.as_slice())
.map(|_| data) .and_then(|mut reader| reader.read_to_end(&mut data))
.ok() .map(|_| data)
}), .ok()
})
}
UiAccountEncoding::Binary | UiAccountEncoding::JsonParsed => None, UiAccountEncoding::Binary | UiAccountEncoding::JsonParsed => None,
}, },
}?; }?;

View File

@ -3,6 +3,7 @@ use {
parse_account_data::{ParsableAccount, ParseAccountError}, parse_account_data::{ParsableAccount, ParseAccountError},
UiAccountData, UiAccountEncoding, UiAccountData, UiAccountEncoding,
}, },
base64::{prelude::BASE64_STANDARD, Engine},
bincode::{deserialize, serialized_size}, bincode::{deserialize, serialized_size},
solana_sdk::{bpf_loader_upgradeable::UpgradeableLoaderState, pubkey::Pubkey}, solana_sdk::{bpf_loader_upgradeable::UpgradeableLoaderState, pubkey::Pubkey},
}; };
@ -27,7 +28,7 @@ pub fn parse_bpf_upgradeable_loader(
BpfUpgradeableLoaderAccountType::Buffer(UiBuffer { BpfUpgradeableLoaderAccountType::Buffer(UiBuffer {
authority: authority_address.map(|pubkey| pubkey.to_string()), authority: authority_address.map(|pubkey| pubkey.to_string()),
data: UiAccountData::Binary( data: UiAccountData::Binary(
base64::encode(&data[offset..]), BASE64_STANDARD.encode(&data[offset..]),
UiAccountEncoding::Base64, UiAccountEncoding::Base64,
), ),
}) })
@ -51,7 +52,7 @@ pub fn parse_bpf_upgradeable_loader(
slot, slot,
authority: upgrade_authority_address.map(|pubkey| pubkey.to_string()), authority: upgrade_authority_address.map(|pubkey| pubkey.to_string()),
data: UiAccountData::Binary( data: UiAccountData::Binary(
base64::encode(&data[offset..]), BASE64_STANDARD.encode(&data[offset..]),
UiAccountEncoding::Base64, UiAccountEncoding::Base64,
), ),
}) })
@ -115,7 +116,10 @@ mod test {
parse_bpf_upgradeable_loader(&account_data).unwrap(), parse_bpf_upgradeable_loader(&account_data).unwrap(),
BpfUpgradeableLoaderAccountType::Buffer(UiBuffer { BpfUpgradeableLoaderAccountType::Buffer(UiBuffer {
authority: Some(authority.to_string()), authority: Some(authority.to_string()),
data: UiAccountData::Binary(base64::encode(&program), UiAccountEncoding::Base64), data: UiAccountData::Binary(
BASE64_STANDARD.encode(&program),
UiAccountEncoding::Base64
),
}) })
); );
@ -130,7 +134,10 @@ mod test {
parse_bpf_upgradeable_loader(&account_data).unwrap(), parse_bpf_upgradeable_loader(&account_data).unwrap(),
BpfUpgradeableLoaderAccountType::Buffer(UiBuffer { BpfUpgradeableLoaderAccountType::Buffer(UiBuffer {
authority: None, authority: None,
data: UiAccountData::Binary(base64::encode(&program), UiAccountEncoding::Base64), data: UiAccountData::Binary(
BASE64_STANDARD.encode(&program),
UiAccountEncoding::Base64
),
}) })
); );
@ -159,7 +166,10 @@ mod test {
BpfUpgradeableLoaderAccountType::ProgramData(UiProgramData { BpfUpgradeableLoaderAccountType::ProgramData(UiProgramData {
slot, slot,
authority: Some(authority.to_string()), authority: Some(authority.to_string()),
data: UiAccountData::Binary(base64::encode(&program), UiAccountEncoding::Base64), data: UiAccountData::Binary(
BASE64_STANDARD.encode(&program),
UiAccountEncoding::Base64
),
}) })
); );
@ -174,7 +184,10 @@ mod test {
BpfUpgradeableLoaderAccountType::ProgramData(UiProgramData { BpfUpgradeableLoaderAccountType::ProgramData(UiProgramData {
slot, slot,
authority: None, authority: None,
data: UiAccountData::Binary(base64::encode(&program), UiAccountEncoding::Base64), data: UiAccountData::Binary(
BASE64_STANDARD.encode(&program),
UiAccountEncoding::Base64
),
}) })
); );
} }

View File

@ -9,6 +9,7 @@ use {
}, },
QuietDisplay, VerboseDisplay, QuietDisplay, VerboseDisplay,
}, },
base64::{prelude::BASE64_STANDARD, Engine},
chrono::{Local, TimeZone}, chrono::{Local, TimeZone},
clap::ArgMatches, clap::ArgMatches,
console::{style, Emoji}, console::{style, Emoji},
@ -2400,7 +2401,7 @@ pub fn return_signers_data(tx: &Transaction, config: &ReturnSignersConfig) -> Cl
}); });
let message = if config.dump_transaction_message { let message = if config.dump_transaction_message {
let message_data = tx.message_data(); let message_data = tx.message_data();
Some(base64::encode(message_data)) Some(BASE64_STANDARD.encode(message_data))
} else { } else {
None None
}; };

View File

@ -1,5 +1,6 @@
use { use {
crate::cli_output::CliSignatureVerificationStatus, crate::cli_output::CliSignatureVerificationStatus,
base64::{prelude::BASE64_STANDARD, Engine},
chrono::{DateTime, Local, NaiveDateTime, SecondsFormat, TimeZone, Utc}, chrono::{DateTime, Local, NaiveDateTime, SecondsFormat, TimeZone, Utc},
console::style, console::style,
indicatif::{ProgressBar, ProgressStyle}, indicatif::{ProgressBar, ProgressStyle},
@ -602,7 +603,7 @@ fn write_return_data<W: io::Write>(
if let Some(return_data) = return_data { if let Some(return_data) = return_data {
let (data, encoding) = &return_data.data; let (data, encoding) = &return_data.data;
let raw_return_data = match encoding { 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::Error::new(
io::ErrorKind::Other, io::ErrorKind::Other,
format!("could not parse data as {encoding:?}: {err:?}"), format!("could not parse data as {encoding:?}: {err:?}"),

View File

@ -2,6 +2,7 @@
#![allow(clippy::integer_arithmetic)] #![allow(clippy::integer_arithmetic)]
use { use {
base64::{prelude::BASE64_STANDARD, Engine},
clap::{crate_description, crate_name, value_t, value_t_or_exit, App, Arg, ArgMatches}, clap::{crate_description, crate_name, value_t, value_t_or_exit, App, Arg, ArgMatches},
itertools::Itertools, itertools::Itertools,
solana_clap_utils::{ solana_clap_utils::{
@ -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); let mut account = AccountSharedData::new(account_details.balance, 0, &owner_program_id);
if account_details.data != "~" { if account_details.data != "~" {
account.set_data( account.set_data(
base64::decode(account_details.data.as_str()).map_err(|err| { BASE64_STANDARD
io::Error::new( .decode(account_details.data.as_str())
io::ErrorKind::Other, .map_err(|err| {
format!("Invalid account data: {}: {:?}", account_details.data, err), io::Error::new(
) io::ErrorKind::Other,
})?, format!("Invalid account data: {}: {:?}", account_details.data, err),
)
})?,
); );
} }
account.set_executable(account_details.executable); account.set_executable(account_details.executable);
@ -784,7 +787,7 @@ mod tests {
assert_eq!( assert_eq!(
b64_account.data, b64_account.data,
base64::encode(&genesis_config.accounts[&pubkey].data) BASE64_STANDARD.encode(&genesis_config.accounts[&pubkey].data)
); );
} }
} }
@ -868,7 +871,7 @@ mod tests {
assert_eq!( assert_eq!(
b64_account.data, b64_account.data,
base64::encode(&genesis_config.accounts[&pubkey].data), BASE64_STANDARD.encode(&genesis_config.accounts[&pubkey].data),
); );
} }
@ -952,7 +955,7 @@ mod tests {
assert_eq!( assert_eq!(
b64_account.data, b64_account.data,
base64::encode(&genesis_config.accounts[&pubkey].data), BASE64_STANDARD.encode(&genesis_config.accounts[&pubkey].data),
); );
} }
@ -977,7 +980,7 @@ mod tests {
assert_eq!( assert_eq!(
genesis_accounts2[&keypair_str].data, genesis_accounts2[&keypair_str].data,
base64::encode(&genesis_config.accounts[&pubkey].data), BASE64_STANDARD.encode(&genesis_config.accounts[&pubkey].data),
); );
}); });
} }

View File

@ -4,6 +4,7 @@
//! of program logging //! of program logging
use { use {
crate::{ic_logger_msg, log_collector::LogCollector}, crate::{ic_logger_msg, log_collector::LogCollector},
base64::{prelude::BASE64_STANDARD, Engine},
itertools::Itertools, itertools::Itertools,
solana_sdk::pubkey::Pubkey, solana_sdk::pubkey::Pubkey,
std::{cell::RefCell, rc::Rc}, std::{cell::RefCell, rc::Rc},
@ -55,7 +56,7 @@ pub fn program_data(log_collector: &Option<Rc<RefCell<LogCollector>>>, data: &[&
ic_logger_msg!( ic_logger_msg!(
log_collector, log_collector,
"Program data: {}", "Program data: {}",
data.iter().map(base64::encode).join(" ") data.iter().map(|v| BASE64_STANDARD.encode(v)).join(" ")
); );
} }
@ -78,7 +79,7 @@ pub fn program_return(
log_collector, log_collector,
"Program return: {} {}", "Program return: {} {}",
program_id, program_id,
base64::encode(data) BASE64_STANDARD.encode(data)
); );
} }

View File

@ -5,6 +5,7 @@
pub use tokio; pub use tokio;
use { use {
async_trait::async_trait, async_trait::async_trait,
base64::{prelude::BASE64_STANDARD, Engine},
chrono_humanize::{Accuracy, HumanTime, Tense}, chrono_humanize::{Accuracy, HumanTime, Tense},
log::*, log::*,
solana_banks_client::start_client, solana_banks_client::start_client,
@ -562,7 +563,8 @@ impl ProgramTest {
address, address,
Account { Account {
lamports, lamports,
data: base64::decode(data_base64) data: BASE64_STANDARD
.decode(data_base64)
.unwrap_or_else(|err| panic!("Failed to base64 decode: {err}")), .unwrap_or_else(|err| panic!("Failed to base64 decode: {err}")),
owner, owner,
executable: false, executable: false,

View File

@ -4499,7 +4499,7 @@ name = "solana-account-decoder"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"bs58", "bs58",
"bv", "bv",
@ -4680,7 +4680,7 @@ name = "solana-cli-output"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"base64 0.13.1", "base64 0.21.0",
"chrono", "chrono",
"clap 2.33.3", "clap 2.33.3",
"console", "console",
@ -4774,7 +4774,7 @@ dependencies = [
name = "solana-core" name = "solana-core"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"bs58", "bs58",
"chrono", "chrono",
@ -5310,7 +5310,7 @@ dependencies = [
"ark-ff 0.4.2", "ark-ff 0.4.2",
"ark-serialize 0.4.2", "ark-serialize 0.4.2",
"array-bytes", "array-bytes",
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"bitflags", "bitflags",
"blake3", "blake3",
@ -5358,7 +5358,7 @@ dependencies = [
name = "solana-program-runtime" name = "solana-program-runtime"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"eager", "eager",
"enum-iterator", "enum-iterator",
@ -5386,7 +5386,7 @@ version = "1.16.0"
dependencies = [ dependencies = [
"assert_matches", "assert_matches",
"async-trait", "async-trait",
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"chrono-humanize", "chrono-humanize",
"crossbeam-channel", "crossbeam-channel",
@ -5483,7 +5483,7 @@ dependencies = [
name = "solana-rpc" name = "solana-rpc"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"bs58", "bs58",
"crossbeam-channel", "crossbeam-channel",
@ -5537,7 +5537,7 @@ name = "solana-rpc-client"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"bs58", "bs58",
"indicatif", "indicatif",
@ -5560,7 +5560,7 @@ dependencies = [
name = "solana-rpc-client-api" name = "solana-rpc-client-api"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"base64 0.13.1", "base64 0.21.0",
"bs58", "bs58",
"jsonrpc-core", "jsonrpc-core",
"reqwest", "reqwest",
@ -6098,7 +6098,7 @@ name = "solana-sdk"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"assert_matches", "assert_matches",
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"bitflags", "bitflags",
"borsh", "borsh",
@ -6304,7 +6304,7 @@ dependencies = [
name = "solana-test-validator" name = "solana-test-validator"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"crossbeam-channel", "crossbeam-channel",
"log", "log",
@ -6370,7 +6370,7 @@ name = "solana-transaction-status"
version = "1.16.0" version = "1.16.0"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"borsh", "borsh",
"bs58", "bs58",
@ -6547,7 +6547,7 @@ version = "1.16.0"
dependencies = [ dependencies = [
"aes-gcm-siv", "aes-gcm-siv",
"arrayref", "arrayref",
"base64 0.13.1", "base64 0.21.0",
"bincode", "bincode",
"bytemuck", "bytemuck",
"byteorder 1.4.3", "byteorder 1.4.3",

View File

@ -3,6 +3,7 @@
use { use {
crate::rpc_sender::*, crate::rpc_sender::*,
async_trait::async_trait, async_trait::async_trait,
base64::{prelude::BASE64_STANDARD, Engine},
serde_json::{json, Number, Value}, serde_json::{json, Number, Value},
solana_account_decoder::{UiAccount, UiAccountEncoding}, solana_account_decoder::{UiAccount, UiAccountEncoding},
solana_rpc_client_api::{ solana_rpc_client_api::{
@ -335,7 +336,7 @@ impl RpcSender for MockSender {
Signature::new(&[8; 64]).to_string() Signature::new(&[8; 64]).to_string()
} else { } else {
let tx_str = params.as_array().unwrap()[0].as_str().unwrap().to_string(); let tx_str = params.as_array().unwrap()[0].as_str().unwrap().to_string();
let data = base64::decode(tx_str).unwrap(); let data = BASE64_STANDARD.decode(tx_str).unwrap();
let tx: Transaction = bincode::deserialize(&data).unwrap(); let tx: Transaction = bincode::deserialize(&data).unwrap();
tx.signatures[0].to_string() tx.signatures[0].to_string()
}; };

View File

@ -24,6 +24,7 @@ use {
}, },
rpc_sender::*, rpc_sender::*,
}, },
base64::{prelude::BASE64_STANDARD, Engine},
bincode::serialize, bincode::serialize,
log::*, log::*,
serde_json::{json, Value}, serde_json::{json, Value},
@ -5387,7 +5388,7 @@ where
.map_err(|e| ClientErrorKind::Custom(format!("Serialization failed: {e}")))?; .map_err(|e| ClientErrorKind::Custom(format!("Serialization failed: {e}")))?;
let encoded = match encoding { let encoded = match encoding {
UiTransactionEncoding::Base58 => bs58::encode(serialized).into_string(), UiTransactionEncoding::Base58 => bs58::encode(serialized).into_string(),
UiTransactionEncoding::Base64 => base64::encode(serialized), UiTransactionEncoding::Base64 => BASE64_STANDARD.encode(serialized),
_ => { _ => {
return Err(ClientErrorKind::Custom(format!( return Err(ClientErrorKind::Custom(format!(
"unsupported encoding: {encoding}. Supported encodings: base58, base64" "unsupported encoding: {encoding}. Supported encodings: base58, base64"

View File

@ -5,6 +5,7 @@ use {
max_slots::MaxSlots, optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, max_slots::MaxSlots, optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank,
parsed_token_accounts::*, rpc_cache::LargestAccountsCache, rpc_health::*, parsed_token_accounts::*, rpc_cache::LargestAccountsCache, rpc_health::*,
}, },
base64::{prelude::BASE64_STANDARD, Engine},
bincode::{config::Options, serialize}, bincode::{config::Options, serialize},
crossbeam_channel::{unbounded, Receiver, Sender}, crossbeam_channel::{unbounded, Receiver, Sender},
jsonrpc_core::{futures::future, types::error, BoxFuture, Error, Metadata, Result}, jsonrpc_core::{futures::future, types::error, BoxFuture, Error, Metadata, Result},
@ -4484,7 +4485,8 @@ where
PACKET_DATA_SIZE, PACKET_DATA_SIZE,
))); )));
} }
base64::decode(encoded) BASE64_STANDARD
.decode(encoded)
.map_err(|e| Error::invalid_params(format!("invalid base64 encoding: {e:?}")))? .map_err(|e| Error::invalid_params(format!("invalid base64 encoding: {e:?}")))?
} }
}; };
@ -5537,7 +5539,7 @@ pub mod tests {
Some(json!([address, {"encoding": "base64"}])), Some(json!([address, {"encoding": "base64"}])),
); );
let result: Value = parse_success_result(rpc.handle_request_sync(request)); let result: Value = parse_success_result(rpc.handle_request_sync(request));
let expected = json!([base64::encode(&data), "base64"]); let expected = json!([BASE64_STANDARD.encode(&data), "base64"]);
assert_eq!(result["value"]["data"], expected); assert_eq!(result["value"]["data"], expected);
assert_eq!(result["value"]["space"], 5); assert_eq!(result["value"]["space"], 5);
@ -5546,7 +5548,7 @@ pub mod tests {
Some(json!([address, {"encoding": "base64", "dataSlice": {"length": 2, "offset": 1}}])), Some(json!([address, {"encoding": "base64", "dataSlice": {"length": 2, "offset": 1}}])),
); );
let result: Value = parse_success_result(rpc.handle_request_sync(request)); let result: Value = parse_success_result(rpc.handle_request_sync(request));
let expected = json!([base64::encode(&data[1..3]), "base64"]); let expected = json!([BASE64_STANDARD.encode(&data[1..3]), "base64"]);
assert_eq!(result["value"]["data"], expected); assert_eq!(result["value"]["data"], expected);
assert_eq!(result["value"]["space"], 5); assert_eq!(result["value"]["space"], 5);
@ -5566,7 +5568,7 @@ pub mod tests {
), ),
); );
let result: Value = parse_success_result(rpc.handle_request_sync(request)); let result: Value = parse_success_result(rpc.handle_request_sync(request));
let expected = json!([base64::encode(&data[1..3]), "base64"]); let expected = json!([BASE64_STANDARD.encode(&data[1..3]), "base64"]);
assert_eq!( assert_eq!(
result["value"]["data"], expected, result["value"]["data"], expected,
"should use data slice if parsing fails" "should use data slice if parsing fails"
@ -5608,7 +5610,7 @@ pub mod tests {
{ {
"owner": "11111111111111111111111111111111", "owner": "11111111111111111111111111111111",
"lamports": 42, "lamports": 42,
"data": [base64::encode(&data), "base64"], "data": [BASE64_STANDARD.encode(&data), "base64"],
"executable": false, "executable": false,
"rentEpoch": 0, "rentEpoch": 0,
"space": 5, "space": 5,
@ -5675,7 +5677,7 @@ pub mod tests {
{ {
"owner": "11111111111111111111111111111111", "owner": "11111111111111111111111111111111",
"lamports": 42, "lamports": 42,
"data": [base64::encode(&data[1..3]), "base64"], "data": [BASE64_STANDARD.encode(&data[1..3]), "base64"],
"executable": false, "executable": false,
"rentEpoch": 0, "rentEpoch": 0,
"space": 5, "space": 5,
@ -8429,7 +8431,7 @@ pub mod tests {
let ff_tx = vec![0xffu8; PACKET_DATA_SIZE]; let ff_tx = vec![0xffu8; PACKET_DATA_SIZE];
let tx58 = bs58::encode(&ff_tx).into_string(); let tx58 = bs58::encode(&ff_tx).into_string();
assert_eq!(tx58.len(), MAX_BASE58_SIZE); assert_eq!(tx58.len(), MAX_BASE58_SIZE);
let tx64 = base64::encode(&ff_tx); let tx64 = BASE64_STANDARD.encode(&ff_tx);
assert_eq!(tx64.len(), MAX_BASE64_SIZE); assert_eq!(tx64.len(), MAX_BASE64_SIZE);
} }
@ -8449,7 +8451,7 @@ pub mod tests {
) )
)); ));
let tx64 = base64::encode(&tx_ser); let tx64 = BASE64_STANDARD.encode(&tx_ser);
let tx64_len = tx64.len(); let tx64_len = tx64.len();
assert_eq!( assert_eq!(
decode_and_deserialize::<Transaction>(tx64, TransactionBinaryEncoding::Base64) decode_and_deserialize::<Transaction>(tx64, TransactionBinaryEncoding::Base64)
@ -8470,7 +8472,7 @@ pub mod tests {
)) ))
); );
let tx64 = base64::encode(&tx_ser); let tx64 = BASE64_STANDARD.encode(&tx_ser);
assert_eq!( assert_eq!(
decode_and_deserialize::<Transaction>(tx64, TransactionBinaryEncoding::Base64) decode_and_deserialize::<Transaction>(tx64, TransactionBinaryEncoding::Base64)
.unwrap_err(), .unwrap_err(),
@ -8480,7 +8482,7 @@ pub mod tests {
); );
let tx_ser = vec![0xffu8; PACKET_DATA_SIZE - 2]; let tx_ser = vec![0xffu8; PACKET_DATA_SIZE - 2];
let mut tx64 = base64::encode(&tx_ser); let mut tx64 = BASE64_STANDARD.encode(&tx_ser);
assert_eq!( assert_eq!(
decode_and_deserialize::<Transaction>(tx64.clone(), TransactionBinaryEncoding::Base64) decode_and_deserialize::<Transaction>(tx64.clone(), TransactionBinaryEncoding::Base64)
.unwrap_err(), .unwrap_err(),
@ -8606,7 +8608,9 @@ pub mod tests {
let request = create_test_request( let request = create_test_request(
"getFeeForMessage", "getFeeForMessage",
Some(json!([base64::encode(serialize(&legacy_msg).unwrap())])), Some(json!([
BASE64_STANDARD.encode(serialize(&legacy_msg).unwrap())
])),
); );
let response: RpcResponse<u64> = parse_success_result(rpc.handle_request_sync(request)); let response: RpcResponse<u64> = parse_success_result(rpc.handle_request_sync(request));
assert_eq!(response.value, TEST_SIGNATURE_FEE); assert_eq!(response.value, TEST_SIGNATURE_FEE);
@ -8625,7 +8629,7 @@ pub mod tests {
let request = create_test_request( let request = create_test_request(
"getFeeForMessage", "getFeeForMessage",
Some(json!([base64::encode(serialize(&v0_msg).unwrap())])), Some(json!([BASE64_STANDARD.encode(serialize(&v0_msg).unwrap())])),
); );
let response: RpcResponse<u64> = parse_success_result(rpc.handle_request_sync(request)); let response: RpcResponse<u64> = parse_success_result(rpc.handle_request_sync(request));
assert_eq!(response.value, TEST_SIGNATURE_FEE); assert_eq!(response.value, TEST_SIGNATURE_FEE);

View File

@ -607,6 +607,7 @@ mod tests {
optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, rpc_pubsub_service, optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, rpc_pubsub_service,
rpc_subscriptions::RpcSubscriptions, rpc_subscriptions::RpcSubscriptions,
}, },
base64::{prelude::BASE64_STANDARD, Engine},
jsonrpc_core::{IoHandler, Response}, jsonrpc_core::{IoHandler, Response},
serial_test::serial, serial_test::serial,
solana_account_decoder::{parse_account_data::parse_account_data, UiAccountEncoding}, solana_account_decoder::{parse_account_data::parse_account_data, UiAccountEncoding},
@ -941,7 +942,7 @@ mod tests {
"value": { "value": {
"owner": stake_program_id.to_string(), "owner": stake_program_id.to_string(),
"lamports": balance, "lamports": balance,
"data": [base64::encode(expected_data), encoding], "data": [BASE64_STANDARD.encode(expected_data), encoding],
"executable": false, "executable": false,
"rentEpoch": u64::MAX, "rentEpoch": u64::MAX,
"space": expected_data.len(), "space": expected_data.len(),

View File

@ -7,6 +7,7 @@ use {
account_info::AccountInfo, entrypoint::ProgramResult, instruction::Instruction, account_info::AccountInfo, entrypoint::ProgramResult, instruction::Instruction,
program_error::UNSUPPORTED_SYSVAR, pubkey::Pubkey, program_error::UNSUPPORTED_SYSVAR, pubkey::Pubkey,
}, },
base64::{prelude::BASE64_STANDARD, Engine},
itertools::Itertools, itertools::Itertools,
std::sync::{Arc, RwLock}, std::sync::{Arc, RwLock},
}; };
@ -89,7 +90,10 @@ pub trait SyscallStubs: Sync + Send {
} }
fn sol_set_return_data(&self, _data: &[u8]) {} fn sol_set_return_data(&self, _data: &[u8]) {}
fn sol_log_data(&self, fields: &[&[u8]]) { fn sol_log_data(&self, fields: &[&[u8]]) {
println!("data: {}", fields.iter().map(base64::encode).join(" ")); println!(
"data: {}",
fields.iter().map(|v| BASE64_STANDARD.encode(v)).join(" ")
);
} }
fn sol_get_processed_sibling_instruction(&self, _index: usize) -> Option<Instruction> { fn sol_get_processed_sibling_instruction(&self, _index: usize) -> Option<Instruction> {
None None

View File

@ -1,5 +1,6 @@
#![allow(clippy::integer_arithmetic)] #![allow(clippy::integer_arithmetic)]
use { use {
base64::{prelude::BASE64_STANDARD, Engine},
crossbeam_channel::Receiver, crossbeam_channel::Receiver,
log::*, log::*,
solana_cli_output::CliAccount, solana_cli_output::CliAccount,
@ -470,7 +471,8 @@ impl TestValidatorGenesis {
address, address,
AccountSharedData::from(Account { AccountSharedData::from(Account {
lamports, lamports,
data: base64::decode(data_base64) data: BASE64_STANDARD
.decode(data_base64)
.unwrap_or_else(|err| panic!("Failed to base64 decode: {err}")), .unwrap_or_else(|err| panic!("Failed to base64 decode: {err}")),
owner, owner,
executable: false, executable: false,

View File

@ -7,6 +7,7 @@ use {
parse_accounts::{parse_legacy_message_accounts, parse_v0_message_accounts, ParsedAccount}, parse_accounts::{parse_legacy_message_accounts, parse_v0_message_accounts, ParsedAccount},
parse_instruction::{parse, ParsedInstruction}, parse_instruction::{parse, ParsedInstruction},
}, },
base64::{prelude::BASE64_STANDARD, Engine},
solana_account_decoder::parse_token::UiTokenAmount, solana_account_decoder::parse_token::UiTokenAmount,
solana_sdk::{ solana_sdk::{
clock::{Slot, UnixTimestamp}, clock::{Slot, UnixTimestamp},
@ -1048,7 +1049,7 @@ impl EncodableWithMeta for VersionedTransaction {
TransactionBinaryEncoding::Base58, TransactionBinaryEncoding::Base58,
), ),
UiTransactionEncoding::Base64 => EncodedTransaction::Binary( UiTransactionEncoding::Base64 => EncodedTransaction::Binary(
base64::encode(bincode::serialize(self).unwrap()), BASE64_STANDARD.encode(bincode::serialize(self).unwrap()),
TransactionBinaryEncoding::Base64, TransactionBinaryEncoding::Base64,
), ),
UiTransactionEncoding::Json => self.json_encode(), UiTransactionEncoding::Json => self.json_encode(),
@ -1088,7 +1089,7 @@ impl Encodable for Transaction {
TransactionBinaryEncoding::Base58, TransactionBinaryEncoding::Base58,
), ),
UiTransactionEncoding::Base64 => EncodedTransaction::Binary( UiTransactionEncoding::Base64 => EncodedTransaction::Binary(
base64::encode(bincode::serialize(self).unwrap()), BASE64_STANDARD.encode(bincode::serialize(self).unwrap()),
TransactionBinaryEncoding::Base64, TransactionBinaryEncoding::Base64,
), ),
UiTransactionEncoding::Json | UiTransactionEncoding::JsonParsed => { UiTransactionEncoding::Json | UiTransactionEncoding::JsonParsed => {
@ -1124,7 +1125,8 @@ impl EncodedTransaction {
.into_vec() .into_vec()
.ok() .ok()
.and_then(|bytes| bincode::deserialize(&bytes).ok()), .and_then(|bytes| bincode::deserialize(&bytes).ok()),
TransactionBinaryEncoding::Base64 => base64::decode(blob) TransactionBinaryEncoding::Base64 => BASE64_STANDARD
.decode(blob)
.ok() .ok()
.and_then(|bytes| bincode::deserialize(&bytes).ok()), .and_then(|bytes| bincode::deserialize(&bytes).ok()),
}; };
@ -1308,7 +1310,7 @@ impl From<TransactionReturnData> for UiTransactionReturnData {
Self { Self {
program_id: return_data.program_id.to_string(), program_id: return_data.program_id.to_string(),
data: ( data: (
base64::encode(return_data.data), BASE64_STANDARD.encode(return_data.data),
UiReturnDataEncoding::Base64, UiReturnDataEncoding::Base64,
), ),
} }

View File

@ -2,6 +2,7 @@ use {
crate::parse_instruction::{ crate::parse_instruction::{
check_num_accounts, ParsableProgram, ParseInstructionError, ParsedInstructionEnum, check_num_accounts, ParsableProgram, ParseInstructionError, ParsedInstructionEnum,
}, },
base64::{prelude::BASE64_STANDARD, Engine},
bincode::deserialize, bincode::deserialize,
serde_json::json, serde_json::json,
solana_sdk::{ solana_sdk::{
@ -28,7 +29,7 @@ pub fn parse_bpf_loader(
instruction_type: "write".to_string(), instruction_type: "write".to_string(),
info: json!({ info: json!({
"offset": offset, "offset": offset,
"bytes": base64::encode(bytes), "bytes": BASE64_STANDARD.encode(bytes),
"account": account_keys[instruction.accounts[0] as usize].to_string(), "account": account_keys[instruction.accounts[0] as usize].to_string(),
}), }),
}) })
@ -86,7 +87,7 @@ pub fn parse_bpf_upgradeable_loader(
instruction_type: "write".to_string(), instruction_type: "write".to_string(),
info: json!({ info: json!({
"offset": offset, "offset": offset,
"bytes": base64::encode(bytes), "bytes": BASE64_STANDARD.encode(bytes),
"account": account_keys[instruction.accounts[0] as usize].to_string(), "account": account_keys[instruction.accounts[0] as usize].to_string(),
"authority": account_keys[instruction.accounts[1] as usize].to_string(), "authority": account_keys[instruction.accounts[1] as usize].to_string(),
}), }),
@ -241,7 +242,7 @@ mod test {
instruction_type: "write".to_string(), instruction_type: "write".to_string(),
info: json!({ info: json!({
"offset": offset, "offset": offset,
"bytes": base64::encode(&bytes), "bytes": BASE64_STANDARD.encode(&bytes),
"account": account_pubkey.to_string(), "account": account_pubkey.to_string(),
}), }),
} }
@ -377,7 +378,7 @@ mod test {
instruction_type: "write".to_string(), instruction_type: "write".to_string(),
info: json!({ info: json!({
"offset": offset, "offset": offset,
"bytes": base64::encode(&bytes), "bytes": BASE64_STANDARD.encode(&bytes),
"account": buffer_address.to_string(), "account": buffer_address.to_string(),
"authority": authority_address.to_string(), "authority": authority_address.to_string(),
}), }),

View File

@ -12,6 +12,7 @@ use {
}; };
use { use {
arrayref::{array_ref, array_refs}, arrayref::{array_ref, array_refs},
base64::{prelude::BASE64_STANDARD, Engine},
sha3::{Digest, Sha3_512}, sha3::{Digest, Sha3_512},
solana_sdk::{ solana_sdk::{
derivation_path::DerivationPath, derivation_path::DerivationPath,
@ -198,7 +199,7 @@ impl AeCiphertext {
impl fmt::Display for AeCiphertext { impl fmt::Display for AeCiphertext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", base64::encode(self.to_bytes())) write!(f, "{}", BASE64_STANDARD.encode(self.to_bytes()))
} }
} }

View File

@ -18,6 +18,7 @@ use {
discrete_log::DiscreteLog, discrete_log::DiscreteLog,
pedersen::{Pedersen, PedersenCommitment, PedersenOpening, G, H}, pedersen::{Pedersen, PedersenCommitment, PedersenOpening, G, H},
}, },
base64::{prelude::BASE64_STANDARD, Engine},
core::ops::{Add, Mul, Sub}, core::ops::{Add, Mul, Sub},
curve25519_dalek::{ curve25519_dalek::{
ristretto::{CompressedRistretto, RistrettoPoint}, ristretto::{CompressedRistretto, RistrettoPoint},
@ -329,7 +330,7 @@ impl ElGamalPubkey {
impl fmt::Display for ElGamalPubkey { impl fmt::Display for ElGamalPubkey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", base64::encode(self.to_bytes())) write!(f, "{}", BASE64_STANDARD.encode(self.to_bytes()))
} }
} }
@ -496,7 +497,7 @@ impl ElGamalCiphertext {
impl fmt::Display for ElGamalCiphertext { impl fmt::Display for ElGamalCiphertext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", base64::encode(self.to_bytes())) write!(f, "{}", BASE64_STANDARD.encode(self.to_bytes()))
} }
} }

View File

@ -1,6 +1,7 @@
pub use bytemuck::{Pod, Zeroable}; pub use bytemuck::{Pod, Zeroable};
use { use {
crate::zk_token_proof_instruction::ProofType, crate::zk_token_proof_instruction::ProofType,
base64::{prelude::BASE64_STANDARD, Engine},
num_traits::{FromPrimitive, ToPrimitive}, num_traits::{FromPrimitive, ToPrimitive},
solana_program::instruction::InstructionError, solana_program::instruction::InstructionError,
std::fmt, std::fmt,
@ -66,7 +67,7 @@ impl fmt::Debug for ElGamalCiphertext {
impl fmt::Display for ElGamalCiphertext { impl fmt::Display for ElGamalCiphertext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", base64::encode(self.0)) write!(f, "{}", BASE64_STANDARD.encode(self.0))
} }
} }
@ -88,7 +89,7 @@ impl fmt::Debug for ElGamalPubkey {
impl fmt::Display for ElGamalPubkey { impl fmt::Display for ElGamalPubkey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", base64::encode(self.0)) write!(f, "{}", BASE64_STANDARD.encode(self.0))
} }
} }
@ -220,7 +221,7 @@ impl fmt::Debug for AeCiphertext {
impl fmt::Display for AeCiphertext { impl fmt::Display for AeCiphertext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", base64::encode(self.0)) write!(f, "{}", BASE64_STANDARD.encode(self.0))
} }
} }