-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
Add RPC endpoint to call tx without commit #4514
Conversation
45926c8
to
4129166
Compare
4129166
to
fdf7e17
Compare
fdf7e17
to
48085aa
Compare
crates/sui-json-rpc/src/api.rs
Outdated
#[method(name = "callTransaction")] | ||
async fn call_transaction( | ||
&self, | ||
tx_bytes: Base64, | ||
sig_scheme: SignatureScheme, | ||
signature: Base64, | ||
pub_key: Base64, | ||
) -> RpcResult<SuiTransactionEffects>; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just my personal opinion :)
will calling it dry_run_transaction
makes it more obvious that this method doesn't commit? call_transaction is a bit ambiguous for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also I think it makes more sense to put it in QuorumDriverApi
together with execute_transaction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patrickkuo dry_run_transaction
is a better name indeed, will change it accordingly!
to put it in QuorumDriverApi
I was thinking about this as well, if I do it this way, iirc the "dry_tx" will go to NetworkAuthorityClient
and then try to reach validators, instead of executing it on the local fullnode following the current impl.
Executing locally on the fullnode is better I think bc
- its not necessary to involve validators here
- dry run request traffic on the fullnode is isolated from other nodes in case of abusing
Did I miss sth?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to do this we will need to pass in the AuthorityState to the FullNodeQuorumDriverApi, this should execute locally.
Having 2nd thoughts, the QuorumDriver is configurable, so fullnode can choose to disable it, maybe it's not a good idea to put it in QuorumDriverApi depends on the use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the QuorumDriver is configurable, so fullnode can choose to disable it
right, iirc QuorumDriver drives txns with a quorum of validators as the name says, and dry_run to me is more like a read-only endpoint.
crates/sui-core/src/authority.rs
Outdated
|
||
// At this point we need to check if any shared objects need locks, | ||
// and whether they have them. | ||
let shared_object_refs = input_objects.filter_shared_objects(); | ||
if !shared_object_refs.is_empty() && !certificate.signed_data.data.kind.is_system_tx() { | ||
if !shared_object_refs.is_empty() && !transaction.signed_data.data.kind.is_system_tx() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the transaction contains shared objects, we need to ensure they have been scheduled
// for processing by the consensus protocol.
Does this also apply to call_transaction
? If so, it seems to open up a vulnerability for DDOS where consensus protocol can be called without gas. cc @lxfind
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iirc, check_shared_locks
only checks local DB of AuthorityState, and the fullnode that processes this dry_run request will not send it elsewhere either, so it will not add extra traffic or workload to other nodes.
https://github.com/gegaowp/sui/blob/5d346fdcceb3e0f42b2b23feb7cffd367a98ed49/crates/sui-core/src/authority.rs#L530
will leave it to Xun to confirm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, this only checks for shared object locks, and does not do consensus.
However, if a transaction does involve shared objects, trying to execute it here without consensus is not going to work.
What do we want to do with call_transaction that involves shared objects? Maybe we should abort it earlier in call_transaction by checking this first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lxfind thanks for the info!
trying to execute it here without consensus is not going to work.
other than the sequence number, does the execution also need anything else from consensus?
What do we want to do with call_transaction that involves shared objects?
the original idea is to implement an eth_call equivalent so ideally we can dry run txns with shared objects as well, but if that is indeed tricky, I think it would still be useful for owned objects only. And yes I should abort earlier if do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sequence number is what it needs, which is usually set by the consensus.
One alternative is that you could just use whatever is the latest state of the shared objects to execute the transaction, which may be useful in most cases if the shared object is not updated all the time. To do that, you can probably bypass the shared object lock check if it's attempting to execute a transaction instead of a certificate.
Some tests would be useful just to make sure this works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lxfind I made a couple of changes accordingly and it should be ready for another review, thanks!
- dry run will skip the shared objects check, I also reverted the helper function change as code sharing is small now
- added a dry run test.
48d6746
to
05484e2
Compare
05484e2
to
1128d0c
Compare
1128d0c
to
a7af667
Compare
Tests: