Revert "lang: Make Anchor use fallback function instead of panicking if ix data.len() is < `8` (#1721)" (#1748)
This commit is contained in:
parent
778e328753
commit
3d0560db2c
|
@ -31,7 +31,6 @@ The minor version will be incremented upon a breaking change and the patch versi
|
||||||
* avm: `avm install` switches to the newly installed version after installation finishes ([#1670](https://github.com/project-serum/anchor/pull/1670)).
|
* avm: `avm install` switches to the newly installed version after installation finishes ([#1670](https://github.com/project-serum/anchor/pull/1670)).
|
||||||
* spl: Re-export the `spl_token` crate ([#1665](https://github.com/project-serum/anchor/pull/1665)).
|
* spl: Re-export the `spl_token` crate ([#1665](https://github.com/project-serum/anchor/pull/1665)).
|
||||||
* lang, cli, spl: Update solana toolchain to v1.9.13 ([#1653](https://github.com/project-serum/anchor/pull/1653)).
|
* lang, cli, spl: Update solana toolchain to v1.9.13 ([#1653](https://github.com/project-serum/anchor/pull/1653)).
|
||||||
* lang: Use fallback function if ix data length smaller than `8` instead of panicking ([#1721](https://github.com/project-serum/anchor/pull/1721)).
|
|
||||||
* lang: `Program` type now deserializes `programdata_address` only on demand ([#1723](https://github.com/project-serum/anchor/pull/1723)).
|
* lang: `Program` type now deserializes `programdata_address` only on demand ([#1723](https://github.com/project-serum/anchor/pull/1723)).
|
||||||
|
|
||||||
## [0.23.0] - 2022-03-20
|
## [0.23.0] - 2022-03-20
|
||||||
|
|
|
@ -143,43 +143,33 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
|
||||||
// Split the instruction data into the first 8 byte method
|
// Split the instruction data into the first 8 byte method
|
||||||
// identifier (sighash) and the serialized instruction data.
|
// identifier (sighash) and the serialized instruction data.
|
||||||
let mut ix_data: &[u8] = data;
|
let mut ix_data: &[u8] = data;
|
||||||
let sighash: Option<[u8; 8]> = {
|
let sighash: [u8; 8] = {
|
||||||
let mut sighash: [u8; 8] = [0; 8];
|
let mut sighash: [u8; 8] = [0; 8];
|
||||||
if ix_data.len() < 8 {
|
sighash.copy_from_slice(&ix_data[..8]);
|
||||||
None
|
ix_data = &ix_data[8..];
|
||||||
} else {
|
sighash
|
||||||
sighash.copy_from_slice(&ix_data[..8]);
|
|
||||||
ix_data = &ix_data[8..];
|
|
||||||
Some(sighash)
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// If the method identifier is the IDL tag, then execute an IDL
|
// If the method identifier is the IDL tag, then execute an IDL
|
||||||
// instruction, injected into all Anchor programs.
|
// instruction, injected into all Anchor programs.
|
||||||
if cfg!(not(feature = "no-idl")) {
|
if cfg!(not(feature = "no-idl")) {
|
||||||
if let Some(sighash) = sighash {
|
if sighash == anchor_lang::idl::IDL_IX_TAG.to_le_bytes() {
|
||||||
if sighash == anchor_lang::idl::IDL_IX_TAG.to_le_bytes() {
|
return __private::__idl::__idl_dispatch(
|
||||||
return __private::__idl::__idl_dispatch(
|
program_id,
|
||||||
program_id,
|
accounts,
|
||||||
accounts,
|
&ix_data,
|
||||||
&ix_data,
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match sighash {
|
match sighash {
|
||||||
Some(sighash) => {
|
#ctor_state_dispatch_arm
|
||||||
match sighash {
|
#(#state_dispatch_arms)*
|
||||||
#ctor_state_dispatch_arm
|
#(#trait_dispatch_arms)*
|
||||||
#(#state_dispatch_arms)*
|
#(#global_dispatch_arms)*
|
||||||
#(#trait_dispatch_arms)*
|
_ => {
|
||||||
#(#global_dispatch_arms)*
|
#fallback_fn
|
||||||
_ => {
|
|
||||||
#fallback_fn
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => #fallback_fn
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ describe("misc", () => {
|
||||||
"Program data: jvbowsvlmkcJAAAA",
|
"Program data: jvbowsvlmkcJAAAA",
|
||||||
"Program data: zxM5neEnS1kBAgMEBQYHCAkK",
|
"Program data: zxM5neEnS1kBAgMEBQYHCAkK",
|
||||||
"Program data: g06Ei2GL1gIBAgMEBQYHCAkKCw==",
|
"Program data: g06Ei2GL1gIBAgMEBQYHCAkKCw==",
|
||||||
"Program 3TEqcc8xhrhdspwbvoamUJe2borm4Nr72JxL66k6rgrh consumed 5418 of 1400000 compute units",
|
"Program 3TEqcc8xhrhdspwbvoamUJe2borm4Nr72JxL66k6rgrh consumed 5395 of 1400000 compute units",
|
||||||
"Program 3TEqcc8xhrhdspwbvoamUJe2borm4Nr72JxL66k6rgrh success",
|
"Program 3TEqcc8xhrhdspwbvoamUJe2borm4Nr72JxL66k6rgrh success",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ async fn update_foo() {
|
||||||
|
|
||||||
let mut pt = ProgramTest::new("zero_copy", zero_copy::id(), None);
|
let mut pt = ProgramTest::new("zero_copy", zero_copy::id(), None);
|
||||||
pt.add_account(foo_pubkey, foo_account);
|
pt.add_account(foo_pubkey, foo_account);
|
||||||
pt.set_compute_max_units(3174);
|
pt.set_compute_max_units(3157);
|
||||||
let (mut banks_client, payer, recent_blockhash) = pt.start().await;
|
let (mut banks_client, payer, recent_blockhash) = pt.start().await;
|
||||||
|
|
||||||
let client = Client::new_with_options(
|
let client = Client::new_with_options(
|
||||||
|
|
Loading…
Reference in New Issue