Skip to content

Commit

Permalink
Start using alloy_primitives serde features isntead of custom deseral…
Browse files Browse the repository at this point in the history
…ization, tweak and add scritps
  • Loading branch information
guilledk committed Jul 11, 2024
1 parent 70ffde6 commit 139398d
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ revm-inspectors = { git = "https://github.com/telosnetwork/telos-evm-inspectors"

# eth
alloy-chains = { version = "0.1", feature = ["serde", "rlp", "arbitrary"] }
alloy-primitives = "0.6"
alloy-primitives = { version = "0.6", feature = ["serde"] }
alloy-dyn-abi = "0.6"
alloy-sol-types = "0.6"
alloy-rlp = "0.3"
Expand Down
27 changes: 0 additions & 27 deletions crates/telos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,6 @@ pub struct TelosNetworkConfig {
pub gas_cache: GasPriceCache,
}

pub fn deserialize_u256<'de, D>(deserializer: D) -> Result<U256, D::Error>
where
D: Deserializer<'de>,
{
struct U256Visitor;

impl<'de> serde::de::Visitor<'de> for U256Visitor {
type Value = U256;

fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("a hex string representing a U256 value")
}

fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: serde::de::Error,
{
Ok(U256::from_str_radix(v, 16).unwrap())
}
}

deserializer.deserialize_str(U256Visitor)
}

// Telos EVM Account Table Row
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "ssz", derive(ssz_derive::Encode, ssz_derive::Decode))]
Expand All @@ -63,7 +39,6 @@ pub struct TelosAccountTableRow {
pub account: String,
pub nonce: u64,
pub code: Bytes,
#[serde(deserialize_with = "deserialize_u256")]
pub balance: U256
}

Expand All @@ -72,9 +47,7 @@ pub struct TelosAccountTableRow {
#[cfg_attr(feature = "ssz", derive(ssz_derive::Encode, ssz_derive::Decode))]
pub struct TelosAccountStateTableRow {
pub address: Address,
#[serde(deserialize_with = "deserialize_u256")]
pub key: U256,
#[serde(deserialize_with = "deserialize_u256")]
pub value: U256
}

Expand Down
7 changes: 7 additions & 0 deletions scripts/build-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

INSTALL_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
OG_DIR="$(pwd)"
cd $INSTALL_ROOT
cargo build --features telos
cd $OG_DIR
28 changes: 28 additions & 0 deletions scripts/run-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

INSTALL_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
OG_DIR="$(pwd)"
cd $INSTALL_ROOT

LOG_NAME="$(basename $INSTALL_ROOT)"
LOG_PATH="$INSTALL_ROOT/$LOG_NAME.log"

CLIENT_BIN="$INSTALL_ROOT/target/debug/reth"

export RUST_BACKTRACE=full

$CLIENT_BIN node --log.stdout.filter info \
--dev \
--datadir $INSTALL_ROOT/data \
--chain tevmmainnet-base \
--config $INSTALL_ROOT/config.toml \
--http --http.api all \
--ws --ws.api all \
--telos.telos_endpoint https://mainnet.telos.net \
--telos.signer_account rpc.evm \
--telos.signer_permission rpc \
--telos.signer_key 5Hq1FmDPfxxxxxxxxxxxxxxynBtJ6oS5C7LfZE5MMyZeRJ \
--telos.gas_cache_seconds 30 \
"$@"

cd $OG_DIR
31 changes: 31 additions & 0 deletions scripts/start-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

INSTALL_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
OG_DIR="$(pwd)"
cd $INSTALL_ROOT

LOG_NAME="$(basename $INSTALL_ROOT)"
LOG_PATH="$INSTALL_ROOT/$LOG_NAME.log"

CLIENT_BIN="$INSTALL_ROOT/target/debug/reth"

export RUST_BACKTRACE=full

nohup $CLIENT_BIN node --log.stdout.filter info \
--dev \
--datadir $INSTALL_ROOT/data \
--chain tevmmainnet-base \
--config $INSTALL_ROOT/config.toml \
--http --http.api all \
--ws --ws.api all \
--telos.telos_endpoint https://mainnet.telos.net \
--telos.signer_account rpc.evm \
--telos.signer_permission rpc \
--telos.signer_key 5Hq1FmDPfxxxxxxxxxxxxxxynBtJ6oS5C7LfZE5MMyZeRJ \
--telos.gas_cache_seconds 30 \
"$@" >> "$LOG_PATH" 2>&1 &

PID="$!"
echo "telos-reth started with pid $PID logging to $LOG_PATH"
echo $PID > $INSTALL_ROOT/telos-reth.pid
cd $OG_DIR
4 changes: 3 additions & 1 deletion scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ LOG_PATH="$INSTALL_ROOT/$LOG_NAME.log"

CLIENT_BIN="$INSTALL_ROOT/target/release/reth"

export RUST_BACKTRACE=full

nohup $CLIENT_BIN node --log.stdout.filter info \
--dev \
--datadir $INSTALL_ROOT/data \
Expand All @@ -26,4 +28,4 @@ nohup $CLIENT_BIN node --log.stdout.filter info \
PID="$!"
echo "telos-reth started with pid $PID logging to $LOG_PATH"
echo $PID > $INSTALL_ROOT/telos-reth.pid
cd $OG_DIR
cd $OG_DIR

0 comments on commit 139398d

Please sign in to comment.