mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-07 15:38:37 +00:00
core: fixed issues from devnet
This commit is contained in:
parent
d14677f344
commit
d27b174680
2 changed files with 26 additions and 17 deletions
|
|
@ -133,6 +133,12 @@ func (gp *GasPool) Set(other *GasPool) {
|
||||||
gp.cumulativeState = other.cumulativeState
|
gp.cumulativeState = other.cumulativeState
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AmsterdamDimensions returns the per-dimension cumulative gas values
|
||||||
|
// for 2D gas accounting (EIP-8037).
|
||||||
|
func (gp *GasPool) AmsterdamDimensions() (regular, state uint64) {
|
||||||
|
return gp.cumulativeRegular, gp.cumulativeState
|
||||||
|
}
|
||||||
|
|
||||||
func (gp *GasPool) String() string {
|
func (gp *GasPool) String() string {
|
||||||
return fmt.Sprintf("initial: %d, remaining: %d, cumulative used: %d", gp.initial, gp.remaining, gp.cumulativeUsed)
|
return fmt.Sprintf("initial: %d, remaining: %d, cumulative used: %d", gp.initial, gp.remaining, gp.cumulativeUsed)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,28 +95,25 @@ func (p *ParallelStateProcessor) prepareExecResult(block *types.Block, tExecStar
|
||||||
})
|
})
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// total gas used not applying refunds
|
// Per-dimension cumulative sums for 2D block gas (EIP-8037).
|
||||||
blockGas = uint64(0)
|
sumRegular uint64
|
||||||
// total gas used applying refunds
|
sumState uint64
|
||||||
execGas = uint64(0)
|
cumulativeReceipt uint64 // cumulative receipt gas (what users pay)
|
||||||
)
|
)
|
||||||
|
|
||||||
var allLogs []*types.Log
|
var allLogs []*types.Log
|
||||||
var allReceipts []*types.Receipt
|
var allReceipts []*types.Receipt
|
||||||
for _, result := range results {
|
for _, result := range results {
|
||||||
blockGas += result.blockGas
|
sumRegular += result.txRegular
|
||||||
execGas += result.execGas
|
sumState += result.txState
|
||||||
result.receipt.CumulativeGasUsed = blockGas
|
cumulativeReceipt += result.execGas
|
||||||
if blockGas > header.GasLimit {
|
result.receipt.CumulativeGasUsed = cumulativeReceipt
|
||||||
return &ProcessResultWithMetrics{
|
|
||||||
ProcessResult: &ProcessResult{Error: fmt.Errorf("gas limit exceeded")},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
allLogs = append(allLogs, result.receipt.Logs...)
|
allLogs = append(allLogs, result.receipt.Logs...)
|
||||||
allReceipts = append(allReceipts, result.receipt)
|
allReceipts = append(allReceipts, result.receipt)
|
||||||
}
|
}
|
||||||
// Block gas limit is enforced against usedGas (pre-refund after Amsterdam, post-refund before).
|
// Block gas = max(sum_regular, sum_state) per EIP-8037.
|
||||||
if blockGas > header.GasLimit {
|
blockGasUsed := max(sumRegular, sumState)
|
||||||
|
if blockGasUsed > header.GasLimit {
|
||||||
return &ProcessResultWithMetrics{
|
return &ProcessResultWithMetrics{
|
||||||
ProcessResult: &ProcessResult{Error: fmt.Errorf("gas limit exceeded")},
|
ProcessResult: &ProcessResult{Error: fmt.Errorf("gas limit exceeded")},
|
||||||
}
|
}
|
||||||
|
|
@ -177,7 +174,7 @@ func (p *ParallelStateProcessor) prepareExecResult(block *types.Block, tExecStar
|
||||||
Receipts: allReceipts,
|
Receipts: allReceipts,
|
||||||
Requests: requests,
|
Requests: requests,
|
||||||
Logs: allLogs,
|
Logs: allLogs,
|
||||||
GasUsed: execGas,
|
GasUsed: blockGasUsed,
|
||||||
},
|
},
|
||||||
PostProcessTime: tPostprocess,
|
PostProcessTime: tPostprocess,
|
||||||
ExecTime: tExec,
|
ExecTime: tExec,
|
||||||
|
|
@ -191,6 +188,10 @@ type txExecResult struct {
|
||||||
blockGas uint64
|
blockGas uint64
|
||||||
execGas uint64
|
execGas uint64
|
||||||
|
|
||||||
|
// Per-tx dimensional gas for Amsterdam 2D gas accounting (EIP-8037).
|
||||||
|
txRegular uint64
|
||||||
|
txState uint64
|
||||||
|
|
||||||
stateReads bal.StateAccesses
|
stateReads bal.StateAccesses
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -292,7 +293,6 @@ func (p *ParallelStateProcessor) execTx(block *types.Block, tx *types.Transactio
|
||||||
gp := NewGasPool(block.GasLimit())
|
gp := NewGasPool(block.GasLimit())
|
||||||
db.SetTxContext(tx.Hash(), balIdx-1)
|
db.SetTxContext(tx.Hash(), balIdx-1)
|
||||||
|
|
||||||
var gasUsed uint64
|
|
||||||
mut, receipt, err := ApplyTransactionWithEVM(msg, gp, db, block.Number(), block.Hash(), context.Time, tx, evm)
|
mut, receipt, err := ApplyTransactionWithEVM(msg, gp, db, block.Number(), block.Hash(), context.Time, tx, evm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("could not apply tx %d [%v]: %w", balIdx, tx.Hash().Hex(), err)
|
err := fmt.Errorf("could not apply tx %d [%v]: %w", balIdx, tx.Hash().Hex(), err)
|
||||||
|
|
@ -305,11 +305,14 @@ func (p *ParallelStateProcessor) execTx(block *types.Block, tx *types.Transactio
|
||||||
return &txExecResult{err: err}
|
return &txExecResult{err: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
txRegular, txState := gp.AmsterdamDimensions()
|
||||||
return &txExecResult{
|
return &txExecResult{
|
||||||
idx: balIdx,
|
idx: balIdx,
|
||||||
receipt: receipt,
|
receipt: receipt,
|
||||||
execGas: receipt.GasUsed,
|
execGas: receipt.GasUsed,
|
||||||
blockGas: gasUsed,
|
blockGas: gp.Used(),
|
||||||
|
txRegular: txRegular,
|
||||||
|
txState: txState,
|
||||||
stateReads: db.Reader().(state.StateReaderTracker).GetStateAccessList(),
|
stateReads: db.Reader().(state.StateReaderTracker).GetStateAccessList(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue