Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/kylelemons/godebug v1.1.0
github.com/leanovate/gopter v0.2.11
github.com/lib/pq v1.10.9
github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4
github.com/onsi/gomega v1.36.2
github.com/pelletier/go-toml/v2 v2.2.4
github.com/pkg/errors v0.9.1
Expand Down Expand Up @@ -125,7 +126,6 @@ require (
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 // indirect
github.com/mitchellh/pointerstructure v1.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand Down
3 changes: 0 additions & 3 deletions pkg/config/toml/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,6 @@ func (c *Transactions) ValidateConfig() (err error) {
if c.AutoPurge.Enabled != nil && !*c.AutoPurge.Enabled {
err = multierr.Append(err, commonconfig.ErrInvalid{Name: "AutoPurge.Enabled", Value: false, Msg: "cannot be false if DualBroadcast is enabled"})
}
if c.AutoPurge.DetectionApiUrl == nil {
err = multierr.Append(err, commonconfig.ErrMissing{Name: "AutoPurge.DetectionApiUrl", Msg: "must be set if DualBroadcast is enabled"})
}
if c.AutoPurge.Threshold == nil {
err = multierr.Append(err, commonconfig.ErrMissing{Name: "AutoPurge.Threshold", Msg: "needs to be set if auto-purge feature is enabled"})
} else if *c.AutoPurge.Threshold == 0 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package clientwrappers
package dualbroadcast

import (
"bytes"
Expand All @@ -17,28 +17,31 @@ import (

"github.com/smartcontractkit/chainlink-evm/pkg/client"
"github.com/smartcontractkit/chainlink-evm/pkg/keys"
"github.com/smartcontractkit/chainlink-evm/pkg/txm"
"github.com/smartcontractkit/chainlink-evm/pkg/txm/types"
)

type DualBroadcastClient struct {
var _ txm.Client = &FlashbotsClient{}

type FlashbotsClient struct {
c client.Client
keystore keys.MessageSigner
customURL *url.URL
}

func NewDualBroadcastClient(c client.Client, keystore keys.MessageSigner, customURL *url.URL) *DualBroadcastClient {
return &DualBroadcastClient{
func NewFlashbotsClient(c client.Client, keystore keys.MessageSigner, customURL *url.URL) *FlashbotsClient {
return &FlashbotsClient{
c: c,
keystore: keystore,
customURL: customURL,
}
}

func (d *DualBroadcastClient) NonceAt(ctx context.Context, address common.Address, blockNumber *big.Int) (uint64, error) {
func (d *FlashbotsClient) NonceAt(ctx context.Context, address common.Address, blockNumber *big.Int) (uint64, error) {
return d.c.NonceAt(ctx, address, blockNumber)
}

func (d *DualBroadcastClient) PendingNonceAt(ctx context.Context, address common.Address) (uint64, error) {
func (d *FlashbotsClient) PendingNonceAt(ctx context.Context, address common.Address) (uint64, error) {
body := []byte(fmt.Sprintf(`{"jsonrpc":"2.0","method":"eth_getTransactionCount","params":["%s","pending"], "id":1}`, address.String()))
response, err := d.signAndPostMessage(ctx, address, body, "")
if err != nil {
Expand All @@ -52,7 +55,7 @@ func (d *DualBroadcastClient) PendingNonceAt(ctx context.Context, address common
return nonce, nil
}

func (d *DualBroadcastClient) SendTransaction(ctx context.Context, tx *types.Transaction, attempt *types.Attempt) error {
func (d *FlashbotsClient) SendTransaction(ctx context.Context, tx *types.Transaction, attempt *types.Attempt) error {
meta, err := tx.GetMeta()
if err != nil {
return err
Expand All @@ -75,7 +78,7 @@ func (d *DualBroadcastClient) SendTransaction(ctx context.Context, tx *types.Tra
return d.c.SendTransaction(ctx, attempt.SignedTransaction)
}

func (d *DualBroadcastClient) signAndPostMessage(ctx context.Context, address common.Address, body []byte, urlParams string) (result string, err error) {
func (d *FlashbotsClient) signAndPostMessage(ctx context.Context, address common.Address, body []byte, urlParams string) (result string, err error) {
bodyReader := bytes.NewReader(body)
postReq, err := http.NewRequestWithContext(ctx, http.MethodPost, d.customURL.String()+"?"+urlParams, bodyReader)
if err != nil {
Expand Down
Loading