Skip to content

Commit

Permalink
fixed linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
silaslenihan committed Apr 4, 2024
1 parent 4d38994 commit e759faa
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 45 deletions.
2 changes: 0 additions & 2 deletions core/chains/evm/gas/arbitrum_estimator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ func TestArbitrumEstimator(t *testing.T) {
const maxGasLimit uint64 = 500_000
calldata := []byte{0x00, 0x00, 0x01, 0x02, 0x03}
const gasLimit uint64 = 80000
const gasPriceBufferPercentage = 50
const bumpPercent = 10
var bumpMin = assets.NewWei(big.NewInt(1))
const chainType = "arbitrum"

t.Run("calling GetLegacyGas on unstarted estimator returns error", func(t *testing.T) {
ethClient := mocks.NewETHClient(t)
Expand Down
8 changes: 4 additions & 4 deletions core/chains/evm/gas/rollups/arbitrum_l1_oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ func newArbitrumL1GasOracle(lggr logger.Logger, ethClient ethClient) ArbL1GasOra
l1GasCostMethodAbi, gasCostErr = abi.JSON(strings.NewReader(GasEstimateL1ComponentAbiString))

if gasPriceErr != nil {
panic(fmt.Sprintf("Failed to parse L1 gas price method ABI for chain: arbitrum"))
panic("Failed to parse L1 gas price method ABI for chain: arbitrum")
}
if gasCostErr != nil {
panic(fmt.Sprintf("Failed to parse L1 gas cost method ABI for chain: arbitrum"))
panic("Failed to parse L1 gas cost method ABI for chain: arbitrum")
}

return &arbitrumL1Oracle{
client: ethClient,
pollPeriod: PollPeriod,
logger: logger.Sugared(logger.Named(lggr, fmt.Sprintf("L1GasOracle(%s)", "arbitrum"))),
logger: logger.Sugared(logger.Named(lggr, "L1GasOracle(arbitrum)")),
chainType: "arbitrum",

l1GasPriceAddress: l1GasPriceAddress,
Expand Down Expand Up @@ -190,7 +190,7 @@ func (o *arbitrumL1Oracle) fetchL1GasPrice(ctx context.Context) (price *big.Int,
precompile := common.HexToAddress(o.l1GasPriceAddress)
callData, err = o.l1GasPriceMethodAbi.Pack(o.gasPriceMethod)
if err != nil {
errMsg := fmt.Sprintf("failed to pack calldata for %s L1 gas price method", o.chainType)
errMsg := "failed to pack calldata for arbitrum L1 gas price method"
o.logger.Errorf(errMsg)
return nil, fmt.Errorf("%s: %w", errMsg, err)
}
Expand Down
28 changes: 0 additions & 28 deletions core/chains/evm/gas/rollups/l1_oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ import (
"fmt"
"math/big"
"slices"
"sync"
"time"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/rpc"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/services"

"github.com/smartcontractkit/chainlink/v2/common/config"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets"
Expand All @@ -35,31 +32,6 @@ type priceEntry struct {
timestamp time.Time
}

// Reads L2-specific precompiles and caches the l1GasPrice set by the L2.
type l1Oracle struct {
services.StateMachine
client ethClient
pollPeriod time.Duration
logger logger.SugaredLogger
chainType config.ChainType

l1GasPriceAddress string
gasPriceMethod string
l1GasPriceMethodAbi abi.ABI
l1GasPriceMu sync.RWMutex
l1GasPrice priceEntry

l1GasCostAddress string
gasCostMethod string
l1GasCostMethodAbi abi.ABI

priceReader daPriceReader

chInitialised chan struct{}
chStop services.StopChan
chDone chan struct{}
}

const (
// Interval at which to poll for L1BaseFee. A good starting point is the L1 block time.
PollPeriod = 6 * time.Second
Expand Down
6 changes: 3 additions & 3 deletions core/chains/evm/gas/rollups/op_l1_oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,16 @@ func newOpStackL1GasOracle(lggr logger.Logger, ethClient ethClient, priceReader
l1GasCostMethodAbi, gasCostErr = abi.JSON(strings.NewReader(GetL1FeeAbiString))

if gasPriceErr != nil {
panic(fmt.Sprintf("Failed to parse L1 gas price method ABI for chain: optimismBedrock"))
panic(fmt.Sprintf("Failed to parse L1 gas price method ABI for chain: %s", chainType))
}
if gasCostErr != nil {
panic(fmt.Sprintf("Failed to parse L1 gas cost method ABI for chain: optimismBedrock"))
panic(fmt.Sprintf("Failed to parse L1 gas cost method ABI for chain: %s", chainType))
}

return &optimismL1Oracle{
client: ethClient,
pollPeriod: PollPeriod,
logger: logger.Sugared(logger.Named(lggr, fmt.Sprintf("L1GasOracle(optimismBedrock)"))),
logger: logger.Sugared(logger.Named(lggr, "L1GasOracle(optimismBedrock)")),
chainType: chainType,

l1GasPriceAddress: l1GasPriceAddress,
Expand Down
8 changes: 4 additions & 4 deletions core/chains/evm/gas/rollups/scroll_l1_oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ func newScrollL1GasOracle(lggr logger.Logger, ethClient ethClient) L1Oracle {
l1GasCostMethodAbi, gasCostErr = abi.JSON(strings.NewReader(GetL1FeeAbiString))

if gasPriceErr != nil {
panic(fmt.Sprintf("Failed to parse L1 gas price method ABI for chain: scroll"))
panic("Failed to parse L1 gas price method ABI for chain: scroll")
}
if gasCostErr != nil {
panic(fmt.Sprintf("Failed to parse L1 gas cost method ABI for chain: scroll"))
panic("Failed to parse L1 gas cost method ABI for chain: scroll")
}

return &scrollL1Oracle{
client: ethClient,
pollPeriod: PollPeriod,
logger: logger.Sugared(logger.Named(lggr, fmt.Sprintf("L1GasOracle(scroll)"))),
logger: logger.Sugared(logger.Named(lggr, "L1GasOracle(scroll)")),
chainType: "scroll",

l1GasPriceAddress: l1GasPriceAddress,
Expand Down Expand Up @@ -178,7 +178,7 @@ func (o *scrollL1Oracle) fetchL1GasPrice(ctx context.Context) (price *big.Int, e
precompile := common.HexToAddress(o.l1GasPriceAddress)
callData, err = o.l1GasPriceMethodAbi.Pack(o.gasPriceMethod)
if err != nil {
errMsg := fmt.Sprintf("failed to pack calldata for %s L1 gas price method", o.chainType)
errMsg := "failed to pack calldata for scroll L1 gas price method"
o.logger.Errorf(errMsg)
return nil, fmt.Errorf("%s: %w", errMsg, err)
}
Expand Down
8 changes: 4 additions & 4 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4716,7 +4716,7 @@ LimitMax = 1000000000
LimitMultiplier = '1'
LimitTransfer = 21000
BumpMin = '5 gwei'
BumpPercent = 20
BumpPercent = 50
BumpThreshold = 0
EIP1559DynamicFees = false
FeeCapDefault = '1 micro'
Expand Down Expand Up @@ -5565,7 +5565,7 @@ LimitMax = 1000000000
LimitMultiplier = '1'
LimitTransfer = 21000
BumpMin = '5 gwei'
BumpPercent = 20
BumpPercent = 50
BumpThreshold = 0
EIP1559DynamicFees = false
FeeCapDefault = '1 micro'
Expand Down Expand Up @@ -5651,7 +5651,7 @@ LimitMax = 1000000000
LimitMultiplier = '1'
LimitTransfer = 21000
BumpMin = '5 gwei'
BumpPercent = 20
BumpPercent = 50
BumpThreshold = 0
EIP1559DynamicFees = false
FeeCapDefault = '1 micro'
Expand Down Expand Up @@ -5736,7 +5736,7 @@ LimitMax = 1000000000
LimitMultiplier = '1'
LimitTransfer = 21000
BumpMin = '5 gwei'
BumpPercent = 20
BumpPercent = 50
BumpThreshold = 0
EIP1559DynamicFees = false
FeeCapDefault = '1 micro'
Expand Down

0 comments on commit e759faa

Please sign in to comment.