Skip to content

feat: add ExpectedSimulationFailureRule to ContractWriter.SubmitTransaction#1894

Draft
Fletch153 wants to merge 4 commits intomainfrom
PLEX-2604/add-submit-transaction-failure-rules
Draft

feat: add ExpectedSimulationFailureRule to ContractWriter.SubmitTransaction#1894
Fletch153 wants to merge 4 commits intomainfrom
PLEX-2604/add-submit-transaction-failure-rules

Conversation

@Fletch153
Copy link

Summary

  • Adds ExpectedSimulationFailureRule struct (ErrorContains string) to pkg/types/ and a new []ExpectedSimulationFailureRule parameter to ContractWriter.SubmitTransaction
  • Adds corresponding proto messages to contract_writer.proto (field 8) and aptos.proto (field 4) with regenerated Go code
  • Wires gRPC client/server via FailureRulesToProto/FailureRulesFromProto converter functions, following the existing TxMeta pattern
  • Adds UnimplementedContractWriter forward-compat base type
  • Updates all in-repo call sites and test fakes

Breaking Change

ContractWriter.SubmitTransaction signature now requires an additional []ExpectedSimulationFailureRule parameter. All implementations must update their signatures. Pass nil to preserve existing behavior.

Context

chainlink-aptos (NONEVM-2618) added ExpectedSimulationFailureRule to its TXM Enqueue, but SubmitTransaction (the product-agnostic interface in chainlink-common) didn't carry these rules. This change enables failure rules to flow from callers through the LOOP gRPC boundary to chain-specific implementations.

Test plan

  • Converter round-trip tests (nil, empty, populated) for both directions
  • go build ./... passes
  • go test ./... passes (pre-existing otelzap failure unrelated)
  • CI pipeline (lint, tests, gorelease API diff)

@github-actions
Copy link

👋 Fletch153, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@github-actions
Copy link

github-actions bot commented Mar 12, 2026

⚠️ API Diff Results - github.com/smartcontractkit/chainlink-common

⚠️ Breaking Changes (3)

pkg/capabilities/pb.(*InitialiseRequest) (1)
  • GetTriggerEventStoreId — 🗑️ Removed
pkg/capabilities/pb.InitialiseRequest (1)
  • TriggerEventStoreId — 🗑️ Removed
pkg/types.ContractWriter (1)
  • SubmitTransaction — Type changed:
func(
  context.Context, 
  string, 
  string, 
  any, 
  IdempotencyKey, 
  string, 
  *TxMeta, 
  *math/big.Int, 
  + *SimulationOptions
)
error

✅ Compatible Changes (9)

pkg/chains/aptos (2)
  • ExpectedSimulationFailureError — ➕ Added

  • SimulationOptions — ➕ Added

pkg/chains/aptos.(*SubmitTransactionRequest) (1)
  • GetSimulationOptions — ➕ Added
pkg/chains/aptos.SubmitTransactionRequest (1)
  • SimulationOptions — ➕ Added
pkg/types (2)
  • ExpectedSimulationFailureError — ➕ Added

  • SimulationOptions — ➕ Added

pkg/types/chains/aptos (2)
  • ExpectedSimulationFailureError — ➕ Added

  • SimulationOptions — ➕ Added

pkg/types/chains/aptos.SubmitTransactionRequest (1)
  • SimulationOptions — ➕ Added

📄 View full apidiff report

}

func (c *Client) SubmitTransaction(ctx context.Context, contractName, method string, params any, transactionID, toAddress string, meta *types.TxMeta, value *big.Int) error {
func (c *Client) SubmitTransaction(ctx context.Context, contractName, method string, params any, transactionID, toAddress string, meta *types.TxMeta, value *big.Int, expectedSimulationFailureRules []types.ExpectedSimulationFailureRule) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

You could avoid future breaking changes by switching to a single struct arg like grpc uses:

Suggested change
func (c *Client) SubmitTransaction(ctx context.Context, contractName, method string, params any, transactionID, toAddress string, meta *types.TxMeta, value *big.Int, expectedSimulationFailureRules []types.ExpectedSimulationFailureRule) error {
func (c *Client) SubmitTransaction(ctx context.Context, req SubmitTransactionRequest) error {

Copy link
Author

Choose a reason for hiding this comment

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

I was thinking of doing this tbh, i've done this for SimulationOptions (in a recent commit) but perhaps it's better we go with a single request argument struct as you suggested

@Fletch153 Fletch153 force-pushed the PLEX-2604/add-submit-transaction-failure-rules branch from 678ec6f to c5b583c Compare March 13, 2026 09:18
@Fletch153 Fletch153 force-pushed the PLEX-2604/add-submit-transaction-failure-rules branch from c5b583c to 6d243cf Compare March 13, 2026 09:28
Replace the trailing expectedSimulationFailureRules parameter with
*SimulationOptions, a struct wrapping both SimulateTransaction (bool)
and ExpectedSimulationFailureErrors. The pointer type makes it nil-able
so existing callers can pass nil to use the implementation's default
simulation behavior.

Changes:
- Add SimulationOptions and ExpectedSimulationFailureError types
- Update ContractWriter interface and UnimplementedContractWriter
- Update proto schemas (contract_writer.proto, aptos.proto) with
  SimulationOptions message
- Regenerate proto Go files
- Update LOOP bridge client/server and converters
- Add SimulationOptions to Aptos SubmitTransactionRequest Go type
  and wire up proto converters
- Update all callers and test helpers
@Fletch153 Fletch153 force-pushed the PLEX-2604/add-submit-transaction-failure-rules branch from 6d243cf to ea5d387 Compare March 13, 2026 09:39
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.

2 participants