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 #4723

Merged
merged 109 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 94 commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
19e89b4
Add structure async call and async call id
AurelienFT May 9, 2024
4407e86
progress
damip May 9, 2024
b6948d0
progress
damip May 9, 2024
bcfaed3
todos
damip May 9, 2024
eb59c84
Improve general behavior
damip May 10, 2024
5315ea4
typo
damip May 10, 2024
d4300c3
reformat registry
damip May 10, 2024
60cbf28
make things compile
damip May 10, 2024
42c47cd
updates
damip May 21, 2024
37a1961
Merge remote-tracking branch 'aurelien/new_asc' into deferred_calls
modship Jul 8, 2024
94016cb
update new interface
modship Jul 8, 2024
d62dbee
deferred calls first step
modship Jul 9, 2024
d18ed1b
rename massa_asc package to massa_deferred_calls
modship Jul 9, 2024
8b3b2da
TDD for ser_deser validation
modship Jul 10, 2024
7d7e850
Test(DeferredRegistrySlotChanges) : Ser/deser
modship Jul 10, 2024
f945386
Test(DeferredRegistryChanges) : Ser/Deser
modship Jul 10, 2024
9814537
update StateChanges Deserializer
modship Jul 10, 2024
90202d3
create macros, put_entry , delete_entry on DB
modship Jul 12, 2024
698a033
refactor + get_total_gas
modship Jul 12, 2024
cfe824a
get_slot_calls && get_slot_base_fee
modship Jul 15, 2024
1a86834
add mod tests / deferred_call_quote
modship Jul 16, 2024
9d74423
get_deferred_call_quote (interface_impl)
modship Jul 16, 2024
e1f2eca
register call
modship Jul 17, 2024
1bcc026
register set gas
modship Jul 17, 2024
14ca8d5
deferred_call_cancel
modship Jul 17, 2024
4a0c7db
execute deferred call, advance_slot, snapshot
modship Jul 24, 2024
ee901f1
execution trace && execution info
modship Jul 24, 2024
693cf0e
delete call from DB
modship Jul 24, 2024
43923d1
slot remaining gas for async msg
modship Jul 25, 2024
e94c57f
in case of fail, refound sender
modship Jul 25, 2024
6297693
get_slot from DeferredCallId
modship Jul 25, 2024
8bbb687
Fix(ser/deser): error and update test
modship Jul 26, 2024
801e65c
Fix(exec_deferred_call) : Fix lock
modship Jul 26, 2024
d59a556
Test(deferred_call) : first execution test
modship Jul 26, 2024
cd44aa1
fix(deferred_call) : remove double delete_call
modship Jul 26, 2024
cc14cdc
Test(abi) : First test for register deferred_call
modship Jul 29, 2024
1668f4d
Test(register) : more assert
modship Jul 30, 2024
24e09fe
Fix(set_total_gas) : fix set / keep
modship Jul 31, 2024
64f6c24
Test(deferred_call) : Register call fail (total_gas)
modship Jul 31, 2024
9a022ef
Fix(execution) : cancel deferred on check target sc + test refound
modship Jul 31, 2024
08bbef2
update wasm file
modship Jul 31, 2024
9fb3c0e
Fix(deferred_call) : fix compute call fee
modship Aug 1, 2024
82938ec
Fix(deferred_call) : some fix
modship Aug 1, 2024
3ce418f
Test(deferred_call) : Add slot base fee
modship Aug 1, 2024
baa1c3a
rename DEFERRED_CALLS_SLOT_PREFIX to DEFERRED_CALLS_PREFIX
modship Aug 14, 2024
87bb3a2
deferred calls ser/deser error msg
modship Aug 14, 2024
1dcab48
deferred_call_id deserializer limit
modship Aug 14, 2024
ac7ccde
models error
modship Aug 14, 2024
ebe33e1
update max_async_gas for async msg
modship Aug 16, 2024
12971b5
remove useless condition
modship Aug 16, 2024
1d61d14
overbooking_fee return Result
modship Aug 16, 2024
8f82d3e
fix operator
modship Aug 16, 2024
6c1caec
add penalty constant
modship Aug 16, 2024
f3331b5
pr comment # 1
modship Aug 26, 2024
9664ca7
Update massa-execution-worker/src/context.rs
modship Aug 26, 2024
a08664e
pr comment # 2
modship Aug 26, 2024
b53c77f
create DeferredCallsConfig
modship Aug 26, 2024
91ac5e3
use config struct
modship Aug 27, 2024
fe347bb
clippy
modship Aug 27, 2024
07863fc
allow unused_macros
modship Aug 27, 2024
5f28f44
fix : massa-bootstrap import
modship Aug 27, 2024
fd69b2e
wrap deferred call execution into a closure
modship Aug 28, 2024
67ad55f
update sc runtime && wasm test file
modship Aug 28, 2024
6815f44
update interface params from bytes to string
modship Aug 29, 2024
db87465
first metrics
modship Aug 29, 2024
d49dda7
Test: Add check on total_gas after execution
modship Aug 29, 2024
f43fdea
Test : Add 2nd call in scenario and check total_gas
modship Aug 30, 2024
5a58f5f
move type Set Update Delete from Ledger to massa_models
modship Sep 2, 2024
3f5f3cc
remove todo
modship Sep 3, 2024
4df7053
add vm allocation gas cost
modship Sep 4, 2024
c8ca2a8
remove todo
modship Sep 5, 2024
3dcd4ab
Fee: calc relu_occupancy_before
modship Sep 5, 2024
b5dae7c
update sc runtime
modship Sep 5, 2024
89c4d1d
add abi gas cost
modship Sep 5, 2024
039e9ba
Fix : total gas booked
modship Sep 6, 2024
562c16f
BugFix && add nb_call_registered
modship Sep 18, 2024
9583fc7
API : Jsonrpc DeferredCallQuote
modship Sep 20, 2024
341db02
API : JsonRpc get_deferred_call_info && list_deferred_calls_by_slot
modship Sep 23, 2024
4f7524d
API : openrpc spec
modship Sep 24, 2024
5b68c00
grpc api
modship Sep 26, 2024
815ed4c
Fix grpc log error
modship Sep 27, 2024
fd9d945
API : Update list call ids by slot
modship Sep 27, 2024
ed88731
rename openrpc method
modship Sep 27, 2024
7cd95b3
Fix : reset_to_snapshot
modship Oct 1, 2024
08be8a9
Fix: reset_to_snapshot
modship Oct 1, 2024
bc225ec
FIX : Api double alloc vm cst
modship Oct 2, 2024
a4e21a3
Fix : compute_fee get_effective_total_gas()
modship Oct 2, 2024
a4f3a6d
Update runtime
modship Oct 2, 2024
34d9975
Fix abi gas cost
modship Oct 2, 2024
9e57b53
Test : compute_call_fee setup && first basic test
modship Oct 2, 2024
6d25ee6
Test : add test for deferred call exists
modship Oct 3, 2024
2aea5a0
clippy
modship Oct 3, 2024
46fccbe
Fix : fee calculation
modship Oct 7, 2024
8ebf906
add storage cost for deferred call
modship Oct 16, 2024
2af6725
Merge remote-tracking branch 'origin/mainnet_2_3' into deferred_calls
modship Oct 18, 2024
88ecb0d
Storage: Refund sender (storage cost for params)
modship Oct 18, 2024
ff28375
Test : deferred call quote
modship Oct 21, 2024
64f4cdb
update runtime
modship Oct 21, 2024
95e1bc8
Fix all feature && update runtime
modship Oct 21, 2024
c8e45d8
fix doc
modship Oct 21, 2024
2453a80
Update storage cost for deferred calls and set MAX_FUNCTION_NAME_LENG…
modship Oct 30, 2024
1ef9d71
Fix comment
modship Oct 30, 2024
dd31e59
condom limits default with gas_calibration
modship Nov 7, 2024
49180c3
Merge branch 'mainnet_2_3' into deferred_calls
modship Nov 27, 2024
7afc88a
fix import
modship Nov 28, 2024
b20b556
update fee compute
modship Nov 29, 2024
f33057f
Test : fix SC address
modship Dec 3, 2024
de3cba3
Merge remote-tracking branch 'origin/mainnet_2_3' into deferred_calls
modship Dec 3, 2024
df245a8
Merge remote-tracking branch 'origin/mainnet_2_3' into deferred_calls
modship Dec 3, 2024
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
65 changes: 30 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ massa_consensus_exports = { path = "./massa-consensus-exports" }
massa_consensus_worker = { path = "./massa-consensus-worker" }
massa_db_exports = { path = "./massa-db-exports" }
massa_db_worker = { path = "./massa-db-worker" }
massa_deferred_calls = { path = "./massa-deferred-calls" }
massa_executed_ops = { path = "./massa-executed-ops" }
massa_execution_exports = { path = "./massa-execution-exports" }
massa_execution_worker = { path = "./massa-execution-worker" }
Expand Down Expand Up @@ -106,8 +107,10 @@ massa_versioning = { path = "./massa-versioning" }
massa_wallet = { path = "./massa-wallet" }

# Massa projects dependencies
massa-proto-rs = { git = "https://github.com/massalabs/massa-proto-rs", "rev" = "38950875a7aa406fedc4f0b8336864e5ff290f2c" }
massa-sc-runtime = { git = "https://github.com/massalabs/massa-sc-runtime", "rev" = "80352eb9f2a6b90a441cd64433d8874c33fb384f" }
massa-proto-rs = { git = "https://github.com/massalabs/massa-proto-rs", "rev" = "67c331c10a1a3f0a9985b3b16c50e31d63074b83" }
massa-sc-runtime = { git = "https://github.com/massalabs/massa-sc-runtime", "rev" = "7289367b2cb490ae1c6c74190d6d36b8d65b30cf" }


peernet = { git = "https://github.com/massalabs/PeerNet", "rev" = "04b05ddd320fbe76cc858115af7b5fc28bdb8310" }

# Common dependencies
Expand Down
1 change: 1 addition & 0 deletions massa-api-exports/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ massa_final_state = {workspace = true}
massa_hash = {workspace = true}
massa_wallet = {workspace = true}
massa_versioning = {workspace = true}
massa_deferred_calls = { workspace = true }

[dev-dependencies]
serial_test = {workspace = true}
3 changes: 3 additions & 0 deletions massa-api-exports/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2022 MASSA LABS <info@massa.net>

use massa_deferred_calls::config::DeferredCallsConfig;
use massa_models::amount::Amount;
use massa_signature::KeyPair;
use massa_time::MassaTime;
Expand Down Expand Up @@ -84,4 +85,6 @@ pub struct APIConfig {
pub deferred_credits_delta: MassaTime,
/// minimal fees to include an operation in a block
pub minimal_fees: Amount,
/// deferred calls config
pub deferred_calls_config: DeferredCallsConfig,
}
43 changes: 43 additions & 0 deletions massa-api-exports/src/execution.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2022 MASSA LABS <info@massa.net>

use massa_deferred_calls::DeferredCall;
use massa_final_state::StateChanges;
use massa_models::{
address::Address, amount::Amount, block_id::BlockId, operation::OperationId,
Expand Down Expand Up @@ -121,3 +122,45 @@ pub struct Transfer {
/// Context
pub context: TransferContext,
}

/// request for deferred call quote
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct DeferredCallsQuoteRequest {
/// The slot at which the deferred call is to be executed.
pub target_slot: Slot,
/// The maximum gas requested.
pub max_gas_request: u64,
/// Size of parameters
pub params_size: u64,
}

/// The response to a request for a deferred call quote.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct DeferredCallsQuoteResponse {
/// The slot at which the deferred call is to be executed.
pub target_slot: Slot,
/// The maximum gas requested.
pub max_gas_request: u64,
/// if the slot is bookable
pub available: bool,
/// the cost for booking the call
pub price: Amount,
}

/// response for deferred call
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct DeferredCallResponse {
/// deferred call id
pub call_id: String,
/// deferred call
pub call: DeferredCall,
}

/// response for deferred calls by slot
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct DeferredCallsSlotResponse {
/// deferred calls
pub slot: Slot,
/// deferred calls
pub call_ids: Vec<String>,
}
26 changes: 25 additions & 1 deletion massa-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ use jsonrpsee::proc_macros::rpc;
use jsonrpsee::server::middleware::HostFilterLayer;
use jsonrpsee::server::{BatchRequestConfig, ServerBuilder, ServerHandle};
use jsonrpsee::RpcModule;
use massa_api_exports::execution::Transfer;
use massa_api_exports::execution::{
DeferredCallResponse, DeferredCallsQuoteRequest, DeferredCallsQuoteResponse,
DeferredCallsSlotResponse, Transfer,
};
use massa_api_exports::{
address::{AddressFilter, AddressInfo},
block::{BlockInfo, BlockSummary},
Expand Down Expand Up @@ -400,6 +403,27 @@ pub trait MassaRpc {
/// Get OpenRPC specification.
#[method(name = "rpc.discover")]
async fn get_openrpc_spec(&self) -> RpcResult<Value>;

/// DeferredCall quote
#[method(name = "get_deferred_call_quote")]
async fn get_deferred_call_quote(
&self,
arg: Vec<DeferredCallsQuoteRequest>,
) -> RpcResult<Vec<DeferredCallsQuoteResponse>>;

/// DeferredCall get info
#[method(name = "get_deferred_call_info")]
async fn get_deferred_call_info(
&self,
arg: Vec<String>,
) -> RpcResult<Vec<DeferredCallResponse>>;

/// List deferred calls for given slot
#[method(name = "get_deferred_call_ids_by_slot")]
async fn get_deferred_call_ids_by_slot(
&self,
arg: Vec<Slot>,
) -> RpcResult<Vec<DeferredCallsSlotResponse>>;
}

fn wrong_api<T>() -> RpcResult<T> {
Expand Down
26 changes: 25 additions & 1 deletion massa-api/src/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ use massa_api_exports::{
datastore::{DatastoreEntryInput, DatastoreEntryOutput},
endorsement::EndorsementInfo,
error::ApiError,
execution::{ExecuteReadOnlyResponse, ReadOnlyBytecodeExecution, ReadOnlyCall, Transfer},
execution::{
DeferredCallResponse, DeferredCallsQuoteRequest, DeferredCallsQuoteResponse,
DeferredCallsSlotResponse, ExecuteReadOnlyResponse, ReadOnlyBytecodeExecution,
ReadOnlyCall, Transfer,
},
node::NodeStatus,
operation::{OperationInfo, OperationInput},
page::{PageRequest, PagedVec},
Expand Down Expand Up @@ -351,6 +355,26 @@ impl MassaRpcServer for API<Private> {
)
}

async fn get_deferred_call_quote(
&self,
_req: Vec<DeferredCallsQuoteRequest>,
) -> RpcResult<Vec<DeferredCallsQuoteResponse>> {
crate::wrong_api::<Vec<DeferredCallsQuoteResponse>>()
}
async fn get_deferred_call_info(
&self,
_arg: Vec<String>,
) -> RpcResult<Vec<DeferredCallResponse>> {
crate::wrong_api::<Vec<DeferredCallResponse>>()
}

async fn get_deferred_call_ids_by_slot(
&self,
_slot: Vec<Slot>,
) -> RpcResult<Vec<DeferredCallsSlotResponse>> {
crate::wrong_api::<Vec<DeferredCallsSlotResponse>>()
}

async fn get_openrpc_spec(&self) -> RpcResult<Value> {
crate::wrong_api::<Value>()
}
Expand Down
Loading
Loading