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
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ jobs:
working-directory: ./machine/emulator
run: |
make bundle-boost
wget https://github.com/cartesi/machine-emulator/releases/download/v0.19.0/add-generated-files.diff
git apply add-generated-files.diff
make
sudo make install

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ repository = "https://github.com/cartesi/dave"

# machine bindings
cartesi-machine = { path = "machine/rust-bindings/cartesi-machine", features = [
"build_uarch",
"download_uarch",
] }

# solidity bindings
Expand Down
22 changes: 21 additions & 1 deletion cartesi-rollups/node/blockchain-reader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,10 @@ async fn latest_finalized_block(
Ok(block_number)
}

fn should_retry_with_partition(err: &Error, long_block_range_error_codes: &Vec<String>) -> bool {
fn should_retry_with_partition(
err: &impl std::error::Error,
long_block_range_error_codes: &Vec<String>,
) -> bool {
for code in long_block_range_error_codes {
let s = format!("{:?}", err);
if s.contains(&code.to_string()) {
Expand Down Expand Up @@ -804,4 +807,21 @@ mod blockchain_reader_tests {

Ok(())
}

#[tokio::test]
async fn test_should_retry() -> Result<()> {
let s = r###"Error: HTTP error 400 with body: {"jsonrpc":"2.0","id":3,"error":{"code":-32600,"message":"You can make eth_getLogs requests with up to a 10000 block range. Based on your parameters, this block range should work: [0x1754746, 0x1756e55]"}}"###;

assert!(should_retry_with_partition(
&std::io::Error::other(s),
&vec![
"-32005".to_string(),
"-32600".to_string(),
"-32602".to_string(),
"-32616".to_string()
]
));

Ok(())
}
}
1 change: 1 addition & 0 deletions cartesi-rollups/node/cartesi-rollups-prt-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub fn create_epoch_manager_task(watch: Watch, parameters: &PRTConfig) -> thread
params.address_book.consensus,
state_manager,
params.sleep_duration,
params.long_block_range_error_codes.clone(),
);

epoch_manager.execution_loop(inner_watch, provider).await
Expand Down
4 changes: 4 additions & 0 deletions cartesi-rollups/node/epoch-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct EpochManager<AS: ArenaSender, SM: StateManager> {
arena_sender: Arc<Mutex<AS>>,
consensus: Address,
sleep_duration: Duration,
long_block_range_error_codes: Vec<String>,
state_manager: SM,
last_react_epoch: (Option<Player<AS>>, u64),
}
Expand All @@ -35,11 +36,13 @@ impl<AS: ArenaSender, SM: StateManager> EpochManager<AS, SM> {
consensus_address: Address,
state_manager: SM,
sleep_duration: Duration,
long_block_range_error_codes: Vec<String>,
) -> Self {
Self {
arena_sender,
consensus: consensus_address,
sleep_duration,
long_block_range_error_codes,
state_manager,
last_react_epoch: (None, 0),
}
Expand Down Expand Up @@ -190,6 +193,7 @@ impl<AS: ArenaSender, SM: StateManager> EpochManager<AS, SM> {
snapshot.to_string_lossy().to_string(),
last_sealed_epoch.root_tournament,
last_sealed_epoch.block_created_number,
self.long_block_range_error_codes.clone(),
self.state_manager
.epoch_directory(last_sealed_epoch.epoch_number)?,
)
Expand Down
20 changes: 14 additions & 6 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
update-submodules:
git submodule update --recursive --init

apply-generated-files-diff VERSION="v0.19.0":
cd machine/emulator && \
wget https://github.com/cartesi/machine-emulator/releases/download/{{VERSION}}/add-generated-files.diff && \
git apply add-generated-files.diff

bundle-boost:
make -C machine/emulator bundle-boost

clean-emulator:
make -C machine/emulator clean depclean distclean

clean-contracts: clean-consensus-contracts clean-prt-contracts clean-bindings clean-deployments
make -C machine/emulator clean depclean distclean

setup: update-submodules clean-emulator clean-contracts
make -C machine/emulator uarch-with-toolchain # Requries docker, necessary for machine bindings
setup: update-submodules clean-emulator clean-contracts bundle-boost apply-generated-files-diff
make -C machine/emulator # Requries docker, necessary for machine bindings
just -f ./test/programs/justfile build-honeypot-snapshot # Requries docker, necessary for tests

# Run this once after cloning, if using a docker environment
Expand Down Expand Up @@ -59,13 +67,13 @@ fmt-rust-workspace: bind
check-fmt-rust-workspace: bind
cargo fmt --check
check-rust-workspace: bind
cargo check --features build_uarch
cargo check --features download_uarch
test-rust-workspace: bind
cargo test --features build_uarch
cargo test --features download_uarch
build-rust-workspace *ARGS: bind
cargo build {{ARGS}} --features build_uarch
cargo build {{ARGS}} --features download_uarch
build-release-rust-workspace *ARGS: bind
cargo build --release {{ARGS}} --features build_uarch
cargo build --release {{ARGS}} --features download_uarch
clean-rust-workspace: bind
cargo clean

Expand Down
4 changes: 2 additions & 2 deletions machine/rust-bindings/cartesi-machine-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn main() {
}

// static link
// println!("cargo:rustc-link-lib=slirp");
println!("cargo:rustc-link-lib=slirp");
cfg_if::cfg_if! {
if #[cfg(feature = "remote_machine")] {
println!("cargo:rustc-link-lib=static=cartesi_jsonrpc");
Expand Down Expand Up @@ -167,7 +167,7 @@ mod build_cm {
mod copy_uarch {
use std::{env, fs, path::Path};

fn copy(uarch_path: &Path) {
pub(crate) fn copy(uarch_path: &Path) {
let uarch_pristine_hash_path =
env::var("UARCH_PRISTINE_HASH_PATH").expect("`UARCH_PRISTINE_HASH_PATH` not set");
let uarch_pristine_ram_path =
Expand Down
7 changes: 6 additions & 1 deletion prt/client-rs/core/src/strategy/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,15 @@ impl<AS: ArenaSender> Player<AS> {
machine_path: String,
root_tournament: Address,
block_created_number: u64,
long_block_range_error_codes: Vec<String>,
state_dir: PathBuf,
) -> Result<Self> {
let db = DisputeStateAccess::new(inputs, leafs, root_tournament.to_string(), state_dir)?;
let reader = StateReader::new(provider.clone(), block_created_number)?;
let reader = StateReader::new(
provider.clone(),
block_created_number,
long_block_range_error_codes,
)?;
let gc = GarbageCollector::new(arena_sender.clone(), root_tournament);
let commitment_builder = MachineCommitmentBuilder::new(machine_path.clone());
Ok(Self {
Expand Down
Loading