Skip to content

Commit 869a18c

Browse files
committed
Merge branch 'develop' of https://github.com/stacks-network/stacks-core into chore/add-drop-reason-to-p2p-logs
2 parents 01d0f15 + 36d49b0 commit 869a18c

File tree

234 files changed

+5717
-5679
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+5717
-5679
lines changed

.github/workflows/bitcoin-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ jobs:
167167
- tests::nakamoto_integrations::sip029_coinbase_change
168168
- tests::nakamoto_integrations::clarity_cost_spend_down
169169
- tests::nakamoto_integrations::v3_blockbyheight_api_endpoint
170+
- tests::nakamoto_integrations::mine_invalid_principal_from_consensus_buff
170171
- tests::nakamoto_integrations::test_tenure_extend_from_flashblocks
171172
# TODO: enable these once v1 signer is supported by a new nakamoto epoch
172173
# - tests::signer::v1::dkg

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to the versioning scheme outlined in the [README.md](README.md).
77

8-
## [Unreleased]
8+
## [3.1.0.0.4]
99

1010
### Added
1111

Cargo.lock

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clarity/src/vm/contexts.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,14 +2134,8 @@ mod test {
21342134
mut tl_env_factory: TopLevelMemoryEnvironmentGenerator,
21352135
) {
21362136
let mut env = tl_env_factory.get_env(epoch);
2137-
let u1 = StacksAddress {
2138-
version: 0,
2139-
bytes: Hash160([1; 20]),
2140-
};
2141-
let u2 = StacksAddress {
2142-
version: 0,
2143-
bytes: Hash160([2; 20]),
2144-
};
2137+
let u1 = StacksAddress::new(0, Hash160([1; 20])).unwrap();
2138+
let u2 = StacksAddress::new(0, Hash160([2; 20])).unwrap();
21452139
// insufficient balance must be a non-includable transaction. it must error here,
21462140
// not simply rollback the tx and squelch the error as includable.
21472141
let e = env

clarity/src/vm/docs/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,9 +2732,7 @@ fn make_all_api_reference() -> ReferenceAPIs {
27322732
#[allow(clippy::expect_used)]
27332733
pub fn make_json_api_reference() -> String {
27342734
let api_out = make_all_api_reference();
2735-
serde_json::to_string(&api_out)
2736-
.expect("Failed to serialize documentation")
2737-
.to_string()
2735+
serde_json::to_string(&api_out).expect("Failed to serialize documentation")
27382736
}
27392737

27402738
#[cfg(test)]

clarity/src/vm/functions/conversions.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use crate::vm::errors::{
2020
check_argument_count, CheckErrors, InterpreterError, InterpreterResult as Result,
2121
};
2222
use crate::vm::representations::SymbolicExpression;
23+
use crate::vm::types::serialization::SerializationError;
2324
use crate::vm::types::SequenceSubtype::BufferType;
2425
use crate::vm::types::TypeSignature::SequenceType;
2526
use crate::vm::types::{
@@ -276,6 +277,9 @@ pub fn from_consensus_buff(
276277
env.epoch().value_sanitizing(),
277278
) {
278279
Ok(value) => value,
280+
Err(SerializationError::UnexpectedSerialization) => {
281+
return Err(CheckErrors::Expects("UnexpectedSerialization".into()).into())
282+
}
279283
Err(_) => return Ok(Value::none()),
280284
};
281285
if !type_arg.admits(env.epoch(), &result)? {

clarity/src/vm/functions/crypto.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ use crate::vm::errors::{
2727
check_argument_count, CheckErrors, InterpreterError, InterpreterResult as Result,
2828
};
2929
use crate::vm::representations::SymbolicExpression;
30-
use crate::vm::types::{
31-
BuffData, SequenceData, StacksAddressExtensions, TypeSignature, Value, BUFF_32, BUFF_33,
32-
BUFF_65,
33-
};
30+
use crate::vm::types::{BuffData, SequenceData, TypeSignature, Value, BUFF_32, BUFF_33, BUFF_65};
3431
use crate::vm::{eval, ClarityVersion, Environment, LocalContext};
3532

3633
macro_rules! native_hash_func {
@@ -120,7 +117,7 @@ pub fn special_principal_of(
120117
} else {
121118
pubkey_to_address_v1(pub_key)?
122119
};
123-
let principal = addr.to_account_principal();
120+
let principal = addr.into();
124121
Ok(Value::okay(Value::Principal(principal))
125122
.map_err(|_| InterpreterError::Expect("Failed to construct ok".into()))?)
126123
} else {

clarity/src/vm/functions/principals.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,10 @@ pub fn special_is_standard(
5858
runtime_cost(ClarityCostFunction::IsStandard, env, 0)?;
5959
let owner = eval(&args[0], env, context)?;
6060

61-
let version = match owner {
62-
Value::Principal(PrincipalData::Standard(StandardPrincipalData(version, _bytes))) => {
63-
version
64-
}
65-
Value::Principal(PrincipalData::Contract(QualifiedContractIdentifier {
66-
issuer,
67-
name: _,
68-
})) => issuer.0,
69-
_ => return Err(CheckErrors::TypeValueError(TypeSignature::PrincipalType, owner).into()),
61+
let version = if let Value::Principal(ref p) = owner {
62+
p.version()
63+
} else {
64+
return Err(CheckErrors::TypeValueError(TypeSignature::PrincipalType, owner).into());
7065
};
7166

7267
Ok(Value::Bool(version_matches_current_network(
@@ -161,10 +156,12 @@ pub fn special_principal_destruct(
161156
let principal = eval(&args[0], env, context)?;
162157

163158
let (version_byte, hash_bytes, name_opt) = match principal {
164-
Value::Principal(PrincipalData::Standard(StandardPrincipalData(version, bytes))) => {
159+
Value::Principal(PrincipalData::Standard(p)) => {
160+
let (version, bytes) = p.destruct();
165161
(version, bytes, None)
166162
}
167163
Value::Principal(PrincipalData::Contract(QualifiedContractIdentifier { issuer, name })) => {
164+
let issuer = issuer.destruct();
168165
(issuer.0, issuer.1, Some(name))
169166
}
170167
_ => {
@@ -254,7 +251,7 @@ pub fn special_principal_construct(
254251
// Construct the principal.
255252
let mut transfer_buffer = [0u8; 20];
256253
transfer_buffer.copy_from_slice(verified_hash_bytes);
257-
let principal_data = StandardPrincipalData(version_byte, transfer_buffer);
254+
let principal_data = StandardPrincipalData::new(version_byte, transfer_buffer)?;
258255

259256
let principal = if let Some(name) = name_opt {
260257
// requested a contract principal. Verify that the `name` is a valid ContractName.

clarity/src/vm/tests/datamaps.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -642,15 +642,15 @@ fn bad_define_maps() {
642642
"(define-map lists { name: int } contents 5)",
643643
"(define-map lists { name: int } { contents: (list 5 0 int) })",
644644
];
645-
let mut expected: Vec<Error> = vec![
645+
let expected: Vec<Error> = vec![
646646
CheckErrors::BadSyntaxExpectedListOfPairs.into(),
647647
CheckErrors::UnknownTypeName("contents".to_string()).into(),
648648
CheckErrors::ExpectedName.into(),
649649
CheckErrors::IncorrectArgumentCount(3, 4).into(),
650650
CheckErrors::InvalidTypeDescription.into(),
651651
];
652652

653-
for (test, expected_err) in tests.iter().zip(expected.drain(..)) {
653+
for (test, expected_err) in tests.iter().zip(expected.into_iter()) {
654654
let outcome = execute(test).unwrap_err();
655655
assert_eq!(outcome, expected_err);
656656
}
@@ -666,7 +666,7 @@ fn bad_tuples() {
666666
"(get name five (tuple (name 1)))",
667667
"(get 1234 (tuple (name 1)))",
668668
];
669-
let mut expected = vec![
669+
let expected = vec![
670670
CheckErrors::NameAlreadyUsed("name".into()),
671671
CheckErrors::BadSyntaxBinding,
672672
CheckErrors::BadSyntaxBinding,
@@ -678,7 +678,7 @@ fn bad_tuples() {
678678
CheckErrors::ExpectedName,
679679
];
680680

681-
for (test, expected_err) in tests.iter().zip(expected.drain(..)) {
681+
for (test, expected_err) in tests.iter().zip(expected.into_iter()) {
682682
let outcome = execute(test).unwrap_err();
683683
assert_eq!(outcome, expected_err.into());
684684
}

clarity/src/vm/tests/principals.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ fn test_principal_construct_good() {
668668
Value::Response(ResponseData {
669669
committed: true,
670670
data: Box::new(Value::Principal(PrincipalData::Standard(
671-
StandardPrincipalData(22, transfer_buffer)
671+
StandardPrincipalData::new(22, transfer_buffer).unwrap()
672672
)))
673673
}),
674674
execute_with_parameters(
@@ -688,7 +688,7 @@ fn test_principal_construct_good() {
688688
Value::Response(ResponseData {
689689
committed: true,
690690
data: Box::new(Value::Principal(PrincipalData::Standard(
691-
StandardPrincipalData(20, transfer_buffer)
691+
StandardPrincipalData::new(20, transfer_buffer).unwrap()
692692
)))
693693
}),
694694
execute_with_parameters(
@@ -710,7 +710,7 @@ fn test_principal_construct_good() {
710710
committed: true,
711711
data: Box::new(Value::Principal(PrincipalData::Contract(
712712
QualifiedContractIdentifier::new(
713-
StandardPrincipalData(22, transfer_buffer),
713+
StandardPrincipalData::new(22, transfer_buffer).unwrap(),
714714
"hello-world".into()
715715
)
716716
)))
@@ -734,7 +734,7 @@ fn test_principal_construct_good() {
734734
committed: true,
735735
data: Box::new(Value::Principal(PrincipalData::Contract(
736736
QualifiedContractIdentifier::new(
737-
StandardPrincipalData(20, transfer_buffer),
737+
StandardPrincipalData::new(20, transfer_buffer).unwrap(),
738738
"hello-world".into()
739739
)
740740
)))
@@ -756,7 +756,7 @@ fn test_principal_construct_good() {
756756
Value::Response(ResponseData {
757757
committed: true,
758758
data: Box::new(Value::Principal(PrincipalData::Standard(
759-
StandardPrincipalData(26, transfer_buffer)
759+
StandardPrincipalData::new(26, transfer_buffer).unwrap()
760760
)))
761761
}),
762762
execute_with_parameters(
@@ -776,7 +776,7 @@ fn test_principal_construct_good() {
776776
Value::Response(ResponseData {
777777
committed: true,
778778
data: Box::new(Value::Principal(PrincipalData::Standard(
779-
StandardPrincipalData(21, transfer_buffer)
779+
StandardPrincipalData::new(21, transfer_buffer).unwrap()
780780
)))
781781
}),
782782
execute_with_parameters(
@@ -798,7 +798,7 @@ fn test_principal_construct_good() {
798798
committed: true,
799799
data: Box::new(Value::Principal(PrincipalData::Contract(
800800
QualifiedContractIdentifier::new(
801-
StandardPrincipalData(26, transfer_buffer),
801+
StandardPrincipalData::new(26, transfer_buffer).unwrap(),
802802
"hello-world".into()
803803
)
804804
)))
@@ -822,7 +822,7 @@ fn test_principal_construct_good() {
822822
committed: true,
823823
data: Box::new(Value::Principal(PrincipalData::Contract(
824824
QualifiedContractIdentifier::new(
825-
StandardPrincipalData(21, transfer_buffer),
825+
StandardPrincipalData::new(21, transfer_buffer).unwrap(),
826826
"hello-world".into()
827827
)
828828
)))
@@ -853,15 +853,14 @@ fn create_principal_from_strings(
853853
if let Some(name) = name {
854854
// contract principal requested
855855
Value::Principal(PrincipalData::Contract(QualifiedContractIdentifier::new(
856-
StandardPrincipalData(version_array[0], principal_array),
856+
StandardPrincipalData::new(version_array[0], principal_array).unwrap(),
857857
name.into(),
858858
)))
859859
} else {
860860
// standard principal requested
861-
Value::Principal(PrincipalData::Standard(StandardPrincipalData(
862-
version_array[0],
863-
principal_array,
864-
)))
861+
Value::Principal(PrincipalData::Standard(
862+
StandardPrincipalData::new(version_array[0], principal_array).unwrap(),
863+
))
865864
}
866865
}
867866

0 commit comments

Comments
 (0)