mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-04 23:03:08 +00:00
Merge pull request #655 from mir-protocol/more_metadata
More metadata fields
This commit is contained in:
commit
5f14bef57e
@ -7,10 +7,20 @@ pub(crate) enum ContextMetadata {
|
||||
ParentProgramCounter = 1,
|
||||
CalldataSize = 2,
|
||||
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 {
|
||||
pub(crate) const COUNT: usize = 4;
|
||||
pub(crate) const COUNT: usize = 8;
|
||||
|
||||
pub(crate) fn all() -> [Self; Self::COUNT] {
|
||||
[
|
||||
@ -18,6 +28,10 @@ impl ContextMetadata {
|
||||
Self::ParentProgramCounter,
|
||||
Self::CalldataSize,
|
||||
Self::ReturndataSize,
|
||||
Self::Address,
|
||||
Self::CodeSize,
|
||||
Self::Caller,
|
||||
Self::CallValue,
|
||||
]
|
||||
}
|
||||
|
||||
@ -28,6 +42,10 @@ impl ContextMetadata {
|
||||
ContextMetadata::ParentProgramCounter => "CTX_METADATA_PARENT_PC",
|
||||
ContextMetadata::CalldataSize => "CTX_METADATA_CALLDATA_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
|
||||
/// give each new context a unique ID, so that its memory will be zero-initialized.
|
||||
LargestContext = 0,
|
||||
/// The address of the sender of the transaction.
|
||||
Origin = 1,
|
||||
/// The size of active memory, in bytes.
|
||||
MemorySize = 2,
|
||||
}
|
||||
|
||||
impl GlobalMetadata {
|
||||
pub(crate) const COUNT: usize = 1;
|
||||
pub(crate) const COUNT: usize = 3;
|
||||
|
||||
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.
|
||||
pub(crate) fn var_name(&self) -> &'static str {
|
||||
match self {
|
||||
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