transfer: SkipTx=true waits for log entry, doesn't fall back to re-submit (closes #150) - #152
Closed
0g-peterzhb wants to merge 1 commit into
Closed
transfer: SkipTx=true waits for log entry, doesn't fall back to re-submit (closes #150)#1520g-peterzhb wants to merge 1 commit into
0g-peterzhb wants to merge 1 commit into
Conversation
…bmit (closes #150) Today the conditional in uploadSlow + uploadFast is: if !opt.SkipTx || info == nil { submit Flow.submit } so SkipTx only takes effect when checkLogExistence also returns info != nil. On retry inside Client.SplitableUpload (#145), the new Uploader is built against a fresh set of storage nodes from the indexer; those nodes may not have synced the previous Flow.submit yet, so info == nil, and a fresh Flow.submit happens regardless of opt.SkipTx. The caller's wallet pays twice on the unlucky race. Change SkipTx's semantics so it means "the caller asserts the entry IS on chain; wait for storage nodes to see it; do NOT re-submit": if !opt.SkipTx { submit } else if info == nil { info, err = waitForLogEntry(..., TransactionPacked, ...) if err != nil { return ... } } Same shape in uploadSlow and uploadFast. Behavior change for callers passing SkipTx=true when the entry is actually NOT on chain: today they fall back to a fresh submit; with this patch they wait until ctx timeout. That's correct — SkipTx is a deliberate caller assertion that the entry exists; silent re-submit was always a bug (operator wallet pays for a duplicate). The 0g-storage-s3 gateway is the main consumer and uses SkipTx exactly this way (crash-resume with a recorded prior tx hash; retry after a previous attempt's submit succeeded). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #150.
What
After #145 + #149, `Client.SplitableUpload`'s retry correctly sets `opt.SkipTx = true` when the previous attempt landed a Flow.submit. But `uploadSlow` / `uploadFast` gate the skip on `checkLogExistence` returning non-nil `info` — and on retry, the new `Uploader` is built against fresh storage nodes from the indexer that may not have synced the previous submit yet. `info == nil` → fresh `Flow.submit` despite `SkipTx=true` → operator wallet pays twice.
Fix
Split the conditional so `SkipTx=true` means "the caller asserts the entry is on chain; wait for storage nodes to see it; do NOT re-submit." When `info == nil` under `SkipTx=true`, `waitForLogEntry` instead of falling back to submit. Same change in both branches.
```go
if !opt.SkipTx {
// submit
} else if info == nil {
info, err = waitForLogEntry(ctx, tree.Root(), TransactionPacked, 0, false)
if err != nil {
return ..., "SkipTx=true but log entry never appeared on storage node"
}
}
```
Behavior change for callers
A caller passing `SkipTx=true` when the entry is NOT actually on chain used to fall back to a fresh submit; with this fix they would wait until ctx timeout. That's correct — `SkipTx` is a deliberate caller assertion that the entry exists. Silent re-submit was always a bug surface (operator wallet pays for a duplicate). The `0g-storage-s3` gateway, the main consumer of this SDK today, uses `SkipTx` exactly this way:
Test plan
🤖 Generated with Claude Code