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

Use blocks to determine other environment settlements #3053

Merged
merged 11 commits into from
Oct 17, 2024
Prev Previous commit
Next Next commit
refactor settlement age
sunce86 committed Oct 17, 2024
commit cf94132cce8de247c4119fbea18cf273085ed4a3
14 changes: 10 additions & 4 deletions crates/autopilot/src/domain/settlement/mod.rs
Original file line number Diff line number Diff line change
@@ -138,16 +138,22 @@ impl Settlement {
}
}

const MAINNET_BLOCK_TIME: u64 = 13_000; // ms
const GNOSIS_BLOCK_TIME: u64 = 5_000; // ms
const SEPOLIA_BLOCK_TIME: u64 = 13_000; // ms
const ARBITRUM_ONE_BLOCK_TIME: u64 = 100; // ms

/// How old (in terms of blocks) a settlement should be, to be considered as a
/// settlement from another environment.
///
/// Currently set to ~6h
sunce86 marked this conversation as resolved.
Show resolved Hide resolved
fn max_settlement_age(chain: &eth::chain::Id) -> u64 {
const TARGET_AGE: u64 = 6 * 60 * 60 * 1000; // 6h in ms
match chain {
m-lord-renkse marked this conversation as resolved.
Show resolved Hide resolved
eth::chain::Id::Mainnet => 2000,
eth::chain::Id::Gnosis => 4000,
eth::chain::Id::Sepolia => 2000,
eth::chain::Id::ArbitrumOne => 100_000,
eth::chain::Id::Mainnet => TARGET_AGE / MAINNET_BLOCK_TIME,
eth::chain::Id::Gnosis => TARGET_AGE / GNOSIS_BLOCK_TIME,
eth::chain::Id::Sepolia => TARGET_AGE / SEPOLIA_BLOCK_TIME,
eth::chain::Id::ArbitrumOne => TARGET_AGE / ARBITRUM_ONE_BLOCK_TIME,
}
}