Selfdestruct gas and set (#947)

* Add new segment and global metadata

* Insert into self-destruct set

* Implement sys_selfdestruct

* PR feedback

* Fix stack underflow

* Forgot that NOT 1 ≠ 0. Added %not_bit macro for that.
This commit is contained in:
wborgeaud
2023-03-31 11:13:36 +02:00
committed by GitHub
parent 786a71d678
commit 2ca00a9ad4
8 changed files with 159 additions and 10 deletions
+6 -1
View File
@@ -48,10 +48,12 @@ pub enum Segment {
AccessedAddresses = 23,
/// List of storage keys that have been accessed in the current transaction.
AccessedStorageKeys = 24,
/// List of addresses that have called SELFDESTRUCT in the current transaction.
SelfDestructSet = 25,
}
impl Segment {
pub(crate) const COUNT: usize = 25;
pub(crate) const COUNT: usize = 26;
pub(crate) fn all() -> [Self; Self::COUNT] {
[
@@ -80,6 +82,7 @@ impl Segment {
Self::BnPairing,
Self::AccessedAddresses,
Self::AccessedStorageKeys,
Self::SelfDestructSet,
]
}
@@ -111,6 +114,7 @@ impl Segment {
Segment::BnPairing => "SEGMENT_KERNEL_BN_PAIRING",
Segment::AccessedAddresses => "SEGMENT_ACCESSED_ADDRESSES",
Segment::AccessedStorageKeys => "SEGMENT_ACCESSED_STORAGE_KEYS",
Segment::SelfDestructSet => "SEGMENT_SELFDESTRUCT_SET",
}
}
@@ -142,6 +146,7 @@ impl Segment {
Segment::BnPairing => 256,
Segment::AccessedAddresses => 256,
Segment::AccessedStorageKeys => 256,
Segment::SelfDestructSet => 256,
}
}
}