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

Dual transmission for 2.19.0 #15466

Merged
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2503e98
Txmv2_from_2.18
dimriou Nov 29, 2024
66ec754
Refactor secondary transmission
george-dorin Nov 21, 2024
d866c94
Add dual transmission ABI
george-dorin Nov 21, 2024
f86527b
Update dual transmission ABI
george-dorin Nov 21, 2024
9c438b9
Update ABI
george-dorin Nov 21, 2024
878cdbc
Refactor dual transmitter
george-dorin Nov 25, 2024
44ca083
Add missing test file
george-dorin Nov 25, 2024
3c7dffc
Add missing file
george-dorin Nov 25, 2024
ff5f503
Fix lint
george-dorin Nov 25, 2024
20bbd33
Fix lint
george-dorin Nov 25, 2024
ed78833
Pass txManagerOCR2 to ocr2FeedsDualTransmission
george-dorin Nov 25, 2024
f886386
Add dualTransmission meta validation
george-dorin Nov 27, 2024
3bd32a3
Implement feedback
george-dorin Nov 27, 2024
00c0f63
Add ContractTransmitter helper function
george-dorin Nov 28, 2024
edbde29
Add debug logging
george-dorin Nov 28, 2024
2d900c0
Update chain selector
george-dorin Nov 29, 2024
e56459b
Update chain selector go.mod and go.sum
george-dorin Nov 29, 2024
b52cfbe
Fix config tests
dimriou Nov 29, 2024
840e84d
Fix integration test go.mod lint
george-dorin Nov 29, 2024
4b08b01
Fix integration test load go.sum lint
george-dorin Nov 29, 2024
db484d5
Revert "Fix integration test load go.sum lint"
george-dorin Dec 2, 2024
389b6b4
Revert "Fix integration test go.mod lint"
george-dorin Dec 2, 2024
7185037
Revert "Update chain selector go.mod and go.sum"
george-dorin Dec 2, 2024
bcde6d3
Revert "Update chain selector"
george-dorin Dec 2, 2024
1584d28
Add Abandon support
dimriou Dec 2, 2024
c6e1f2e
Latest TXMv2 updates
dimriou Dec 4, 2024
129c734
Fix CI
dimriou Dec 5, 2024
b603fd7
Add hint and refund validation
george-dorin Dec 5, 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
Prev Previous commit
Next Next commit
Refactor secondary transmission
george-dorin committed Nov 29, 2024
commit 66ec754cf8d4dfe4155d9d13b554d0f864c51637
11 changes: 11 additions & 0 deletions core/services/ocr2/plugins/ccip/transmitter/transmitter.go
Original file line number Diff line number Diff line change
@@ -26,6 +26,9 @@ type txManager interface {
type Transmitter interface {
CreateEthTransaction(ctx context.Context, toAddress common.Address, payload []byte, txMeta *txmgr.TxMeta) error
FromAddress(context.Context) common.Address

SendSecondaryTransaction() bool
CreateSecondaryEthTransaction(ctx context.Context, payload []byte, txMeta *txmgr.TxMeta) error
}

type transmitter struct {
@@ -40,6 +43,14 @@ type transmitter struct {
statuschecker statuschecker.CCIPTransactionStatusChecker // Used for CCIP's idempotency key generation
}

func (t *transmitter) SendSecondaryTransaction() bool {
return false
}

func (t *transmitter) CreateSecondaryEthTransaction(ctx context.Context, payload []byte, txMeta *txmgr.TxMeta) error {
return errors.New("secondary transmission attempted on a non-dual transmitter")
}

// NewTransmitter creates a new eth transmitter
func NewTransmitter(
txm txManager,
49 changes: 39 additions & 10 deletions core/services/ocrcommon/transmitter.go
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@ package ocrcommon

import (
"context"
errors2 "errors"
"fmt"
"math/big"
"net/url"
"slices"
@@ -28,6 +26,9 @@ type txManager interface {
type Transmitter interface {
CreateEthTransaction(ctx context.Context, toAddress common.Address, payload []byte, txMeta *txmgr.TxMeta) error
FromAddress(context.Context) common.Address

SendSecondaryTransaction() bool
CreateSecondaryEthTransaction(ctx context.Context, payload []byte, txMeta *txmgr.TxMeta) error
}

type transmitter struct {
@@ -157,6 +158,14 @@ func (t *transmitter) forwarderAddress() common.Address {
return t.effectiveTransmitterAddress
}

func (t *transmitter) SendSecondaryTransaction() bool {
return false
}

func (t *transmitter) CreateSecondaryEthTransaction(ctx context.Context, payload []byte, txMeta *txmgr.TxMeta) error {
return errors.New("secondary transmission attempted on a non-dual transmitter")
}

func (t *ocr2FeedsTransmitter) CreateEthTransaction(ctx context.Context, toAddress common.Address, payload []byte, txMeta *txmgr.TxMeta) error {
roundRobinFromAddress, err := t.keystore.GetRoundRobinAddress(ctx, t.chainID, t.fromAddresses...)
if err != nil {
@@ -227,13 +236,35 @@ type ocr2FeedsDualTransmission struct {
secondaryMeta map[string][]string
}

func (t *ocr2FeedsDualTransmission) SendSecondaryTransaction() bool {
return true
}

func (t *ocr2FeedsDualTransmission) CreateEthTransaction(ctx context.Context, toAddress common.Address, payload []byte, txMeta *txmgr.TxMeta) error {
// Primary transmission
errPrimary := t.transmitter.CreateEthTransaction(ctx, toAddress, payload, txMeta)
if errPrimary != nil {
errPrimary = fmt.Errorf("skipped primary transmission: %w", errPrimary)
roundRobinFromAddress, err := t.transmitter.keystore.GetRoundRobinAddress(ctx, t.transmitter.chainID, t.transmitter.fromAddresses...)
if err != nil {
return errors.Wrap(err, "skipped OCR transmission, error getting round-robin address")
}

forwarderAddress, err := t.transmitter.forwarderAddress(ctx, roundRobinFromAddress, toAddress)
if err != nil {
return err
}

_, err = t.transmitter.txm.CreateTransaction(ctx, txmgr.TxRequest{
FromAddress: roundRobinFromAddress,
ToAddress: toAddress,
EncodedPayload: payload,
FeeLimit: t.transmitter.gasLimit,
ForwarderAddress: forwarderAddress,
Strategy: t.transmitter.strategy,
Checker: t.transmitter.checker,
Meta: txMeta,
})

return errors.Wrap(err, "skipped OCR transmission: skipped primary transmission")
}
func (t *ocr2FeedsDualTransmission) CreateSecondaryEthTransaction(ctx context.Context, payload []byte, txMeta *txmgr.TxMeta) error {
if txMeta == nil {
txMeta = &txmgr.TxMeta{}
}
@@ -244,8 +275,7 @@ func (t *ocr2FeedsDualTransmission) CreateEthTransaction(ctx context.Context, to
txMeta.DualBroadcast = &dualBroadcast
txMeta.DualBroadcastParams = &dualBroadcastParams

// Secondary transmission
_, errSecondary := t.transmitter.txm.CreateTransaction(ctx, txmgr.TxRequest{
_, err := t.transmitter.txm.CreateTransaction(ctx, txmgr.TxRequest{
FromAddress: t.secondaryFromAddress,
ToAddress: t.secondaryContractAddress,
EncodedPayload: payload,
@@ -255,8 +285,7 @@ func (t *ocr2FeedsDualTransmission) CreateEthTransaction(ctx context.Context, to
Meta: txMeta,
})

errSecondary = errors.Wrap(errSecondary, "skipped secondary transmission")
return errors2.Join(errPrimary, errSecondary)
return errors.Wrap(err, "skipped secondary transmission")
}

func (t *ocr2FeedsDualTransmission) FromAddress(ctx context.Context) common.Address {
19 changes: 18 additions & 1 deletion core/services/relay/evm/contract_transmitter.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"encoding/hex"
errors2 "errors"
"math/big"
"time"

@@ -34,6 +35,9 @@ var _ ContractTransmitter = &contractTransmitter{}
type Transmitter interface {
CreateEthTransaction(ctx context.Context, toAddress gethcommon.Address, payload []byte, txMeta *txmgr.TxMeta) error
FromAddress(context.Context) gethcommon.Address

SendSecondaryTransaction() bool
CreateSecondaryEthTransaction(ctx context.Context, payload []byte, txMeta *txmgr.TxMeta) error
}

type ReportToEthMetadata func([]byte) (*txmgr.TxMeta, error)
@@ -162,7 +166,20 @@ func (oc *contractTransmitter) Transmit(ctx context.Context, reportCtx ocrtypes.
return errors.Wrap(err, "abi.Pack failed")
}

return errors.Wrap(oc.transmitter.CreateEthTransaction(ctx, oc.contractAddress, payload, txMeta), "failed to send Eth transaction")
err = errors.Wrap(oc.transmitter.CreateEthTransaction(ctx, oc.contractAddress, payload, txMeta), "failed to send Eth transaction")

if oc.transmitter.SendSecondaryTransaction() {
secondaryPayload, err2 := oc.contractABI.Pack("transmitSecondary", rawReportCtx, []byte(report), rs, ss, vs)
if err2 != nil {
return errors.Wrap(err2, "abi.Pack failed")
}

err3 := errors.Wrap(oc.transmitter.CreateSecondaryEthTransaction(ctx, secondaryPayload, txMeta), "failed to send secondary Eth transaction")
return errors2.Join(err, err3)
}

return err

}

type contractReader interface {
8 changes: 8 additions & 0 deletions core/services/relay/evm/contract_transmitter_test.go
Original file line number Diff line number Diff line change
@@ -34,6 +34,14 @@ type mockTransmitter struct {
lastPayload []byte
}

func (m *mockTransmitter) SendSecondaryTransaction() bool {
return false
}

func (m *mockTransmitter) CreateSecondaryEthTransaction(ctx context.Context, payload []byte, txMeta *txmgr.TxMeta) error {
return nil
}

func (m *mockTransmitter) CreateEthTransaction(ctx context.Context, toAddress gethcommon.Address, payload []byte, _ *txmgr.TxMeta) error {
m.lastPayload = payload
return nil