Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert casper ffi change #4842

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ lint-smart-contracts:

.PHONY: audit-rs
audit-rs:
$(CARGO) audit --ignore RUSTSEC-2024-0344
$(CARGO) audit --ignore RUSTSEC-2024-0344 --ignore RUSTSEC-2024-0367

.PHONY: audit-as
audit-as:
Expand Down
2 changes: 1 addition & 1 deletion execution_engine/src/resolvers/v1_function_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub(crate) enum FunctionIndex {
GetMainPurseIndex,
ReadHostBufferIndex,
CreateContractPackageAtHash,
AddPackageVersion,
AddContractVersion,
DisableContractVersion,
CallVersionedContract,
CreateContractUserGroup,
Expand Down
4 changes: 2 additions & 2 deletions execution_engine/src/resolvers/v1_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ impl ModuleImportResolver for RuntimeModuleImportResolver {
Signature::new(&[ValueType::I32; 8][..], Some(ValueType::I32)),
FunctionIndex::CreateContractUserGroup.into(),
),
"casper_add_package_version" => FuncInstance::alloc_host(
"casper_add_contract_version" => FuncInstance::alloc_host(
Signature::new(&[ValueType::I32; 11][..], Some(ValueType::I32)),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will still not solve the issue -> the import statement embedded in already stored contracts have 10 args, but this one has 11 args. We'd perhaps need two host functions?

"casper_add_contract_version" => FuncInstance::alloc_host(
Signature::new(&[ValueType::I32; 10][..], Some(ValueType::I32)),
FunctionIndex::AddContractVersion.into(),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah makes sense, let me just bring back the old FFI

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, you need both the old (for retrograde support) and the new (for go forward)

FunctionIndex::AddPackageVersion.into(),
FunctionIndex::AddContractVersion.into(),
),
"casper_disable_contract_version" => FuncInstance::alloc_host(
Signature::new(&[ValueType::I32; 4][..], Some(ValueType::I32)),
Expand Down
2 changes: 1 addition & 1 deletion execution_engine/src/runtime/externals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ where
)?;
Ok(Some(RuntimeValue::I32(api_error::i32_from(ret))))
}
FunctionIndex::AddPackageVersion => {
FunctionIndex::AddContractVersion => {
// args(0) = pointer to package hash in wasm memory
// args(1) = size of package hash in wasm memory
// args(2) = pointer to entity version in wasm memory
Expand Down
2 changes: 1 addition & 1 deletion smart_contracts/contract/src/contract_api/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ pub fn add_contract_version(
let mut entity_version: EntityVersion = 0;

let ret = unsafe {
ext_ffi::casper_add_package_version(
ext_ffi::casper_add_contract_version(
package_hash_ptr,
package_hash_size,
&mut entity_version as *mut EntityVersion, // Fixed width
Expand Down
2 changes: 1 addition & 1 deletion smart_contracts/contract/src/ext_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ extern "C" {
/// * `message_topics_size` - size of serialized BTreeMap<String, MessageTopicOperation>
/// * `output_ptr` - pointer to a memory where host assigned contract hash is set to
/// * `output_size` - expected width of output (currently 32)
pub fn casper_add_package_version(
pub fn casper_add_contract_version(
package_hash_ptr: *const u8,
package_hash_size: usize,
version_ptr: *const u32,
Expand Down
Loading