Skip to content

Commit

Permalink
JournalBase
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Dec 6, 2023
1 parent 7762104 commit 58f0866
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions test/state/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,45 @@

namespace evmone::state
{
struct JournalBalanceChange
struct JournalBase
{
address addr;
intx::uint256 prev_balance;
};

struct JournalTouched
struct JournalBalanceChange : JournalBase
{
address addr;
intx::uint256 prev_balance;
};

struct JournalStorageChange
struct JournalTouched : JournalBase
{};

struct JournalStorageChange : JournalBase
{
address addr;
bytes32 key;
bytes32 prev_value;
evmc_access_status prev_access_status;
};

struct JournalTransientStorageChange
struct JournalTransientStorageChange : JournalBase
{
address addr;
bytes32 key;
bytes32 prev_value;
};

struct JournalNonceBump
{
address addr;
};
struct JournalNonceBump : JournalBase
{};

struct JournalCreate
struct JournalCreate : JournalBase
{
address addr;
bool existed;
};

struct JournalDestruct
{
address addr;
};
struct JournalDestruct : JournalBase
{};

struct JournalAccessAccount
{
address addr;
};
struct JournalAccessAccount : JournalBase
{};

using JournalEntry =
std::variant<JournalBalanceChange, JournalTouched, JournalStorageChange, JournalNonceBump,
Expand Down Expand Up @@ -125,25 +118,26 @@ class State

void journal_balance_change(const address& addr, const intx::uint256& prev_balance)
{
m_journal.emplace_back(JournalBalanceChange{addr, prev_balance});
m_journal.emplace_back(JournalBalanceChange{{addr}, prev_balance});
}

void journal_storage_change(const address& addr, const bytes32& key, const StorageValue& value)
{
m_journal.emplace_back(JournalStorageChange{addr, key, value.current, value.access_status});
m_journal.emplace_back(
JournalStorageChange{{addr}, key, value.current, value.access_status});
}

void journal_transient_storage_change(
const address& addr, const bytes32& key, const bytes32& value)
{
m_journal.emplace_back(JournalTransientStorageChange{addr, key, value});
m_journal.emplace_back(JournalTransientStorageChange{{addr}, key, value});
}

void journal_bump_nonce(const address& addr) { m_journal.emplace_back(JournalNonceBump{addr}); }

void journal_create(const address& addr, bool existed)
{
m_journal.emplace_back(JournalCreate{addr, existed});
m_journal.emplace_back(JournalCreate{{addr}, existed});
}

void journal_destruct(const address& addr) { m_journal.emplace_back(JournalDestruct{addr}); }
Expand Down

0 comments on commit 58f0866

Please sign in to comment.