From 2ea5485f925179e4d8a51c05236ad258e0612587 Mon Sep 17 00:00:00 2001 From: Ed Hastings Date: Thu, 24 Aug 2023 10:15:55 -0700 Subject: [PATCH 1/2] fixing audit & schema to satisfy ci --- Makefile | 2 +- resources/test/rpc_schema.json | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 6eeaee48c3..1966077a9b 100644 --- a/Makefile +++ b/Makefile @@ -134,7 +134,7 @@ lint-smart-contracts: .PHONY: audit-rs audit-rs: - $(CARGO) audit + $(CARGO) audit --ignore RUSTSEC-2022-0093 .PHONY: audit-as audit-as: diff --git a/resources/test/rpc_schema.json b/resources/test/rpc_schema.json index 2ccbc08423..1b05fb2a49 100644 --- a/resources/test/rpc_schema.json +++ b/resources/test/rpc_schema.json @@ -4117,18 +4117,11 @@ ] }, { - "description": "Pattern of entry point types introduced in 2.0.\n\nIf this bit is missing, that means given entry point type was defined in pre-2.0 world. Installer entry point.", + "description": "Installer entry point.", "type": "string", "enum": [ "Install" ] - }, - { - "description": "Normal entry point.", - "type": "string", - "enum": [ - "Normal" - ] } ] }, From 7e3964e272767b75498d45b70c37337ce6fa121c Mon Sep 17 00:00:00 2001 From: Ed Hastings Date: Thu, 24 Aug 2023 10:48:36 -0700 Subject: [PATCH 2/2] renaming Abstract to Template --- execution_engine/src/engine_state/mod.rs | 2 +- execution_engine/src/execution/error.rs | 2 +- execution_engine/src/runtime/mod.rs | 4 ++-- .../tests/src/test/counter_factory.rs | 4 ++-- .../contracts/test/counter-factory/src/main.rs | 4 ++-- types/src/addressable_entity.rs | 10 +++++----- types/src/gens.rs | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/execution_engine/src/engine_state/mod.rs b/execution_engine/src/engine_state/mod.rs index 8d449ce77c..eb5f6545ad 100644 --- a/execution_engine/src/engine_state/mod.rs +++ b/execution_engine/src/engine_state/mod.rs @@ -2553,7 +2553,7 @@ fn should_charge_for_errors_in_wasm(execution_result: &ExecutionResult) -> bool | ExecError::NoActiveContractVersions(_) | ExecError::InvalidContractVersion(_) | ExecError::NoSuchMethod(_) - | ExecError::AbstractMethod(_) + | ExecError::TemplateMethod(_) | ExecError::KeyIsNotAURef(_) | ExecError::UnexpectedStoredValueVariant | ExecError::LockedContract(_) diff --git a/execution_engine/src/execution/error.rs b/execution_engine/src/execution/error.rs index 2dc526c2f5..ba283b47be 100644 --- a/execution_engine/src/execution/error.rs +++ b/execution_engine/src/execution/error.rs @@ -130,7 +130,7 @@ pub enum Error { NoSuchMethod(String), /// Contract does #[error("Error calling an abstract entry point: {}", _0)] - AbstractMethod(String), + TemplateMethod(String), /// Error processing WASM bytes. #[error("Wasm preprocessing error: {}", _0)] WasmPreprocessing(PreprocessingError), diff --git a/execution_engine/src/runtime/mod.rs b/execution_engine/src/runtime/mod.rs index cf1e1ef17c..2bdf10d35b 100644 --- a/execution_engine/src/runtime/mod.rs +++ b/execution_engine/src/runtime/mod.rs @@ -2665,7 +2665,7 @@ where Ok(()) } - EntryPointAccess::Abstract => Err(Error::AbstractMethod(name.to_string())), + EntryPointAccess::Template => Err(Error::TemplateMethod(name.to_string())), } } @@ -2695,7 +2695,7 @@ where }; for entry_point in entry_points { match entry_point.access() { - EntryPointAccess::Public | EntryPointAccess::Abstract => { + EntryPointAccess::Public | EntryPointAccess::Template => { continue; } EntryPointAccess::Groups(groups) => { diff --git a/execution_engine_testing/tests/src/test/counter_factory.rs b/execution_engine_testing/tests/src/test/counter_factory.rs index 03cbb3703d..0d6637ae88 100644 --- a/execution_engine_testing/tests/src/test/counter_factory.rs +++ b/execution_engine_testing/tests/src/test/counter_factory.rs @@ -56,7 +56,7 @@ fn should_not_call_undefined_entrypoints_on_factory() { let no_such_method_2 = builder.get_error().expect("should have error"); assert!( - matches!(&no_such_method_2, Error::Exec(execution::Error::AbstractMethod(function_name)) if function_name == INCREASE_ENTRY_POINT), + matches!(&no_such_method_2, Error::Exec(execution::Error::TemplateMethod(function_name)) if function_name == INCREASE_ENTRY_POINT), "{:?}", &no_such_method_2 ); @@ -76,7 +76,7 @@ fn should_not_call_undefined_entrypoints_on_factory() { let no_such_method_3 = builder.get_error().expect("should have error"); assert!( - matches!(&no_such_method_3, Error::Exec(execution::Error::AbstractMethod(function_name)) if function_name == DECREASE_ENTRY_POINT), + matches!(&no_such_method_3, Error::Exec(execution::Error::TemplateMethod(function_name)) if function_name == DECREASE_ENTRY_POINT), "{:?}", &no_such_method_3 ); diff --git a/smart_contracts/contracts/test/counter-factory/src/main.rs b/smart_contracts/contracts/test/counter-factory/src/main.rs index ba2ad1d3b4..dc14dea846 100644 --- a/smart_contracts/contracts/test/counter-factory/src/main.rs +++ b/smart_contracts/contracts/test/counter-factory/src/main.rs @@ -136,7 +136,7 @@ pub extern "C" fn call() { INCREASE_ENTRY_POINT.to_string(), Parameters::new(), CLType::Unit, - EntryPointAccess::Abstract, + EntryPointAccess::Template, EntryPointType::Contract, ); entry_points.add_entry_point(entry_point); @@ -144,7 +144,7 @@ pub extern "C" fn call() { DECREASE_ENTRY_POINT.to_string(), Parameters::new(), CLType::Unit, - EntryPointAccess::Abstract, + EntryPointAccess::Template, EntryPointType::Contract, ); entry_points.add_entry_point(entry_point); diff --git a/types/src/addressable_entity.rs b/types/src/addressable_entity.rs index 7239c78d33..169e93bd30 100644 --- a/types/src/addressable_entity.rs +++ b/types/src/addressable_entity.rs @@ -1234,7 +1234,7 @@ pub enum EntryPointAccess { /// contract. Groups(Vec), /// Can't be accessed directly but are kept in the derived wasm bytes. - Abstract, + Template, } const ENTRYPOINTACCESS_PUBLIC_TAG: u8 = 1; @@ -1264,7 +1264,7 @@ impl ToBytes for EntryPointAccess { result.push(ENTRYPOINTACCESS_GROUPS_TAG); result.append(&mut groups.to_bytes()?); } - EntryPointAccess::Abstract => { + EntryPointAccess::Template => { result.push(ENTRYPOINTACCESS_ABSTRACT_TAG); } } @@ -1275,7 +1275,7 @@ impl ToBytes for EntryPointAccess { match self { EntryPointAccess::Public => 1, EntryPointAccess::Groups(groups) => 1 + groups.serialized_length(), - EntryPointAccess::Abstract => 1, + EntryPointAccess::Template => 1, } } @@ -1288,7 +1288,7 @@ impl ToBytes for EntryPointAccess { writer.push(ENTRYPOINTACCESS_GROUPS_TAG); groups.write_bytes(writer)?; } - EntryPointAccess::Abstract => { + EntryPointAccess::Template => { writer.push(ENTRYPOINTACCESS_ABSTRACT_TAG); } } @@ -1307,7 +1307,7 @@ impl FromBytes for EntryPointAccess { let result = EntryPointAccess::Groups(groups); Ok((result, bytes)) } - ENTRYPOINTACCESS_ABSTRACT_TAG => Ok((EntryPointAccess::Abstract, bytes)), + ENTRYPOINTACCESS_ABSTRACT_TAG => Ok((EntryPointAccess::Template, bytes)), _ => Err(bytesrepr::Error::Formatting), } } diff --git a/types/src/gens.rs b/types/src/gens.rs index 29acf6bb4a..9a1c9135db 100644 --- a/types/src/gens.rs +++ b/types/src/gens.rs @@ -291,7 +291,7 @@ pub fn entry_point_access_arb() -> impl Strategy { prop_oneof![ Just(EntryPointAccess::Public), collection::vec(group_arb(), 0..32).prop_map(EntryPointAccess::Groups), - Just(EntryPointAccess::Abstract), + Just(EntryPointAccess::Template), ] }