Skip to content
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

Antithesis: Skip checks if tx confirmation fails #3563

Merged
merged 22 commits into from
Nov 22, 2024
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ea8fb82
Antithesis: Skip checks if tx confirmation fails
StephenButtolph Nov 21, 2024
9d42348
[testing] Switch to logging with zap
maru-ava Oct 12, 2024
72d27a9
fixup: Self-review
maru-ava Nov 20, 2024
1192c19
fixup: s/node/nodeID/ in log output
maru-ava Nov 20, 2024
53d0040
fixup: Fix lint failures
maru-ava Nov 20, 2024
5880edc
fixup: Implement SimpleTestContext.Log
maru-ava Nov 20, 2024
4563083
fixup: Switch antithesis to zap
maru-ava Nov 20, 2024
0f24b3e
Update tests/antithesis/avalanchego/main.go
maru-ava Nov 21, 2024
35ba879
Update tests/antithesis/avalanchego/main.go
maru-ava Nov 21, 2024
7cd40f1
Update tests/antithesis/xsvm/main.go
maru-ava Nov 21, 2024
0ea4cd5
Update tests/antithesis/xsvm/main.go
maru-ava Nov 21, 2024
81e0c55
Update tests/e2e/x/transfer/virtuous.go
maru-ava Nov 21, 2024
1b0abce
Update tests/fixture/bootstrapmonitor/e2e/e2e_test.go
maru-ava Nov 21, 2024
bde8d72
Update tests/fixture/e2e/helpers.go
maru-ava Nov 21, 2024
a6cad4a
Update tests/fixture/e2e/helpers.go
maru-ava Nov 21, 2024
9c4e037
Update tests/fixture/e2e/helpers.go
maru-ava Nov 21, 2024
292016a
fixup: Respond to review feedback
maru-ava Nov 21, 2024
b960199
fixup: Rename and move ginkgo-specific logger and fix level output
maru-ava Nov 21, 2024
34ababd
fixup: Update tmpnet network test to define its own logger
maru-ava Nov 21, 2024
248e86a
merged
StephenButtolph Nov 21, 2024
e05b964
merged
StephenButtolph Nov 21, 2024
30052c0
Merge branch 'master' into antithesis-skip-test-on-flaky-error
StephenButtolph Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 82 additions & 23 deletions tests/antithesis/avalanchego/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func main() {
zap.Duration("duration", time.Since(baseStartTime)),
)

genesisWorkload.confirmXChainTx(ctx, baseTx)
require.NoError(genesisWorkload.confirmXChainTx(ctx, baseTx), "failed to confirm initial funding X-chain baseTx")

uri := c.URIs[i%len(c.URIs)]
kc := secp256k1fx.NewKeychain(key)
Expand Down Expand Up @@ -266,7 +266,15 @@ func (w *workload) issueXChainBaseTx(ctx context.Context) {
zap.Duration("duration", time.Since(baseStartTime)),
)

w.confirmXChainTx(ctx, baseTx)
if err := w.confirmXChainTx(ctx, baseTx); err != nil {
w.log.Warn("failed to confirm transaction",
zap.String("chain", "X"),
zap.String("txType", "base"),
zap.Error(err),
)
return
}

w.verifyXChainTxConsumedUTXOs(ctx, baseTx)
}

Expand Down Expand Up @@ -329,7 +337,15 @@ func (w *workload) issueXChainCreateAssetTx(ctx context.Context) {
zap.Duration("duration", time.Since(createAssetStartTime)),
)

w.confirmXChainTx(ctx, createAssetTx)
if err := w.confirmXChainTx(ctx, createAssetTx); err != nil {
w.log.Warn("failed to confirm transaction",
zap.String("chain", "X"),
zap.String("txType", "createAsset"),
zap.Error(err),
)
return
}

w.verifyXChainTxConsumedUTXOs(ctx, createAssetTx)
}

Expand Down Expand Up @@ -409,9 +425,26 @@ func (w *workload) issueXChainOperationTx(ctx context.Context) {
zap.Duration("duration", time.Since(operationStartTime)),
)

w.confirmXChainTx(ctx, createAssetTx)
if err := w.confirmXChainTx(ctx, createAssetTx); err != nil {
w.log.Warn("failed to confirm transaction",
zap.String("chain", "X"),
zap.String("txType", "createAsset"),
zap.Error(err),
)
return
}

w.verifyXChainTxConsumedUTXOs(ctx, createAssetTx)
w.confirmXChainTx(ctx, operationTx)

if err := w.confirmXChainTx(ctx, operationTx); err != nil {
w.log.Warn("failed to confirm transaction",
zap.String("chain", "X"),
zap.String("txType", "operation"),
zap.Error(err),
)
return
}

w.verifyXChainTxConsumedUTXOs(ctx, operationTx)
Copy link
Contributor

Choose a reason for hiding this comment

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

should this method be refactored to return an error? It seems to just log an error if one occurs during but then returns nothing.

I could create a follow up PR if so

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because this function doesn't actually perform any modifications, it isn't required to propagate the error up... So that's why I didn't include that in this PR... But it certainly could.

}

Expand Down Expand Up @@ -497,9 +530,26 @@ func (w *workload) issueXToPTransfer(ctx context.Context) {
zap.Duration("duration", time.Since(importStartTime)),
)

w.confirmXChainTx(ctx, exportTx)
if err := w.confirmXChainTx(ctx, exportTx); err != nil {
w.log.Warn("failed to confirm transaction",
zap.String("chain", "X"),
zap.String("txType", "export"),
zap.Error(err),
)
return
}

w.verifyXChainTxConsumedUTXOs(ctx, exportTx)
w.confirmPChainTx(ctx, importTx)

if err := w.confirmPChainTx(ctx, importTx); err != nil {
w.log.Warn("failed to confirm transaction",
zap.String("chain", "P"),
zap.String("txType", "import"),
zap.Error(err),
)
return
}

w.verifyPChainTxConsumedUTXOs(ctx, importTx)
}

Expand Down Expand Up @@ -583,9 +633,26 @@ func (w *workload) issuePToXTransfer(ctx context.Context) {
zap.Duration("duration", time.Since(importStartTime)),
)

w.confirmPChainTx(ctx, exportTx)
if err := w.confirmPChainTx(ctx, exportTx); err != nil {
w.log.Warn("failed to confirm transaction",
zap.String("chain", "P"),
zap.String("txType", "export"),
zap.Error(err),
)
return
}

w.verifyPChainTxConsumedUTXOs(ctx, exportTx)
w.confirmXChainTx(ctx, importTx)

if err := w.confirmXChainTx(ctx, importTx); err != nil {
w.log.Warn("failed to confirm transaction",
zap.String("chain", "X"),
zap.String("txType", "import"),
zap.Error(err),
)
return
}

w.verifyXChainTxConsumedUTXOs(ctx, importTx)
}

Expand All @@ -599,17 +666,12 @@ func (w *workload) makeOwner() secp256k1fx.OutputOwners {
}
}

func (w *workload) confirmXChainTx(ctx context.Context, tx *xtxs.Tx) {
func (w *workload) confirmXChainTx(ctx context.Context, tx *xtxs.Tx) error {
txID := tx.ID()
for _, uri := range w.uris {
client := avm.NewClient(uri, "X")
if err := avm.AwaitTxAccepted(client, ctx, txID, 100*time.Millisecond); err != nil {
w.log.Warn("failed to confirm X-chain transaction",
zap.Stringer("txID", txID),
zap.String("uri", uri),
zap.Error(err),
)
return
return fmt.Errorf("failed to confirm X-chain transaction %s on %s: %w", txID, uri, err)
marun marked this conversation as resolved.
Show resolved Hide resolved
}
w.log.Info("confirmed X-chain transaction",
zap.Stringer("txID", txID),
Expand All @@ -619,19 +681,15 @@ func (w *workload) confirmXChainTx(ctx context.Context, tx *xtxs.Tx) {
w.log.Info("confirmed X-chain transaction",
zap.Stringer("txID", txID),
)
return nil
}

func (w *workload) confirmPChainTx(ctx context.Context, tx *ptxs.Tx) {
func (w *workload) confirmPChainTx(ctx context.Context, tx *ptxs.Tx) error {
txID := tx.ID()
for _, uri := range w.uris {
client := platformvm.NewClient(uri)
if err := platformvm.AwaitTxAccepted(client, ctx, txID, 100*time.Millisecond); err != nil {
w.log.Warn("failed to confirm P-chain transaction",
zap.Stringer("txID", txID),
zap.String("uri", uri),
zap.Error(err),
)
return
return fmt.Errorf("failed to confirm P-chain transaction %s on %s: %w", txID, uri, err)
}
w.log.Info("confirmed P-chain transaction",
zap.Stringer("txID", txID),
Expand All @@ -641,6 +699,7 @@ func (w *workload) confirmPChainTx(ctx context.Context, tx *ptxs.Tx) {
w.log.Info("confirmed P-chain transaction",
zap.Stringer("txID", txID),
)
return nil
}

func (w *workload) verifyXChainTxConsumedUTXOs(ctx context.Context, tx *xtxs.Tx) {
Expand Down
Loading