Fixes to access list and state overrides (#3570)

Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
This commit is contained in:
ledgerwatch 2022-02-22 10:29:02 +00:00 committed by GitHub
parent 20452c3dd6
commit 266625f56a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -336,7 +336,6 @@ func (api *APIImpl) CreateAccessList(ctx context.Context, args ethapi.CallArgs,
} else {
stateReader = state.NewPlainState(tx, blockNumber)
}
state := state.New(stateReader)
header := block.Header()
// If the gas amount is not set, extract this as it will depend on access
@ -373,6 +372,7 @@ func (api *APIImpl) CreateAccessList(ctx context.Context, args ethapi.CallArgs,
prevTracer = logger.NewAccessListTracer(*args.AccessList, *args.From, to, precompiles)
}
for {
state := state.New(stateReader)
// Retrieve the current access list to expand
accessList := prevTracer.AccessList()
log.Trace("Creating access list", "input", accessList)

View File

@ -156,6 +156,11 @@ func (so *stateObject) touch() {
// GetState returns a value from account storage.
func (so *stateObject) GetState(key *common.Hash, out *uint256.Int) {
// If the fake storage is set, only lookup the state here(in the debugging mode)
if so.fakeStorage != nil {
*out = so.fakeStorage[*key]
return
}
value, dirty := so.dirtyStorage[*key]
if dirty {
*out = value
@ -167,6 +172,11 @@ func (so *stateObject) GetState(key *common.Hash, out *uint256.Int) {
// GetCommittedState retrieves a value from the committed account storage trie.
func (so *stateObject) GetCommittedState(key *common.Hash, out *uint256.Int) {
// If the fake storage is set, only lookup the state here(in the debugging mode)
if so.fakeStorage != nil {
*out = so.fakeStorage[*key]
return
}
// If we have the original value cached, return that
{
value, cached := so.originStorage[*key]
@ -197,6 +207,11 @@ func (so *stateObject) GetCommittedState(key *common.Hash, out *uint256.Int) {
// SetState updates a value in account storage.
func (so *stateObject) SetState(key *common.Hash, value uint256.Int) {
// If the fake storage is set, put the temporary state update here.
if so.fakeStorage != nil {
so.fakeStorage[*key] = value
return
}
// If the new value is the same as old, don't set
var prev uint256.Int
so.GetState(key, &prev)