Skip to content

Commit

Permalink
Merge pull request #7 from EdHastingsCasperAssociation/casper-network…
Browse files Browse the repository at this point in the history
…gh-2064-factory-pattern

fixing audit & schema to satisfy ci
  • Loading branch information
mpapierski authored Aug 25, 2023
2 parents 98dbf48 + 7e3964e commit bb8b58d
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion execution_engine/src/engine_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_)
Expand Down
2 changes: 1 addition & 1 deletion execution_engine/src/execution/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions execution_engine/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2665,7 +2665,7 @@ where

Ok(())
}
EntryPointAccess::Abstract => Err(Error::AbstractMethod(name.to_string())),
EntryPointAccess::Template => Err(Error::TemplateMethod(name.to_string())),
}
}

Expand Down Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions execution_engine_testing/tests/src/test/counter_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand All @@ -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
);
Expand Down
9 changes: 1 addition & 8 deletions resources/test/rpc_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
]
},
Expand Down
4 changes: 2 additions & 2 deletions smart_contracts/contracts/test/counter-factory/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ 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);
let entry_point: EntryPoint = EntryPoint::new(
DECREASE_ENTRY_POINT.to_string(),
Parameters::new(),
CLType::Unit,
EntryPointAccess::Abstract,
EntryPointAccess::Template,
EntryPointType::Contract,
);
entry_points.add_entry_point(entry_point);
Expand Down
10 changes: 5 additions & 5 deletions types/src/addressable_entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ pub enum EntryPointAccess {
/// contract.
Groups(Vec<Group>),
/// Can't be accessed directly but are kept in the derived wasm bytes.
Abstract,
Template,
}

const ENTRYPOINTACCESS_PUBLIC_TAG: u8 = 1;
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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,
}
}

Expand All @@ -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);
}
}
Expand All @@ -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),
}
}
Expand Down
2 changes: 1 addition & 1 deletion types/src/gens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ pub fn entry_point_access_arb() -> impl Strategy<Value = EntryPointAccess> {
prop_oneof![
Just(EntryPointAccess::Public),
collection::vec(group_arb(), 0..32).prop_map(EntryPointAccess::Groups),
Just(EntryPointAccess::Abstract),
Just(EntryPointAccess::Template),
]
}

Expand Down

0 comments on commit bb8b58d

Please sign in to comment.