Skip to content

Commit

Permalink
Merge pull request #110 from oasysgames/fix/blob-freeze
Browse files Browse the repository at this point in the history
fix blob freeze bug on localchain
  • Loading branch information
tak1827 authored Dec 2, 2024
2 parents e94a68c + 463d765 commit e8315cd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion consensus/oasys/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func (c *Oasys) IsSystemTransaction(tx *types.Transaction, header *types.Header)
}

if sender, err := types.Sender(c.txSigner, tx); err != nil {
return false, errors.New("unauthorized transaction")
return false, fmt.Errorf("unauthorized transaction: %w", err)
} else if sender != header.Coinbase {
// not created by validator
return false, nil
Expand Down
2 changes: 1 addition & 1 deletion consensus/oasys/oasys.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func New(chainConfig *params.ChainConfig, config *params.OasysConfig, db ethdb.D
signatures: signatures,
proposals: make(map[common.Address]bool),
ethAPI: ethAPI,
txSigner: types.MakeSigner(chainConfig, common.Big0, 0),
txSigner: types.LatestSigner(chainConfig),
}
}

Expand Down
14 changes: 5 additions & 9 deletions core/rawdb/chain_freezer.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,9 @@ func (f *chainFreezer) freezeRangeWithBlobs(nfdb *nofreezedb, number, limit uint
}

// freeze pre cancun
if cancunNumber == 0 {
// case of development
} else {
preHashes, err = f.freezeRange(nfdb, number, cancunNumber-1)
if err != nil {
return preHashes, err
}
preHashes, err = f.freezeRange(nfdb, number, cancunNumber-1)
if err != nil {
return preHashes, err
}

if err = ResetEmptyBlobAncientTable(f, cancunNumber); err != nil {
Expand Down Expand Up @@ -391,7 +387,7 @@ func (f *chainFreezer) freezeRange(nfdb *nofreezedb, number, limit uint64) (hash
}
// blobs is nil before cancun fork
var sidecars rlp.RawValue
if isCancun(env, h.Number, h.Time) && number != 0 { // except genesis block in case of development
if isCancun(env, h.Number, h.Time) {
sidecars = ReadBlobSidecarsRLP(nfdb, hash, number)
if len(sidecars) == 0 {
return fmt.Errorf("block blobs missing, can't freeze block %d", number)
Expand All @@ -414,7 +410,7 @@ func (f *chainFreezer) freezeRange(nfdb *nofreezedb, number, limit uint64) (hash
if err := op.AppendRaw(ChainFreezerDifficultyTable, number, td); err != nil {
return fmt.Errorf("can't write td to Freezer: %v", err)
}
if isCancun(env, h.Number, h.Time) && number != 0 { // except genesis block in case of development
if isCancun(env, h.Number, h.Time) {
if err := op.AppendRaw(ChainFreezerBlobSidecarTable, number, sidecars); err != nil {
return fmt.Errorf("can't write blobs to Freezer: %v", err)
}
Expand Down
19 changes: 11 additions & 8 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,17 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
if err != nil {
return nil, err
}
// Override the chain config with provided settings.
var overrides core.ChainOverrides
if config.OverrideCancun != nil {
chainConfig.CancunTime = config.OverrideCancun
overrides.OverrideCancun = config.OverrideCancun
}
if config.OverrideVerkle != nil {
chainConfig.VerkleTime = config.OverrideVerkle
overrides.OverrideVerkle = config.OverrideVerkle
}

// startup ancient freeze
if err = chainDb.SetupFreezerEnv(&ethdb.FreezerEnv{
ChainCfg: chainConfig,
Expand Down Expand Up @@ -225,14 +236,6 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
StateScheme: scheme,
}
)
// Override the chain config with provided settings.
var overrides core.ChainOverrides
if config.OverrideCancun != nil {
overrides.OverrideCancun = config.OverrideCancun
}
if config.OverrideVerkle != nil {
overrides.OverrideVerkle = config.OverrideVerkle
}
eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TransactionHistory)
if err != nil {
return nil, err
Expand Down
4 changes: 4 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,10 @@ func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64, time u
// CheckConfigForkOrder checks that we don't "skip" any forks, geth isn't pluggable enough
// to guarantee that forks can be implemented in a different order than on official networks
func (c *ChainConfig) CheckConfigForkOrder() error {
// skip checking for non-Oasys egine
if c.Oasys == nil {
return nil
}
type fork struct {
name string
block *big.Int // forks up to - and including the merge - were defined with block numbers
Expand Down

0 comments on commit e8315cd

Please sign in to comment.