Add journal entry for logs (#1286)

* Add journal entry for logs

* Move journal labels to another file.

* Minor cleanup
This commit is contained in:
Linda Guiga 2023-10-11 10:36:23 -04:00 committed by GitHub
parent 9fd0425f67
commit d7990ee137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 1 deletions

View File

@ -148,6 +148,7 @@ pub(crate) fn combined_kernel() -> Kernel {
include_str!("asm/journal/refund.asm"),
include_str!("asm/journal/account_created.asm"),
include_str!("asm/journal/revert.asm"),
include_str!("asm/journal/log.asm"),
include_str!("asm/transactions/common_decoding.asm"),
include_str!("asm/transactions/router.asm"),
include_str!("asm/transactions/type_0.asm"),

View File

@ -188,6 +188,8 @@ log_after_topics:
%rlp_list_len
// stack: rlp_log_len, data_len_ptr, num_topics, data_len, data_offset, retdest
%mload_global_metadata(@GLOBAL_METADATA_LOGS_PAYLOAD_LEN)
// Add payload length and logs_data_len to journal.
DUP1 %mload_global_metadata(@GLOBAL_METADATA_LOGS_DATA_LEN) %journal_add_log
ADD
%mstore_global_metadata(@GLOBAL_METADATA_LOGS_PAYLOAD_LEN)
// stack: data_len_ptr, num_topics, data_len, data_offset, retdest

View File

@ -0,0 +1,20 @@
// struct Log { logs_data_len, logs_payload_len }
%macro journal_add_log
%journal_add_2(@JOURNAL_ENTRY_LOG)
%endmacro
global revert_log:
// stack: entry_type, ptr, retdest
POP
// First, reduce the number of logs.
%mload_global_metadata(@GLOBAL_METADATA_LOGS_LEN)
%decrement
%mstore_global_metadata(@GLOBAL_METADATA_LOGS_LEN)
// stack: ptr, retdest
// Second, restore payload length.
%journal_load_2
// stack: prev_logs_data_len, prev_payload_len, retdest
%mstore_global_metadata(@GLOBAL_METADATA_LOGS_DATA_LEN)
%mstore_global_metadata(@GLOBAL_METADATA_LOGS_PAYLOAD_LEN)
JUMP

View File

@ -16,6 +16,7 @@
DUP1 %eq_const(@JOURNAL_ENTRY_CODE_CHANGE) %jumpi(revert_code_change)
DUP1 %eq_const(@JOURNAL_ENTRY_REFUND) %jumpi(revert_refund)
DUP1 %eq_const(@JOURNAL_ENTRY_ACCOUNT_CREATED) %jumpi(revert_account_created)
DUP1 %eq_const(@JOURNAL_ENTRY_LOG) %jumpi(revert_log)
PANIC // This should never happen.
%%after:
// stack: journal_size-1

View File

@ -11,10 +11,11 @@ pub(crate) enum JournalEntry {
CodeChange = 7,
Refund = 8,
AccountCreated = 9,
Log = 10,
}
impl JournalEntry {
pub(crate) const COUNT: usize = 10;
pub(crate) const COUNT: usize = 11;
pub(crate) fn all() -> [Self; Self::COUNT] {
[
@ -28,6 +29,7 @@ impl JournalEntry {
Self::CodeChange,
Self::Refund,
Self::AccountCreated,
Self::Log,
]
}
@ -44,6 +46,7 @@ impl JournalEntry {
Self::CodeChange => "JOURNAL_ENTRY_CODE_CHANGE",
Self::Refund => "JOURNAL_ENTRY_REFUND",
Self::AccountCreated => "JOURNAL_ENTRY_ACCOUNT_CREATED",
Self::Log => "JOURNAL_ENTRY_LOG",
}
}
}