Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo update and set a 3s timeout on antelope client #64

Merged
merged 5 commits into from
Sep 18, 2024
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
113 changes: 91 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

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

cargo build --release --features bad_sig_padding

cd $OG_DIR
3 changes: 2 additions & 1 deletion client/tests/ship_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ async fn evm_deploy() {
let port_18999 = container.get_host_port_ipv4(18999).await.unwrap();

let api_base_url = format!("http://localhost:{port_8888}");
let api_client = APIClient::<DefaultProvider>::default_provider(api_base_url).unwrap();
let api_client =
APIClient::<DefaultProvider>::default_provider(api_base_url, Some(10)).unwrap();

let mut last_block = 0;

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

INSTALL_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
OG_DIR="$(pwd)"
CONSENSUS_BIN_PATH=$INSTALL_ROOT/target/release/telos-consensus-client

if [ ! -f $CONSENSUS_BIN_PATH ] || [ ! -x $CONSENSUS_BIN_PATH ]; then
echo "Error: telos-consensus-client binary not found at $CONSENSUS_BIN_PATH\nHint: Did you run build.sh yet?"
exit 1
fi

cd $INSTALL_ROOT

[ -f $INSTALL_ROOT/.env ] && . $INSTALL_ROOT/.env

[ -z "$CONSENSUS_CONFIG" ] && CONSENSUS_CONFIG=$INSTALL_ROOT/config.toml
[ -z "$LOG_PATH" ] && LOG_PATH=$INSTALL_ROOT/consensus.log

nohup $CONSENSUS_BIN_PATH --config $CONSENSUS_CONFIG >> "$LOG_PATH" 2>&1 &

PID="$!"
echo $PID > $INSTALL_ROOT/consensus.pid

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

INSTALL_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PID_FILE="$INSTALL_ROOT/consensus.pid"
PID="$( cat $PID_FILE )"

if [ -n "$PID" ]; then
echo "Killing pid " $PID
kill $PID

for i in $(seq 1 20); do
IS_RUNNING=`ps $PID | wc -l`

if [ $IS_RUNNING = "1" ]; then
echo "$INSTALL_ROOT node has been shutdown"
break;
fi

echo "Waiting..."

sleep 2
done

if [ $IS_RUNNING = "2" ]; then
echo "ERROR: Unable to shutdown $INSTALL_ROOT node successfully, check log"
fi

else
echo "No pid found at $PID_FILE"
fi
10 changes: 6 additions & 4 deletions translator/src/translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ impl Translator {
}

pub async fn launch(self, output_tx: Option<mpsc::Sender<TelosEVMBlock>>) -> Result<()> {
let api_client =
APIClient::<DefaultProvider>::default_provider(self.config.http_endpoint.clone())
.map_err(|error| eyre!(error))
.wrap_err("Failed to create API client")?;
let api_client = APIClient::<DefaultProvider>::default_provider(
self.config.http_endpoint.clone(),
Some(3),
)
.map_err(|error| eyre!(error))
.wrap_err("Failed to create API client")?;

let (ws_stream, _) = connect_async(&self.config.ship_endpoint)
.await
Expand Down
6 changes: 3 additions & 3 deletions translator/tests/block_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async fn generate_block(
block_num: u32,
) -> ProcessingEVMBlock {
let api_client: APIClient<DefaultProvider> =
APIClient::<DefaultProvider>::default_provider(http_endpoint.clone())
APIClient::<DefaultProvider>::default_provider(http_endpoint.clone(), Some(10))
.expect("Failed to create API client");

let block = api_client
Expand Down Expand Up @@ -82,7 +82,7 @@ async fn genesis_mainnet() {
let http_endpoint = "https://mainnet.telos.net".to_string();

let native_to_evm_cache = NameToAddressCache::new(
APIClient::<DefaultProvider>::default_provider(http_endpoint.clone())
APIClient::<DefaultProvider>::default_provider(http_endpoint.clone(), Some(10))
.expect("Failed to create API client"),
);
let zero_bytes = FixedBytes::from_slice(&[
Expand Down Expand Up @@ -118,7 +118,7 @@ async fn deploy_mainnet() {
let http_endpoint = "https://mainnet.telos.net".to_string();

let native_to_evm_cache = NameToAddressCache::new(
APIClient::<DefaultProvider>::default_provider(http_endpoint.clone())
APIClient::<DefaultProvider>::default_provider(http_endpoint.clone(), Some(10))
.expect("Failed to create API client"),
);
let parent_hash = FixedBytes::from_hex(&MAINNET_DEPLOY_CONFIG.prev_hash).unwrap();
Expand Down
Loading