Skip to content

Commit

Permalink
Merge branch 'develop' into use-new-avltree-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
ross-weir authored Dec 1, 2023
2 parents fa75445 + 417b928 commit 0dd80fb
Show file tree
Hide file tree
Showing 40 changed files with 432 additions and 80 deletions.
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ repository = "https://github.com/ergoplatform/sigma-rust"
edition = "2021"

[workspace.dependencies]
sigma-util = { version = "^0.12.1", path = "./sigma-util" }
sigma-ser = { version = "^0.13.1", path = "./sigma-ser" }
ergotree-ir = { version = "^0.24.1", path = "./ergotree-ir" }
ergo-chain-types = { version = "^0.11.1", path = "./ergo-chain-types" }
sigma-util = { version = "^0.14.0", path = "./sigma-util" }
sigma-ser = { version = "^0.15.0", path = "./sigma-ser" }
ergotree-ir = { version = "^0.26.0", path = "./ergotree-ir" }
ergo-chain-types = { version = "^0.13.0", path = "./ergo-chain-types" }
sigma-test-util = { version = "^0.3.0", path = "./sigma-test-util" }
ergoscript-compiler = { version = "^0.20.1", path = "./ergoscript-compiler" }
ergotree-interpreter = { version = "^0.24.1", path = "./ergotree-interpreter" }
ergo-nipopow = { version = "^0.11", path = "./ergo-nipopow" }
ergo-merkle-tree = { version = "^0.11.1", path = "./ergo-merkle-tree" }
ergo-rest = { version = "^0.9.1", path = "./ergo-rest" }
ergo-lib = { version = "^0.24.1", path = "./ergo-lib"}
ergoscript-compiler = { version = "^0.22.0", path = "./ergoscript-compiler" }
ergotree-interpreter = { version = "^0.26.0", path = "./ergotree-interpreter" }
ergo-nipopow = { version = "^0.13", path = "./ergo-nipopow" }
ergo-merkle-tree = { version = "^0.13.0", path = "./ergo-merkle-tree" }
ergo-rest = { version = "^0.11.0", path = "./ergo-rest" }
ergo-lib = { version = "^0.26.0", path = "./ergo-lib"}
k256 = { version = "0.13.1", features = ["arithmetic", "ecdsa"] }
elliptic-curve = { version = "0.12", features = ["ff"] }
thiserror = "1"
Expand Down
2 changes: 1 addition & 1 deletion bindings/ergo-lib-c-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ergo-lib-c-core"
version = "0.24.1"
version = "0.26.0"
license = "CC0-1.0"
authors = ["Denys Zadorozhnyi <[email protected]>"]
repository.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions bindings/ergo-lib-c/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ergo-lib-c"
version = "0.24.1"
version = "0.26.0"
license = "CC0-1.0"
authors = ["Denys Zadorozhnyi <[email protected]>"]
repository.workspace = true
Expand All @@ -16,7 +16,7 @@ name = "ergo"
crate-type = ["staticlib"]

[dependencies]
ergo-lib-c-core = { version = "^0.24.1", path = "../ergo-lib-c-core" }
ergo-lib-c-core = { version = "^0.26.0", path = "../ergo-lib-c-core" }
paste = "^1.0"

[features]
Expand Down
4 changes: 2 additions & 2 deletions bindings/ergo-lib-jni/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ergo-lib-jni"
version = "0.24.1"
version = "0.26.0"
license = "CC0-1.0"
authors = ["Denys Zadorozhnyi <[email protected]>"]
repository.workspace = true
Expand All @@ -16,4 +16,4 @@ path = "src/main/rust/lib.rs"
jni = "0.19.0"
log = "0.4.16"
ergo-lib = { workspace = true }
ergo-lib-c-core = { version = "^0.24.1", path = "../ergo-lib-c-core" }
ergo-lib-c-core = { version = "^0.26.0", path = "../ergo-lib-c-core" }
2 changes: 1 addition & 1 deletion bindings/ergo-lib-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ergo-lib-wasm"
version = "0.24.1"
version = "0.26.0"
license = "CC0-1.0"
authors = ["Denys Zadorozhnyi <[email protected]>"]
repository = "https://github.com/ergoplatform/sigma-rust"
Expand Down
5 changes: 5 additions & 0 deletions bindings/ergo-lib-wasm/src/ergo_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,9 @@ impl ErgoTree {
pub fn template_bytes(&self) -> Result<Vec<u8>, JsValue> {
self.0.template_bytes().map_err(to_js)
}

/// Returns pretty printed tree
pub fn pretty_print(&self) -> Result<String, JsValue> {
Ok(self.0.pretty_print().map_err(to_js)?.1)
}
}
1 change: 1 addition & 0 deletions bindings/ergo-lib-wasm/src/error_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ from_error_to_wrap!(ConvError);
from_error_to_wrap!(TransactionContextError);
from_error_to_wrap!(TxVerifyError);
from_error_to_wrap!(RegisterValueError);
from_error_to_wrap!(String);

macro_rules! from_error_to_wrap_via_debug {
($t:ident) => {
Expand Down
2 changes: 1 addition & 1 deletion ergo-chain-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ergo-chain-types"
version = "0.11.1"
version = "0.13.0"
license = "CC0-1.0"
authors = ["Denys Zadorozhnyi <[email protected]>"]
repository.workspace = true
Expand Down
13 changes: 12 additions & 1 deletion ergo-lib/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

<!-- next-header -->
## [Unreleased] - ReleaseDate
## [0.26.0] - 2023-10-13

### Added
* Add pretty_print method to ErgoTree and Expr https://github.com/ergoplatform/sigma-rust/pull/729

### Fixed
* Reset interpreter env after lambda call https://github.com/ergoplatform/sigma-rust/pull/728

## [0.25.0] - 2023-10-09

### Added
* Revamped errro messages for ErgoTree evaluation errors https://github.com/ergoplatform/sigma-rust/pull/720
Expand Down Expand Up @@ -443,7 +452,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- ErgoTree constant values conversion.

<!-- next-url -->
[Unreleased]: https://github.com/ergoplatform/sigma-rust/compare/ergo-lib-v0.24.1...HEAD
[Unreleased]: https://github.com/ergoplatform/sigma-rust/compare/ergo-lib-v0.26.0...HEAD
[0.26.0]: https://github.com/ergoplatform/sigma-rust/compare/ergo-lib-v0.25.0...ergo-lib-v0.26.0
[0.25.0]: https://github.com/ergoplatform/sigma-rust/compare/ergo-lib-v0.24.1...ergo-lib-v0.25.0
[0.24.1]: https://github.com/ergoplatform/sigma-rust/compare/ergo-lib-v0.24.0...ergo-lib-v0.24.1
[0.24.0]: https://github.com/ergoplatform/sigma-rust/compare/ergo-lib-v0.23.0...ergo-lib-v0.24.0
[0.23.0]: https://github.com/ergoplatform/sigma-rust/compare/ergo-lib-v0.22.0...ergo-lib-v0.23.0
Expand Down
2 changes: 1 addition & 1 deletion ergo-lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ergo-lib"
version = "0.24.1"
version = "0.26.0"
license = "CC0-1.0"
authors = ["Denys Zadorozhnyi <[email protected]>"]
repository.workspace = true
Expand Down
28 changes: 12 additions & 16 deletions ergo-lib/src/chain/transaction/reduced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::rc::Rc;

use ergotree_interpreter::eval::env::Env;
use ergotree_interpreter::eval::reduce_to_crypto;
use ergotree_interpreter::eval::ReductionResult;
use ergotree_interpreter::sigma_protocol::prover::ContextExtension;
use ergotree_interpreter::sigma_protocol::prover::ProverError;
use ergotree_ir::serialization::sigma_byte_reader::SigmaByteRead;
Expand All @@ -31,8 +30,10 @@ use super::TxIoVec;
/// <https://github.com/ergoplatform/eips/blob/f280890a4163f2f2e988a0091c078e36912fc531/eip-0019.md>
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct ReducedInput {
/// Input box script reduced to SigmaBoolean
pub reduction_result: ReductionResult,
/// value of SigmaProp type which represents a statement verifiable via sigma protocol.
pub sigma_prop: SigmaBoolean,
/// estimated cost of expression evaluation
pub cost: u64,
/// ContextExtension for the input
pub extension: ContextExtension,
}
Expand Down Expand Up @@ -87,8 +88,9 @@ pub fn reduce_tx(
.map_err(ProverError::EvalError)
.map_err(|e| TxSigningError::ProverError(e, idx))?;
Ok(ReducedInput {
reduction_result,
extension: input.extension,
sigma_prop: reduction_result.sigma_prop,
cost: reduction_result.cost,
})
})?;
Ok(ReducedTransaction {
Expand All @@ -104,8 +106,8 @@ impl SigmaSerializable for ReducedTransaction {
w.put_usize_as_u32_unwrapped(msg.len())?;
w.write_all(&msg)?;
self.reduced_inputs.as_vec().iter().try_for_each(|red_in| {
red_in.reduction_result.sigma_prop.sigma_serialize(w)?;
w.put_u64(red_in.reduction_result.cost)?;
red_in.sigma_prop.sigma_serialize(w)?;
w.put_u64(red_in.cost)?;
SigmaSerializeResult::Ok(())
})?;
w.put_u32(self.tx_cost)?;
Expand All @@ -123,11 +125,8 @@ impl SigmaSerializable for ReducedTransaction {
let cost = r.get_u64()?;
let extension = input.spending_proof.extension;
let reduced_input = ReducedInput {
reduction_result: ReductionResult {
sigma_prop,
cost,
env: Env::empty(),
},
sigma_prop,
cost,
extension: extension.clone(),
};
let unsigned_input = UnsignedInput {
Expand Down Expand Up @@ -168,11 +167,8 @@ pub mod arbitrary {
.prop_map(|(unsigned_tx, sb, tx_cost)| Self {
unsigned_tx: unsigned_tx.clone(),
reduced_inputs: unsigned_tx.inputs.mapped(|unsigned_input| ReducedInput {
reduction_result: ReductionResult {
sigma_prop: sb.clone(),
cost: 0,
env: Env::empty(),
},
sigma_prop: sb.clone(),
cost: 0,
extension: unsigned_input.extension,
}),
tx_cost,
Expand Down
2 changes: 1 addition & 1 deletion ergo-lib/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl Wallet {
.map(|secret| secret.public_image())
.collect();
for (index, input) in reduced_tx.reduced_inputs().iter().enumerate() {
let sigma_prop = input.clone().reduction_result.sigma_prop;
let sigma_prop = input.clone().sigma_prop;
let hints = generate_commitments_for(&sigma_prop, &public_keys);
tx_hints.add_hints_for_input(index, hints);
}
Expand Down
2 changes: 1 addition & 1 deletion ergo-lib/src/wallet/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ pub fn sign_reduced_transaction(
}
prover
.generate_proof(
reduced_input.reduction_result.sigma_prop.clone(),
reduced_input.sigma_prop.clone(),
message_to_sign.as_slice(),
&hints_bag,
)
Expand Down
2 changes: 1 addition & 1 deletion ergo-merkle-tree/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ergo-merkle-tree"
version = "0.11.1"
version = "0.13.0"
repository.workspace = true
edition.workspace = true
license = "CC0-1.0"
Expand Down
2 changes: 1 addition & 1 deletion ergo-nipopow/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ergo-nipopow"
version = "0.11.1"
version = "0.13.0"
license = "CC0-1.0"
authors = ["Denys Zadorozhnyi <[email protected]>"]
repository.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion ergo-rest/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ergo-rest"
version = "0.9.1"
version = "0.11.0"
license = "CC0-1.0"
authors = ["Denys Zadorozhnyi <[email protected]>"]
repository.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion ergoscript-compiler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ergoscript-compiler"
version = "0.20.1"
version = "0.22.0"
license = "CC0-1.0"
authors = ["Denys Zadorozhnyi <[email protected]>"]
repository.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion ergotree-interpreter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ergotree-interpreter"
version = "0.24.1"
version = "0.26.0"
license = "CC0-1.0"
authors = ["Denys Zadorozhnyi <[email protected]>"]
repository.workspace = true
Expand Down Expand Up @@ -37,6 +37,7 @@ proptest = { workspace = true, optional = true }
ergo_avltree_rust = "0.1.0"
gf2_192 = { version = "^0.24.1", path = "../gf2_192" }
miette = { workspace = true }
hashbrown = "0.14.1"

[features]
default = ["json"]
Expand Down
Loading

0 comments on commit 0dd80fb

Please sign in to comment.