Skip to content

Commit

Permalink
Merge pull request #5108 from zajko/contract_json_refactor
Browse files Browse the repository at this point in the history
Changed the json representation of StoredValue::Contract.entry_points…
  • Loading branch information
zajko authored Feb 28, 2025
2 parents 6c3b6d0 + c76104f commit 0dfa3a8
Show file tree
Hide file tree
Showing 72 changed files with 612 additions and 409 deletions.
4 changes: 2 additions & 2 deletions execution_engine/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use casper_types::{
},
addressable_entity::{
self, ActionThresholds, ActionType, AddressableEntity, AddressableEntityHash,
AssociatedKeys, ContractRuntimeTag, EntityKindTag, EntryPoint, EntryPointAccess,
AssociatedKeys, ContractRuntimeTag, EntityEntryPoint, EntityKindTag, EntryPointAccess,
EntryPointType, EntryPoints, MessageTopicError, MessageTopics, NamedKeyAddr, NamedKeyValue,
Parameter, Weight, DEFAULT_ENTRY_POINT_NAME,
},
Expand Down Expand Up @@ -1453,7 +1453,7 @@ where
fn get_context_key_for_contract_call(
&self,
entity_addr: EntityAddr,
entry_point: &EntryPoint,
entry_point: &EntityEntryPoint,
) -> Result<Key, ExecError> {
let current = self.context.entry_point_type();
let next = entry_point.entry_point_type();
Expand Down
4 changes: 2 additions & 2 deletions executor/wasm-host/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use casper_types::{
addressable_entity::{ActionThresholds, AssociatedKeys, NamedKeyAddr},
bytesrepr::ToBytes,
AddressableEntity, AddressableEntityHash, BlockHash, ByteCode, ByteCodeAddr, ByteCodeHash,
ByteCodeKind, CLType, ContractRuntimeTag, Digest, EntityAddr, EntityKind, EntryPoint,
ByteCodeKind, CLType, ContractRuntimeTag, Digest, EntityAddr, EntityEntryPoint, EntityKind,
EntryPointAccess, EntryPointAddr, EntryPointPayment, EntryPointType, EntryPointValue, Groups,
HashAddr, Key, Package, PackageHash, PackageStatus, ProtocolVersion, StoredValue, URef, U512,
};
Expand Down Expand Up @@ -142,7 +142,7 @@ pub fn casper_write<S: GlobalStateReader, E: Executor>(
}
};

let entry_point = EntryPoint::new(
let entry_point = EntityEntryPoint::new(
"_",
Vec::new(),
CLType::Unit,
Expand Down
2 changes: 1 addition & 1 deletion node/src/components/contract_runtime/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ mod test_mod {
let key = Key::EntryPoint(
EntryPointAddr::new_v1_entry_point_addr(entity_addr, entry_point_name).unwrap(),
);
let entry_point = casper_types::EntryPoint::new(
let entry_point = casper_types::EntityEntryPoint::new(
entry_point_name,
vec![],
CLType::Unit,
Expand Down
34 changes: 6 additions & 28 deletions resources/test/sse_data_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4116,7 +4116,10 @@
"$ref": "#/definitions/NamedKeys"
},
"entry_points": {
"$ref": "#/definitions/Array_of_NamedEntryPoint"
"type": "array",
"items": {
"$ref": "#/definitions/EntryPoint"
}
},
"protocol_version": {
"$ref": "#/definitions/ProtocolVersion"
Expand All @@ -4127,31 +4130,6 @@
"description": "The hash address of the contract wasm",
"type": "string"
},
"Array_of_NamedEntryPoint": {
"type": "array",
"items": {
"$ref": "#/definitions/NamedEntryPoint"
}
},
"NamedEntryPoint": {
"type": "object",
"required": [
"entry_point",
"name"
],
"properties": {
"name": {
"type": "string"
},
"entry_point": {
"allOf": [
{
"$ref": "#/definitions/EntryPoint"
}
]
}
}
},
"EntryPoint": {
"description": "Type signature of a method. Order of arguments matter since can be referenced by index as well as name.",
"type": "object",
Expand Down Expand Up @@ -4841,14 +4819,14 @@
],
"properties": {
"V1CasperVm": {
"$ref": "#/definitions/EntryPoint2"
"$ref": "#/definitions/EntityEntryPoint"
}
},
"additionalProperties": false
}
]
},
"EntryPoint2": {
"EntityEntryPoint": {
"description": "Type signature of a method. Order of arguments matter since can be referenced by index as well as name.",
"type": "object",
"required": [
Expand Down
11 changes: 6 additions & 5 deletions smart_contracts/contracts/explorer/faucet-stored/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ use casper_contract::{
unwrap_or_revert::UnwrapOrRevert,
};
use casper_types::{
contracts::NamedKeys, AddressableEntityHash, ApiError, CLType, EntryPoint, EntryPointAccess,
EntryPointPayment, EntryPointType, EntryPoints, Key, Parameter, PublicKey, URef, U512,
contracts::NamedKeys, AddressableEntityHash, ApiError, CLType, EntityEntryPoint,
EntryPointAccess, EntryPointPayment, EntryPointType, EntryPoints, Key, Parameter, PublicKey,
URef, U512,
};

#[repr(u16)]
Expand Down Expand Up @@ -105,7 +106,7 @@ pub extern "C" fn call() {
let entry_points = {
let mut entry_points = EntryPoints::new();

let faucet = EntryPoint::new(
let faucet = EntityEntryPoint::new(
faucet::ENTRY_POINT_FAUCET,
vec![
Parameter::new(faucet::ARG_ID, CLType::Option(Box::new(CLType::U64))),
Expand All @@ -118,7 +119,7 @@ pub extern "C" fn call() {
EntryPointPayment::Caller,
);

let set_variables = EntryPoint::new(
let set_variables = EntityEntryPoint::new(
faucet::ENTRY_POINT_SET_VARIABLES,
vec![
Parameter::new(
Expand All @@ -140,7 +141,7 @@ pub extern "C" fn call() {
EntryPointPayment::Caller,
);

let authorize_to = EntryPoint::new(
let authorize_to = EntityEntryPoint::new(
faucet::ENTRY_POINT_AUTHORIZE_TO,
vec![Parameter::new(
faucet::ARG_TARGET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use casper_types::{
account::{AccountHash, ActionType, Weight},
bytesrepr::Bytes,
contracts::{ContractHash, ContractVersion, NamedKeys},
runtime_args, ApiError, BlockTime, CLType, CLValue, EntryPoint, EntryPointAccess,
runtime_args, ApiError, BlockTime, CLType, CLValue, EntityEntryPoint, EntryPointAccess,
EntryPointPayment, EntryPointType, EntryPoints, Key, Parameter, Phase, U512,
};

Expand Down Expand Up @@ -218,7 +218,7 @@ fn store_function(
let entry_points = {
let mut entry_points = EntryPoints::new();

let entry_point = EntryPoint::new(
let entry_point = EntityEntryPoint::new(
entry_point_name,
vec![
Parameter::new(ARG_SEED, CLType::U64),
Expand Down
4 changes: 2 additions & 2 deletions smart_contracts/contracts/test/add-gas-subcall/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use casper_contract::contract_api::{runtime, storage};

use casper_types::{
contracts::{ContractHash, ContractVersion},
runtime_args, ApiError, CLType, EntryPoint, EntryPointAccess, EntryPointPayment,
runtime_args, ApiError, CLType, EntityEntryPoint, EntryPointAccess, EntryPointPayment,
EntryPointType, EntryPoints, Key, Parameter,
};

Expand Down Expand Up @@ -51,7 +51,7 @@ pub extern "C" fn add_gas() {
fn store() -> (ContractHash, ContractVersion) {
let entry_points = {
let mut entry_points = EntryPoints::new();
let entry_point = EntryPoint::new(
let entry_point = EntityEntryPoint::new(
SUBCALL_NAME,
vec![Parameter::new(ARG_GAS_AMOUNT, CLType::I32)],
CLType::Unit,
Expand Down
6 changes: 3 additions & 3 deletions smart_contracts/contracts/test/contract-context/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use casper_contract::{
unwrap_or_revert::UnwrapOrRevert,
};
use casper_types::{
addressable_entity::{EntryPoint, EntryPointAccess, EntryPointType, EntryPoints},
addressable_entity::{EntityEntryPoint, EntryPointAccess, EntryPointType, EntryPoints},
contracts::{ContractHash, ContractPackageHash, ContractVersion, NamedKeys},
runtime_args, AddressableEntityHash, CLType, EntryPointPayment, Key, ENTITY_INITIAL_VERSION,
};
Expand Down Expand Up @@ -92,7 +92,7 @@ pub extern "C" fn session_code_caller_as_contract() {
fn create_entrypoints_1() -> EntryPoints {
let mut entry_points = EntryPoints::new();

let contract_code_test = EntryPoint::new(
let contract_code_test = EntityEntryPoint::new(
CONTRACT_CODE.to_string(),
Vec::new(),
CLType::I32,
Expand All @@ -102,7 +102,7 @@ fn create_entrypoints_1() -> EntryPoints {
);
entry_points.add_entry_point(contract_code_test);

let session_code_caller_as_contract = EntryPoint::new(
let session_code_caller_as_contract = EntityEntryPoint::new(
"session_code_caller_as_contract".to_string(),
Vec::new(),
CLType::I32,
Expand Down
4 changes: 2 additions & 2 deletions smart_contracts/contracts/test/contract-funds/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use casper_contract::{

use casper_types::{
account::AccountHash,
addressable_entity::{EntryPoint, EntryPointAccess, EntryPointType, Parameter},
addressable_entity::{EntityEntryPoint, EntryPointAccess, EntryPointType, Parameter},
contracts::NamedKeys,
AddressableEntityHash, CLTyped, CLValue, EntryPointPayment, EntryPoints, Key, URef,
};
Expand Down Expand Up @@ -41,7 +41,7 @@ pub extern "C" fn call() {
let entry_points = {
let mut entry_points = EntryPoints::new();

let faucet_entrypoint = EntryPoint::new(
let faucet_entrypoint = EntityEntryPoint::new(
GET_PAYMENT_PURSE_NAME.to_string(),
vec![Parameter::new(ARG_TARGET, AccountHash::cl_type())],
URef::cl_type(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use casper_contract::{
};

use casper_types::{
addressable_entity::{EntryPoint, EntryPointAccess, EntryPointType, EntryPoints},
addressable_entity::{EntityEntryPoint, EntryPointAccess, EntryPointType, EntryPoints},
api_error::ApiError,
contract_messages::MessageTopicOperation,
contracts::NamedKeys,
Expand Down Expand Up @@ -88,31 +88,31 @@ pub extern "C" fn call() {
runtime::get_named_arg(ARG_REGISTER_DEFAULT_TOPIC_WITH_INIT);

let mut emitter_entry_points = EntryPoints::new();
emitter_entry_points.add_entry_point(EntryPoint::new(
emitter_entry_points.add_entry_point(EntityEntryPoint::new(
ENTRY_POINT_INIT,
Vec::new(),
CLType::Unit,
EntryPointAccess::Public,
EntryPointType::Called,
EntryPointPayment::Caller,
));
emitter_entry_points.add_entry_point(EntryPoint::new(
emitter_entry_points.add_entry_point(EntityEntryPoint::new(
ENTRY_POINT_EMIT_MESSAGE,
vec![Parameter::new(ARG_MESSAGE_SUFFIX_NAME, String::cl_type())],
CLType::Unit,
EntryPointAccess::Public,
EntryPointType::Called,
EntryPointPayment::Caller,
));
emitter_entry_points.add_entry_point(EntryPoint::new(
emitter_entry_points.add_entry_point(EntityEntryPoint::new(
ENTRY_POINT_ADD_TOPIC,
vec![Parameter::new(ARG_TOPIC_NAME, String::cl_type())],
CLType::Unit,
EntryPointAccess::Public,
EntryPointType::Called,
EntryPointPayment::Caller,
));
emitter_entry_points.add_entry_point(EntryPoint::new(
emitter_entry_points.add_entry_point(EntityEntryPoint::new(
ENTRY_POINT_EMIT_MULTIPLE_MESSAGES,
vec![Parameter::new(ARG_NUM_MESSAGES_TO_EMIT, u32::cl_type())],
CLType::Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use casper_contract::{
};

use casper_types::{
addressable_entity::{EntryPoint, EntryPointAccess, EntryPointType, EntryPoints},
addressable_entity::{EntityEntryPoint, EntryPointAccess, EntryPointType, EntryPoints},
api_error::ApiError,
contract_messages::MessageTopicOperation,
contracts::NamedKeys,
Expand Down Expand Up @@ -102,23 +102,23 @@ pub extern "C" fn call() {
runtime::get_named_arg(ARG_REGISTER_DEFAULT_TOPIC_WITH_INIT);

let mut emitter_entry_points = EntryPoints::new();
emitter_entry_points.add_entry_point(EntryPoint::new(
emitter_entry_points.add_entry_point(EntityEntryPoint::new(
ENTRY_POINT_INIT,
Vec::new(),
CLType::Unit,
EntryPointAccess::Public,
EntryPointType::Called,
EntryPointPayment::Caller,
));
emitter_entry_points.add_entry_point(EntryPoint::new(
emitter_entry_points.add_entry_point(EntityEntryPoint::new(
ENTRY_POINT_EMIT_MESSAGE,
vec![Parameter::new(ARG_MESSAGE_SUFFIX_NAME, String::cl_type())],
CLType::Unit,
EntryPointAccess::Public,
EntryPointType::Called,
EntryPointPayment::Caller,
));
emitter_entry_points.add_entry_point(EntryPoint::new(
emitter_entry_points.add_entry_point(EntityEntryPoint::new(
ENTRY_POINT_EMIT_MESSAGE_FROM_EACH_VERSION,
vec![Parameter::new(ARG_MESSAGE_SUFFIX_NAME, String::cl_type())],
CLType::Unit,
Expand Down
14 changes: 7 additions & 7 deletions smart_contracts/contracts/test/counter-factory/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use casper_contract::{
unwrap_or_revert::UnwrapOrRevert,
};
use casper_types::{
addressable_entity::{EntryPoint, EntryPoints, Parameters},
addressable_entity::{EntityEntryPoint, EntryPoints, Parameters},
bytesrepr::FromBytes,
contracts::NamedKeys,
ApiError, CLType, CLTyped, EntryPointAccess, EntryPointPayment, EntryPointType, Key, URef,
Expand Down Expand Up @@ -82,7 +82,7 @@ fn installer(name: String, initial_value: U512) {

let entry_points = {
let mut entry_points = EntryPoints::new();
let entry_point: EntryPoint = EntryPoint::new(
let entry_point: EntityEntryPoint = EntityEntryPoint::new(
INCREASE_ENTRY_POINT.to_string(),
Parameters::new(),
CLType::Unit,
Expand All @@ -91,7 +91,7 @@ fn installer(name: String, initial_value: U512) {
EntryPointPayment::Caller,
);
entry_points.add_entry_point(entry_point);
let entry_point: EntryPoint = EntryPoint::new(
let entry_point: EntityEntryPoint = EntityEntryPoint::new(
DECREASE_ENTRY_POINT.to_string(),
Parameters::new(),
CLType::Unit,
Expand Down Expand Up @@ -121,7 +121,7 @@ pub extern "C" fn call() {
let entry_points = {
let mut entry_points = EntryPoints::new();

let entry_point: EntryPoint = EntryPoint::new(
let entry_point: EntityEntryPoint = EntityEntryPoint::new(
CONTRACT_FACTORY_ENTRY_POINT.to_string(),
Parameters::new(),
CLType::Unit,
Expand All @@ -130,7 +130,7 @@ pub extern "C" fn call() {
EntryPointPayment::Caller,
);
entry_points.add_entry_point(entry_point);
let entry_point: EntryPoint = EntryPoint::new(
let entry_point: EntityEntryPoint = EntityEntryPoint::new(
CONTRACT_FACTORY_DEFAULT_ENTRY_POINT.to_string(),
Parameters::new(),
CLType::Unit,
Expand All @@ -139,7 +139,7 @@ pub extern "C" fn call() {
EntryPointPayment::Caller,
);
entry_points.add_entry_point(entry_point);
let entry_point: EntryPoint = EntryPoint::new(
let entry_point: EntityEntryPoint = EntityEntryPoint::new(
INCREASE_ENTRY_POINT.to_string(),
Parameters::new(),
CLType::Unit,
Expand All @@ -148,7 +148,7 @@ pub extern "C" fn call() {
EntryPointPayment::Caller,
);
entry_points.add_entry_point(entry_point);
let entry_point: EntryPoint = EntryPoint::new(
let entry_point: EntityEntryPoint = EntityEntryPoint::new(
DECREASE_ENTRY_POINT.to_string(),
Parameters::new(),
CLType::Unit,
Expand Down
4 changes: 2 additions & 2 deletions smart_contracts/contracts/test/deserialize-error/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use alloc::vec::Vec;
use casper_contract::{self, contract_api::storage, unwrap_or_revert::UnwrapOrRevert};
use casper_types::{
addressable_entity::Parameters, api_error, bytesrepr::ToBytes, contracts::ContractHash, CLType,
EntryPoint, EntryPointAccess, EntryPointPayment, EntryPointType, EntryPoints,
EntityEntryPoint, EntryPointAccess, EntryPointPayment, EntryPointType, EntryPoints,
};

#[no_mangle]
Expand Down Expand Up @@ -71,7 +71,7 @@ pub extern "C" fn call() {
let entry_points = {
let mut entry_points = EntryPoints::new();

let entry_point = EntryPoint::new(
let entry_point = EntityEntryPoint::new(
"do_nothing",
Parameters::default(),
CLType::Unit,
Expand Down
Loading

0 comments on commit 0dfa3a8

Please sign in to comment.