-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement genesis for the Evm module
- Loading branch information
Showing
4 changed files
with
63 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
module-system/module-implementations/sov-evm/src/genesis.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,29 @@ | ||
use anyhow::Result; | ||
use sov_state::WorkingSet; | ||
|
||
use crate::evm::db_init::InitEvmDb; | ||
use crate::evm::AccountInfo; | ||
use crate::Evm; | ||
|
||
impl<C: sov_modules_api::Context> Evm<C> { | ||
pub(crate) fn init_module( | ||
&self, | ||
config: &<Self as sov_modules_api::Module>::Config, | ||
working_set: &mut WorkingSet<C::Storage>, | ||
) -> Result<()> { | ||
let mut evm_db = self.get_db(working_set); | ||
|
||
for acc in &config.data { | ||
evm_db.insert_account_info( | ||
acc.address, | ||
AccountInfo { | ||
balance: acc.balance, | ||
code_hash: acc.code_hash, | ||
code: acc.code.clone(), | ||
nonce: acc.nonce, | ||
}, | ||
) | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters