Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions arbitrator/prover/src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,6 @@ pub struct Local {
pub struct NameCustomSection {
pub module: String,
pub functions: HashMap<u32, String>,
// TODO: remove this when re-initializing the rollup
// this is kept around to deserialize old binaries
pub _locals_removed: HashMap<u32, HashMap<u32, String>>,
}

#[derive(Clone, Default)]
Expand Down
7 changes: 3 additions & 4 deletions arbitrator/prover/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
memory::Memory,
merkle::{Merkle, MerkleType},
reinterpret::{ReinterpretAsSigned, ReinterpretAsUnsigned},
utils::{file_bytes, Bytes32, CBytes, DeprecatedTableType},
utils::{file_bytes, Bytes32, CBytes, RemoteTableType},
value::{ArbValueType, FunctionType, IntegerValType, ProgramCounter, Value},
wavm::{
pack_cross_module_call, unpack_cross_module_call, wasm_to_wavm, FloatingPointImpls,
Expand All @@ -21,7 +21,7 @@ use fnv::FnvHashMap as HashMap;
use num::{traits::PrimInt, Zero};
use rayon::prelude::*;
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, FromInto};
use serde_with::serde_as;
use sha3::Keccak256;
use std::{
borrow::Cow,
Expand Down Expand Up @@ -211,7 +211,7 @@ impl TableElement {
#[serde_as]
#[derive(Clone, Debug, Serialize, Deserialize)]
struct Table {
#[serde_as(as = "FromInto<DeprecatedTableType>")]
#[serde(with = "RemoteTableType")]
ty: TableType,
elems: Vec<TableElement>,
#[serde(skip)]
Expand Down Expand Up @@ -1102,7 +1102,6 @@ impl Machine {
let mut entrypoint_names = NameCustomSection {
module: "entry".into(),
functions: HashMap::default(),
_locals_removed: HashMap::default(),
};
entrypoint_names
.functions
Expand Down
74 changes: 21 additions & 53 deletions arbitrator/prover/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,6 @@ impl fmt::Debug for Bytes32 {
}
}

impl From<DeprecatedTableType> for TableType {
fn from(table: DeprecatedTableType) -> Self {
Self {
element_type: match table.ty {
DeprecatedRefType::FuncRef => Type::FuncRef,
DeprecatedRefType::ExternRef => Type::ExternRef,
},
initial: table.limits.minimum_size,
maximum: table.limits.maximum_size,
}
}
}

/// A Vec<u8> allocated with libc::malloc
pub struct CBytes {
ptr: *mut u8,
Expand Down Expand Up @@ -150,46 +137,6 @@ impl fmt::Debug for CBytes {
}
}

// TODO: remove this when re-initializing the rollup
// this is kept around to deserialize old binaries
#[derive(Serialize, Deserialize)]
pub enum DeprecatedRefType {
FuncRef,
ExternRef,
}

// TODO: remove this when re-initializing the rollup
// this is kept around to deserialize old binaries
#[derive(Serialize, Deserialize)]
pub struct DeprecatedLimits {
pub minimum_size: u32,
pub maximum_size: Option<u32>,
}

// TODO: remove this when re-initializing the rollup
// this is kept around to deserialize old binaries
#[derive(Serialize, Deserialize)]
pub struct DeprecatedTableType {
pub ty: DeprecatedRefType,
pub limits: DeprecatedLimits,
}

impl From<TableType> for DeprecatedTableType {
fn from(table: TableType) -> Self {
Self {
ty: match table.element_type {
Type::FuncRef => DeprecatedRefType::FuncRef,
Type::ExternRef => DeprecatedRefType::ExternRef,
x => panic!("impossible table type {:?}", x),
},
limits: DeprecatedLimits {
minimum_size: table.initial,
maximum_size: table.maximum,
},
}
}
}

impl From<&[u8]> for CBytes {
fn from(slice: &[u8]) -> Self {
if slice.is_empty() {
Expand All @@ -209,6 +156,27 @@ impl From<&[u8]> for CBytes {
}
}

#[derive(Serialize, Deserialize)]
#[serde(remote = "Type")]
enum RemoteType {
I32,
I64,
F32,
F64,
V128,
FuncRef,
ExternRef,
}

#[derive(Serialize, Deserialize)]
#[serde(remote = "TableType")]
pub struct RemoteTableType {
#[serde(with = "RemoteType")]
pub element_type: Type,
pub initial: u32,
pub maximum: Option<u32>,
}

impl Drop for CBytes {
fn drop(&mut self) {
unsafe { libc::free(self.ptr as _) }
Expand Down