Skip to content

Commit

Permalink
Merge branch 'finalizationTx' into 'main'
Browse files Browse the repository at this point in the history
finalization in grace period sends transaction without dry run

See merge request flarenetwork/flare-system-client!57
  • Loading branch information
GrePod committed Dec 22, 2024
2 parents 6c15b0a + 8e712d7 commit ae69f63
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/finalizer/finalizer_client_test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ type sentTxInfo struct {
data []byte
}

func (eth *testEthClient) SendRawTx(privateKey *ecdsa.PrivateKey, to common.Address, data []byte, _ *config.Gas, _ time.Duration) error {
func (eth *testEthClient) SendRawTx(privateKey *ecdsa.PrivateKey, to common.Address, data []byte, _ *config.Gas, _ time.Duration, _ bool) error {
eth.mu.Lock()
defer eth.mu.Unlock()

Expand Down
2 changes: 1 addition & 1 deletion client/finalizer/relay_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (r *relayContractClient) SubmitPayloads(ctx context.Context, input []byte,
}

execStatusChan := shared.ExecuteWithRetryChan(func() (string, error) {
err := r.chainClient.SendRawTx(r.privateKey, r.address, input, r.gasConfig, chain.DefaultTxTimeout)
err := r.chainClient.SendRawTx(r.privateKey, r.address, input, r.gasConfig, chain.DefaultTxTimeout, dryRun)
if err != nil {
if shared.ExistsAsSubstring(nonFatalRelayErrors, err.Error()) {
logger.Debugf("Non fatal error sending relay tx for protocol %d: %v", protocolID, err)
Expand Down
2 changes: 1 addition & 1 deletion client/protocol/protocol_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ type sentTxInfo struct {
}

func (c *testChainClient) SendRawTx(
privateKey *ecdsa.PrivateKey, to common.Address, payload []byte, _ *clientConfig.Gas, _ time.Duration,
privateKey *ecdsa.PrivateKey, to common.Address, payload []byte, _ *clientConfig.Gas, _ time.Duration, _ bool,
) error {
c.sentTxs = append(c.sentTxs, &sentTxInfo{
privateKey: privateKey,
Expand Down
2 changes: 1 addition & 1 deletion client/protocol/submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (s *SubmitterBase) submit(payload []byte) bool {
sendResult := <-shared.ExecuteWithRetryAttempts(func(ri int) (any, error) {
gasConfig := gasConfigForAttempt(s.gasConfig, ri)
logger.Debugf("[Attempt %d] Submitter %s sending tx with gas config: %+v, timeout: %s", ri, s.name, gasConfig, s.submitTimeout)
err := s.chainClient.SendRawTx(s.submitPrivateKey, s.protocolContext.submitContractAddress, payload, gasConfig, s.submitTimeout)
err := s.chainClient.SendRawTx(s.submitPrivateKey, s.protocolContext.submitContractAddress, payload, gasConfig, s.submitTimeout, true)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("error sending submit tx for submitter %s tx", s.name))
}
Expand Down
8 changes: 4 additions & 4 deletions utils/chain/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ import (
)

type Client interface {
SendRawTx(privateKey *ecdsa.PrivateKey, to common.Address, payload []byte, gasConfig *config.Gas, timeout time.Duration) error
SendRawTx(privateKey *ecdsa.PrivateKey, to common.Address, payload []byte, gasConfig *config.Gas, timeout time.Duration, dryRun bool) error
}

type ClientImpl struct {
EthClient *ethclient.Client
}

// SendRawTx sends a transaction with payload signed by privateKey to to address.
func (c ClientImpl) SendRawTx(privateKey *ecdsa.PrivateKey, to common.Address, payload []byte, gasConfig *config.Gas, timeout time.Duration) error {
func (c ClientImpl) SendRawTx(privateKey *ecdsa.PrivateKey, to common.Address, payload []byte, gasConfig *config.Gas, timeout time.Duration, dryRun bool) error {
switch gasConfig.TxType {
case 0:
return SendRawTx(c.EthClient, privateKey, to, payload, true, gasConfig, timeout)
return SendRawTx(c.EthClient, privateKey, to, payload, dryRun, gasConfig, timeout)
case 2:
return SendRawType2Tx(c.EthClient, privateKey, to, payload, true, gasConfig, timeout)
return SendRawType2Tx(c.EthClient, privateKey, to, payload, dryRun, gasConfig, timeout)
default:
return errors.New("unsupported tx type: set TxType to 0 or 2")
}
Expand Down

0 comments on commit ae69f63

Please sign in to comment.