diff --git a/Cargo.lock b/Cargo.lock index d4bddd4..c43d5ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -464,7 +464,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" dependencies = [ "borsh-derive 0.10.3", - "hashbrown 0.12.3", + "hashbrown 0.13.2", ] [[package]] @@ -2751,9 +2751,9 @@ dependencies = [ [[package]] name = "solana-account-decoder" -version = "1.16.5" +version = "1.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b3b5782ae2ea0206115e5353cb8708ef4130123b0250f0fd983e0ff4e234ea4" +checksum = "f0ada16ccd5ca6884ae28b716211c4f09d22225a9ebde14eccd4f605cc321e42" dependencies = [ "Inflector", "base64 0.21.2", @@ -2775,9 +2775,9 @@ dependencies = [ [[package]] name = "solana-address-lookup-table-program" -version = "1.16.5" +version = "1.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf51fb7b53405fd5af275d0df02128416dc271807b02eb942727cc97b57d0d0" +checksum = "248b435722d18100b70bb8f09fd38b8a8c46031a0de86f6b31768f64cf4092c5" dependencies = [ "bincode", "bytemuck", @@ -2796,9 +2796,9 @@ dependencies = [ [[package]] name = "solana-config-program" -version = "1.16.5" +version = "1.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13818f85d7f6b8dac260c43962a6cd606d623ea0942b43c37ee375f2a8138afa" +checksum = "e0622d8798d060c84883572483f214b0d5c1640450e4322483cfe2e72823a6d7" dependencies = [ "bincode", "chrono", @@ -2810,9 +2810,9 @@ dependencies = [ [[package]] name = "solana-frozen-abi" -version = "1.16.5" +version = "1.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15610c43f150a99322c295c903cc521fa6921002ceed29fc419b7832c4ce4a4c" +checksum = "0e74d294241df12a73a229e38a819e810d54234da494c3d43f8a1a828631047d" dependencies = [ "ahash 0.8.3", "blake3", @@ -2843,9 +2843,9 @@ dependencies = [ [[package]] name = "solana-frozen-abi-macro" -version = "1.16.5" +version = "1.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6f5a146d452c451b052034ac9bb3fe7fe323fe0c891c3e71dcda50d944c5ad1" +checksum = "4dabde7fbd88a68eb083ae9d6d5f6855b7ba1bfc45d200c786b1b448ac49da5f" dependencies = [ "proc-macro2", "quote", @@ -2855,9 +2855,9 @@ dependencies = [ [[package]] name = "solana-geyser-plugin-interface" -version = "1.16.5" +version = "1.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29343e859ae6e821c9a38f66338817a9742227db9b40c81ddefb03ac962d09f" +checksum = "908cad0de1330b6b05d6cb6a9f5004df22a9fe46529d6bf6839835ba345ef966" dependencies = [ "log", "solana-sdk", @@ -2867,9 +2867,9 @@ dependencies = [ [[package]] name = "solana-logger" -version = "1.16.5" +version = "1.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9302be0d873cdd53768fae0eb0edb339337831fab45490fae0c2871ef720ad31" +checksum = "24dc0037a389d782c8de3c6f509b74efa1d60523ef9e5561cefe41f1a354fee0" dependencies = [ "env_logger", "lazy_static", @@ -2878,9 +2878,9 @@ dependencies = [ [[package]] name = "solana-measure" -version = "1.16.5" +version = "1.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dae1b9ce4af26a2fb24992226b57f26f312a76d89e48f52572cdbf4f5f40ec99" +checksum = "19563c27f12801e0e65b42d0f216db1d910dfeaad88d8f1335dd6369697eda60" dependencies = [ "log", "solana-sdk", @@ -2888,9 +2888,9 @@ dependencies = [ [[package]] name = "solana-metrics" -version = "1.16.5" +version = "1.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5a450b75836dccea96ed135ca43af1bc9c96e309cee08835d0217e6c717b21c" +checksum = "7f74c557e821c7ff48c9b4ef4ab3a296918d7fb745e3f2e820ebdb38e8e3555b" dependencies = [ "crossbeam-channel", "gethostname", @@ -2902,9 +2902,9 @@ dependencies = [ [[package]] name = "solana-program" -version = "1.16.5" +version = "1.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ad3f1977e6bf4f3f2bbf3d8988c58b8729c6aa1086b908eb50b138ddc6a812c" +checksum = "3a2faeb9c89b354b547a229e3b39fa8fd6d11c78362ba8580f0c4721739725b6" dependencies = [ "ark-bn254", "ark-ec", @@ -2916,6 +2916,7 @@ dependencies = [ "bitflags", "blake3", "borsh 0.10.3", + "borsh 0.9.3", "bs58", "bv", "bytemuck", @@ -2956,9 +2957,9 @@ dependencies = [ [[package]] name = "solana-program-runtime" -version = "1.16.5" +version = "1.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77b02d32f763d4cfcc8451745591c85498951dfa0049cae0b24fb23ac9c691c9" +checksum = "9f65907a405764cda63be89335ffd2138ade18f065e5cae09d20adab7fb09502" dependencies = [ "base64 0.21.2", "bincode", @@ -2984,9 +2985,9 @@ dependencies = [ [[package]] name = "solana-sdk" -version = "1.16.5" +version = "1.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e86f3523fa2612c7c7748b6fdbc16006e84a2bfda06c5835c9389bdf151621" +checksum = "57f4046d0d487e3d79be809ff29c63c1484793956e6ccbc5d3307b0aafbf989d" dependencies = [ "assert_matches", "base64 0.21.2", @@ -3037,9 +3038,9 @@ dependencies = [ [[package]] name = "solana-sdk-macro" -version = "1.16.5" +version = "1.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3673ef415e5d2673f00b78b4115536144c98f3253cc07b63b0df6b42720dc6" +checksum = "760fdfd4b7edb02fd9173a6dcec899ffae06ac21b66b65f8c7c5f3d17b12fa64" dependencies = [ "bs58", "proc-macro2", @@ -3050,9 +3051,9 @@ dependencies = [ [[package]] name = "solana-transaction-status" -version = "1.16.5" +version = "1.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae10df99518431cedaaa4ffe339582523dea40af76bf9151c9c7799971fb9df2" +checksum = "8bdf7379a72c051d7879f1c36cfdab5fed0653a2a613718bc5d343e44e603401" dependencies = [ "Inflector", "base64 0.21.2", @@ -3076,9 +3077,9 @@ dependencies = [ [[package]] name = "solana-vote-program" -version = "1.16.5" +version = "1.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cca8888b77f196b95b4c71b7330ef65f953d74284418ddc74d18e5f86aaf2092" +checksum = "dfde11af84827c25b484baf1743b5d0db068af32cf2e4f533148a2d2a31c2263" dependencies = [ "bincode", "log", @@ -3098,9 +3099,9 @@ dependencies = [ [[package]] name = "solana-zk-token-sdk" -version = "1.16.5" +version = "1.16.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "796023a165cc5c656a951ce667d746e24f599bfa76e0b4cc1e07513578d4322d" +checksum = "3bdec366a15133a70a8dfc4f027b5d0f508bd7cb46af11971076c9ebaf9ede2d" dependencies = [ "aes-gcm-siv", "base64 0.21.2", @@ -3127,9 +3128,9 @@ dependencies = [ [[package]] name = "solana_rbpf" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3082ec3a1d4ef7879eb5b84916d5acde057abd59733eec3647e0ab8885283ef" +checksum = "17d4ba1e58947346e360fabde0697029d36ba83c42f669199b16a8931313cf29" dependencies = [ "byteorder", "combine", diff --git a/Cargo.toml b/Cargo.toml index 2113c38..c97f62f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,6 @@ members = [ "server" ] - [workspace.package] version = "0.1.0" authors = ["Jito Foundation Maintainers "] @@ -35,14 +34,14 @@ rand = "0.8" serde = "1.0.160" serde_derive = "1.0.160" serde_json = "1.0.96" -solana-account-decoder = "1.16.5" -solana-geyser-plugin-interface = "1.16.5" -solana-logger = "1.16.5" -solana-metrics = "1.16.5" -solana-program = "1.16.5" -solana-sdk = "1.16.5" -solana-transaction-status = "1.16.5" -solana-vote-program = "1.16.5" +solana-account-decoder = "1.16.14" +solana-geyser-plugin-interface = "1.16.14" +solana-logger = "1.16.14" +solana-metrics = "1.16.14" +solana-program = "1.16.14" +solana-sdk = "1.16.14" +solana-transaction-status = "1.16.14" +solana-vote-program = "1.16.14" thiserror = "1.0.40" tokio = { version = "~1.14.1", features = ["rt-multi-thread"] } tokio-stream = "0.1" diff --git a/proto/proto/transaction_by_addr.proto b/proto/proto/transaction_by_addr.proto index 800ed40..8678dc3 100644 --- a/proto/proto/transaction_by_addr.proto +++ b/proto/proto/transaction_by_addr.proto @@ -60,6 +60,7 @@ enum TransactionErrorType { MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED = 32; INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT = 33; RESANITIZATION_NEEDED = 34; + UNBALANCED_TRANSACTION = 36; } message InstructionError { diff --git a/proto/src/convert.rs b/proto/src/convert.rs index 2da10c2..5aa6efe 100644 --- a/proto/src/convert.rs +++ b/proto/src/convert.rs @@ -909,6 +909,9 @@ impl From for tx_by_addr::TransactionError { TransactionError::ResanitizationNeeded => { tx_by_addr::TransactionErrorType::ResanitizationNeeded } + TransactionError::UnbalancedTransaction => { + tx_by_addr::TransactionErrorType::UnbalancedTransaction + } } as i32, instruction_error: match transaction_error { TransactionError::InstructionError(index, ref instruction_error) => { @@ -1160,706 +1163,3 @@ impl TryFrom for Vec { .collect::, Self::Error>>() } } - -#[cfg(test)] -mod test { - use crate::solana::storage::confirmed_block; - use solana_sdk::bs58; - use {super::*, enum_iterator::all}; - - #[test] - fn test_reward_type_encode() { - let mut reward = Reward { - pubkey: "invalid".to_string(), - lamports: 123, - post_balance: 321, - reward_type: None, - commission: None, - }; - let gen_reward: confirmed_block::Reward = reward.clone().into(); - assert_eq!(reward, gen_reward.into()); - - reward.reward_type = Some(RewardType::Fee); - let gen_reward: confirmed_block::Reward = reward.clone().into(); - assert_eq!(reward, gen_reward.into()); - - reward.reward_type = Some(RewardType::Rent); - let gen_reward: confirmed_block::Reward = reward.clone().into(); - assert_eq!(reward, gen_reward.into()); - - reward.reward_type = Some(RewardType::Voting); - let gen_reward: confirmed_block::Reward = reward.clone().into(); - assert_eq!(reward, gen_reward.into()); - - reward.reward_type = Some(RewardType::Staking); - let gen_reward: confirmed_block::Reward = reward.clone().into(); - assert_eq!(reward, gen_reward.into()); - } - - #[test] - fn test_transaction_by_addr_encode() { - let info = TransactionByAddrInfo { - signature: bs58::decode("Nfo6rgemG1KLbk1xuNwfrQTsdxaGfLuWURHNRy9LYnDrubG7LFQZaA5obPNas9LQ6DdorJqxh2LxA3PsnWdkSrL") - .into_vec() - .map(Signature::try_from) - .unwrap() - .unwrap(), - err: None, - index: 5, - memo: Some("string".to_string()), - block_time: Some(1610674861) - }; - - let tx_by_addr_transaction_info: tx_by_addr::TransactionByAddrInfo = info.clone().into(); - assert_eq!(info, tx_by_addr_transaction_info.try_into().unwrap()); - } - - #[test] - fn test_transaction_error_encode() { - let transaction_error = TransactionError::AccountBorrowOutstanding; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::AccountInUse; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::AccountLoadedTwice; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::AccountNotFound; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::AlreadyProcessed; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::BlockhashNotFound; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::CallChainTooDeep; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::ClusterMaintenance; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::InsufficientFundsForFee; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::InvalidAccountForFee; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::InvalidAccountIndex; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::InvalidProgramForExecution; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::MissingSignatureForFee; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::ProgramAccountNotFound; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::SanitizeFailure; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::SignatureFailure; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::WouldExceedMaxBlockCostLimit; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::WouldExceedMaxVoteCostLimit; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::WouldExceedMaxAccountCostLimit; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::UnsupportedVersion; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::AccountAlreadyInitialized); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::AccountBorrowFailed); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::AccountBorrowOutstanding); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::AccountDataSizeChanged); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::AccountDataTooSmall); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::AccountNotExecutable); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::InstructionError(10, InstructionError::CallDepth); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::ComputationalBudgetExceeded); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::DuplicateAccountIndex); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::DuplicateAccountOutOfSync); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::InstructionError( - 10, - InstructionError::ExecutableAccountNotRentExempt, - ); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::ExecutableDataModified); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::ExecutableLamportChange); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::ExecutableModified); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::ExternalAccountDataModified); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::ExternalAccountLamportSpend); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::GenericError); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::InstructionError(10, InstructionError::Immutable); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::IncorrectAuthority); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::IncorrectProgramId); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::InsufficientFunds); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::InvalidAccountData); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::InvalidArgument); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::InvalidError); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::InvalidInstructionData); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::InvalidRealloc); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::InvalidSeeds); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::MaxSeedLengthExceeded); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::MissingAccount); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::MissingRequiredSignature); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::ModifiedProgramId); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::NotEnoughAccountKeys); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::PrivilegeEscalation); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::InstructionError( - 10, - InstructionError::ProgramEnvironmentSetupFailure, - ); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::ProgramFailedToCompile); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::ProgramFailedToComplete); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::ReadonlyDataModified); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::ReadonlyLamportChange); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::ReentrancyNotAllowed); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::RentEpochModified); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::UnbalancedInstruction); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::UninitializedAccount); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::UnsupportedProgramId); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = - TransactionError::InstructionError(10, InstructionError::Custom(10)); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::DuplicateInstruction(10); - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - - let transaction_error = TransactionError::InsufficientFundsForRent { account_index: 10 }; - let tx_by_addr_transaction_error: tx_by_addr::TransactionError = - transaction_error.clone().into(); - assert_eq!( - transaction_error, - tx_by_addr_transaction_error.try_into().unwrap() - ); - } - - #[test] - fn test_error_enums() { - let ix_index = 1; - let custom_error = 42; - for error in all::() { - match error { - tx_by_addr::TransactionErrorType::DuplicateInstruction - | tx_by_addr::TransactionErrorType::InsufficientFundsForRent => { - let tx_by_addr_error = tx_by_addr::TransactionError { - transaction_error: error as i32, - instruction_error: None, - transaction_details: Some(tx_by_addr::TransactionDetails { - index: ix_index, - }), - }; - let transaction_error: TransactionError = tx_by_addr_error - .clone() - .try_into() - .unwrap_or_else(|_| panic!("{error:?} conversion implemented?")); - assert_eq!(tx_by_addr_error, transaction_error.into()); - } - tx_by_addr::TransactionErrorType::InstructionError => { - for ix_error in all::() { - if ix_error != tx_by_addr::InstructionErrorType::Custom { - let tx_by_addr_error = tx_by_addr::TransactionError { - transaction_error: error as i32, - instruction_error: Some(tx_by_addr::InstructionError { - index: ix_index, - error: ix_error as i32, - custom: None, - }), - transaction_details: None, - }; - let transaction_error: TransactionError = tx_by_addr_error - .clone() - .try_into() - .unwrap_or_else(|_| panic!("{ix_error:?} conversion implemented?")); - assert_eq!(tx_by_addr_error, transaction_error.into()); - } else { - let tx_by_addr_error = tx_by_addr::TransactionError { - transaction_error: error as i32, - instruction_error: Some(tx_by_addr::InstructionError { - index: ix_index, - error: ix_error as i32, - custom: Some(tx_by_addr::CustomError { - custom: custom_error, - }), - }), - transaction_details: None, - }; - let transaction_error: TransactionError = - tx_by_addr_error.clone().try_into().unwrap(); - assert_eq!(tx_by_addr_error, transaction_error.into()); - } - } - } - _ => { - let tx_by_addr_error = tx_by_addr::TransactionError { - transaction_error: error as i32, - instruction_error: None, - transaction_details: None, - }; - let transaction_error: TransactionError = tx_by_addr_error - .clone() - .try_into() - .unwrap_or_else(|_| panic!("{error:?} conversion implemented?")); - assert_eq!(tx_by_addr_error, transaction_error.into()); - } - } - } - } -} diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 9c46aac..e5adabc 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -# https://github.com/solana-labs/solana/blob/v1.16.5/rust-toolchain.toml +# https://github.com/solana-labs/solana/blob/v1.16.14/rust-toolchain.toml channel = "1.69.0" components = [ "rustfmt", "rustc-dev", "clippy", "cargo" ]