mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
feat: allow triggering one-off CCC on a block (#1043)
Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
This commit is contained in:
parent
1d02d04b5d
commit
89639dd74a
2 changed files with 27 additions and 0 deletions
21
eth/api.go
21
eth/api.go
|
|
@ -38,6 +38,7 @@ import (
|
|||
"github.com/scroll-tech/go-ethereum/internal/ethapi"
|
||||
"github.com/scroll-tech/go-ethereum/log"
|
||||
"github.com/scroll-tech/go-ethereum/rlp"
|
||||
"github.com/scroll-tech/go-ethereum/rollup/ccc"
|
||||
"github.com/scroll-tech/go-ethereum/rpc"
|
||||
"github.com/scroll-tech/go-ethereum/trie"
|
||||
)
|
||||
|
|
@ -812,3 +813,23 @@ func (api *ScrollAPI) GetSkippedTransactionHashes(ctx context.Context, from uint
|
|||
|
||||
return hashes, nil
|
||||
}
|
||||
|
||||
// CalculateRowConsumptionByBlockNumber
|
||||
func (api *ScrollAPI) CalculateRowConsumptionByBlockNumber(ctx context.Context, number rpc.BlockNumber) (*types.RowConsumption, error) {
|
||||
block := api.eth.blockchain.GetBlockByNumber(uint64(number.Int64()))
|
||||
if block == nil {
|
||||
return nil, errors.New("block not found")
|
||||
}
|
||||
|
||||
// todo: fix temp AsyncChecker leaking the internal Checker instances
|
||||
var checkErr error
|
||||
asyncChecker := ccc.NewAsyncChecker(api.eth.blockchain, 1, false).WithOnFailingBlock(func(b *types.Block, err error) {
|
||||
log.Error("failed to calculate row consumption on demand", "number", number, "hash", b.Hash().Hex(), "err", err)
|
||||
checkErr = err
|
||||
})
|
||||
if err := asyncChecker.Check(block); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
asyncChecker.Wait()
|
||||
return rawdb.ReadBlockRowConsumption(api.eth.ChainDb(), block.Hash()), checkErr
|
||||
}
|
||||
|
|
|
|||
|
|
@ -926,6 +926,12 @@ web3._extend({
|
|||
inputFormatter: [web3._extend.formatters.inputCallFormatter, web3._extend.formatters.inputBlockNumberFormatter],
|
||||
outputFormatter: web3._extend.utils.toDecimal
|
||||
}),
|
||||
new web3._extend.Method({
|
||||
name: 'calculateRowConsumptionByBlockNumber',
|
||||
call: 'scroll_calculateRowConsumptionByBlockNumber',
|
||||
params: 1,
|
||||
inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter]
|
||||
}),
|
||||
],
|
||||
properties:
|
||||
[
|
||||
|
|
|
|||
Loading…
Reference in a new issue