-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #315 from dashpay/develop
chore: fast forward merge develop into master
- Loading branch information
Showing
153 changed files
with
26,130 additions
and
16,902 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,14 +19,22 @@ jobs: | |
access_token: ${{ github.token }} | ||
|
||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Setup Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
target: wasm32-unknown-unknown | ||
|
||
- name: Enable Rust cache | ||
uses: Swatinem/rust-cache@v2 | ||
with: | ||
cache-on-failure: "false" | ||
|
||
- name: Setup Trunk | ||
uses: jetli/[email protected] | ||
|
||
- run: cargo test --workspace --all-features | ||
|
||
|
@@ -42,16 +50,24 @@ jobs: | |
|
||
- name: Check out repo | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Setup Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
default: true | ||
components: clippy | ||
target: wasm32-unknown-unknown | ||
|
||
- name: Enable Rust cache | ||
uses: Swatinem/rust-cache@v2 | ||
with: | ||
cache-on-failure: "false" | ||
|
||
- name: Setup Trunk | ||
uses: jetli/[email protected] | ||
|
||
- uses: actions-rs/clippy-check@v1 | ||
with: | ||
|
@@ -78,6 +94,8 @@ jobs: | |
|
||
- name: Enable Rust cache | ||
uses: Swatinem/rust-cache@v2 | ||
with: | ||
cache-on-failure: "false" | ||
|
||
- run: exit `cargo +nightly fmt --check | wc -l` | ||
|
||
|
@@ -100,6 +118,8 @@ jobs: | |
|
||
- name: Enable Rust cache | ||
uses: Swatinem/rust-cache@v2 | ||
with: | ||
cache-on-failure: "false" | ||
|
||
- run: cargo check | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "grovedb/grovedbg"] | ||
path = grovedb/grovedbg | ||
url = https://github.com/dashpay/grovedbg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "grovedb-version" | ||
authors = ["Samuel Westrich <[email protected]>"] | ||
description = "Versioning library for Platform" | ||
version = "1.0.0-rc.2" | ||
edition = "2021" | ||
license = "MIT" | ||
|
||
[dependencies] | ||
thiserror = { version = "1.0.59" } | ||
versioned-feature-core = { git = "https://github.com/dashpay/versioned-feature-core", version = "1.0.0" } | ||
|
||
[features] | ||
mock-versions = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use thiserror::Error; | ||
use versioned_feature_core::FeatureVersion; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum GroveVersionError { | ||
/// Expected some specific versions | ||
#[error("grove unknown version on {method}, received: {received}")] | ||
UnknownVersionMismatch { | ||
/// method | ||
method: String, | ||
/// the allowed versions for this method | ||
known_versions: Vec<FeatureVersion>, | ||
/// requested core height | ||
received: FeatureVersion, | ||
}, | ||
|
||
/// Expected some specific versions | ||
#[error("{method} not active for grove version")] | ||
VersionNotActive { | ||
/// method | ||
method: String, | ||
/// the allowed versions for this method | ||
known_versions: Vec<FeatureVersion>, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
use crate::version::GroveVersion; | ||
|
||
pub mod error; | ||
pub mod version; | ||
|
||
#[macro_export] | ||
macro_rules! check_grovedb_v0_with_cost { | ||
($method:expr, $version:expr) => {{ | ||
const EXPECTED_VERSION: u16 = 0; | ||
if $version != EXPECTED_VERSION { | ||
return Err(GroveVersionError::UnknownVersionMismatch { | ||
method: $method.to_string(), | ||
known_versions: vec![EXPECTED_VERSION], | ||
received: $version, | ||
} | ||
.into()) | ||
.wrap_with_cost(OperationCost::default()); | ||
} | ||
}}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! check_grovedb_v0 { | ||
($method:expr, $version:expr) => {{ | ||
const EXPECTED_VERSION: u16 = 0; | ||
if $version != EXPECTED_VERSION { | ||
return Err(GroveVersionError::UnknownVersionMismatch { | ||
method: $method.to_string(), | ||
known_versions: vec![EXPECTED_VERSION], | ||
received: $version, | ||
} | ||
.into()); | ||
} | ||
}}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! check_merk_v0_with_cost { | ||
($method:expr, $version:expr) => {{ | ||
const EXPECTED_VERSION: u16 = 0; | ||
if $version != EXPECTED_VERSION { | ||
return Err(GroveVersionError::UnknownVersionMismatch { | ||
method: $method.to_string(), | ||
known_versions: vec![EXPECTED_VERSION], | ||
received: $version, | ||
} | ||
.into()) | ||
.wrap_with_cost(OperationCost::default()); | ||
} | ||
}}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! check_merk_v0 { | ||
($method:expr, $version:expr) => {{ | ||
const EXPECTED_VERSION: u16 = 0; | ||
if $version != EXPECTED_VERSION { | ||
return Err(GroveVersionError::UnknownVersionMismatch { | ||
method: $method.to_string(), | ||
known_versions: vec![EXPECTED_VERSION], | ||
received: $version, | ||
} | ||
.into()); | ||
} | ||
}}; | ||
} | ||
|
||
pub trait TryFromVersioned<T>: Sized { | ||
/// The type returned in the event of a conversion error. | ||
type Error; | ||
|
||
/// Performs the conversion. | ||
fn try_from_versioned(value: T, grove_version: &GroveVersion) -> Result<Self, Self::Error>; | ||
} | ||
|
||
pub trait TryIntoVersioned<T>: Sized { | ||
/// The type returned in the event of a conversion error. | ||
type Error; | ||
|
||
/// Performs the conversion. | ||
fn try_into_versioned(self, grove_version: &GroveVersion) -> Result<T, Self::Error>; | ||
} | ||
|
||
impl<T, U> TryIntoVersioned<U> for T | ||
where | ||
U: TryFromVersioned<T>, | ||
{ | ||
type Error = U::Error; | ||
|
||
#[inline] | ||
fn try_into_versioned(self, grove_version: &GroveVersion) -> Result<U, U::Error> { | ||
U::try_from_versioned(self, grove_version) | ||
} | ||
} | ||
|
||
impl<T, U> TryFromVersioned<U> for T | ||
where | ||
T: TryFrom<U>, | ||
{ | ||
type Error = T::Error; | ||
|
||
#[inline] | ||
fn try_from_versioned(value: U, _grove_version: &GroveVersion) -> Result<Self, Self::Error> { | ||
T::try_from(value) | ||
} | ||
} |
Oops, something went wrong.