Merge pull request #2460 from bnb-chain/develop
merge some PRs for v1.4.7(2nd)
This commit is contained in:
commit
c577ce3720
@ -193,14 +193,6 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
|
||||
v := ctx.Uint64(utils.OverrideVerkle.Name)
|
||||
cfg.Eth.OverrideVerkle = &v
|
||||
}
|
||||
if ctx.IsSet(utils.OverrideFeynman.Name) {
|
||||
v := ctx.Uint64(utils.OverrideFeynman.Name)
|
||||
cfg.Eth.OverrideFeynman = &v
|
||||
}
|
||||
if ctx.IsSet(utils.OverrideFeynmanFix.Name) {
|
||||
v := ctx.Uint64(utils.OverrideFeynmanFix.Name)
|
||||
cfg.Eth.OverrideFeynmanFix = &v
|
||||
}
|
||||
if ctx.IsSet(utils.OverrideFullImmutabilityThreshold.Name) {
|
||||
params.FullImmutabilityThreshold = ctx.Uint64(utils.OverrideFullImmutabilityThreshold.Name)
|
||||
downloader.FullMaxForkAncestry = ctx.Uint64(utils.OverrideFullImmutabilityThreshold.Name)
|
||||
|
@ -74,8 +74,6 @@ var (
|
||||
utils.RialtoHash,
|
||||
utils.OverrideCancun,
|
||||
utils.OverrideVerkle,
|
||||
utils.OverrideFeynman,
|
||||
utils.OverrideFeynmanFix,
|
||||
utils.OverrideFullImmutabilityThreshold,
|
||||
utils.OverrideMinBlocksForBlobRequests,
|
||||
utils.OverrideDefaultExtraReserveForBlobRequests,
|
||||
|
@ -315,15 +315,6 @@ var (
|
||||
Usage: "Manually specify the Verkle fork timestamp, overriding the bundled setting",
|
||||
Category: flags.EthCategory,
|
||||
}
|
||||
OverrideFeynman = &cli.Uint64Flag{
|
||||
Name: "override.feynman",
|
||||
Usage: "Manually specify the Feynman fork timestamp, overriding the bundled setting",
|
||||
Category: flags.EthCategory,
|
||||
}
|
||||
OverrideFeynmanFix = &cli.Uint64Flag{
|
||||
Name: "override.feynmanfix",
|
||||
Usage: "Manually specify the FeynmanFix fork timestamp, overriding the bundled setting",
|
||||
}
|
||||
OverrideFullImmutabilityThreshold = &cli.Uint64Flag{
|
||||
Name: "override.immutabilitythreshold",
|
||||
Usage: "It is the number of blocks after which a chain segment is considered immutable, only for testing purpose",
|
||||
|
@ -218,8 +218,6 @@ func (e *GenesisMismatchError) Error() string {
|
||||
type ChainOverrides struct {
|
||||
OverrideCancun *uint64
|
||||
OverrideVerkle *uint64
|
||||
OverrideFeynman *uint64
|
||||
OverrideFeynmanFix *uint64
|
||||
}
|
||||
|
||||
// SetupGenesisBlock writes or updates the genesis block in db.
|
||||
@ -251,12 +249,6 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g
|
||||
if overrides != nil && overrides.OverrideVerkle != nil {
|
||||
config.VerkleTime = overrides.OverrideVerkle
|
||||
}
|
||||
if overrides != nil && overrides.OverrideFeynman != nil {
|
||||
config.FeynmanTime = overrides.OverrideFeynman
|
||||
}
|
||||
if overrides != nil && overrides.OverrideFeynmanFix != nil {
|
||||
config.FeynmanFixTime = overrides.OverrideFeynmanFix
|
||||
}
|
||||
}
|
||||
}
|
||||
// Just commit the new block if there is no stored genesis block.
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -57,31 +57,3 @@ var (
|
||||
//go:embed chapel/TokenRecoverPortalContract
|
||||
ChapelTokenRecoverPortalContract string
|
||||
)
|
||||
|
||||
// contract codes for Rialto upgrade
|
||||
var (
|
||||
//go:embed rialto/ValidatorContract
|
||||
RialtoValidatorContract string
|
||||
//go:embed rialto/SlashContract
|
||||
RialtoSlashContract string
|
||||
//go:embed rialto/TokenHubContract
|
||||
RialtoTokenHubContract string
|
||||
//go:embed rialto/GovHubContract
|
||||
RialtoGovHubContract string
|
||||
//go:embed rialto/CrossChainContract
|
||||
RialtoCrossChainContract string
|
||||
//go:embed rialto/StakingContract
|
||||
RialtoStakingContract string
|
||||
//go:embed rialto/StakeHubContract
|
||||
RialtoStakeHubContract string
|
||||
//go:embed rialto/StakeCreditContract
|
||||
RialtoStakeCreditContract string
|
||||
//go:embed rialto/GovernorContract
|
||||
RialtoGovernorContract string
|
||||
//go:embed rialto/GovTokenContract
|
||||
RialtoGovTokenContract string
|
||||
//go:embed rialto/TimelockContract
|
||||
RialtoTimelockContract string
|
||||
//go:embed rialto/TokenRecoverPortalContract
|
||||
RialtoTokenRecoverPortalContract string
|
||||
)
|
||||
|
@ -680,72 +680,6 @@ func init() {
|
||||
},
|
||||
}
|
||||
|
||||
feynmanUpgrade[rialtoNet] = &Upgrade{
|
||||
UpgradeName: "feynman",
|
||||
Configs: []*UpgradeConfig{
|
||||
{
|
||||
ContractAddr: common.HexToAddress(ValidatorContract),
|
||||
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/2d6372ddba77902ef01e45887a425938376d5a5c",
|
||||
Code: feynman.RialtoValidatorContract,
|
||||
},
|
||||
{
|
||||
ContractAddr: common.HexToAddress(SlashContract),
|
||||
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/2d6372ddba77902ef01e45887a425938376d5a5c",
|
||||
Code: feynman.RialtoSlashContract,
|
||||
},
|
||||
{
|
||||
ContractAddr: common.HexToAddress(TokenHubContract),
|
||||
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/2d6372ddba77902ef01e45887a425938376d5a5c",
|
||||
Code: feynman.RialtoTokenHubContract,
|
||||
},
|
||||
{
|
||||
ContractAddr: common.HexToAddress(GovHubContract),
|
||||
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/2d6372ddba77902ef01e45887a425938376d5a5c",
|
||||
Code: feynman.RialtoGovHubContract,
|
||||
},
|
||||
{
|
||||
ContractAddr: common.HexToAddress(CrossChainContract),
|
||||
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/2d6372ddba77902ef01e45887a425938376d5a5c",
|
||||
Code: feynman.RialtoCrossChainContract,
|
||||
},
|
||||
{
|
||||
ContractAddr: common.HexToAddress(StakingContract),
|
||||
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/2d6372ddba77902ef01e45887a425938376d5a5c",
|
||||
Code: feynman.RialtoStakingContract,
|
||||
},
|
||||
{
|
||||
ContractAddr: common.HexToAddress(StakeHubContract),
|
||||
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/2d6372ddba77902ef01e45887a425938376d5a5c",
|
||||
Code: feynman.RialtoStakeHubContract,
|
||||
},
|
||||
{
|
||||
ContractAddr: common.HexToAddress(StakeCreditContract),
|
||||
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/2d6372ddba77902ef01e45887a425938376d5a5c",
|
||||
Code: feynman.MainnetStakeCreditContract,
|
||||
},
|
||||
{
|
||||
ContractAddr: common.HexToAddress(GovernorContract),
|
||||
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/2d6372ddba77902ef01e45887a425938376d5a5c",
|
||||
Code: feynman.RialtoGovernorContract,
|
||||
},
|
||||
{
|
||||
ContractAddr: common.HexToAddress(GovTokenContract),
|
||||
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/2d6372ddba77902ef01e45887a425938376d5a5c",
|
||||
Code: feynman.MainnetGovTokenContract,
|
||||
},
|
||||
{
|
||||
ContractAddr: common.HexToAddress(TimelockContract),
|
||||
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/2d6372ddba77902ef01e45887a425938376d5a5c",
|
||||
Code: feynman.RialtoTimelockContract,
|
||||
},
|
||||
{
|
||||
ContractAddr: common.HexToAddress(TokenRecoverPortalContract),
|
||||
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/2d6372ddba77902ef01e45887a425938376d5a5c",
|
||||
Code: feynman.RialtoTokenRecoverPortalContract,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// This upgrade is to fix an error on testnet only. So the upgrade config of mainnet is empty.
|
||||
feynmanFixUpgrade[mainNet] = &Upgrade{
|
||||
UpgradeName: "feynmanFix",
|
||||
@ -767,11 +701,6 @@ func init() {
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
feynmanFixUpgrade[rialtoNet] = &Upgrade{
|
||||
UpgradeName: "feynmanFix",
|
||||
Configs: []*UpgradeConfig{},
|
||||
}
|
||||
}
|
||||
|
||||
func UpgradeBuildInSystemContract(config *params.ChainConfig, blockNumber *big.Int, lastBlockTime uint64, blockTime uint64, statedb *state.StateDB) {
|
||||
|
@ -26,7 +26,7 @@ func TestAllCodesHash(t *testing.T) {
|
||||
|
||||
allCodes := make([]byte, 0, 10_000_000)
|
||||
for _, hardfork := range upgradesList {
|
||||
for _, network := range []string{mainNet, chapelNet, rialtoNet} {
|
||||
for _, network := range []string{mainNet, chapelNet} {
|
||||
allCodes = append(allCodes, []byte(network)...)
|
||||
if hardfork[network] != nil {
|
||||
for _, addressConfig := range hardfork[network].Configs {
|
||||
@ -37,6 +37,5 @@ func TestAllCodesHash(t *testing.T) {
|
||||
}
|
||||
}
|
||||
allCodeHash := sha256.Sum256(allCodes)
|
||||
|
||||
require.Equal(t, allCodeHash[:], common.Hex2Bytes("3d68c07faa6b9385e981a45bd539f15d4cbb712426c604b9cab22591af446fc8"))
|
||||
require.Equal(t, allCodeHash[:], common.Hex2Bytes("833cc0fc87c46ad8a223e44ccfdc16a51a7e7383525136441bd0c730f06023df"))
|
||||
}
|
||||
|
@ -187,14 +187,6 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||
chainConfig.VerkleTime = config.OverrideVerkle
|
||||
overrides.OverrideVerkle = config.OverrideVerkle
|
||||
}
|
||||
if config.OverrideFeynman != nil {
|
||||
chainConfig.FeynmanTime = config.OverrideFeynman
|
||||
overrides.OverrideFeynman = config.OverrideFeynman
|
||||
}
|
||||
if config.OverrideFeynmanFix != nil {
|
||||
chainConfig.FeynmanFixTime = config.OverrideFeynmanFix
|
||||
overrides.OverrideFeynmanFix = config.OverrideFeynmanFix
|
||||
}
|
||||
|
||||
// startup ancient freeze
|
||||
if err = chainDb.SetupFreezerEnv(ðdb.FreezerEnv{
|
||||
|
@ -194,12 +194,6 @@ type Config struct {
|
||||
// OverrideVerkle (TODO: remove after the fork)
|
||||
OverrideVerkle *uint64 `toml:",omitempty"`
|
||||
|
||||
// OverrideFeynman (TODO: remove after the fork)
|
||||
OverrideFeynman *uint64 `toml:",omitempty"`
|
||||
|
||||
// OverrideFeynmanFix (TODO: remove after the fork)
|
||||
OverrideFeynmanFix *uint64 `toml:",omitempty"`
|
||||
|
||||
// blob setting
|
||||
BlobExtraReserve uint64
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
||||
StateHistory uint64 `toml:",omitempty"`
|
||||
StateScheme string `toml:",omitempty"`
|
||||
PathSyncFlush bool `toml:",omitempty"`
|
||||
JournalFileEnabled bool
|
||||
RequiredBlocks map[uint64]common.Hash `toml:"-"`
|
||||
LightServ int `toml:",omitempty"`
|
||||
LightIngress int `toml:",omitempty"`
|
||||
@ -71,8 +72,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
||||
RPCTxFeeCap float64
|
||||
OverrideCancun *uint64 `toml:",omitempty"`
|
||||
OverrideVerkle *uint64 `toml:",omitempty"`
|
||||
OverrideFeynman *uint64 `toml:",omitempty"`
|
||||
OverrideFeynmanFix *uint64 `toml:",omitempty"`
|
||||
BlobExtraReserve uint64
|
||||
}
|
||||
var enc Config
|
||||
enc.Genesis = c.Genesis
|
||||
@ -95,6 +95,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
||||
enc.StateHistory = c.StateHistory
|
||||
enc.StateScheme = c.StateScheme
|
||||
enc.PathSyncFlush = c.PathSyncFlush
|
||||
enc.JournalFileEnabled = c.JournalFileEnabled
|
||||
enc.RequiredBlocks = c.RequiredBlocks
|
||||
enc.LightServ = c.LightServ
|
||||
enc.LightIngress = c.LightIngress
|
||||
@ -129,8 +130,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
||||
enc.RPCTxFeeCap = c.RPCTxFeeCap
|
||||
enc.OverrideCancun = c.OverrideCancun
|
||||
enc.OverrideVerkle = c.OverrideVerkle
|
||||
enc.OverrideFeynman = c.OverrideFeynman
|
||||
enc.OverrideFeynmanFix = c.OverrideFeynmanFix
|
||||
enc.BlobExtraReserve = c.BlobExtraReserve
|
||||
return &enc, nil
|
||||
}
|
||||
|
||||
@ -157,6 +157,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
||||
StateHistory *uint64 `toml:",omitempty"`
|
||||
StateScheme *string `toml:",omitempty"`
|
||||
PathSyncFlush *bool `toml:",omitempty"`
|
||||
JournalFileEnabled *bool
|
||||
RequiredBlocks map[uint64]common.Hash `toml:"-"`
|
||||
LightServ *int `toml:",omitempty"`
|
||||
LightIngress *int `toml:",omitempty"`
|
||||
@ -191,8 +192,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
||||
RPCTxFeeCap *float64
|
||||
OverrideCancun *uint64 `toml:",omitempty"`
|
||||
OverrideVerkle *uint64 `toml:",omitempty"`
|
||||
OverrideFeynman *uint64 `toml:",omitempty"`
|
||||
OverrideFeynmanFix *uint64 `toml:",omitempty"`
|
||||
BlobExtraReserve *uint64
|
||||
}
|
||||
var dec Config
|
||||
if err := unmarshal(&dec); err != nil {
|
||||
@ -258,6 +258,9 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
||||
if dec.PathSyncFlush != nil {
|
||||
c.PathSyncFlush = *dec.PathSyncFlush
|
||||
}
|
||||
if dec.JournalFileEnabled != nil {
|
||||
c.JournalFileEnabled = *dec.JournalFileEnabled
|
||||
}
|
||||
if dec.RequiredBlocks != nil {
|
||||
c.RequiredBlocks = dec.RequiredBlocks
|
||||
}
|
||||
@ -360,11 +363,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
||||
if dec.OverrideVerkle != nil {
|
||||
c.OverrideVerkle = dec.OverrideVerkle
|
||||
}
|
||||
if dec.OverrideFeynman != nil {
|
||||
c.OverrideFeynman = dec.OverrideFeynman
|
||||
}
|
||||
if dec.OverrideFeynmanFix != nil {
|
||||
c.OverrideFeynmanFix = dec.OverrideFeynmanFix
|
||||
if dec.BlobExtraReserve != nil {
|
||||
c.BlobExtraReserve = *dec.BlobExtraReserve
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
mapset "github.com/deckarep/golang-set/v2"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/prque"
|
||||
"github.com/ethereum/go-ethereum/consensus"
|
||||
@ -66,6 +67,10 @@ var (
|
||||
headerFilterOutMeter = metrics.NewRegisteredMeter("eth/fetcher/block/filter/headers/out", nil)
|
||||
bodyFilterInMeter = metrics.NewRegisteredMeter("eth/fetcher/block/filter/bodies/in", nil)
|
||||
bodyFilterOutMeter = metrics.NewRegisteredMeter("eth/fetcher/block/filter/bodies/out", nil)
|
||||
|
||||
blockInsertFailRecords = mapset.NewSet[common.Hash]()
|
||||
blockInsertFailRecordslimit = 1000
|
||||
blockInsertFailGauge = metrics.NewRegisteredGauge("chain/insert/failed", nil)
|
||||
)
|
||||
|
||||
var errTerminated = errors.New("terminated")
|
||||
@ -934,6 +939,10 @@ func (f *BlockFetcher) importBlocks(op *blockOrHeaderInject) {
|
||||
}
|
||||
// Run the actual import and log any issues
|
||||
if _, err := f.insertChain(types.Blocks{block}); err != nil {
|
||||
if blockInsertFailRecords.Cardinality() < blockInsertFailRecordslimit {
|
||||
blockInsertFailRecords.Add(block.Hash())
|
||||
blockInsertFailGauge.Update(int64(blockInsertFailRecords.Cardinality()))
|
||||
}
|
||||
log.Debug("Propagated block import failed", "peer", peer, "number", block.Number(), "hash", hash, "err", err)
|
||||
return
|
||||
}
|
||||
|
@ -131,9 +131,9 @@ func (ec *Client) BlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumb
|
||||
}
|
||||
|
||||
// BlobSidecars return the Sidecars of a given block number or hash.
|
||||
func (ec *Client) BlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]*types.BlobTxSidecar, error) {
|
||||
func (ec *Client) BlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, fullBlob bool) ([]*types.BlobTxSidecar, error) {
|
||||
var r []*types.BlobTxSidecar
|
||||
err := ec.c.CallContext(ctx, &r, "eth_getBlobSidecars", blockNrOrHash.String())
|
||||
err := ec.c.CallContext(ctx, &r, "eth_getBlobSidecars", blockNrOrHash.String(), fullBlob)
|
||||
if err == nil && r == nil {
|
||||
return nil, ethereum.NotFound
|
||||
}
|
||||
@ -141,9 +141,9 @@ func (ec *Client) BlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumbe
|
||||
}
|
||||
|
||||
// BlobSidecarByTxHash return a sidecar of a given blob transaction
|
||||
func (ec *Client) BlobSidecarByTxHash(ctx context.Context, hash common.Hash) (*types.BlobTxSidecar, error) {
|
||||
func (ec *Client) BlobSidecarByTxHash(ctx context.Context, hash common.Hash, fullBlob bool) (*types.BlobTxSidecar, error) {
|
||||
var r *types.BlobTxSidecar
|
||||
err := ec.c.CallContext(ctx, &r, "eth_getBlockSidecarByTxHash", hash)
|
||||
err := ec.c.CallContext(ctx, &r, "eth_getBlockSidecarByTxHash", hash, fullBlob)
|
||||
if err == nil && r == nil {
|
||||
return nil, ethereum.NotFound
|
||||
}
|
||||
|
@ -48,6 +48,9 @@ const (
|
||||
|
||||
// numLevels is the level number of pebble sst files
|
||||
numLevels = 7
|
||||
// degradationWarnInterval specifies how often warning should be printed if the
|
||||
// leveldb database cannot keep up with requested writes.
|
||||
degradationWarnInterval = time.Minute
|
||||
)
|
||||
|
||||
// Database is a persistent key-value store based on the pebble storage engine.
|
||||
@ -84,6 +87,8 @@ type Database struct {
|
||||
compTime atomic.Int64 // Total time spent in compaction in ns
|
||||
level0Comp atomic.Uint32 // Total number of level-zero compactions
|
||||
nonLevel0Comp atomic.Uint32 // Total number of non level-zero compactions
|
||||
|
||||
writeStalled atomic.Bool // Flag whether the write is stalled
|
||||
writeDelayStartTime time.Time // The start time of the latest write stall
|
||||
writeDelayCount atomic.Int64 // Total number of write stall counts
|
||||
writeDelayTime atomic.Int64 // Total time spent in write stalls
|
||||
@ -115,10 +120,13 @@ func (d *Database) onCompactionEnd(info pebble.CompactionInfo) {
|
||||
|
||||
func (d *Database) onWriteStallBegin(b pebble.WriteStallBeginInfo) {
|
||||
d.writeDelayStartTime = time.Now()
|
||||
d.writeDelayCount.Add(1)
|
||||
d.writeStalled.Store(true)
|
||||
}
|
||||
|
||||
func (d *Database) onWriteStallEnd() {
|
||||
d.writeDelayTime.Add(int64(time.Since(d.writeDelayStartTime)))
|
||||
d.writeStalled.Store(false)
|
||||
}
|
||||
|
||||
// panicLogger is just a noop logger to disable Pebble's internal logger.
|
||||
@ -462,12 +470,14 @@ func (d *Database) meter(refresh time.Duration, namespace string) {
|
||||
// Create storage and warning log tracer for write delay.
|
||||
var (
|
||||
compTimes [2]int64
|
||||
writeDelayTimes [2]int64
|
||||
writeDelayCounts [2]int64
|
||||
compWrites [2]int64
|
||||
compReads [2]int64
|
||||
|
||||
nWrites [2]int64
|
||||
|
||||
writeDelayTimes [2]int64
|
||||
writeDelayCounts [2]int64
|
||||
lastWriteStallReport time.Time
|
||||
)
|
||||
|
||||
// Iterate ad infinitum and collect the stats
|
||||
@ -507,6 +517,13 @@ func (d *Database) meter(refresh time.Duration, namespace string) {
|
||||
if d.writeDelayMeter != nil {
|
||||
d.writeDelayMeter.Mark(writeDelayTimes[i%2] - writeDelayTimes[(i-1)%2])
|
||||
}
|
||||
// Print a warning log if writing has been stalled for a while. The log will
|
||||
// be printed per minute to avoid overwhelming users.
|
||||
if d.writeStalled.Load() && writeDelayCounts[i%2] == writeDelayCounts[(i-1)%2] &&
|
||||
time.Now().After(lastWriteStallReport.Add(degradationWarnInterval)) {
|
||||
d.log.Warn("Database compacting, degraded performance")
|
||||
lastWriteStallReport = time.Now()
|
||||
}
|
||||
if d.compTimeMeter != nil {
|
||||
d.compTimeMeter.Mark(compTimes[i%2] - compTimes[(i-1)%2])
|
||||
}
|
||||
@ -600,8 +617,8 @@ func (b *batch) Reset() {
|
||||
func (b *batch) Replay(w ethdb.KeyValueWriter) error {
|
||||
reader := b.b.Reader()
|
||||
for {
|
||||
kind, k, v, ok := reader.Next()
|
||||
if !ok {
|
||||
kind, k, v, ok, err := reader.Next()
|
||||
if !ok || err != nil {
|
||||
break
|
||||
}
|
||||
// The (k,v) slices might be overwritten if the batch is reset/reused,
|
||||
|
2
go.mod
2
go.mod
@ -17,8 +17,8 @@ require (
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2
|
||||
github.com/cespare/cp v1.1.1
|
||||
github.com/cloudflare/cloudflare-go v0.79.0
|
||||
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593
|
||||
github.com/cometbft/cometbft v0.37.0
|
||||
github.com/cockroachdb/pebble v1.1.0
|
||||
github.com/consensys/gnark-crypto v0.12.1
|
||||
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233
|
||||
github.com/crate-crypto/go-kzg-4844 v0.7.0
|
||||
|
4
go.sum
4
go.sum
@ -275,8 +275,8 @@ github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZ
|
||||
github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw=
|
||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE=
|
||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs=
|
||||
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 h1:aPEJyR4rPBvDmeyi+l/FS/VtA00IWvjeFvjen1m1l1A=
|
||||
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593/go.mod h1:6hk1eMY/u5t+Cf18q5lFMUA1Rc+Sm5I6Ra1QuPyxXCo=
|
||||
github.com/cockroachdb/pebble v1.1.0 h1:pcFh8CdCIt2kmEpK0OIatq67Ln9uGDYY3d5XnE0LJG4=
|
||||
github.com/cockroachdb/pebble v1.1.0/go.mod h1:sEHm5NOXxyiAoKWhoFxT8xMgd/f3RA6qUqQ1BXKrh2E=
|
||||
github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30=
|
||||
github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
|
||||
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo=
|
||||
|
@ -1010,7 +1010,7 @@ func (s *BlockChainAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rpc.
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *BlockChainAPI) GetBlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]map[string]interface{}, error) {
|
||||
func (s *BlockChainAPI) GetBlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, fullBlob bool) ([]map[string]interface{}, error) {
|
||||
header, err := s.b.HeaderByNumberOrHash(ctx, blockNrOrHash)
|
||||
if header == nil || err != nil {
|
||||
// When the block doesn't exist, the RPC method should return JSON null
|
||||
@ -1023,12 +1023,12 @@ func (s *BlockChainAPI) GetBlobSidecars(ctx context.Context, blockNrOrHash rpc.B
|
||||
}
|
||||
result := make([]map[string]interface{}, len(blobSidecars))
|
||||
for i, sidecar := range blobSidecars {
|
||||
result[i] = marshalBlobSidecar(sidecar)
|
||||
result[i] = marshalBlobSidecar(sidecar, fullBlob)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *BlockChainAPI) GetBlobSidecarByTxHash(ctx context.Context, hash common.Hash) (map[string]interface{}, error) {
|
||||
func (s *BlockChainAPI) GetBlobSidecarByTxHash(ctx context.Context, hash common.Hash, fullBlob bool) (map[string]interface{}, error) {
|
||||
txTarget, blockHash, _, Index := rawdb.ReadTransaction(s.b.ChainDb(), hash)
|
||||
if txTarget == nil {
|
||||
return nil, nil
|
||||
@ -1045,7 +1045,7 @@ func (s *BlockChainAPI) GetBlobSidecarByTxHash(ctx context.Context, hash common.
|
||||
}
|
||||
for _, sidecar := range blobSidecars {
|
||||
if sidecar.TxIndex == Index {
|
||||
return marshalBlobSidecar(sidecar), nil
|
||||
return marshalBlobSidecar(sidecar, fullBlob), nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -2142,13 +2142,31 @@ func marshalReceipt(receipt *types.Receipt, blockHash common.Hash, blockNumber u
|
||||
return fields
|
||||
}
|
||||
|
||||
func marshalBlobSidecar(sidecar *types.BlobSidecar) map[string]interface{} {
|
||||
func marshalBlobSidecar(sidecar *types.BlobSidecar, fullBlob bool) map[string]interface{} {
|
||||
fields := map[string]interface{}{
|
||||
"blockHash": sidecar.BlockHash,
|
||||
"blockNumber": hexutil.EncodeUint64(sidecar.BlockNumber.Uint64()),
|
||||
"txHash": sidecar.TxHash,
|
||||
"txIndex": hexutil.EncodeUint64(sidecar.TxIndex),
|
||||
"blobSidecar": sidecar.BlobTxSidecar,
|
||||
}
|
||||
fields["blobSidecar"] = marshalBlob(sidecar.BlobTxSidecar, fullBlob)
|
||||
return fields
|
||||
}
|
||||
|
||||
func marshalBlob(blobTxSidecar types.BlobTxSidecar, fullBlob bool) map[string]interface{} {
|
||||
fields := map[string]interface{}{
|
||||
"blobs": blobTxSidecar.Blobs,
|
||||
"commitments": blobTxSidecar.Commitments,
|
||||
"proofs": blobTxSidecar.Proofs,
|
||||
}
|
||||
if !fullBlob {
|
||||
var blobs []common.Hash
|
||||
for _, blob := range blobTxSidecar.Blobs {
|
||||
var value common.Hash
|
||||
copy(value[:], blob[:32])
|
||||
blobs = append(blobs, value)
|
||||
}
|
||||
fields["blobs"] = blobs
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
@ -2140,48 +2140,63 @@ func TestRPCGetBlobSidecars(t *testing.T) {
|
||||
|
||||
var testSuite = []struct {
|
||||
test rpc.BlockNumberOrHash
|
||||
fullBlob bool
|
||||
file string
|
||||
}{
|
||||
// 1. block without any txs(number)
|
||||
{
|
||||
test: rpc.BlockNumberOrHashWithNumber(0),
|
||||
fullBlob: true,
|
||||
file: "number-1",
|
||||
},
|
||||
// 2. earliest tag
|
||||
{
|
||||
test: rpc.BlockNumberOrHashWithNumber(rpc.EarliestBlockNumber),
|
||||
fullBlob: true,
|
||||
file: "tag-earliest",
|
||||
},
|
||||
// 3. latest tag
|
||||
{
|
||||
test: rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber),
|
||||
fullBlob: true,
|
||||
file: "tag-latest",
|
||||
},
|
||||
// 4. block is empty
|
||||
{
|
||||
test: rpc.BlockNumberOrHashWithHash(common.Hash{}, false),
|
||||
fullBlob: true,
|
||||
file: "hash-empty",
|
||||
},
|
||||
// 5. block is not found
|
||||
{
|
||||
test: rpc.BlockNumberOrHashWithHash(common.HexToHash("deadbeef"), false),
|
||||
fullBlob: true,
|
||||
file: "hash-notfound",
|
||||
},
|
||||
// 6. block is not found
|
||||
{
|
||||
test: rpc.BlockNumberOrHashWithNumber(rpc.BlockNumber(genBlocks + 1)),
|
||||
fullBlob: true,
|
||||
file: "block-notfound",
|
||||
},
|
||||
// 7. block with blob tx
|
||||
{
|
||||
test: rpc.BlockNumberOrHashWithNumber(rpc.BlockNumber(6)),
|
||||
fullBlob: true,
|
||||
file: "block-with-blob-tx",
|
||||
},
|
||||
// 8. block with sidecar
|
||||
{
|
||||
test: rpc.BlockNumberOrHashWithNumber(rpc.BlockNumber(7)),
|
||||
fullBlob: true,
|
||||
file: "block-with-blobSidecars",
|
||||
},
|
||||
// 9. block with sidecar but show little
|
||||
{
|
||||
test: rpc.BlockNumberOrHashWithNumber(rpc.BlockNumber(7)),
|
||||
fullBlob: false,
|
||||
file: "block-with-blobSidecars-show-little",
|
||||
},
|
||||
}
|
||||
|
||||
for i, tt := range testSuite {
|
||||
@ -2189,7 +2204,7 @@ func TestRPCGetBlobSidecars(t *testing.T) {
|
||||
result interface{}
|
||||
err error
|
||||
)
|
||||
result, err = api.GetBlobSidecars(context.Background(), tt.test)
|
||||
result, err = api.GetBlobSidecars(context.Background(), tt.test, tt.fullBlob)
|
||||
if err != nil {
|
||||
t.Errorf("test %d: want no error, have %v", i, err)
|
||||
continue
|
||||
@ -2206,33 +2221,45 @@ func TestGetBlobSidecarByTxHash(t *testing.T) {
|
||||
)
|
||||
var testSuite = []struct {
|
||||
test common.Hash
|
||||
fullBlob bool
|
||||
file string
|
||||
}{
|
||||
// 0. txHash is empty
|
||||
{
|
||||
test: common.Hash{},
|
||||
fullBlob: true,
|
||||
file: "hash-empty",
|
||||
},
|
||||
// 1. txHash is not found
|
||||
{
|
||||
test: common.HexToHash("deadbeef"),
|
||||
fullBlob: true,
|
||||
file: "hash-notfound",
|
||||
},
|
||||
// 2. txHash is not blob tx
|
||||
{
|
||||
test: common.HexToHash("deadbeef"),
|
||||
fullBlob: true,
|
||||
file: "not-blob-tx",
|
||||
},
|
||||
// 3. block with blob tx without sidecar
|
||||
{
|
||||
test: txHashs[5],
|
||||
fullBlob: true,
|
||||
file: "block-with-blob-tx",
|
||||
},
|
||||
// 4. block with sidecar
|
||||
{
|
||||
test: txHashs[6],
|
||||
fullBlob: true,
|
||||
file: "block-with-blobSidecars",
|
||||
},
|
||||
// 4. block show part blobs
|
||||
{
|
||||
test: txHashs[6],
|
||||
fullBlob: false,
|
||||
file: "block-with-blobSidecars-show-little",
|
||||
},
|
||||
}
|
||||
|
||||
for i, tt := range testSuite {
|
||||
@ -2240,7 +2267,7 @@ func TestGetBlobSidecarByTxHash(t *testing.T) {
|
||||
result interface{}
|
||||
err error
|
||||
)
|
||||
result, err = api.GetBlobSidecarByTxHash(context.Background(), tt.test)
|
||||
result, err = api.GetBlobSidecarByTxHash(context.Background(), tt.test, tt.fullBlob)
|
||||
if err != nil {
|
||||
t.Errorf("test %d: want no error, have %v", i, err)
|
||||
continue
|
||||
|
17
internal/ethapi/testdata/eth_getBlobSidecarByTxHash-block-with-blobSidecars-show-little.json
vendored
Normal file
17
internal/ethapi/testdata/eth_getBlobSidecarByTxHash-block-with-blobSidecars-show-little.json
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"blobSidecar": {
|
||||
"blobs": [
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000000"
|
||||
],
|
||||
"commitments": [
|
||||
"0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||
],
|
||||
"proofs": [
|
||||
"0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||
]
|
||||
},
|
||||
"blockHash": "0x6fe5e7eea22c44f700c95da066d6e0740894b6c1e993825cc63f634ad4f74250",
|
||||
"blockNumber": "0x7",
|
||||
"txHash": "0xc520427e696154779f6b21ab03a0735769e1c029035a484f5876f60383a0a7ce",
|
||||
"txIndex": "0x0"
|
||||
}
|
19
internal/ethapi/testdata/eth_getBlobSidecars-block-with-blobSidecars-show-little.json
vendored
Normal file
19
internal/ethapi/testdata/eth_getBlobSidecars-block-with-blobSidecars-show-little.json
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
[
|
||||
{
|
||||
"blobSidecar": {
|
||||
"blobs": [
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000000"
|
||||
],
|
||||
"commitments": [
|
||||
"0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||
],
|
||||
"proofs": [
|
||||
"0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||
]
|
||||
},
|
||||
"blockHash": "0x6fe5e7eea22c44f700c95da066d6e0740894b6c1e993825cc63f634ad4f74250",
|
||||
"blockNumber": "0x7",
|
||||
"txHash": "0xc520427e696154779f6b21ab03a0735769e1c029035a484f5876f60383a0a7ce",
|
||||
"txIndex": "0x0"
|
||||
}
|
||||
]
|
@ -617,12 +617,12 @@ web3._extend({
|
||||
new web3._extend.Method({
|
||||
name: 'getBlobSidecars',
|
||||
call: 'eth_getBlobSidecars',
|
||||
params: 1,
|
||||
params: 2,
|
||||
}),
|
||||
new web3._extend.Method({
|
||||
name: 'getBlobSidecarByTxHash',
|
||||
call: 'eth_getBlobSidecarByTxHash',
|
||||
params: 1,
|
||||
params: 2,
|
||||
}),
|
||||
],
|
||||
properties: [
|
||||
|
Loading…
Reference in New Issue
Block a user