Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixFan1992 committed Dec 8, 2023
1 parent 7d16f1d commit ccafeba
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

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

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas"
httypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker/types"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller"
evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types"
Expand Down Expand Up @@ -43,10 +44,12 @@ type BlockSubscriber struct {
mu sync.RWMutex
hb httypes.HeadBroadcaster
lp logpoller.LogPoller
ge gas.EvmFeeEstimator

Check failure on line 47 in core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/block_subscriber.go

View workflow job for this annotation

GitHub Actions / lint

field `ge` is unused (unused)
headC chan *evmtypes.Head
unsubscribe func()
subscribers map[int]chan ocr2keepers.BlockHistory
blocks map[int64]string
fastGas map[int64]int64
maxSubId int
lastClearedBlock int64
lastSentBlock int64
Expand All @@ -71,6 +74,7 @@ func NewBlockSubscriber(hb httypes.HeadBroadcaster, lp logpoller.LogPoller, fina
headC: make(chan *evmtypes.Head, channelSize),
subscribers: map[int]chan ocr2keepers.BlockHistory{},
blocks: map[int64]string{},
fastGas: map[int64]int64{},
blockHistorySize: blockHistorySize,
blockSize: lookbackDepth,
finalityDepth: finalityDepth,
Expand Down Expand Up @@ -274,6 +278,15 @@ func (bs *BlockSubscriber) processHead(h *evmtypes.Head) {
}
}

//fee, _, err := bs.ge.GetFee(ctx, _, feeLimit, maxFeeWei)
//var fg int64
//if fee.ValidDynamic() {
// fg = fee.DynamicFeeCap.Int64() + fee.DynamicTipCap.Int64()
//} else {
// fg = fee.Legacy.Int64()
//}
//bs.fastGas[h.Number] = fg

bs.lggr.Debugf("published block history with length %d and latestBlock %d to %d subscriber(s)", len(history), bs.latestBlock.Load(), len(bs.subscribers))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,14 @@ func (r *EvmRegistry) checkUpkeeps(ctx context.Context, payloads []ocr2keepers.U
continue
}

// estimated_tx_call_data is not needed to estimate fast gas except for Arbitrum.
//fee, _, _ := r.gasEstimator.GetFee(ctx, estimated_tx_call_data, feeLimit, maxFeePrice)
//fastGas := new(big.Int)
//if fee.ValidDynamic() {
// fastGas = fee.DynamicFeeCap.ToInt() // should we consider tipping??
//} else {
// fastGas = fee.Legacy.ToInt()
//}
//
//// this block will be updated by plug-in to keep it relatively new. e.g. within 2 min from block height
//// call gas estimator (GE) component to get L2 gas cost
//// estimated_tx_call_data is not needed to estimate fast gas except for Arbitrum.
//fg, ok := r.bs.fastGas[block.Int64()]
//if !ok {
// // if fast gas at this block does not exist, use the latest
// fg, _, _ = r.gasEstimator.GetFee(...)
//}
//
//var estimatedL1GasCost uint256
//var err error
Expand All @@ -227,7 +224,7 @@ func (r *EvmRegistry) checkUpkeeps(ctx context.Context, payloads []ocr2keepers.U
}

// check data will include the log trigger config
payload, err = r.abi.Pack("checkUpkeep", upkeepId, p.CheckData /* ChainConfig(estimatedL1GasCost, fastGas) */)
payload, err = r.abi.Pack("checkUpkeep", upkeepId, p.CheckData /* ChainConfig(estimatedL1GasCost, fg) */)
if err != nil {
// pack error, no retryable
r.lggr.Warnf("failed to pack log trigger checkUpkeep data for upkeepId %s with check data %s: %s", upkeepId, hexutil.Encode(p.CheckData), err)
Expand All @@ -237,7 +234,7 @@ func (r *EvmRegistry) checkUpkeeps(ctx context.Context, payloads []ocr2keepers.U
default:
// checkUpkeep is overloaded on the contract for conditionals and log upkeeps
// Need to use the first function (checkUpkeep0) for conditionals
payload, err = r.abi.Pack("checkUpkeep0", upkeepId /* ChainConfig(estimatedL1GasCost, fastGas) */)
payload, err = r.abi.Pack("checkUpkeep0", upkeepId /* ChainConfig(estimatedL1GasCost, fg) */)
if err != nil {
// pack error, no retryable
r.lggr.Warnf("failed to pack conditional checkUpkeep data for upkeepId %s with check data %s: %s", upkeepId, hexutil.Encode(p.CheckData), err)
Expand Down Expand Up @@ -389,20 +386,17 @@ func (r *EvmRegistry) simulatePerformUpkeeps(ctx context.Context, checkResults [
} else {

Check failure on line 386 in core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/registry_check_pipeline.go

View workflow job for this annotation

GitHub Actions / lint

empty-block: this block is empty, you can remove it (revive)
// at this point, the core node knows the exact perform data of the upkeep and the call data to L1.
// it can calculate a relatively accurate L1 gas cost

//actual_tx_call_data := checkResults[performToKeyIdx[i]].PerformData + byte padding;
//fee, _, _ := r.gasEstimator.GetFee(ctx, actual_tx_call_data, feeLimit, maxFeePrice)
//fastGas := new(big.Int)
//if fee.ValidDynamic() {
// fastGas = fee.DynamicFeeCap.ToInt() // should we consider tipping??
//} else {
// fastGas = fee.Legacy.ToInt()
//fg, ok := r.bs.fastGas[block.Int64()]
//if !ok {
// // if fast gas at this block does not exist, use the latest
// fg, _, _ = r.gasEstimator.GetFee(...)
//}
//
//// this block will be updated by plug-in to keep it relatively new. e.g. within 2 min from block height
//// call gas estimator (GE) component to get L2 gas cost
//
//// can we estimate this L1GasCost by comparing estimated call data and actual call data??
//actual_tx_call_data := checkResults[performToKeyIdx[i]].PerformData + byte padding;
//var executionL1GasCost uint256
//var err error
//// if L1 oracle is configured, it's a L2
Expand All @@ -412,7 +406,7 @@ func (r *EvmRegistry) simulatePerformUpkeeps(ctx context.Context, checkResults [
// // handle error
// }
//}
//checkResults[performToKeyIdx[i]].FastGasWei = fastGas
//checkResults[performToKeyIdx[i]].FastGasWei = fg
//checkResults[performToKeyIdx[i]].L1GasCost = executionL1GasCost
}
}
Expand Down

0 comments on commit ccafeba

Please sign in to comment.