Skip to content

Commit e6adc69

Browse files
committed
refactor: turn witnet_stack crate into module inside witnet_data_structures
1 parent 7f00e25 commit e6adc69

File tree

15 files changed

+32
-58
lines changed

15 files changed

+32
-58
lines changed

Cargo.lock

Lines changed: 1 addition & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ description = "An in-progress open source implementation of the Witnet protocol
1111
edition = "2021"
1212

1313
[workspace]
14-
members = ["config", "node", "crypto", "data_structures", "p2p", "storage", "wallet", "validations", "protected", "reputation", "net", "toolkit", "stack", "bridges/ethereum", "bridges/centralized-ethereum", "futures_utils"]
14+
members = ["config", "node", "crypto", "data_structures", "p2p", "storage", "wallet", "validations", "protected", "reputation", "net", "toolkit", "bridges/ethereum", "bridges/centralized-ethereum", "futures_utils"]
1515

1616
[features]
1717
default = ["wallet", "node", "telemetry"]
@@ -47,7 +47,6 @@ witnet_crypto = { path = "./crypto" }
4747
witnet_data_structures = { path = "./data_structures" }
4848
witnet_node = { path = "./node", optional = true }
4949
witnet_rad = { path = "./rad" }
50-
witnet_stack = { path = "./stack" }
5150
witnet_util = { path = "./util" }
5251
witnet_validations = { path = "./validations" }
5352
witnet_wallet = { path = "./wallet", optional = true }

data_structures/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ serde = { version = "1.0.104", features = ["derive"] }
2929
serde_cbor = "0.11.1"
3030
serde_json = "1.0.48"
3131
vrf = "0.2.3"
32+
scriptful = { version = "0.4", features = ["use_serde"] }
3233

3334
witnet_crypto = { path = "../crypto" }
3435
witnet_reputation = { path = "../reputation", features = ["serde"] }

data_structures/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ pub mod radon_error;
5959
/// Module containing RadonReport structures
6060
pub mod radon_report;
6161

62+
/// Module containing scripting logic
63+
pub mod stack;
64+
6265
/// Serialization boilerplate to allow serializing some data structures as
6366
/// strings or bytes depending on the serializer.
6467
mod serialization_helpers;
File renamed without changes.

stack/src/lib.rs renamed to data_structures/src/stack/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use scriptful::{core::machine::Machine, core::Script, core::ScriptRef};
22

3-
pub use crate::error::ScriptError;
4-
pub use crate::operators::{MyOperator, MyValue};
3+
pub use self::error::ScriptError;
4+
pub use self::operators::{MyOperator, MyValue};
5+
use crate::chain::Hash;
56
pub use scriptful::core::item::Item;
6-
use witnet_data_structures::chain::Hash;
77

88
mod error;
99
mod operators;

stack/src/operators.rs renamed to data_structures/src/stack/operators.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use crate::{ScriptContext, ScriptError};
1+
use super::{ScriptContext, ScriptError};
2+
use crate::chain::{Hash, PublicKey, Secp256k1Signature, Signature};
3+
use crate::chain::{KeyedSignature, PublicKeyHash};
24
use scriptful::prelude::{ConditionStack, Stack};
35
use serde::{Deserialize, Serialize};
46
use witnet_crypto::hash::{calculate_sha256, Sha256};
5-
use witnet_data_structures::chain::{Hash, PublicKey, Secp256k1Signature, Signature};
6-
use witnet_data_structures::chain::{KeyedSignature, PublicKeyHash};
77

88
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
99
// TODO: Include more operators

stack/src/parser.rs renamed to data_structures/src/stack/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{MyOperator, MyValue};
1+
use super::{MyOperator, MyValue};
22
use scriptful::prelude::Item;
33
use std::str::FromStr;
44

@@ -143,7 +143,7 @@ pub fn parse_operator(s: &str) -> Option<MyOperator> {
143143
#[cfg(test)]
144144
mod tests {
145145
use super::*;
146-
use witnet_data_structures::chain::PublicKey;
146+
use crate::chain::PublicKey;
147147

148148
#[test]
149149
fn script_to_string_multisig() {

stack/src/tests.rs renamed to data_structures/src/stack/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use crate::{
1+
use super::{
22
encode, execute_complete_script, execute_locking_script, execute_redeem_script, execute_script,
33
Item, MyOperator, MyValue, ScriptContext, ScriptError,
44
};
5+
use crate::chain::KeyedSignature;
56
use witnet_crypto::hash::calculate_sha256;
6-
use witnet_data_structures::chain::KeyedSignature;
77

88
const EQUAL_OPERATOR_HASH: [u8; 20] = [
99
52, 128, 191, 80, 253, 28, 169, 253, 237, 29, 0, 51, 201, 0, 31, 203, 157, 99, 218, 210,
@@ -142,7 +142,7 @@ fn test_ks_id(id: u8) -> KeyedSignature {
142142
let secret_key =
143143
witnet_crypto::secp256k1::SecretKey::from_slice(&mk).expect("32 bytes, within curve order");
144144
let public_key = witnet_crypto::secp256k1::PublicKey::from_secret_key_global(&secret_key);
145-
let public_key = witnet_data_structures::chain::PublicKey::from(public_key);
145+
let public_key = crate::chain::PublicKey::from(public_key);
146146
// TODO: mock this signature, it is not even validated in tests but we need a valid signature to
147147
// test signature deserialization
148148
let signature = witnet_crypto::signature::sign(secret_key, &[0x01; 32]).unwrap();

node/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ witnet_futures_utils = { path = "../futures_utils" }
3636
witnet_p2p = { path = "../p2p" }
3737
witnet_protected = { path = "../protected", features = ["with-serde"] }
3838
witnet_rad = { path = "../rad" }
39-
witnet_stack = { path = "../stack" }
4039
witnet_storage = { path = "../storage", features = ["rocksdb-backend"] }
4140
witnet_util = { path = "../util" }
4241
witnet_validations = { path = "../validations" }

0 commit comments

Comments
 (0)