Skip to content

Commit

Permalink
couple of renames and streamlines
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofel committed Apr 2, 2024
1 parent b3658fa commit 95e388a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 57 deletions.
14 changes: 8 additions & 6 deletions integration-tests/actions/seth/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,15 @@ func SendFunds(logger zerolog.Logger, client *seth.Client, payload FundsToSendPa
}

if client.Cfg.Network.EIP1559DynamicFees {
// if any of the dynamic fees are not set, we need to either estimate them or read them from config
if payload.GasFeeCap == nil || payload.GasTipCap == nil {
// estimatior or config reading happens here
txOptions := client.NewTXOpts()
gasFeeCap = txOptions.GasFeeCap
gasTipCap = txOptions.GasTipCap
}

// override with payload values if they are set
if payload.GasFeeCap != nil {
gasFeeCap = payload.GasFeeCap
}
Expand All @@ -155,30 +158,29 @@ func SendFunds(logger zerolog.Logger, client *seth.Client, payload FundsToSendPa
}
}

var signedTx *types.Transaction
var rawTx types.TxData

if client.Cfg.Network.EIP1559DynamicFees {
rawTx := &types.DynamicFeeTx{
rawTx = &types.DynamicFeeTx{
Nonce: nonce,
To: &payload.ToAddress,
Value: payload.Amount,
Gas: gasLimit,
GasFeeCap: gasFeeCap,
GasTipCap: gasTipCap,
}
// in the future we might need to dynamically set the signer to reflect the hard fork for given chain
signedTx, err = types.SignNewTx(payload.PrivateKey, types.NewLondonSigner(big.NewInt(client.ChainID)), rawTx)
} else {
rawTx := &types.LegacyTx{
rawTx = &types.LegacyTx{
Nonce: nonce,
To: &payload.ToAddress,
Value: payload.Amount,
Gas: gasLimit,
GasPrice: gasPrice,
}
signedTx, err = types.SignNewTx(payload.PrivateKey, types.NewEIP155Signer(big.NewInt(client.ChainID)), rawTx)
}

signedTx, err := types.SignNewTx(payload.PrivateKey, types.LatestSignerForChainID(big.NewInt(client.ChainID)), rawTx)

if err != nil {
return nil, errors.Wrap(err, "failed to sign tx")
}
Expand Down
11 changes: 6 additions & 5 deletions integration-tests/actions/seth/refund.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ func ReturnFunds(log zerolog.Logger, sethClient *seth.Client, chainlinkNodes []c
return err
}

// if not set, it will be just set to empty string, which is okay as long as gas estimation is disabled
txPriority := sethClient.Cfg.Network.GasEstimationTxPriority
txTimeout := sethClient.Cfg.Network.TxnTimeout.Duration()

Expand All @@ -291,19 +292,19 @@ func ReturnFunds(log zerolog.Logger, sethClient *seth.Client, chainlinkNodes []c
Priority: txPriority,
})

var totalGasCost *big.Int
var maxTotalGasCost *big.Int
if sethClient.Cfg.Network.EIP1559DynamicFees {
totalGasCost = new(big.Int).Mul(big.NewInt(0).SetInt64(sethClient.Cfg.Network.TransferGasFee), estimations.GasFeeCap)
maxTotalGasCost = new(big.Int).Mul(big.NewInt(0).SetInt64(sethClient.Cfg.Network.TransferGasFee), estimations.GasFeeCap)
} else {
totalGasCost = new(big.Int).Mul(big.NewInt(0).SetInt64(sethClient.Cfg.Network.TransferGasFee), estimations.GasPrice)
maxTotalGasCost = new(big.Int).Mul(big.NewInt(0).SetInt64(sethClient.Cfg.Network.TransferGasFee), estimations.GasPrice)
}

toSend := new(big.Int).Sub(balance, totalGasCost)
toSend := new(big.Int).Sub(balance, maxTotalGasCost)

if toSend.Cmp(big.NewInt(0)) <= 0 {
log.Warn().
Str("Address", fromAddress.String()).
Str("Estimated total cost", totalGasCost.String()).
Str("Estimated maximum total gas cost", maxTotalGasCost.String()).
Str("Balance", balance.String()).
Str("To send", toSend.String()).
Msg("Not enough balance to cover gas cost. Skipping return.")
Expand Down
5 changes: 4 additions & 1 deletion integration-tests/docker/test_env/test_env_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,10 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) {

if b.hasSeth {
readSethCfg := b.testConfig.GetSethConfig()
sethCfg := utils.MergeSethAndEvmNetworkConfigs(b.l, networkConfig, *readSethCfg)
sethCfg, err := utils.MergeSethAndEvmNetworkConfigs(networkConfig, *readSethCfg)
if err != nil {
return nil, err
}
err = utils.ValidateSethNetworkConfig(sethCfg.Network)
if err != nil {
return nil, err
Expand Down
40 changes: 0 additions & 40 deletions integration-tests/experiments/gas_test.go

This file was deleted.

5 changes: 0 additions & 5 deletions integration-tests/soak/ocr_soak_report.csv

This file was deleted.

0 comments on commit 95e388a

Please sign in to comment.