Async calls #1990
Replies: 5 comments 2 replies
-
About handle_message(message):
I some question about the message handling. That may be in other threads...
|
Beta Was this translation helpful? Give feedback.
-
Looks good to me. Not completely related but at some point I think it would be interesting to think about a more complex mechanism for the gas price. Ideally you want to monitor autonomous SCs as little as possible. If you want to be sure that your autonomous SCs operation are included, you have to put a large gas price, even though it may currently be quite small. It would be nice to be able to put bounds on the gas price, or something like that so that if no one uses autonomous SCs it does not cost much and otherwise you can still be sure it's included. |
Beta Was this translation helpful? Give feedback.
-
Protocol constants:
|
Beta Was this translation helpful? Give feedback.
-
After a first reflexion with Damir, one plausible implementation of the Async Pool system would be to regroup the Ledger and the Pool (of SC's async messages) in a single object called "State", which would be handled the same way the Ledger currently is. Other points where discussed such as: The possibility of adding Events to the "State"
The possibility of handling the Async Pool the same way we currently handle Events (sending SC's messages to the Nodes, save locally for execution)
The possibility of not saving changes for the Async Pool, but always the full Pool:
To resume, the best implementation (at first sight) appears to be the "State" containing only the Ledger and the Async Pool, handling both of their final states and changes. Also the Pool changes could be handled by saving the added messages and removed messages after a slot, or only the added messages which would require to compute which messages were removed. |
Beta Was this translation helpful? Give feedback.
-
Goal
Allow a smart contract to send a message to trigger another smart contract's handler asynchronously.
It works like amazon lambda + SNS:
Note that all the "coins" mentioned in this document are SCE coins.
Message format
How to send a message during bytecode execution
send_message(target_addrress, target_handler, validity_start, validity_end, max_gas, gas_price, coins, payload: JSON string) -> Result<(), ABIReturnError>
. Note that payload has a config defined max_async_message_payload_sizecompute_gas_cost_of_message_storage(context.current_slot, validity_end_slot)
of gas in the current execution. This allows making the message emission more gas-consuming when it requires storing the message in queue for longermax_gas * gas_price + coins
coins from the senderHow is the Async pool handled
In the Async pool, Messages are kept sorted by
priority = max_gas * gas_price
when a Message is added to the Async pool:
At every slot S :
How to receive a message (inside the smart contract)
handle_message(message)
Beta Was this translation helpful? Give feedback.
All reactions