diff --git a/Cargo.lock b/Cargo.lock index 9433aafaff..f5f7820ca7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4943,7 +4943,7 @@ name = "solana-account-decoder" version = "1.16.0" dependencies = [ "Inflector", - "base64 0.13.1", + "base64 0.21.0", "bincode", "bs58", "bv", @@ -5372,7 +5372,7 @@ name = "solana-cli-output" version = "1.16.0" dependencies = [ "Inflector", - "base64 0.13.1", + "base64 0.21.0", "chrono", "clap 2.33.3", "console", @@ -5502,7 +5502,7 @@ dependencies = [ name = "solana-core" version = "1.16.0" dependencies = [ - "base64 0.13.1", + "base64 0.21.0", "bincode", "bs58", "chrono", @@ -5760,7 +5760,7 @@ dependencies = [ name = "solana-genesis" version = "1.16.0" dependencies = [ - "base64 0.13.1", + "base64 0.21.0", "bincode", "clap 2.33.3", "itertools", @@ -6338,7 +6338,7 @@ dependencies = [ "ark-serialize 0.4.2", "array-bytes", "assert_matches", - "base64 0.13.1", + "base64 0.21.0", "bincode", "bitflags", "blake3", @@ -6388,7 +6388,7 @@ dependencies = [ name = "solana-program-runtime" version = "1.16.0" dependencies = [ - "base64 0.13.1", + "base64 0.21.0", "bincode", "eager", "enum-iterator", @@ -6417,7 +6417,7 @@ version = "1.16.0" dependencies = [ "assert_matches", "async-trait", - "base64 0.13.1", + "base64 0.21.0", "bincode", "chrono-humanize", "crossbeam-channel", @@ -6520,7 +6520,7 @@ dependencies = [ name = "solana-rpc" version = "1.16.0" dependencies = [ - "base64 0.13.1", + "base64 0.21.0", "bincode", "bs58", "crossbeam-channel", @@ -6579,7 +6579,7 @@ version = "1.16.0" dependencies = [ "assert_matches", "async-trait", - "base64 0.13.1", + "base64 0.21.0", "bincode", "bs58", "crossbeam-channel", @@ -6606,7 +6606,7 @@ dependencies = [ name = "solana-rpc-client-api" version = "1.16.0" dependencies = [ - "base64 0.13.1", + "base64 0.21.0", "bs58", "jsonrpc-core", "reqwest", @@ -6799,7 +6799,7 @@ version = "1.16.0" dependencies = [ "anyhow", "assert_matches", - "base64 0.13.1", + "base64 0.21.0", "bincode", "bitflags", "borsh", @@ -7046,7 +7046,7 @@ dependencies = [ name = "solana-test-validator" version = "1.16.0" dependencies = [ - "base64 0.13.1", + "base64 0.21.0", "bincode", "crossbeam-channel", "log", @@ -7173,7 +7173,7 @@ name = "solana-transaction-status" version = "1.16.0" dependencies = [ "Inflector", - "base64 0.13.1", + "base64 0.21.0", "bincode", "borsh", "bs58", @@ -7392,7 +7392,7 @@ version = "1.16.0" dependencies = [ "aes-gcm-siv", "arrayref", - "base64 0.13.1", + "base64 0.21.0", "bincode", "bytemuck", "byteorder", diff --git a/Cargo.toml b/Cargo.toml index 5d7c84b1aa..4ecc4db115 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/account-decoder/src/lib.rs b/account-decoder/src/lib.rs index 0fb64d947a..b0f52c8d01 100644 --- a/account-decoder/src/lib.rs +++ b/account-decoder/src/lib.rs @@ -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, @@ -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 => { @@ -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, ), } @@ -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, ) } @@ -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, }, }?; diff --git a/account-decoder/src/parse_bpf_loader.rs b/account-decoder/src/parse_bpf_loader.rs index 44be1c1912..df9208bc29 100644 --- a/account-decoder/src/parse_bpf_loader.rs +++ b/account-decoder/src/parse_bpf_loader.rs @@ -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}, }; @@ -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, ), }) @@ -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, ), }) @@ -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 + ), }) ); @@ -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 + ), }) ); @@ -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 + ), }) ); @@ -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 + ), }) ); } diff --git a/cli-output/src/cli_output.rs b/cli-output/src/cli_output.rs index bd8beeb0ac..cf7fe3d274 100644 --- a/cli-output/src/cli_output.rs +++ b/cli-output/src/cli_output.rs @@ -9,6 +9,7 @@ use { }, QuietDisplay, VerboseDisplay, }, + base64::{prelude::BASE64_STANDARD, Engine}, chrono::{Local, TimeZone}, clap::ArgMatches, 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_data = tx.message_data(); - Some(base64::encode(message_data)) + Some(BASE64_STANDARD.encode(message_data)) } else { None }; diff --git a/cli-output/src/display.rs b/cli-output/src/display.rs index 66aa116d21..d2fa3947cb 100644 --- a/cli-output/src/display.rs +++ b/cli-output/src/display.rs @@ -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}, @@ -602,7 +603,7 @@ fn write_return_data( 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:?}"), diff --git a/genesis/src/main.rs b/genesis/src/main.rs index 043fd0e291..fb6b3de347 100644 --- a/genesis/src/main.rs +++ b/genesis/src/main.rs @@ -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::{ @@ -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); @@ -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) ); } } @@ -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), ); } @@ -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), ); } @@ -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), ); }); } diff --git a/program-runtime/src/stable_log.rs b/program-runtime/src/stable_log.rs index 7633e640df..9ba7542e9c 100644 --- a/program-runtime/src/stable_log.rs +++ b/program-runtime/src/stable_log.rs @@ -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}, @@ -55,7 +56,7 @@ pub fn program_data(log_collector: &Option>>, data: &[& ic_logger_msg!( log_collector, "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, "Program return: {} {}", program_id, - base64::encode(data) + BASE64_STANDARD.encode(data) ); } diff --git a/program-test/src/lib.rs b/program-test/src/lib.rs index 43d8dc7e71..9a610a11b4 100644 --- a/program-test/src/lib.rs +++ b/program-test/src/lib.rs @@ -5,6 +5,7 @@ pub use tokio; use { async_trait::async_trait, + base64::{prelude::BASE64_STANDARD, Engine}, chrono_humanize::{Accuracy, HumanTime, Tense}, log::*, solana_banks_client::start_client, @@ -562,7 +563,8 @@ impl ProgramTest { address, Account { lamports, - data: base64::decode(data_base64) + data: BASE64_STANDARD + .decode(data_base64) .unwrap_or_else(|err| panic!("Failed to base64 decode: {err}")), owner, executable: false, diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index ba00629054..4a2941a974 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -4499,7 +4499,7 @@ name = "solana-account-decoder" version = "1.16.0" dependencies = [ "Inflector", - "base64 0.13.1", + "base64 0.21.0", "bincode", "bs58", "bv", @@ -4680,7 +4680,7 @@ name = "solana-cli-output" version = "1.16.0" dependencies = [ "Inflector", - "base64 0.13.1", + "base64 0.21.0", "chrono", "clap 2.33.3", "console", @@ -4774,7 +4774,7 @@ dependencies = [ name = "solana-core" version = "1.16.0" dependencies = [ - "base64 0.13.1", + "base64 0.21.0", "bincode", "bs58", "chrono", @@ -5310,7 +5310,7 @@ dependencies = [ "ark-ff 0.4.2", "ark-serialize 0.4.2", "array-bytes", - "base64 0.13.1", + "base64 0.21.0", "bincode", "bitflags", "blake3", @@ -5358,7 +5358,7 @@ dependencies = [ name = "solana-program-runtime" version = "1.16.0" dependencies = [ - "base64 0.13.1", + "base64 0.21.0", "bincode", "eager", "enum-iterator", @@ -5386,7 +5386,7 @@ version = "1.16.0" dependencies = [ "assert_matches", "async-trait", - "base64 0.13.1", + "base64 0.21.0", "bincode", "chrono-humanize", "crossbeam-channel", @@ -5483,7 +5483,7 @@ dependencies = [ name = "solana-rpc" version = "1.16.0" dependencies = [ - "base64 0.13.1", + "base64 0.21.0", "bincode", "bs58", "crossbeam-channel", @@ -5537,7 +5537,7 @@ name = "solana-rpc-client" version = "1.16.0" dependencies = [ "async-trait", - "base64 0.13.1", + "base64 0.21.0", "bincode", "bs58", "indicatif", @@ -5560,7 +5560,7 @@ dependencies = [ name = "solana-rpc-client-api" version = "1.16.0" dependencies = [ - "base64 0.13.1", + "base64 0.21.0", "bs58", "jsonrpc-core", "reqwest", @@ -6098,7 +6098,7 @@ name = "solana-sdk" version = "1.16.0" dependencies = [ "assert_matches", - "base64 0.13.1", + "base64 0.21.0", "bincode", "bitflags", "borsh", @@ -6304,7 +6304,7 @@ dependencies = [ name = "solana-test-validator" version = "1.16.0" dependencies = [ - "base64 0.13.1", + "base64 0.21.0", "bincode", "crossbeam-channel", "log", @@ -6370,7 +6370,7 @@ name = "solana-transaction-status" version = "1.16.0" dependencies = [ "Inflector", - "base64 0.13.1", + "base64 0.21.0", "bincode", "borsh", "bs58", @@ -6547,7 +6547,7 @@ version = "1.16.0" dependencies = [ "aes-gcm-siv", "arrayref", - "base64 0.13.1", + "base64 0.21.0", "bincode", "bytemuck", "byteorder 1.4.3", diff --git a/rpc-client/src/mock_sender.rs b/rpc-client/src/mock_sender.rs index 5664c1be3f..cee12e8689 100644 --- a/rpc-client/src/mock_sender.rs +++ b/rpc-client/src/mock_sender.rs @@ -3,6 +3,7 @@ use { crate::rpc_sender::*, async_trait::async_trait, + base64::{prelude::BASE64_STANDARD, Engine}, serde_json::{json, Number, Value}, solana_account_decoder::{UiAccount, UiAccountEncoding}, solana_rpc_client_api::{ @@ -335,7 +336,7 @@ impl RpcSender for MockSender { Signature::new(&[8; 64]).to_string() } else { let tx_str = params.as_array().unwrap()[0].as_str().unwrap().to_string(); - let data = base64::decode(tx_str).unwrap(); + let data = BASE64_STANDARD.decode(tx_str).unwrap(); let tx: Transaction = bincode::deserialize(&data).unwrap(); tx.signatures[0].to_string() }; diff --git a/rpc-client/src/nonblocking/rpc_client.rs b/rpc-client/src/nonblocking/rpc_client.rs index 4a55d1b69a..21350938a7 100644 --- a/rpc-client/src/nonblocking/rpc_client.rs +++ b/rpc-client/src/nonblocking/rpc_client.rs @@ -24,6 +24,7 @@ use { }, rpc_sender::*, }, + base64::{prelude::BASE64_STANDARD, Engine}, bincode::serialize, log::*, serde_json::{json, Value}, @@ -5387,7 +5388,7 @@ where .map_err(|e| ClientErrorKind::Custom(format!("Serialization failed: {e}")))?; let encoded = match encoding { UiTransactionEncoding::Base58 => bs58::encode(serialized).into_string(), - UiTransactionEncoding::Base64 => base64::encode(serialized), + UiTransactionEncoding::Base64 => BASE64_STANDARD.encode(serialized), _ => { return Err(ClientErrorKind::Custom(format!( "unsupported encoding: {encoding}. Supported encodings: base58, base64" diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index f555d87cbd..8854af9f93 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -5,6 +5,7 @@ use { max_slots::MaxSlots, optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, parsed_token_accounts::*, rpc_cache::LargestAccountsCache, rpc_health::*, }, + base64::{prelude::BASE64_STANDARD, Engine}, bincode::{config::Options, serialize}, crossbeam_channel::{unbounded, Receiver, Sender}, jsonrpc_core::{futures::future, types::error, BoxFuture, Error, Metadata, Result}, @@ -4484,7 +4485,8 @@ where PACKET_DATA_SIZE, ))); } - base64::decode(encoded) + BASE64_STANDARD + .decode(encoded) .map_err(|e| Error::invalid_params(format!("invalid base64 encoding: {e:?}")))? } }; @@ -5537,7 +5539,7 @@ pub mod tests { Some(json!([address, {"encoding": "base64"}])), ); 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"]["space"], 5); @@ -5546,7 +5548,7 @@ pub mod tests { Some(json!([address, {"encoding": "base64", "dataSlice": {"length": 2, "offset": 1}}])), ); 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"]["space"], 5); @@ -5566,7 +5568,7 @@ pub mod tests { ), ); 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, "should use data slice if parsing fails" @@ -5608,7 +5610,7 @@ pub mod tests { { "owner": "11111111111111111111111111111111", "lamports": 42, - "data": [base64::encode(&data), "base64"], + "data": [BASE64_STANDARD.encode(&data), "base64"], "executable": false, "rentEpoch": 0, "space": 5, @@ -5675,7 +5677,7 @@ pub mod tests { { "owner": "11111111111111111111111111111111", "lamports": 42, - "data": [base64::encode(&data[1..3]), "base64"], + "data": [BASE64_STANDARD.encode(&data[1..3]), "base64"], "executable": false, "rentEpoch": 0, "space": 5, @@ -8429,7 +8431,7 @@ pub mod tests { let ff_tx = vec![0xffu8; PACKET_DATA_SIZE]; let tx58 = bs58::encode(&ff_tx).into_string(); 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); } @@ -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(); assert_eq!( decode_and_deserialize::(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!( decode_and_deserialize::(tx64, TransactionBinaryEncoding::Base64) .unwrap_err(), @@ -8480,7 +8482,7 @@ pub mod tests { ); 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!( decode_and_deserialize::(tx64.clone(), TransactionBinaryEncoding::Base64) .unwrap_err(), @@ -8606,7 +8608,9 @@ pub mod tests { let request = create_test_request( "getFeeForMessage", - Some(json!([base64::encode(serialize(&legacy_msg).unwrap())])), + Some(json!([ + BASE64_STANDARD.encode(serialize(&legacy_msg).unwrap()) + ])), ); let response: RpcResponse = parse_success_result(rpc.handle_request_sync(request)); assert_eq!(response.value, TEST_SIGNATURE_FEE); @@ -8625,7 +8629,7 @@ pub mod tests { let request = create_test_request( "getFeeForMessage", - Some(json!([base64::encode(serialize(&v0_msg).unwrap())])), + Some(json!([BASE64_STANDARD.encode(serialize(&v0_msg).unwrap())])), ); let response: RpcResponse = parse_success_result(rpc.handle_request_sync(request)); assert_eq!(response.value, TEST_SIGNATURE_FEE); diff --git a/rpc/src/rpc_pubsub.rs b/rpc/src/rpc_pubsub.rs index 0aec5951e6..339f95d681 100644 --- a/rpc/src/rpc_pubsub.rs +++ b/rpc/src/rpc_pubsub.rs @@ -607,6 +607,7 @@ mod tests { optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, rpc_pubsub_service, rpc_subscriptions::RpcSubscriptions, }, + base64::{prelude::BASE64_STANDARD, Engine}, jsonrpc_core::{IoHandler, Response}, serial_test::serial, solana_account_decoder::{parse_account_data::parse_account_data, UiAccountEncoding}, @@ -941,7 +942,7 @@ mod tests { "value": { "owner": stake_program_id.to_string(), "lamports": balance, - "data": [base64::encode(expected_data), encoding], + "data": [BASE64_STANDARD.encode(expected_data), encoding], "executable": false, "rentEpoch": u64::MAX, "space": expected_data.len(), diff --git a/sdk/program/src/program_stubs.rs b/sdk/program/src/program_stubs.rs index 1313099786..682be12ad2 100644 --- a/sdk/program/src/program_stubs.rs +++ b/sdk/program/src/program_stubs.rs @@ -7,6 +7,7 @@ use { account_info::AccountInfo, entrypoint::ProgramResult, instruction::Instruction, program_error::UNSUPPORTED_SYSVAR, pubkey::Pubkey, }, + base64::{prelude::BASE64_STANDARD, Engine}, itertools::Itertools, std::sync::{Arc, RwLock}, }; @@ -89,7 +90,10 @@ pub trait SyscallStubs: Sync + Send { } fn sol_set_return_data(&self, _data: &[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 { None diff --git a/test-validator/src/lib.rs b/test-validator/src/lib.rs index 982ab859ae..9a54d855b7 100644 --- a/test-validator/src/lib.rs +++ b/test-validator/src/lib.rs @@ -1,5 +1,6 @@ #![allow(clippy::integer_arithmetic)] use { + base64::{prelude::BASE64_STANDARD, Engine}, crossbeam_channel::Receiver, log::*, solana_cli_output::CliAccount, @@ -470,7 +471,8 @@ impl TestValidatorGenesis { address, AccountSharedData::from(Account { lamports, - data: base64::decode(data_base64) + data: BASE64_STANDARD + .decode(data_base64) .unwrap_or_else(|err| panic!("Failed to base64 decode: {err}")), owner, executable: false, diff --git a/transaction-status/src/lib.rs b/transaction-status/src/lib.rs index 94f6bec3c6..c975fef6de 100644 --- a/transaction-status/src/lib.rs +++ b/transaction-status/src/lib.rs @@ -7,6 +7,7 @@ use { parse_accounts::{parse_legacy_message_accounts, parse_v0_message_accounts, ParsedAccount}, parse_instruction::{parse, ParsedInstruction}, }, + base64::{prelude::BASE64_STANDARD, Engine}, solana_account_decoder::parse_token::UiTokenAmount, solana_sdk::{ clock::{Slot, UnixTimestamp}, @@ -1048,7 +1049,7 @@ impl EncodableWithMeta for VersionedTransaction { TransactionBinaryEncoding::Base58, ), UiTransactionEncoding::Base64 => EncodedTransaction::Binary( - base64::encode(bincode::serialize(self).unwrap()), + BASE64_STANDARD.encode(bincode::serialize(self).unwrap()), TransactionBinaryEncoding::Base64, ), UiTransactionEncoding::Json => self.json_encode(), @@ -1088,7 +1089,7 @@ impl Encodable for Transaction { TransactionBinaryEncoding::Base58, ), UiTransactionEncoding::Base64 => EncodedTransaction::Binary( - base64::encode(bincode::serialize(self).unwrap()), + BASE64_STANDARD.encode(bincode::serialize(self).unwrap()), TransactionBinaryEncoding::Base64, ), UiTransactionEncoding::Json | UiTransactionEncoding::JsonParsed => { @@ -1124,7 +1125,8 @@ impl EncodedTransaction { .into_vec() .ok() .and_then(|bytes| bincode::deserialize(&bytes).ok()), - TransactionBinaryEncoding::Base64 => base64::decode(blob) + TransactionBinaryEncoding::Base64 => BASE64_STANDARD + .decode(blob) .ok() .and_then(|bytes| bincode::deserialize(&bytes).ok()), }; @@ -1308,7 +1310,7 @@ impl From for UiTransactionReturnData { Self { program_id: return_data.program_id.to_string(), data: ( - base64::encode(return_data.data), + BASE64_STANDARD.encode(return_data.data), UiReturnDataEncoding::Base64, ), } diff --git a/transaction-status/src/parse_bpf_loader.rs b/transaction-status/src/parse_bpf_loader.rs index 313c2dd4fb..f4d531a482 100644 --- a/transaction-status/src/parse_bpf_loader.rs +++ b/transaction-status/src/parse_bpf_loader.rs @@ -2,6 +2,7 @@ use { crate::parse_instruction::{ check_num_accounts, ParsableProgram, ParseInstructionError, ParsedInstructionEnum, }, + base64::{prelude::BASE64_STANDARD, Engine}, bincode::deserialize, serde_json::json, solana_sdk::{ @@ -28,7 +29,7 @@ pub fn parse_bpf_loader( instruction_type: "write".to_string(), info: json!({ "offset": offset, - "bytes": base64::encode(bytes), + "bytes": BASE64_STANDARD.encode(bytes), "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(), info: json!({ "offset": offset, - "bytes": base64::encode(bytes), + "bytes": BASE64_STANDARD.encode(bytes), "account": account_keys[instruction.accounts[0] 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(), info: json!({ "offset": offset, - "bytes": base64::encode(&bytes), + "bytes": BASE64_STANDARD.encode(&bytes), "account": account_pubkey.to_string(), }), } @@ -377,7 +378,7 @@ mod test { instruction_type: "write".to_string(), info: json!({ "offset": offset, - "bytes": base64::encode(&bytes), + "bytes": BASE64_STANDARD.encode(&bytes), "account": buffer_address.to_string(), "authority": authority_address.to_string(), }), diff --git a/zk-token-sdk/src/encryption/auth_encryption.rs b/zk-token-sdk/src/encryption/auth_encryption.rs index 4081b33749..f85abe8430 100644 --- a/zk-token-sdk/src/encryption/auth_encryption.rs +++ b/zk-token-sdk/src/encryption/auth_encryption.rs @@ -12,6 +12,7 @@ use { }; use { arrayref::{array_ref, array_refs}, + base64::{prelude::BASE64_STANDARD, Engine}, sha3::{Digest, Sha3_512}, solana_sdk::{ derivation_path::DerivationPath, @@ -198,7 +199,7 @@ impl AeCiphertext { impl fmt::Display for AeCiphertext { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", base64::encode(self.to_bytes())) + write!(f, "{}", BASE64_STANDARD.encode(self.to_bytes())) } } diff --git a/zk-token-sdk/src/encryption/elgamal.rs b/zk-token-sdk/src/encryption/elgamal.rs index b5cbde910b..8c9d10bc29 100644 --- a/zk-token-sdk/src/encryption/elgamal.rs +++ b/zk-token-sdk/src/encryption/elgamal.rs @@ -18,6 +18,7 @@ use { discrete_log::DiscreteLog, pedersen::{Pedersen, PedersenCommitment, PedersenOpening, G, H}, }, + base64::{prelude::BASE64_STANDARD, Engine}, core::ops::{Add, Mul, Sub}, curve25519_dalek::{ ristretto::{CompressedRistretto, RistrettoPoint}, @@ -329,7 +330,7 @@ impl ElGamalPubkey { impl fmt::Display for ElGamalPubkey { 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 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", base64::encode(self.to_bytes())) + write!(f, "{}", BASE64_STANDARD.encode(self.to_bytes())) } } diff --git a/zk-token-sdk/src/zk_token_elgamal/pod.rs b/zk-token-sdk/src/zk_token_elgamal/pod.rs index fd728bc6a7..041bd2177c 100644 --- a/zk-token-sdk/src/zk_token_elgamal/pod.rs +++ b/zk-token-sdk/src/zk_token_elgamal/pod.rs @@ -1,6 +1,7 @@ pub use bytemuck::{Pod, Zeroable}; use { crate::zk_token_proof_instruction::ProofType, + base64::{prelude::BASE64_STANDARD, Engine}, num_traits::{FromPrimitive, ToPrimitive}, solana_program::instruction::InstructionError, std::fmt, @@ -66,7 +67,7 @@ impl fmt::Debug for ElGamalCiphertext { impl fmt::Display for ElGamalCiphertext { 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 { 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 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", base64::encode(self.0)) + write!(f, "{}", BASE64_STANDARD.encode(self.0)) } }