Skip to content

[consensus] Return consensus position when calling submit_transaction #22157

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

arun-koshy
Copy link
Contributor

@arun-koshy arun-koshy commented May 16, 2025

Description

Moved logic from old submit_transaction path to get_effects. New submit_transaction path will only submit transaction to consensus and get back the consensus position. get_effects will not submit to consensus and will just check if effects are available to be returned. This path may be deprecated if we don't have any use for it once wait_for_effects is in.

ConsensusTxPosition is based on the tx indices calculated while transactions are being pulled when the block is being generated in try_new_block. There is no guarantee that a returned ConsensusTxPosition will be sequenced and it is up to the client to retry and get a new consensus position if needed.

Test plan

Still working on adding tests


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:

@arun-koshy arun-koshy requested review from lxfind and mwtian May 16, 2025 20:56
@arun-koshy arun-koshy requested a review from a team as a code owner May 16, 2025 20:56
Copy link

vercel bot commented May 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) May 16, 2025 8:56pm
sui-kiosk ⬜️ Ignored (Inspect) May 16, 2025 8:56pm

@arun-koshy arun-koshy temporarily deployed to sui-typescript-aws-kms-test-env May 16, 2025 20:56 — with GitHub Actions Inactive
Comment on lines +565 to +574
#[error(
"Failure serializing consensus position in the requested format: {:?}",
error
)]
ConsensusPositionSerializationError { error: String },
#[error(
"Failure deserializing consensus position from the provided format: {:?}",
error
)]
ConsensusPositionDeserializationError { error: String },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can now use the unified grpc serde errors

})
}

async fn handle_get_effects(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably do want to use wait_for_effects since it handles the wait within the validator, instead of client keeping polling and wait.
On a side note the function name handle_vote_transaction is a bit strange in AuthorityState. I seems to be literally getting executed effects.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lxfind are you proposing on not introducing the handle_get_effects?

I thought that handle_vote_transaction is also acquiring locks if tx hasn't been executed , no? Which also made me curious if that would be ok to do when calling the get_effects

Copy link
Contributor

@akichidis akichidis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments for now, but I would like to do another pass and catch up about the changes

@@ -548,7 +572,7 @@ mod tests {
// Now iterate over all the waiters. Everyone should have been acknowledged.
let mut block_status_waiters = Vec::new();
while let Some(result) = included_in_block_waiters.next().await {
let (block_ref, block_status_waiter) =
let (block_ref, _tx_indices, block_status_waiter) =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please extend the test to ensure that the correct indexes are getting calculated? (batched & single txes)

Comment on lines +562 to +564
// TODO(fastpath): Skip checking for execution effects
// Effects are useless in mfp if they cannot be mapped to a consensus
// position
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the effects will always be checked against a tx of a specific consensus position right?

})
}

async fn handle_get_effects(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lxfind are you proposing on not introducing the handle_get_effects?

I thought that handle_vote_transaction is also acquiring locks if tx hasn't been executed , no? Which also made me curious if that would be ok to do when calling the get_effects

})
}

async fn handle_get_effects(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arun-koshy could you please add a couple of lines of what someone should expect from the handle_get_effects request?

}

#[derive(Clone, prost::Message)]
pub struct RawGetEffectsRequest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why some responses are returned as "raw" on the API (where we explicitly serialise the fields) and others not? (ex the HandleCertificateResponseV2). Does it have to do with the ability of the server to serialise the properties it self or for reasons of determinism?

Comment on lines +833 to +835
// to the submitting client. They can handle retries as needed
// if the consensus position does not return the desired results
// (e.g. not sequenced due to garbage collection).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is the client going to find out the new position?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants