-
Notifications
You must be signed in to change notification settings - Fork 334
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
base: master
Are you sure you want to change the base?
Conversation
|
err := store.tx.Commit() | ||
if err != nil { | ||
return err | ||
} | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return store.tx.Commit()
func WithBlockTimeGetter(getBlockTime func(uint64) (time.Time, error)) StateDBOption { | ||
return func(sdb *stateDB, cfg *Config) error { | ||
cfg.getBlockTime = getBlockTime | ||
return nil | ||
} | ||
} |
There was a problem hiding this comment.
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?
if sdb.erigonDB != nil { | ||
ws, err = sdb.newWorkingSetWithErigonOutput(ctx, 0) | ||
} else { | ||
ws, err = sdb.newWorkingSet(ctx, 0) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repeated code
// 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() | ||
// } |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
} else { | ||
panic(fmt.Sprintf("no isn for sn %d", sn)) |
There was a problem hiding this comment.
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?
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) |
There was a problem hiding this comment.
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?
err = tx.Put(systemNS, heightKey, uint256.NewInt(height).Bytes()) | ||
if err != nil { | ||
return err | ||
} |
There was a problem hiding this comment.
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())
err = c.WriteHistory() | ||
if err != nil { | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return c.WriteHistory()
Description
based #4551
Type of change
Please delete options that are not relevant.
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
Test Configuration:
Checklist: