mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-07 08:13:11 +00:00
More metadata fields
This commit is contained in:
parent
002b568a12
commit
b4d83f8db2
@ -7,10 +7,20 @@ pub(crate) enum ContextMetadata {
|
|||||||
ParentProgramCounter = 1,
|
ParentProgramCounter = 1,
|
||||||
CalldataSize = 2,
|
CalldataSize = 2,
|
||||||
ReturndataSize = 3,
|
ReturndataSize = 3,
|
||||||
|
/// The address of the account associated with this context.
|
||||||
|
Address = 4,
|
||||||
|
/// The size of the code under the account associated with this context.
|
||||||
|
/// While this information could be obtained from the state trie, it is best to cache it since
|
||||||
|
/// the `CODESIZE` instruction is very cheap.
|
||||||
|
CodeSize = 5,
|
||||||
|
/// The address of the caller who spawned this context.
|
||||||
|
Caller = 6,
|
||||||
|
/// The value (in wei) deposited by the caller.
|
||||||
|
CallValue = 7,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ContextMetadata {
|
impl ContextMetadata {
|
||||||
pub(crate) const COUNT: usize = 4;
|
pub(crate) const COUNT: usize = 8;
|
||||||
|
|
||||||
pub(crate) fn all() -> [Self; Self::COUNT] {
|
pub(crate) fn all() -> [Self; Self::COUNT] {
|
||||||
[
|
[
|
||||||
@ -18,6 +28,10 @@ impl ContextMetadata {
|
|||||||
Self::ParentProgramCounter,
|
Self::ParentProgramCounter,
|
||||||
Self::CalldataSize,
|
Self::CalldataSize,
|
||||||
Self::ReturndataSize,
|
Self::ReturndataSize,
|
||||||
|
Self::Address,
|
||||||
|
Self::CodeSize,
|
||||||
|
Self::Caller,
|
||||||
|
Self::CallValue,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,6 +42,10 @@ impl ContextMetadata {
|
|||||||
ContextMetadata::ParentProgramCounter => "CTX_METADATA_PARENT_PC",
|
ContextMetadata::ParentProgramCounter => "CTX_METADATA_PARENT_PC",
|
||||||
ContextMetadata::CalldataSize => "CTX_METADATA_CALLDATA_SIZE",
|
ContextMetadata::CalldataSize => "CTX_METADATA_CALLDATA_SIZE",
|
||||||
ContextMetadata::ReturndataSize => "CTX_METADATA_RETURNDATA_SIZE",
|
ContextMetadata::ReturndataSize => "CTX_METADATA_RETURNDATA_SIZE",
|
||||||
|
ContextMetadata::Address => "CTX_METADATA_ADDRESS",
|
||||||
|
ContextMetadata::CodeSize => "CTX_METADATA_CODE_SIZE",
|
||||||
|
ContextMetadata::Caller => "CTX_METADATA_CALLER",
|
||||||
|
ContextMetadata::CallValue => "CTX_METADATA_CALL_VALUE",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,19 +5,25 @@ pub(crate) enum GlobalMetadata {
|
|||||||
/// The largest context ID that has been used so far in this execution. Tracking this allows us
|
/// The largest context ID that has been used so far in this execution. Tracking this allows us
|
||||||
/// give each new context a unique ID, so that its memory will be zero-initialized.
|
/// give each new context a unique ID, so that its memory will be zero-initialized.
|
||||||
LargestContext = 0,
|
LargestContext = 0,
|
||||||
|
/// The address of the sender of the transaction.
|
||||||
|
Origin = 1,
|
||||||
|
/// The size of active memory, in bytes.
|
||||||
|
MemorySize = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlobalMetadata {
|
impl GlobalMetadata {
|
||||||
pub(crate) const COUNT: usize = 1;
|
pub(crate) const COUNT: usize = 3;
|
||||||
|
|
||||||
pub(crate) fn all() -> [Self; Self::COUNT] {
|
pub(crate) fn all() -> [Self; Self::COUNT] {
|
||||||
[Self::LargestContext]
|
[Self::LargestContext, Self::Origin, Self::MemorySize]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The variable name that gets passed into kernel assembly code.
|
/// The variable name that gets passed into kernel assembly code.
|
||||||
pub(crate) fn var_name(&self) -> &'static str {
|
pub(crate) fn var_name(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
GlobalMetadata::LargestContext => "GLOBAL_METADATA_LARGEST_CONTEXT",
|
GlobalMetadata::LargestContext => "GLOBAL_METADATA_LARGEST_CONTEXT",
|
||||||
|
GlobalMetadata::Origin => "GLOBAL_METADATA_ORIGIN",
|
||||||
|
GlobalMetadata::MemorySize => "GLOBAL_METADATA_MEMORY_SIZE",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user