From a0fbd3a5b24bb46aba98d55ee696eea561f5ff4b Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Fri, 1 Nov 2024 16:03:58 -0500 Subject: [PATCH] deployment: use pointer for eth tx (#15039) --- core/scripts/chaincli/handler/report.go | 6 +++--- deployment/environment/devenv/chain.go | 2 +- deployment/environment/memory/environment.go | 2 +- deployment/helpers.go | 2 +- deployment/multiclient.go | 8 +++----- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/core/scripts/chaincli/handler/report.go b/core/scripts/chaincli/handler/report.go index eb4ce5c83ac..2bd09c6543d 100644 --- a/core/scripts/chaincli/handler/report.go +++ b/core/scripts/chaincli/handler/report.go @@ -210,7 +210,7 @@ func NewOCR2Transaction(raw map[string]interface{}) (*OCR2Transaction, error) { encoder: evm.EVMAutomationEncoder20{}, abi: contract, raw: raw, - tx: tx, + tx: &tx, }, nil } @@ -218,7 +218,7 @@ type OCR2Transaction struct { encoder evm.EVMAutomationEncoder20 abi abi.ABI raw map[string]interface{} - tx types.Transaction + tx *types.Transaction } func (t *OCR2Transaction) TransactionHash() common.Hash { @@ -252,7 +252,7 @@ func (t *OCR2Transaction) To() *common.Address { func (t *OCR2Transaction) From() (common.Address, error) { switch t.tx.Type() { case 2: - from, err := types.Sender(types.NewLondonSigner(t.tx.ChainId()), &t.tx) + from, err := types.Sender(types.NewLondonSigner(t.tx.ChainId()), t.tx) if err != nil { return common.Address{}, fmt.Errorf("failed to get from addr: %s", err) } else { diff --git a/deployment/environment/devenv/chain.go b/deployment/environment/devenv/chain.go index 2a2b58e4100..cdbaf35e860 100644 --- a/deployment/environment/devenv/chain.go +++ b/deployment/environment/devenv/chain.go @@ -74,7 +74,7 @@ func NewChains(logger logger.Logger, configs []ChainConfig) (map[uint64]deployme } blockNumber = receipt.BlockNumber.Uint64() if receipt.Status == 0 { - errReason, err := deployment.GetErrorReasonFromTx(ec, chainCfg.DeployerKey.From, *tx, receipt) + errReason, err := deployment.GetErrorReasonFromTx(ec, chainCfg.DeployerKey.From, tx, receipt) if err == nil && errReason != "" { return blockNumber, fmt.Errorf("tx %s reverted,error reason: %s", tx.Hash().Hex(), errReason) } diff --git a/deployment/environment/memory/environment.go b/deployment/environment/memory/environment.go index 75e74534184..79fe4d18838 100644 --- a/deployment/environment/memory/environment.go +++ b/deployment/environment/memory/environment.go @@ -63,7 +63,7 @@ func generateMemoryChain(t *testing.T, inputs map[uint64]EVMChain) map[uint64]de continue } if receipt.Status == 0 { - errReason, err := deployment.GetErrorReasonFromTx(chain.Backend, chain.DeployerKey.From, *tx, receipt) + errReason, err := deployment.GetErrorReasonFromTx(chain.Backend, chain.DeployerKey.From, tx, receipt) if err == nil && errReason != "" { return 0, fmt.Errorf("tx %s reverted,error reason: %s", tx.Hash().Hex(), errReason) } diff --git a/deployment/helpers.go b/deployment/helpers.go index 226de9a7024..420e9e03f06 100644 --- a/deployment/helpers.go +++ b/deployment/helpers.go @@ -44,7 +44,7 @@ func SimTransactOpts() *bind.TransactOpts { }, From: common.HexToAddress("0x0"), NoSend: true, GasLimit: 1_000_000} } -func GetErrorReasonFromTx(client bind.ContractBackend, from common.Address, tx types.Transaction, receipt *types.Receipt) (string, error) { +func GetErrorReasonFromTx(client bind.ContractBackend, from common.Address, tx *types.Transaction, receipt *types.Receipt) (string, error) { call := ethereum.CallMsg{ From: from, To: tx.To(), diff --git a/deployment/multiclient.go b/deployment/multiclient.go index 65f9e82bd01..dcda07ebb0b 100644 --- a/deployment/multiclient.go +++ b/deployment/multiclient.go @@ -103,9 +103,9 @@ func (mc *MultiClient) WaitMined(ctx context.Context, tx *types.Transaction) (*t resultCh := make(chan *types.Receipt) doneCh := make(chan struct{}) - waitMined := func(client *ethclient.Client, tx types.Transaction) { + waitMined := func(client *ethclient.Client, tx *types.Transaction) { mc.lggr.Debugf("Waiting for tx %s to be mined with client %v", tx.Hash().Hex(), client) - receipt, err := bind.WaitMined(ctx, client, &tx) + receipt, err := bind.WaitMined(ctx, client, tx) if err != nil { mc.lggr.Warnf("WaitMined error %v with client %v", err, client) return @@ -118,9 +118,7 @@ func (mc *MultiClient) WaitMined(ctx context.Context, tx *types.Transaction) (*t } for _, client := range append([]*ethclient.Client{mc.Client}, mc.Backups...) { - txn := tx - c := client - go waitMined(c, *txn) + go waitMined(client, tx) } var receipt *types.Receipt select {