Skip to content

Commit

Permalink
Hardfork Prague removed until needed
Browse files Browse the repository at this point in the history
  • Loading branch information
gzanitti committed Oct 20, 2023
1 parent 57e8df5 commit 0743a79
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 993 deletions.
7 changes: 0 additions & 7 deletions etk-asm/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::path::PathBuf;
use crate::ops::{Abstract, AbstractOp, ExpressionMacroDefinition, InstructionMacroDefinition};
use etk_ops::cancun::Op as CancunOp;
use etk_ops::london::Op as LondonOp;
use etk_ops::prague::Op as PragueOp;
use etk_ops::shanghai::Op as ShanghaiOp;

#[derive(Debug, Clone, PartialEq)]
Expand All @@ -25,12 +24,6 @@ impl From<ShanghaiOp<Abstract>> for Node {
}
}

impl From<PragueOp<Abstract>> for Node {
fn from(op: PragueOp<Abstract>) -> Self {
Node::Op(AbstractOp::Op(etk_ops::HardForkOp::Prague(op)))
}
}

impl From<LondonOp<Abstract>> for Node {
fn from(op: LondonOp<Abstract>) -> Self {
Node::Op(AbstractOp::Op(etk_ops::HardForkOp::London(op)))
Expand Down
17 changes: 0 additions & 17 deletions etk-asm/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ pub(crate) use self::error::Error;

use etk_ops::cancun::Push32 as CancunPush32;
use etk_ops::london::Push32 as LondonPush32;
use etk_ops::prague::Push32 as PraguePush32;
use etk_ops::shanghai::Push32 as ShanghaiPush32;
use etk_ops::HardFork;
use etk_ops::HardForkOp;
Expand Down Expand Up @@ -147,16 +146,6 @@ impl Concretize for HardForkOp<Abstract> {
})?;
HardForkOp::London(op_context)
}
HardForkOp::Prague(op) => {
let op_context =
op.code()
.with(bytes.as_slice())
.context(error::ExpressionTooLarge {
value,
spec: self.code(),
})?;
HardForkOp::Prague(op_context)
}
};

Ok(result)
Expand Down Expand Up @@ -268,9 +257,6 @@ impl AbstractOp {
HardFork::London => {
HardForkOp::London(etk_ops::london::Op::Push32(LondonPush32(())))
}
HardFork::Prague => {
HardForkOp::Prague(etk_ops::prague::Op::Push32(PraguePush32(())))
}
};
// TODO: Fix hack to get a TryFromSliceError.
let err = <[u8; 32]>::try_from(bytes.as_slice())
Expand All @@ -295,9 +281,6 @@ impl AbstractOp {
HardFork::London => HardForkOp::London(
etk_ops::london::Op::<()>::push(size.try_into().unwrap()).unwrap(),
),
HardFork::Prague => HardForkOp::Prague(
etk_ops::prague::Op::<()>::push(size.try_into().unwrap()).unwrap(),
),
};

let start = bytes.len() + 1 - spec.size();
Expand Down
6 changes: 0 additions & 6 deletions etk-asm/src/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use self::{

use etk_ops::cancun::Op as CancunOp;
use etk_ops::london::Op as LondonOp;
use etk_ops::prague::Op as PragueOp;
use etk_ops::shanghai::Op as ShanghaiOp;

use crate::ast::Node;
Expand Down Expand Up @@ -62,9 +61,6 @@ fn parse_abstract_op(pair: Pair<Rule>, hardfork: HardFork) -> Result<AbstractOp,
HardFork::Shanghai => {
HardForkOp::Shanghai(ShanghaiOp::new(pair.as_str().parse().unwrap()).unwrap())
}
HardFork::Prague => {
HardForkOp::Prague(PragueOp::new(pair.as_str().parse().unwrap()).unwrap())
}
HardFork::London => {
HardForkOp::London(LondonOp::new(pair.as_str().parse().unwrap()).unwrap())
}
Expand All @@ -87,11 +83,9 @@ fn parse_push(pair: Pair<Rule>, hardfork: HardFork) -> Result<AbstractOp, ParseE
let spec = match hardfork {
HardFork::Cancun => HardForkOp::Cancun(CancunOp::<()>::push(size).unwrap()),
HardFork::Shanghai => HardForkOp::Shanghai(ShanghaiOp::<()>::push(size).unwrap()),
HardFork::Prague => HardForkOp::Prague(PragueOp::<()>::push(size).unwrap()),
HardFork::London => HardForkOp::London(LondonOp::<()>::push(size).unwrap()),
};

//let spec = Op::<()>::push(size).unwrap();
let expr = expression::parse(operand)?;

if let Ok(val) = expr.eval() {
Expand Down
20 changes: 10 additions & 10 deletions etk-asm/tests/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ where
#[test]
fn simple_constructor() -> Result<(), Error> {
let mut output = Vec::new();
let mut ingester = Ingest::new(&mut output, HardFork::default());
let mut ingester = Ingest::new(&mut output, HardFork::Cancun);
ingester.ingest_file(source(&["simple-constructor", "ctor.etk"]))?;

assert_eq!(
Expand All @@ -40,7 +40,7 @@ fn simple_constructor() -> Result<(), Error> {
#[test]
fn out_of_bounds() {
let mut output = Vec::new();
let mut ingester = Ingest::new(&mut output, HardFork::default());
let mut ingester = Ingest::new(&mut output, HardFork::Cancun);
let err = ingester
.ingest_file(source(&["out-of-bounds", "main", "main.etk"]))
.unwrap_err();
Expand All @@ -51,7 +51,7 @@ fn out_of_bounds() {
#[test]
fn subdirectory() -> Result<(), Error> {
let mut output = Vec::new();
let mut ingester = Ingest::new(&mut output, HardFork::default());
let mut ingester = Ingest::new(&mut output, HardFork::Cancun);
ingester.ingest_file(source(&["subdirectory", "main.etk"]))?;

assert_eq!(output, hex!("63c001c0de60ff"));
Expand All @@ -62,7 +62,7 @@ fn subdirectory() -> Result<(), Error> {
#[test]
fn variable_jump() -> Result<(), Error> {
let mut output = Vec::new();
let mut ingester = Ingest::new(&mut output, HardFork::default());
let mut ingester = Ingest::new(&mut output, HardFork::Cancun);
ingester.ingest_file(source(&["variable-jump", "main.etk"]))?;

assert_eq!(output, hex!("6003565b"));
Expand All @@ -73,7 +73,7 @@ fn variable_jump() -> Result<(), Error> {
#[test]
fn instruction_macro() -> Result<(), Error> {
let mut output = Vec::new();
let mut ingester = Ingest::new(&mut output, HardFork::default());
let mut ingester = Ingest::new(&mut output, HardFork::Cancun);
ingester.ingest_file(source(&["instruction-macro", "main.etk"]))?;

assert_eq!(
Expand All @@ -87,7 +87,7 @@ fn instruction_macro() -> Result<(), Error> {
#[test]
fn instruction_macro_with_empty_lines() -> Result<(), Error> {
let mut output = Vec::new();
let mut ingester = Ingest::new(&mut output, HardFork::default());
let mut ingester = Ingest::new(&mut output, HardFork::Cancun);
ingester.ingest_file(source(&["instruction-macro", "empty_lines.etk"]))?;

assert_eq!(output, hex!("6000600060006000600060006000"));
Expand All @@ -98,7 +98,7 @@ fn instruction_macro_with_empty_lines() -> Result<(), Error> {
#[test]
fn instruction_macro_with_two_instructions_per_line() {
let mut output = Vec::new();
let mut ingester = Ingest::new(&mut output, HardFork::default());
let mut ingester = Ingest::new(&mut output, HardFork::Cancun);
let err = ingester
.ingest_file(source(&[
"instruction-macro",
Expand All @@ -112,7 +112,7 @@ fn instruction_macro_with_two_instructions_per_line() {
#[test]
fn undefined_label_undefined_macro() {
let mut output = Vec::new();
let mut ingester = Ingest::new(&mut output, HardFork::default());
let mut ingester = Ingest::new(&mut output, HardFork::Cancun);
let err = ingester
.ingest_file(source(&[
"instruction-macro",
Expand All @@ -128,7 +128,7 @@ fn undefined_label_undefined_macro() {
#[test]
fn every_op() -> Result<(), Error> {
let mut output = Vec::new();
let mut ingester = Ingest::new(&mut output, HardFork::default());
let mut ingester = Ingest::new(&mut output, HardFork::Cancun);
ingester.ingest_file(source(&["every-op", "main.etk"]))?;

assert_eq!(
Expand Down Expand Up @@ -297,7 +297,7 @@ fn every_op() -> Result<(), Error> {
#[test]
fn test_dynamic_push_and_include() -> Result<(), Error> {
let mut output = Vec::new();
let mut ingester = Ingest::new(&mut output, HardFork::default());
let mut ingester = Ingest::new(&mut output, HardFork::Cancun);
ingester.ingest_file(source(&["variable-push", "main.etk"]))?;

assert_eq!(output, hex!("61025758585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585801010101010158585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858585858015b58"));
Expand Down
1 change: 0 additions & 1 deletion etk-ops/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,5 +819,4 @@ fn main() {
generate_fork("london").unwrap();
generate_fork("shanghai").unwrap();
generate_fork("cancun").unwrap();
generate_fork("prague").unwrap();
}
32 changes: 1 addition & 31 deletions etk-ops/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ pub mod cancun {
include!(concat!(env!("OUT_DIR"), "/cancun.rs"));
}

pub mod prague {
//! Instructions available in the Prague hard fork.
include!(concat!(env!("OUT_DIR"), "/prague.rs"));
}

/// An operation that can be executed by the EVM.
#[derive(Debug)]
pub enum HardForkOp<T>
Expand All @@ -108,9 +103,6 @@ where

/// London hard fork operations.
London(london::Op<T>),

/// Prague hard fork operations.
Prague(prague::Op<T>),
}

impl<T> Clone for HardForkOp<T>
Expand Down Expand Up @@ -154,7 +146,6 @@ where
Self::Cancun(ref op) => Self::Cancun(op.clone()),
Self::Shanghai(ref op) => Self::Shanghai(op.clone()),
Self::London(ref op) => Self::London(op.clone()),
Self::Prague(ref op) => Self::Prague(op.clone()),
}
}
}
Expand Down Expand Up @@ -200,7 +191,6 @@ where
(Self::Cancun(op1), HardForkOp::Cancun(op2)) => op1 == op2,
(Self::Shanghai(op1), HardForkOp::Shanghai(op2)) => op1 == op2,
(Self::London(op1), HardForkOp::London(op2)) => op1 == op2,
(Self::Prague(op1), HardForkOp::Prague(op2)) => op1 == op2,
_ => false,
}
}
Expand Down Expand Up @@ -254,7 +244,6 @@ where
HardForkOp::Cancun(op) => cancun::Op::new(op).map(HardForkOp::Cancun),
HardForkOp::Shanghai(op) => shanghai::Op::new(op).map(HardForkOp::Shanghai),
HardForkOp::London(op) => london::Op::new(op).map(HardForkOp::London),
HardForkOp::Prague(op) => prague::Op::new(op).map(HardForkOp::Prague),
}
}

Expand All @@ -264,7 +253,6 @@ where
HardForkOp::Cancun(op) => op.size(),
HardForkOp::Shanghai(op) => op.size(),
HardForkOp::London(op) => op.size(),
HardForkOp::Prague(op) => op.size(),
}
}
}
Expand Down Expand Up @@ -313,7 +301,6 @@ impl HardForkOp<()> {
HardForkOp::Cancun(op) => Ok(HardForkOp::Cancun(op.with(immediate)?)),
HardForkOp::Shanghai(op) => Ok(HardForkOp::Shanghai(op.with(immediate)?)),
HardForkOp::London(op) => Ok(HardForkOp::London(op.with(immediate)?)),
HardForkOp::Prague(op) => Ok(HardForkOp::Prague(op.with(immediate)?)),
}
}
}
Expand All @@ -330,87 +317,76 @@ where
HardForkOp::Cancun(op) => op.immediate(),
HardForkOp::Shanghai(op) => op.immediate(),
HardForkOp::London(op) => op.immediate(),
HardForkOp::Prague(op) => op.immediate(),
}
}
fn immediate_mut(&mut self) -> Option<&mut Self::ImmediateRef> {
match self {
HardForkOp::Cancun(op) => op.immediate_mut(),
HardForkOp::Shanghai(op) => op.immediate_mut(),
HardForkOp::London(op) => op.immediate_mut(),
HardForkOp::Prague(op) => op.immediate_mut(),
}
}
fn into_immediate(self) -> Option<Self::Immediate> {
match self {
HardForkOp::Cancun(op) => op.into_immediate(),
HardForkOp::Shanghai(op) => op.into_immediate(),
HardForkOp::London(op) => op.into_immediate(),
HardForkOp::Prague(op) => op.into_immediate(),
}
}
fn extra_len(&self) -> usize {
match self {
HardForkOp::Cancun(op) => op.extra_len(),
HardForkOp::Shanghai(op) => op.extra_len(),
HardForkOp::London(op) => op.extra_len(),
HardForkOp::Prague(op) => op.extra_len(),
}
}
fn code(&self) -> Self::Code {
match self {
HardForkOp::Cancun(op) => HardForkOp::Cancun(op.code()),
HardForkOp::Shanghai(op) => HardForkOp::Shanghai(op.code()),
HardForkOp::London(op) => HardForkOp::London(op.code()),
HardForkOp::Prague(op) => HardForkOp::Prague(op.code()),
}
}
fn mnemonic(&self) -> &str {
match self {
HardForkOp::Cancun(op) => op.mnemonic(),
HardForkOp::Shanghai(op) => op.mnemonic(),
HardForkOp::London(op) => op.mnemonic(),
HardForkOp::Prague(op) => op.mnemonic(),
}
}
fn is_jump(&self) -> bool {
match self {
HardForkOp::Cancun(op) => op.is_jump(),
HardForkOp::Shanghai(op) => op.is_jump(),
HardForkOp::London(op) => op.is_jump(),
HardForkOp::Prague(op) => op.is_jump(),
}
}
fn is_jump_target(&self) -> bool {
match self {
HardForkOp::Cancun(op) => op.is_jump_target(),
HardForkOp::Shanghai(op) => op.is_jump_target(),
HardForkOp::London(op) => op.is_jump_target(),
HardForkOp::Prague(op) => op.is_jump_target(),
}
}
fn is_exit(&self) -> bool {
match self {
HardForkOp::Cancun(op) => op.is_exit(),
HardForkOp::Shanghai(op) => op.is_exit(),
HardForkOp::London(op) => op.is_exit(),
HardForkOp::Prague(op) => op.is_exit(),
}
}
fn pops(&self) -> usize {
match self {
HardForkOp::Cancun(op) => op.pops(),
HardForkOp::Shanghai(op) => op.pops(),
HardForkOp::London(op) => op.pops(),
HardForkOp::Prague(op) => op.pops(),
}
}
fn pushes(&self) -> usize {
match self {
HardForkOp::Cancun(op) => op.pushes(),
HardForkOp::Shanghai(op) => op.pushes(),
HardForkOp::London(op) => op.pushes(),
HardForkOp::Prague(op) => op.pushes(),
}
}
}
Expand All @@ -421,7 +397,6 @@ impl From<HardForkOp<()>> for u8 {
HardForkOp::Cancun(op) => op.code_byte(),
HardForkOp::Shanghai(op) => op.code_byte(),
HardForkOp::London(op) => op.code_byte(),
HardForkOp::Prague(op) => op.code_byte(),
}
}
}
Expand All @@ -432,7 +407,6 @@ impl std::fmt::Display for HardForkOp<()> {
HardForkOp::Cancun(op) => op.fmt(f),
HardForkOp::Shanghai(op) => op.fmt(f),
HardForkOp::London(op) => op.fmt(f),
HardForkOp::Prague(op) => op.fmt(f),
}
}
}
Expand All @@ -448,14 +422,11 @@ pub enum HardFork {

/// The London hard fork.
London,

/// The Prague hard fork.
Prague,
}

impl Default for HardFork {
fn default() -> Self {
Self::Prague
Self::Cancun
}
}

Expand All @@ -466,7 +437,6 @@ impl From<&OsStr> for HardFork {
"cancun" => Self::Cancun,
"shanghai" => Self::Shanghai,
"london" => Self::London,
"prague" => Self::Prague,
_ => Self::default(),
}
}
Expand Down
Loading

0 comments on commit 0743a79

Please sign in to comment.