forked from lambdaclass/ethrex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: store account info in db (lambdaclass#63)
**Motivation** Enable storing account information in DB **Description** * Rename `Account` into `GenesisAccount` and add a separate `Account` struct containing the storage, code, and info fields, with the info being an `AccountInfo` struct containing the code hash. Also implement conversion from `GenesisAccount` to `Account` * Create `AccountInfos` table mapping addresses to account info * Implement TODO comment related to encoding <!-- Link to issues: Resolves lambdaclass#111, Resolves lambdaclass#222 --> Closes lambdaclass#40
- Loading branch information
Showing
6 changed files
with
120 additions
and
19 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use libmdbx::orm::{Decodable, Encodable}; | ||
|
||
pub struct AddressRLP(Vec<u8>); | ||
|
||
pub struct AccountInfoRLP(Vec<u8>); | ||
|
||
impl Encodable for AddressRLP { | ||
type Encoded = Vec<u8>; | ||
|
||
fn encode(self) -> Self::Encoded { | ||
self.0 | ||
} | ||
} | ||
|
||
impl Decodable for AddressRLP { | ||
fn decode(b: &[u8]) -> anyhow::Result<Self> { | ||
Ok(AddressRLP(b.to_vec())) | ||
} | ||
} | ||
|
||
impl Encodable for AccountInfoRLP { | ||
type Encoded = Vec<u8>; | ||
|
||
fn encode(self) -> Self::Encoded { | ||
self.0 | ||
} | ||
} | ||
|
||
impl Decodable for AccountInfoRLP { | ||
fn decode(b: &[u8]) -> anyhow::Result<Self> { | ||
Ok(AccountInfoRLP(b.to_vec())) | ||
} | ||
} |
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