Skip to content

Commit

Permalink
deployment: use pointer for eth tx (#15039)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 authored Nov 1, 2024
1 parent 007cf1f commit a0fbd3a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions core/scripts/chaincli/handler/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,15 @@ func NewOCR2Transaction(raw map[string]interface{}) (*OCR2Transaction, error) {
encoder: evm.EVMAutomationEncoder20{},
abi: contract,
raw: raw,
tx: tx,
tx: &tx,
}, nil
}

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 {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion deployment/environment/devenv/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion deployment/environment/memory/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion deployment/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
8 changes: 3 additions & 5 deletions deployment/multiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit a0fbd3a

Please sign in to comment.