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

Deferred calls #35

Open
wants to merge 21 commits into
base: mainnet_2_3
Choose a base branch
from
Open
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 .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "massa-proto"]
path = massa-proto
url = https:/massalabs/massa-proto.git
branch = main
branch = deferred_calls
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ prost = { version = "=0.13", default-features = false, features = [
] }
prost-types = { version = "=0.13", default-features = false }
tonic = { version = "=0.12", optional = true }
tower-service = "0.3.3"

[build-dependencies]
glob = "0.3"
Expand Down
10 changes: 5 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod tonic {
.build_client(false)
.include_file("_abi_includes.rs")
.out_dir("src/")
.compile(&protos, &proto_include_paths)
.compile_protos(&protos, &proto_include_paths)
.map_err(|e| format!("ABI protobuf compilation error: {:?}", e))?;

// Generate PUBLIC API file descriptor set
Expand All @@ -59,7 +59,7 @@ mod tonic {
.include_file("_api_includes.rs")
.file_descriptor_set_path("src/api_public.bin")
.out_dir("src/")
.compile(&vec![public_api_path], &proto_include_paths)
.compile_protos(&vec![public_api_path], &proto_include_paths)
.map_err(|e| format!("PUBLIC API protobuf compilation error: {:?}", e))?;

// Generate PRIVATE API file descriptor set
Expand All @@ -84,7 +84,7 @@ mod tonic {
.include_file("_api_includes.rs")
.file_descriptor_set_path("src/api_private.bin")
.out_dir("src/")
.compile(&vec![private_api_path], &proto_include_paths)
.compile_protos(&vec![private_api_path], &proto_include_paths)
.map_err(|e| format!("PRIVATE API protobuf compilation error: {:?}", e))?;

// Generate API bindings
Expand All @@ -109,7 +109,7 @@ mod tonic {
)
.include_file("_api_includes.rs")
.out_dir("src/")
.compile(&protos, &proto_include_paths)
.compile_protos(&protos, &proto_include_paths)
.map_err(|e| format!("API protobuf compilation error: {:?}", e))?;

// Generate COMMONS bindings
Expand All @@ -123,7 +123,7 @@ mod tonic {
.build_client(false)
.include_file("_commons_includes.rs")
.out_dir("src/")
.compile(&protos, &proto_include_paths)
.compile_protos(&protos, &proto_include_paths)
.map_err(|e| format!("COMMONS protobuf compilation error: {:?}", e))?;

Ok(())
Expand Down
Binary file modified src/api_public.bin
Binary file not shown.
86 changes: 85 additions & 1 deletion src/massa.abi.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub struct FunctionExistsResult {
pub struct RespResult {
#[prost(
oneof = "resp_result::Res",
tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63"
tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67"
)]
pub res: ::core::option::Option<resp_result::Res>,
}
Expand Down Expand Up @@ -250,6 +250,14 @@ pub mod resp_result {
IsAddressEoaResult(super::IsAddressEoaResult),
#[prost(message, tag = "63")]
ChainIdResult(super::ChainIdResult),
#[prost(message, tag = "64")]
DeferredCallQuoteResult(super::DeferredCallQuoteResult),
#[prost(message, tag = "65")]
DeferredCallExistsResult(super::DeferredCallExistsResult),
#[prost(message, tag = "66")]
DeferredCallRegisterResult(super::DeferredCallRegisterResult),
#[prost(message, tag = "67")]
DeferredCallCancelResult(super::DeferredCallCancelResult),
}
}
/// Generic message that encapsulate response from ABI calls.
Expand Down Expand Up @@ -866,6 +874,82 @@ pub struct UnsafeRandomResult {
#[prost(bytes = "vec", tag = "1")]
pub random_bytes: ::prost::alloc::vec::Vec<u8>,
}
/// / Deferred call cancel request
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeferredCallCancelRequest {
/// / call id
#[prost(message, optional, tag = "1")]
pub call_id: ::core::option::Option<::prost::alloc::string::String>,
}
/// / Deferred call cancel result
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct DeferredCallCancelResult {}
/// Deferred call quote
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct DeferredCallQuoteRequest {
/// / target slot
#[prost(message, optional, tag = "1")]
pub target_slot: ::core::option::Option<super::super::model::v1::Slot>,
/// / max gas requested
#[prost(uint64, tag = "2")]
pub max_gas: u64,
/// / params size in bytes
#[prost(uint64, tag = "3")]
pub params_size: u64,
}
/// Deferred call quote result
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct DeferredCallQuoteResult {
/// / available
#[prost(bool, tag = "1")]
pub available: bool,
/// / cost
#[prost(uint64, tag = "2")]
pub cost: u64,
}
/// deferred call exists request
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeferredCallExistsRequest {
/// / deferred call id
#[prost(message, optional, tag = "1")]
pub call_id: ::core::option::Option<::prost::alloc::string::String>,
}
/// deferred call exists result
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct DeferredCallExistsResult {
/// / call exists
#[prost(bool, tag = "1")]
pub call_exists: bool,
}
/// deferred call register request
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeferredCallRegisterRequest {
/// / target address
#[prost(string, tag = "1")]
pub target_address: ::prost::alloc::string::String,
/// / target function
#[prost(string, tag = "2")]
pub target_function: ::prost::alloc::string::String,
/// / start slot
#[prost(message, optional, tag = "3")]
pub target_slot: ::core::option::Option<super::super::model::v1::Slot>,
/// / gas requested
#[prost(uint64, tag = "4")]
pub max_gas: u64,
/// / params of the call
#[prost(bytes = "vec", tag = "5")]
pub params: ::prost::alloc::vec::Vec<u8>,
/// / coins
#[prost(uint64, tag = "6")]
pub coins: u64,
}
/// / deferred call register result
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeferredCallRegisterResult {
/// / deferred call id
#[prost(message, optional, tag = "1")]
pub call_id: ::core::option::Option<::prost::alloc::string::String>,
}
/// Send async message request filter
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SendAsyncMessageFilter {
Expand Down
113 changes: 105 additions & 8 deletions src/massa.api.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2369,7 +2369,7 @@ pub struct QueryStateRequest {
pub struct ExecutionQueryRequestItem {
#[prost(
oneof = "execution_query_request_item::RequestItem",
tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20"
tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23"
)]
pub request_item: ::core::option::Option<execution_query_request_item::RequestItem>,
}
Expand Down Expand Up @@ -2439,6 +2439,15 @@ pub mod execution_query_request_item {
/// Gets filtered events
#[prost(message, tag = "20")]
Events(super::Events),
/// Deferred call quote
#[prost(message, tag = "21")]
DeferredCallQuote(super::DeferredCallQuote),
/// Deferred calls info
#[prost(message, tag = "22")]
DeferredCallInfo(super::DeferredCallInfo),
/// Deferred calls by slot
#[prost(message, tag = "23")]
DeferredCallsBySlot(super::DeferredCallsBySlot),
}
}
/// Request to check if address exists (candidate)
Expand Down Expand Up @@ -2589,7 +2598,8 @@ pub struct CycleInfos {
/// Cycle to query
#[prost(uint64, tag = "1")]
pub cycle: u64,
/// Addresses to restrict the query (if None, info for all addresses will be returned)
/// Addresses to restrict the query (if None, info for all addresses will be
/// returned)
#[prost(string, repeated, tag = "2")]
pub restrict_to_addresses: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
Expand All @@ -2600,6 +2610,80 @@ pub struct Events {
#[prost(message, repeated, tag = "1")]
pub filters: ::prost::alloc::vec::Vec<ScExecutionEventsFilter>,
}
/// Deferred call quote
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct DeferredCallQuote {
/// / target slot
#[prost(message, optional, tag = "1")]
pub target_slot: ::core::option::Option<super::super::model::v1::Slot>,
/// / max gas requested
#[prost(uint64, tag = "2")]
pub max_gas: u64,
/// / params size in bytes
#[prost(uint64, tag = "3")]
pub params_size: u64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeferredCallInfo {
#[prost(string, tag = "1")]
pub call_id: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeferredCallInfoResponse {
#[prost(string, tag = "1")]
pub call_id: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub call: ::core::option::Option<DeferredCallInfoEntry>,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct DeferredCallsBySlot {
#[prost(message, optional, tag = "1")]
pub slot: ::core::option::Option<super::super::model::v1::Slot>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeferredCallsBySlotResponse {
#[prost(message, optional, tag = "1")]
pub slot: ::core::option::Option<super::super::model::v1::Slot>,
#[prost(string, repeated, tag = "2")]
pub call_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeferredCallInfoEntry {
#[prost(string, tag = "1")]
pub sender_address: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub target_slot: ::core::option::Option<super::super::model::v1::Slot>,
#[prost(string, tag = "3")]
pub target_address: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub target_function: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "5")]
pub parameters: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag = "6")]
pub coins: ::core::option::Option<super::super::model::v1::NativeAmount>,
#[prost(uint64, tag = "7")]
pub max_gas: u64,
#[prost(message, optional, tag = "8")]
pub fee: ::core::option::Option<super::super::model::v1::NativeAmount>,
#[prost(bool, tag = "9")]
pub cancelled: bool,
}
/// deferred call quote response
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct DeferredCallQuoteResponse {
/// the slot requested
#[prost(message, optional, tag = "1")]
pub target_slot: ::core::option::Option<super::super::model::v1::Slot>,
/// The gas requested
#[prost(uint64, tag = "2")]
pub max_gas_request: u64,
/// if the quote is available
#[prost(bool, tag = "3")]
pub available: bool,
/// The amount
#[prost(message, optional, tag = "4")]
pub price: ::core::option::Option<super::super::model::v1::NativeAmount>,
}
/// Response to atomically execute a batch of execution state queries
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryStateResponse {
Expand Down Expand Up @@ -2641,7 +2725,7 @@ pub mod execution_query_response {
pub struct ExecutionQueryResponseItem {
#[prost(
oneof = "execution_query_response_item::ResponseItem",
tags = "1, 2, 3, 4, 5, 6, 7, 8, 9"
tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12"
)]
pub response_item: ::core::option::Option<
execution_query_response_item::ResponseItem,
Expand Down Expand Up @@ -2678,6 +2762,15 @@ pub mod execution_query_response_item {
/// Events
#[prost(message, tag = "9")]
Events(super::ScOutputEventsWrapper),
/// Deferred call quote
#[prost(message, tag = "10")]
DeferredCallQuote(super::DeferredCallQuoteResponse),
/// Deferred call info
#[prost(message, tag = "11")]
DeferredCallInfo(super::DeferredCallInfoResponse),
/// Deferred calls by slot
#[prost(message, tag = "12")]
DeferredCallsBySlot(super::DeferredCallsBySlotResponse),
}
}
/// Deferred credits entry wrapper
Expand Down Expand Up @@ -2989,8 +3082,10 @@ pub mod async_pool_changes_filter {
/// The address that sent the message
#[prost(string, tag = "5")]
EmitterAddress(::prost::alloc::string::String),
/// Boolean that determine if the message can be executed. For messages without filter this boolean is always true.
/// For messages with filter, this boolean is true if the filter has been matched between `validity_start` and current slot.
/// Boolean that determine if the message can be executed. For messages
/// without filter this boolean is always true. For messages with filter,
/// this boolean is true if the filter has been matched between
/// `validity_start` and current slot.
#[prost(bool, tag = "6")]
CanBeExecuted(bool),
}
Expand Down Expand Up @@ -3532,7 +3627,7 @@ pub enum ExecutionQueryExecutionStatus {
AlreadyExecutedWithSuccess = 1,
/// The operation or denunciation was executed recently with failure
AlreadyExecutedWithFailure = 2,
/// The operation or denunciation was not executed recently but can still be executed unless expired
/// The operation or denunciation was not executed recently but can
ExecutableOrExpired = 3,
}
impl ExecutionQueryExecutionStatus {
Expand Down Expand Up @@ -4125,7 +4220,8 @@ pub mod public_service_client {
);
self.inner.unary(req, path, codec).await
}
/// Get ABI call stack of all asynchronous executions and all operations for a given slot
/// Get ABI call stack of all asynchronous executions and all operations for a
/// given slot
pub async fn get_slot_abi_call_stacks(
&mut self,
request: impl tonic::IntoRequest<super::GetSlotAbiCallStacksRequest>,
Expand Down Expand Up @@ -4641,7 +4737,8 @@ pub mod public_service_server {
tonic::Response<super::GetOperationAbiCallStacksResponse>,
tonic::Status,
>;
/// Get ABI call stack of all asynchronous executions and all operations for a given slot
/// Get ABI call stack of all asynchronous executions and all operations for a
/// given slot
async fn get_slot_abi_call_stacks(
&self,
request: tonic::Request<super::GetSlotAbiCallStacksRequest>,
Expand Down
4 changes: 1 addition & 3 deletions src/massa.model.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,9 +731,7 @@ impl BlockStatus {
"BLOCK_STATUS_UNSPECIFIED" => Some(Self::Unspecified),
"BLOCK_STATUS_NON_FINAL_BLOCKCLIQUE" => Some(Self::NonFinalBlockclique),
"BLOCK_STATUS_FINAL" => Some(Self::Final),
"BLOCK_STATUS_NON_FINAL_ALTERNATE_CLIQUE" => {
Some(Self::NonFinalAlternateClique)
}
"BLOCK_STATUS_NON_FINAL_ALTERNATE_CLIQUE" => Some(Self::NonFinalAlternateClique),
"BLOCK_STATUS_DISCARDED" => Some(Self::Discarded),
_ => None,
}
Expand Down
Loading