-
Notifications
You must be signed in to change notification settings - Fork 7
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
Initialize precompiles in InitGenesis #57
Conversation
9894b45
to
98311b4
Compare
stateDB.SetNonce(addr, PrecompileNonce) | ||
// Set the code of the precompile's address to a non-zero length byte slice to ensure that the precompile | ||
// can be called from within Solidity contracts. Solidity adds a check before invoking a contract to ensure | ||
// that it does not attempt to invoke a non-existent contract. | ||
stateDB.SetCode(addr, PrecompileCode) |
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.
We could use Keeper.SetAccount()
for nonce+codehash and Keeper.SetCode
directly instead of using StateDB since we don't need the snapshot/rollback/commit features of StateDB.
SetCode
also is global mapping of codeHash to code too, so we only need to set the code once (still need to set codehash in account)
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.
This task was split into 2 tasks:
- Init precompiles in
InitGenesis
- this part is postponed, Nick finalizes the spec - Init precompiles in
UpdateParams
- this part is implemented here: Initialize precompiles in UpdateParams #58
This PR will be closed, sorry for confusion.
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.
ah no worries
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.
and yeah, in #58 I'm directly using evmKeeper
instead of StateDB
@@ -68,7 +68,14 @@ func (k *Keeper) NewEVM( | |||
tracer = k.Tracer(ctx, msg, cfg.ChainConfig) | |||
} | |||
vmConfig := k.VMConfig(ctx, msg, cfg, tracer) | |||
return k.evmConstructor(blockCtx, txCtx, stateDB, cfg.ChainConfig, vmConfig) | |||
|
|||
enabledPrecompiles := k.GetParams(ctx).EnabledPrecompiles |
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.
Params is in EVMConfig so we don't need to fetch it again - cfg.Params.EnabledPrecompiles
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.
got it
657942a
to
b3ff7b3
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days-before-close if no further activity occurs. |
Moved to #58
PR is deprecated,
Initialize precompiles in InitGenesis
should follow these guildelines: https://kava-labs.atlassian.net/wiki/spaces/ENG/pages/1469448211/Module+Genesis+GuidelinesPR breaks this requirement:
ExportGenesis(InitGenesis(genesisState)) == genesisState
, because we callSetNonce
&SetCode
in InitGenesis which creates evm accounts, then these accounts will be exported inExportGenesis
.We should instead rely on GenesisAccount{ 0x100…0, 0x01, []State{}) being in the genesis state for each enabled precompile