Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[statedb] store account by erigon #4559

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

envestcc
Copy link
Member

Description

based #4551

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • [] Code refactor or improvement
  • [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
  • [] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [] make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

@envestcc envestcc requested review from CoderZhi, dustinxie, Liuhaai and a team as code owners February 14, 2025 00:56
@envestcc envestcc added the erigon integrate erigon as archive mode storage label Feb 27, 2025
Comment on lines +155 to +159
err := store.tx.Commit()
if err != nil {
return err
}
return nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return store.tx.Commit()

Comment on lines +95 to +100
func WithBlockTimeGetter(getBlockTime func(uint64) (time.Time, error)) StateDBOption {
return func(sdb *stateDB, cfg *Config) error {
cfg.getBlockTime = getBlockTime
return nil
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we delete it and always set getBlockTime? Is this part of the Config or part of the StateDB?

Comment on lines +493 to +497
if sdb.erigonDB != nil {
ws, err = sdb.newWorkingSetWithErigonOutput(ctx, 0)
} else {
ws, err = sdb.newWorkingSet(ctx, 0)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repeated code

Comment on lines +201 to +223
// func (store *stateDBWorkingSetStoreWithErigonDryrun) WriteView(name string, value interface{}) error {
// return store.outer.WriteView(name, value)
// }

// func (store *stateDBWorkingSetStoreWithErigonDryrun) Put(ns string, key []byte, value []byte) error {
// return store.outer.Put(ns, key, value)
// }

// func (store *stateDBWorkingSetStoreWithErigonDryrun) Delete(ns string, key []byte) error {
// return store.outer.Delete(ns, key)
// }

// func (store *stateDBWorkingSetStoreWithErigonDryrun) Snapshot() int {
// return store.outer.Snapshot()
// }

// func (store *stateDBWorkingSetStoreWithErigonDryrun) RevertSnapshot(sn int) error {
// return store.outer.RevertSnapshot(sn)
// }

// func (store *stateDBWorkingSetStoreWithErigonDryrun) ResetSnapshots() {
// store.outer.ResetSnapshots()
// }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete

}

func (store *stateDBWorkingSetStoreWithErigonOutput) RevertSnapshot(sn int) error {
store.store.RevertSnapshot(sn)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the error of RevertSnapshot is not handled

Comment on lines +121 to +122
} else {
panic(fmt.Sprintf("no isn for sn %d", sn))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we return error or panic?

Comment on lines +104 to +111
blkCtx := protocol.MustGetBlockCtx(ctx)
g := genesis.MustExtractGenesisContext(ctx)
chainCfg, err := evm.NewChainConfig(g.Blockchain, blkCtx.BlockHeight, protocol.MustGetBlockchainCtx(ctx).EvmNetworkID, store.getBlockTime)
if err != nil {
return err
}
chainRules := chainCfg.Rules(big.NewInt(int64(blkCtx.BlockHeight)), g.IsSumatra(blkCtx.BlockHeight), uint64(blkCtx.BlockTimeStamp.Unix()))
rules := evm.NewErigonRules(&chainRules)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to recreate rules for every tx?

Comment on lines +145 to +148
err = tx.Put(systemNS, heightKey, uint256.NewInt(height).Bytes())
if err != nil {
return err
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return tx.Put(systemNS, heightKey, uint256.NewInt(height).Bytes())

Comment on lines +138 to +141
err = c.WriteHistory()
if err != nil {
return err
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return c.WriteHistory()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
erigon integrate erigon as archive mode storage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants