Skip to content

Commit

Permalink
vm: fix consensus ordering for regtest
Browse files Browse the repository at this point in the history
Closes #273
  • Loading branch information
dr-orlovsky committed Sep 20, 2024
2 parents 8be4962 + b66f340 commit cac0e1f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
strategy:
fail-fast: false
matrix:
toolchain: [ nightly, beta, stable, 1.75.0 ]
toolchain: [ nightly, beta, stable, 1.76.0 ]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ categories = ["cryptography::cryptocurrencies"]
readme = "README.md"
license = "Apache-2.0"
edition = "2021"
rust-version = "1.75.0"
rust-version = "1.76.0"
exclude = [".github"]

[lib]
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Type: Library
Kind: Free software
License: Apache-2.0
Language: Rust
Compiler: 1.75
Compiler: 1.76
Author: Maxim Orlovsky
Maintained: LNP/BP Standards Association, Switzerland
Maintainers:
Expand Down
8 changes: 7 additions & 1 deletion src/vm/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,16 @@ impl Ord for WitnessPos {
/// timestamp information and not height. The timestamp data are consistent
/// across multiple blockchains, while height evolves with a different
/// speed and can't be used in comparisons.
///
/// If the timestamp of two witnesses is the same, we use the height for the ordering. This
/// might be the case for regtests, where multiple blocks can be mined with the same timestamp.
fn cmp(&self, other: &Self) -> Ordering {
assert!(self.timestamp > 0);
assert!(other.timestamp > 0);
self.timestamp.cmp(&other.timestamp)
match self.timestamp.cmp(&other.timestamp) {
Ordering::Equal => self.height.cmp(&other.height),
ordering => ordering,

Check warning on line 335 in src/vm/contract.rs

View check run for this annotation

Codecov / codecov/patch

src/vm/contract.rs#L333-L335

Added lines #L333 - L335 were not covered by tests
}
}
}

Expand Down

0 comments on commit cac0e1f

Please sign in to comment.