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

core/state: construct access list from current state #22289

Closed

Conversation

MariusVanDerWijden
Copy link
Member

@MariusVanDerWijden MariusVanDerWijden commented Feb 8, 2021

Implement access list helpers on top of #21502 and #22290

TODO:

Usage:

> debug.createAccessList("pending", 0, {"from": "0xe840410a7f7a9ecb9010e781cae90b9bb8cbece4", "to":   "0xebe8efa441b9302a0d7eaecc277c09d20d684540", "gas":  "0x1bd7c","data": "0xd459fc46000000000000000000000000000000000000000000000000000000000046c650dbb5e8cb2bac4d2ed0b1e6475d37361157738801c494ca482f96527eb48f9eec488c2eba92d31baeccfb6968fad5c21a3df93181b43b4cf253b4d572b64172ef000000000000000000000000000000000000000000000000000000000000008c00000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000002b85c0c828d7a98633b4e1b65eac0c017502da909420aeade9a280675013df36bdc71cffdf420cef3d24ba4b3f9b980bfbb26bd5e2dcf7795b3519a3fd22ffbb2000000000000000000000000000000000000000000000000000000000000000238fb6606dc2b5e42d00c653372c153da8560de77bd9afaba94b4ab6e4aa11d565d858c761320dbf23a94018d843772349bd9d92301b0ca9ca983a22d86a70628"})
[{
    address: "0x0000000000000000000000000000000000000007",
    storageKeys: null
}, {
    address: "0x0000000000000000000000000000000000000005",
    storageKeys: null
}, {
    address: "0x0000000000000000000000000000000000000008",
    storageKeys: null
}, {
    address: "0x0000000000000000000000000000000000000001",
    storageKeys: null
}, {
    address: "0x0000000000000000000000000000000000000003",
    storageKeys: null
}, {
    address: "0x0000000000000000000000000000000000000002",
    storageKeys: null
}, {
    address: "0xebe8efa441b9302a0d7eaecc277c09d20d684540",
    storageKeys: null
}, {
    address: "0xe840410a7f7a9ecb9010e781cae90b9bb8cbece4",
    storageKeys: null
}, {
    address: "0x0000000000000000000000000000000000000004",
    storageKeys: null
}, {
    address: "0x0000000000000000000000000000000000000006",
    storageKeys: null
}, {
    address: "0x0000000000000000000000000000000000000009",
    storageKeys: null
}]

Edit: the above output was from before the access list was unprepared.

> debug.createAccessList("pending", 0, {"from": "0x067dc07d4df2bda13d5a1ea9efced4c129974350", "to":   "0xebe8efa441b9302a0d7eaecc277c09d20d684540", "gas":  "0x1bd7c","data": "0xd459fc46000000000000000000000000000000000000000000000000000000000046c650dbb5e8cb2bac4d2ed0b1e6475d37361157738801c494ca482f96527eb48f9eec488c2eba92d31baeccfb6968fad5c21a3df93181b43b4cf253b4d572b64172ef000000000000000000000000000000000000000000000000000000000000008c00000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000002b85c0c828d7a98633b4e1b65eac0c017502da909420aeade9a280675013df36bdc71cffdf420cef3d24ba4b3f9b980bfbb26bd5e2dcf7795b3519a3fd22ffbb2000000000000000000000000000000000000000000000000000000000000000238fb6606dc2b5e42d00c653372c153da8560de77bd9afaba94b4ab6e4aa11d565d858c761320dbf23a94018d843772349bd9d92301b0ca9ca983a22d86a70628"})
[]

@MariusVanDerWijden MariusVanDerWijden force-pushed the access_list_stuff branch 2 times, most recently from 06200a2 to 48a207f Compare February 10, 2021 12:06
@MariusVanDerWijden MariusVanDerWijden force-pushed the access_list_stuff branch 2 times, most recently from ceb7be3 to 4fcf1cb Compare February 22, 2021 12:58
@MariusVanDerWijden MariusVanDerWijden marked this pull request as ready for review March 4, 2021 12:10
@MariusVanDerWijden MariusVanDerWijden changed the title Access list stuff core/state: construct access list from current state Mar 4, 2021
core/state/statedb.go Outdated Show resolved Hide resolved
return nil, fmt.Errorf("failed to apply transaction: %v err: %v", args.ToTransaction().Hash(), err)
}
if res.UsedGas == gas {
vmenv.StateDB.UnprepareAccessList(args.From, args.To, vmenv.ActivePrecompiles())
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see why we need this Unprepare, whicih also is journalled.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that was a question I had, whether I should unprepare the access list inside or outside of the statedb.
If I unprepare inside of the statedb (the way it currently is) then this should be journalled. But I guess I should unprepare it outside of the statedb.
We need unprepare to remove sender, recipient and the precompiles from the access list
Note to myself, we should only remove the recipient if it has no other state accesses

Copy link
Contributor

Choose a reason for hiding this comment

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

Note to myself, we should only remove the recipient if it has no other state accesses

Yes. only if the slotlist is empty.

Copy link
Contributor

Choose a reason for hiding this comment

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

But really, you only need to 'clean it' as the very last step before returning it to the user.

@holiman
Copy link
Contributor

holiman commented Mar 22, 2021

One gotcha, that I don't think we handle in this PR is that if a tx calls X a subscope, and X tries to call Y, but goes OOG. Then Y will be un-added to the access list. And the caill fails, but would have succeeded had Y been in there from the beginining. And I don't think this PR will spit out Y.
Need to think about how we can solve that in a nice clean way

@MariusVanDerWijden MariusVanDerWijden mentioned this pull request Mar 22, 2021
2 tasks
@MariusVanDerWijden
Copy link
Member Author

Superseeded by #22550

@MariusVanDerWijden MariusVanDerWijden deleted the access_list_stuff branch November 30, 2021 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants