-
Notifications
You must be signed in to change notification settings - Fork 746
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
VM: Custom precompiles #1813
VM: Custom precompiles #1813
Changes from 15 commits
b9db2c7
899b943
3296439
c83c188
fc1a67d
4752594
0b7a064
da1f81b
c168dd7
05cba44
a87ec6f
0a1dd86
e5697ef
09ea3e4
f6a909e
45bac5d
c85658e
12e0f96
09856f8
66686c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ import Common, { Chain, Hardfork } from '@ethereumjs/common' | |
import { AccessList, AccessListItem } from '@ethereumjs/tx' | ||
import { debug as createDebugLogger, Debugger } from 'debug' | ||
import { Account, Address, toBuffer } from 'ethereumjs-util' | ||
import { getActivePrecompiles, ripemdPrecompileAddress } from '../evm/precompiles' | ||
import { CustomPrecompile, getActivePrecompiles, ripemdPrecompileAddress } from '../evm/precompiles' | ||
import Cache from './cache' | ||
import { DefaultStateManagerOpts } from './stateManager' | ||
|
||
|
@@ -25,6 +25,7 @@ export abstract class BaseStateManager { | |
_common: Common | ||
_debug: Debugger | ||
_cache!: Cache | ||
_customPrecompiles?: CustomPrecompile[] | ||
|
||
_touched: Set<AddressHex> | ||
_touchedStack: Set<AddressHex>[] | ||
|
@@ -75,6 +76,10 @@ export abstract class BaseStateManager { | |
|
||
this._checkpointCount = 0 | ||
|
||
if (opts.customPrecompiles) { | ||
this._customPrecompiles = opts.customPrecompiles | ||
} | ||
jochem-brouwer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Safeguard if "process" is not available (browser) | ||
if (process !== undefined && process.env.DEBUG) { | ||
this.DEBUG = true | ||
|
@@ -480,7 +485,9 @@ export abstract class BaseStateManager { | |
const accessList: AccessList = [] | ||
folded.forEach((slots, addressStr) => { | ||
const address = Address.fromString(`0x${addressStr}`) | ||
const check1 = getActivePrecompiles(this._common).find((a) => a.equals(address)) | ||
const check1 = getActivePrecompiles(this._common, this._customPrecompiles).has( | ||
address.buf.toString('hex') | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This very much feels like the wrong abstraction to me to bake the precompiles even more into This becomes even more apparent regarding the upcoming Would it be a way to generally remove this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah right, I don't know why I added this, it should not be there. I think I had in the original PR also the remark that we should probably wait for the state manager to be extracted. |
||
const check2 = addressesRemoved.find((a) => a.equals(address)) | ||
const check3 = | ||
addressesOnlyStorage.find((a) => a.equals(address)) !== undefined && slots.size === 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.
I have changed this function sig, because it is incorrect anyways. Our internal logic calls this method, if
undefined
is returned we run a normal call, otherwise we run the precompile. (Also per the comment above)