-
Notifications
You must be signed in to change notification settings - Fork 12
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
Make sure contract calls apply to the current open block. #75
Comments
Alternatively, instead of changing what's passed into |
Another complication is that we need the client to turn the call data into a transaction first. It looks like we'll need to change the |
Is this actually possible for any node except the currently mining validator? |
No, these methods would all be just for use-cases like ours, where the current block author has to make contract calls. |
@afck what would happen if any other node tried to do this? |
You can only call the methods with a mutable |
I have an implementation that seems to work now: I realized that So we can't assume that we're creating a block in either of those calls. I'm not entirely sure what we can assume: E.g. if someone sent us any bogus block, could they trick us into creating a transaction that reveals our secret? Maybe it's cleanest to add yet another method to Edit: Possibly something like fn on_new_mining_block(&self, _block: &mut M::LiveBlock) -> Result<(), M::Error>; or fn block_author_transactions(&self) -> Result<Vec<SignedTransaction>, M::Error>; (where the latter would just use |
@afck I will handle this. |
|
Caveat: |
Marking as low-priority, per discussion on Zoom. The current approach is more robust, and fixing this should be left until after the network is operational. |
@afck Could we close this? |
We are currently adding the randomness contract calls (#51) to the transaction queue in
AuthorityRound::on_new_block
and assume they will be applied to the current open block. We make the constant calls via theEngineClient
usingBlockId::Latest
and assume that will always give us up-to-date information.We should either verify that our assumptions are correct, or make those calls in a more direct way to the currently open block.
It would be easy to pass an
OpenBlock
toon_new_block
instead of anExecutedBlock
: It is available asr
at the only call site,OpenBlock::new
.OpenBlock
has apush_transaction
method that would allow us to add transactions directly, without the queue.Client::call_contract
, which is currently used for the constant calls, first turns the call into a transaction inClient::contract_call_tx
and then passes it toClient::call
, which in turn usesClient::do_virtual_call
(a static method) to retrieve the result of the transaction. Note that this updates the state, but that state object is just a local copy that has been created incall_contract
.Client::do_virtual_call
usesExecutive::transact_virtual
, which automatically adds sufficient gas to the state and executes the transaction. (The method name seems to be misleading: it is meant to be used with cloned state objects that won't be persisted anywhere, but what the method does is no more virtual thanExecutive::transact
.)We should probably do something like
Client::contract_call_tx
inBoundContract
, and then just useClient::call
with a clone of the current block's state.The text was updated successfully, but these errors were encountered: