Skip to content

Soft Bundle authority API implementation#17868

Merged
mystenmark merged 7 commits intoMystenLabs:mainfrom
shio-coder:authority_draft
Jun 17, 2024
Merged

Soft Bundle authority API implementation#17868
mystenmark merged 7 commits intoMystenLabs:mainfrom
shio-coder:authority_draft

Conversation

@shio-coder
Copy link
Copy Markdown
Contributor

Description

This is a follow up change after PR #17508 , for SIP-19.

The changeset focuses on sui-core, particularly authority server, to add a new API SoftBundleCertifiedTransactionsV3 that allows submission of a Soft Bundle through gRPC.

The API accepts a list of CertifiedTransaction for input, then returns either nothing (should wait_for_effects be false) or a list of HandleCertificateResponseV3 containing the execution result.

The API is named _v3 because it reuses HandleCertificateResponseV3.

Besides introducing a new feature flag and a protocol config field, a local node config field enable_soft_bundle is also added, to allow a validator node to turn off soft bundle support without having to upgrade the entire network. This can be useful should the feature causes undesired effect.

Test plan

The feature is not exactly user-facing and do not break anything.


Release notes

  • Protocol: New feature flag and protocol config fields will be introduced.
  • Nodes (Validators and Full nodes): A new API SoftBundleCertifiedTransactionsV3 will be added.
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:

@shio-coder shio-coder requested a review from mystenmark as a code owner May 22, 2024 07:36
@vercel
Copy link
Copy Markdown

vercel bot commented May 22, 2024

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

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 15, 2024 6:26am

@vercel
Copy link
Copy Markdown

vercel bot commented May 22, 2024

@shio-coder is attempting to deploy a commit to the Mysten Labs Team on Vercel.

A member of the Team first needs to authorize it.

// For owned objects this will return without waiting for certificate to be sequenced
// First do quick dirty non-async check
if !epoch_store.is_tx_cert_consensus_message_processed(&certificate)? {
if !epoch_store.is_all_tx_certs_consensus_message_processed(&verified_certificates)? {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

iiuc, this means that if a single transaction in the bundle is unprocessed, we will re-submit the entire bundle. That's okay from the protocol perspective, but is that what is desired for the submitter of the soft bundle? Or would they rather fail in this case, since it is known their bundle will not be sequenced in the order they expect?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The intention here is to wait for all txs to be sequenced before proceeding. In a Soft Bundle context, the check was done previously (by using self.state.is_tx_already_executed()).

However this check cannot be enforced as another thread or another validator may be submitting a subset of the bundle and/or the entire bundle.

This falls into the case where Soft Bundle cannot guarantee specified ordering.

})
.collect::<Vec<_>>();
self.consensus_adapter.submit_batch(
&transactions,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems like a potential bug, since we may be submitting already sequenced transactions, which would then be inserted into process_consensus_transactions. But it may be benign since insertions into that table are already racing with consensus handler. @mwtian any thoughts?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My reading of the code is that this change does not seem to introduce new behavior. Transactions inflight or already sequenced in consensus can be submitted to consensus adapter, as mentioned by the "quick dirty non-async check" above. This behavior should be tolerated right now. I think only unique transactions by digests are or can be used for epoch change and revert.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree - any extra checkpointed transactions in that table are ignored and not reverted

.contains_key(key)?)
}

pub fn check_consensus_messages_processed<'a>(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we have to remove the lifetime and pass-by-reference? I think we should be able to call this from is_any_tx_certs_consensus_message_processed and also pass by reference?

Copy link
Copy Markdown
Contributor Author

@shio-coder shio-coder Jun 13, 2024

Choose a reason for hiding this comment

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

I have updated this a bit so that there is no copy involved. Now is_any_tx_certs_consensus_message_processed would have lifetime and pass-by-reference, then it owns keys until it is passed to and consumed by this function.

/// Soft Bundle request. See [SIP-19](https://github.com/sui-foundation/sips/blob/main/sips/sip-19.md).
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct HandleSoftBundleCertificatesRequestV3 {
pub certificates: Vec<CertifiedTransaction>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should use the NonEmpty type here so that we don't have to worry about whether it is empty.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is part of gRPC protocol definition and it seems Serialize is not implemented for NonEmpty

let should_submit = if is_soft_bundle {
fp_ensure!(
!epoch_store
.is_any_tx_certs_consensus_message_processed(&verified_certificates)?,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you move this check to be together with all the other soft bundle specific checks, here you can simply submit if any cert is not already submitted. Once you do so, we could then even remove the is_soft_bundle argument from this function.

Copy link
Copy Markdown
Contributor Author

@shio-coder shio-coder Jun 13, 2024

Choose a reason for hiding this comment

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

I have moved the check to soft_bundle_validity_check, which is closer to its RPC handler.
Now the only place that relies on is_soft_bundle is where we determine whether it is necessary to check if the first certificate has been executed.

Copy link
Copy Markdown
Contributor

@lxfind lxfind left a comment

Choose a reason for hiding this comment

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

Overall LGTM. Thanks!

@mystenmark mystenmark merged commit ff05210 into MystenLabs:main Jun 17, 2024
mystenmark added a commit that referenced this pull request Jun 26, 2024
## Description 

This is a follow up change after PR #17508 and #17868 , for SIP-19.

The change adds a unit test for soft bundle failure modes, as well as
enable soft bundle feature flag in devnet and testnet.

## Test plan 

The feature is not exactly user-facing and do not break anything.

---

## Release notes

- [x] Protocol: Enable soft bundle on Protocol Version 50 in devnet and
testnet.
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:

---------

Co-authored-by: Mark Logan <103447440+mystenmark@users.noreply.github.com>
tx-tomcat pushed a commit to tx-tomcat/sui-network that referenced this pull request Jul 29, 2024
## Description 

This is a follow up change after PR MystenLabs#17508 , for
[SIP-19](https://github.com/sui-foundation/sips/blob/main/sips/sip-19.md).

The changeset focuses on sui-core, particularly authority server, to add
a new API `SoftBundleCertifiedTransactionsV3` that allows submission of
a Soft Bundle through gRPC.

The API accepts a list of `CertifiedTransaction` for input, then returns
either nothing (should `wait_for_effects` be `false`) or a list of
`HandleCertificateResponseV3` containing the execution result.

The API is named `_v3` because it reuses `HandleCertificateResponseV3`. 

Besides introducing a new feature flag and a protocol config field, a
local node config field `enable_soft_bundle` is also added, to allow a
validator node to turn off soft bundle support without having to upgrade
the entire network. This can be useful should the feature causes
undesired effect.

## Test plan 

The feature is not exactly user-facing and do not break anything.

---

## Release notes

- [x] Protocol: New feature flag and protocol config fields will be
introduced.
- [x] Nodes (Validators and Full nodes): A new API
`SoftBundleCertifiedTransactionsV3` will be added.
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:

---------

Co-authored-by: Mark Logan <mark@mystenlabs.com>
tx-tomcat pushed a commit to tx-tomcat/sui-network that referenced this pull request Jul 29, 2024
## Description 

This is a follow up change after PR MystenLabs#17508 and MystenLabs#17868 , for SIP-19.

The change adds a unit test for soft bundle failure modes, as well as
enable soft bundle feature flag in devnet and testnet.

## Test plan 

The feature is not exactly user-facing and do not break anything.

---

## Release notes

- [x] Protocol: Enable soft bundle on Protocol Version 50 in devnet and
testnet.
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:

---------

Co-authored-by: Mark Logan <103447440+mystenmark@users.noreply.github.com>
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.

4 participants