Skip to content

sae: Implement AtomicRequests on custom txs#5325

Merged
StephenButtolph merged 153 commits intomasterfrom
StephenButtolph/atomic-tx-rewrite.3
May 4, 2026
Merged

sae: Implement AtomicRequests on custom txs#5325
StephenButtolph merged 153 commits intomasterfrom
StephenButtolph/atomic-tx-rewrite.3

Conversation

@StephenButtolph
Copy link
Copy Markdown
Contributor

@StephenButtolph StephenButtolph commented Apr 28, 2026

Why this should be merged

This PR factors out Tx.AtomicRequests from #5303.

How this works

This function is almost exactly taken from coreth, the implementations are almost identical.

How this was tested

  • Added to tx test vectors.
  • Fuzzed against the existing coreth implementation.

Need to be documented in RELEASES.md?

No

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR factors out and exposes Tx.AtomicRequests() for SAE custom C-Chain atomic transactions (import/export), aligning the shared-memory request generation with the existing coreth implementation.

Changes:

  • Add AtomicRequests() on *Tx and plumb an atomicRequests(txID) method through the Unsigned interface.
  • Implement shared-memory request generation for Import (remove requests) and Export (put requests).
  • Extend unit tests and add a fuzz compatibility test against the coreth implementation.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
vms/saevm/cchain/tx/tx.go Adds the exported Tx.AtomicRequests() API and extends the Unsigned interface with atomicRequests(txID).
vms/saevm/cchain/tx/import.go Implements Import.atomicRequests to produce shared-memory remove operations for imported UTXOs.
vms/saevm/cchain/tx/export.go Implements Export.atomicRequests to produce shared-memory put operations for exported UTXOs (including traits).
vms/saevm/cchain/tx/tx_test.go Adds test-vector expectations and a unit test for AtomicRequests().
vms/saevm/cchain/tx/compatibility_test.go Adds fuzz test validating compatibility with coreth’s AtomicOps() output.
vms/saevm/cchain/tx/BUILD.bazel Adds Bazel deps for //chains/atomic to library and tests.
go.work.sum Updates workspace module sums due to dependency graph changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread vms/saevm/cchain/tx/import.go
Comment thread vms/saevm/cchain/tx/export.go Outdated
Base automatically changed from StephenButtolph/atomic-tx-rewrite.2 to master May 2, 2026 16:05
Copy link
Copy Markdown
Contributor

@powerslider powerslider left a comment

Choose a reason for hiding this comment

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

LGTM! The only optional addition I can think of is a synthetic export test case with two or more recipient addresses, because the static cases only ever exercise single-address outputs, so the path that attaches multiple address traits to an exported UTXO is currently only validated by the fuzzer (which is still fine).

Copy link
Copy Markdown
Contributor

@alarso16 alarso16 left a comment

Choose a reason for hiding this comment

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

Lots of commits since my review, but all nits

Comment thread vms/saevm/cchain/tx/export.go
Comment on lines +39 to +46
Name string
Old *atomic.Tx
New *Tx
JSON string
Bytes []byte
Op hook.Op
AtomicRequestsChainID ids.ID
AtomicRequests *chainsatomic.Requests
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 feel like this is getting pretty dense, and could maybe be split into more focused helpers / tables?

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.

I agree, but this is also the last modification to this Tests vector that I'm planning on making...

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.

I can't think of anything better... Sooo :shipit:

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 someone else is concerned about this in the future, I think it's worth taking another look at. It does make tests harder to reason about and compartmentalize. Not blocking though

@StephenButtolph StephenButtolph enabled auto-merge May 4, 2026 16:55
@StephenButtolph StephenButtolph disabled auto-merge May 4, 2026 16:56
@StephenButtolph StephenButtolph added this pull request to the merge queue May 4, 2026
Merged via the queue into master with commit c1ee39b May 4, 2026
60 checks passed
@StephenButtolph StephenButtolph deleted the StephenButtolph/atomic-tx-rewrite.3 branch May 4, 2026 17:44
@github-project-automation github-project-automation Bot moved this from In Progress 🏗️ to Done 🎉 in avalanchego May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done 🎉

Development

Successfully merging this pull request may close these issues.

5 participants