mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
fix(worker): check gas limit before running ccc (#511)
Co-authored-by: maskpp <maskpp266@gmail.com>
This commit is contained in:
parent
417dd02827
commit
530830a01c
2 changed files with 22 additions and 3 deletions
|
|
@ -891,12 +891,17 @@ func (w *worker) commitTransaction(tx *types.Transaction, coinbase common.Addres
|
|||
|
||||
// do not do CCC checks on follower nodes
|
||||
if w.isRunning() {
|
||||
// do gas limit check up-front and do not run CCC if it fails
|
||||
if w.current.gasPool.Gas() < tx.Gas() {
|
||||
return nil, nil, core.ErrGasLimitReached
|
||||
}
|
||||
|
||||
snap := w.current.state.Snapshot()
|
||||
|
||||
log.Trace(
|
||||
"Worker apply ccc for tx",
|
||||
"id", w.circuitCapacityChecker.ID,
|
||||
"txhash", tx.Hash(),
|
||||
"txHash", tx.Hash().Hex(),
|
||||
)
|
||||
|
||||
// 1. we have to check circuit capacity before `core.ApplyTransaction`,
|
||||
|
|
@ -922,7 +927,7 @@ func (w *worker) commitTransaction(tx *types.Transaction, coinbase common.Addres
|
|||
log.Trace(
|
||||
"Worker apply ccc for tx result",
|
||||
"id", w.circuitCapacityChecker.ID,
|
||||
"txhash", tx.Hash(),
|
||||
"txHash", tx.Hash().Hex(),
|
||||
"accRows", accRows,
|
||||
)
|
||||
}
|
||||
|
|
@ -933,6 +938,20 @@ func (w *worker) commitTransaction(tx *types.Transaction, coinbase common.Addres
|
|||
receipt, err := core.ApplyTransaction(w.chainConfig, w.chain, &coinbase, w.current.gasPool, w.current.state, w.current.header, tx, &w.current.header.GasUsed, *w.chain.GetVMConfig())
|
||||
if err != nil {
|
||||
w.current.state.RevertToSnapshot(snap)
|
||||
|
||||
if accRows != nil {
|
||||
// At this point, we have called CCC but the transaction failed in `ApplyTransaction`.
|
||||
// If we skip this tx and continue to pack more, the next tx will likely fail with
|
||||
// `circuitcapacitychecker.ErrUnknown`. However, at this point we cannot decide whether
|
||||
// we should seal the block or skip the tx and continue, so we simply return the error.
|
||||
log.Error(
|
||||
"GetBlockTrace passed but ApplyTransaction failed, ccc is left in inconsistent state",
|
||||
"blockNumber", w.current.header.Number,
|
||||
"txHash", tx.Hash().Hex(),
|
||||
"err", err,
|
||||
)
|
||||
}
|
||||
|
||||
return nil, traces, err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
const (
|
||||
VersionMajor = 4 // Major version component of the current release
|
||||
VersionMinor = 4 // Minor version component of the current release
|
||||
VersionPatch = 6 // Patch version component of the current release
|
||||
VersionPatch = 7 // Patch version component of the current release
|
||||
VersionMeta = "sepolia" // Version metadata to append to the version string
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue