Skip to content

Commit

Permalink
Merge pull request #2665 from blockstack/develop
Browse files Browse the repository at this point in the history
Release 2.0.11.1.0
  • Loading branch information
lgalabru authored Jun 2, 2021
2 parents 08c4b9d + ddc0a29 commit 85f07f1
Show file tree
Hide file tree
Showing 150 changed files with 6,370 additions and 4,940 deletions.
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,38 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to the versioning scheme outlined in the [README.md](README.md).

## [2.0.11.1.0]

This software update is our monthly release. It introduces fixes and features for both developers and miners.
This release's chainstate directory is compatible with chainstate directories from 2.0.11.0.0.

## Added

- `/new_microblock` endpoint to notify event observers when a valid microblock
has been received (#2571).
- Added new features to `clarity-cli` (#2597)
- Exposing new mining-related metrics in prometheus (#2664)
- Miner's computed relative miner score as a percentage
- Miner's computed commitment, the min of their previous commitment and their median commitment
- Miner's current median commitment
- Add `key-for-seed` command to the `stacks-node` binary - outputs the associated secret key hex string
and WIF formatted secret key for a given "seed" value (#2658).

## Changed

- Improved mempool walk order (#2514).
- Renamed database `tx_tracking.db` to `tx_tracking.sqlite` (#2666).

## Fixed

- Alter the miner to prioritize spending the most recent UTXO when building a transaction,
instead of the largest UTXO. In the event of a tie, it uses the smallest UTXO first (#2661).
- Fix trait rpc lookups for implicitly implemented traits (#2602).
- Fix `v2/pox` endpoint, broken on Mocknet (#2634).
- Align cost limits on mocknet, testnet and mainnet (#2660).
- Log peer addresses in the HTTP server (#2667)
- Mine microblocks if there are no recent unprocessed Stacks blocks

## [2.0.11.0.0]

The chainstate directory has been restructured in this release. It is not
Expand Down
28 changes: 11 additions & 17 deletions benches/block_limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,26 @@ extern crate blockstack_lib;
extern crate rand;
extern crate serde_json;

use std::fs;
use std::process;
use std::{env, time::Instant};

use rand::Rng;

use blockstack_lib::clarity_vm::database::marf::MarfedKV;
use blockstack_lib::types::chainstate::{StacksAddress, StacksBlockId};
use blockstack_lib::types::{BlockHeaderHash, BurnchainHeaderHash, VRFSeed};
use blockstack_lib::util::boot::boot_code_id;
use blockstack_lib::{
burnchains::BurnchainHeaderHash,
chainstate::{
self,
burn::BlockHeaderHash,
stacks::{index::MarfTrieId, StacksBlockId},
},
chainstate::{self, stacks::index::MarfTrieId},
vm::clarity::ClarityInstance,
vm::costs::ExecutionCost,
vm::database::MarfedKV,
vm::{
database::{HeadersDB, NULL_BURN_STATE_DB},
types::{PrincipalData, QualifiedContractIdentifier, StandardPrincipalData},
Value,
},
};
use chainstate::{
burn::VRFSeed,
stacks::{boot::boot_code_id, StacksAddress},
};

use std::fs;
use std::process;
use std::{env, time::Instant};

use rand::Rng;

struct TestHeadersDB;

Expand Down
10 changes: 4 additions & 6 deletions benches/large_contract_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ extern crate criterion;
extern crate blockstack_lib;
extern crate rand;

use blockstack_lib::clarity_vm::database::marf::MarfedKV;
use blockstack_lib::types::BlockHeaderHash;
use blockstack_lib::{
chainstate::burn::BlockHeaderHash,
chainstate::stacks::index::storage::TrieFileStorage,
vm::clarity::ClarityInstance,
vm::database::{MarfedKV, NULL_HEADER_DB},
vm::types::QualifiedContractIdentifier,
chainstate::stacks::index::storage::TrieFileStorage, vm::clarity::ClarityInstance,
vm::database::NULL_HEADER_DB, vm::types::QualifiedContractIdentifier,
};

use criterion::Criterion;

pub fn rollback_log_memory_test() {
Expand Down
10 changes: 6 additions & 4 deletions benches/marf_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ extern crate criterion;
extern crate blockstack_lib;
extern crate rand;

use blockstack_lib::chainstate::burn::BlockHeaderHash;
use blockstack_lib::chainstate::stacks::index::{marf::MARF, storage::TrieFileStorage, MARFValue};
use std::fs;

use criterion::Criterion;
use rand::prelude::*;
use std::fs;

use blockstack_lib::chainstate::stacks::index::{marf::MARF, storage::TrieFileStorage};
use blockstack_lib::types::chainstate::MARFValue;
use blockstack_lib::types::BlockHeaderHash;
use criterion::Criterion;

fn benchmark_marf_usage(
filename: &str,
Expand Down
5 changes: 3 additions & 2 deletions net-test/tests/test_2_nat_miners_microblocks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ with_miner_1
RC=$?
if [ $RC -ne 0 ]; then
logln "Failed to make a token transfer to $STX_DEST_ADDR at attempt $i: rc $RC"
DONE=1
break

# keep trying
continue
fi

TXID="$(echo "$TX" | send_tx "http://localhost:21443")"
Expand Down
6 changes: 4 additions & 2 deletions net-test/tests/testlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,21 @@ easy_token_transfer() {
local ADDR="$(blockstack-cli --testnet addresses "$PRIVKEY" | jq -r '.STX')"
local NONCE="$(get_unconfirmed_account_nonce "$STACKS_NODE_URL" "$ADDR")"
local RC=$?
if [ $RC -ne 0 ]; then
logln "Failed to query unconfirmed account nonce: rc $RC"
if [ $RC -ne 0 ] || [ -z "$NONCE" ]; then
logln "Failed to query unconfirmed account nonce: rc '$RC' nonce '$NONCE'"
return 1
fi

local MEMO="test $NONCE"
logln "blockstack-cli --testnet token-transfer '$PRIVKEY' '$FEE_RATE' '$NONCE' '$DEST' '$AMOUNT' '$MEMO' '$OPTS'"
local TX="$(blockstack-cli --testnet token-transfer "$PRIVKEY" "$FEE_RATE" "$NONCE" "$DEST" "$AMOUNT" "$MEMO" "$OPTS" 2>&1)"
RC=$?
if [ $RC -ne 0 ]; then
logln "Failed to generate tx: blockstack-cli --testnet token-transfer $PRIVKEY $FEE_RATE $NONCE $DEST $AMOUNT \"$MEMO\""
return 1
fi

logln "Generated tx: $TX"
printf "$TX"
return 0
}
5 changes: 5 additions & 0 deletions sample-contracts/tokens-ft-mint.clar
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(begin
(as-contract
(contract-call? 'S1G2081040G2081040G2081040G208105NK8PE5.tokens-ft mint! u100)
)
)
16 changes: 16 additions & 0 deletions sample-contracts/tokens-ft.clar
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(define-fungible-token tokens)
(define-private (get-balance (account principal))
(ft-get-balance tokens account))

(define-private (token-credit! (account principal) (amount uint))
(ft-mint? tokens amount account))

(define-public (token-transfer (to principal) (amount uint))
(ft-transfer? tokens amount tx-sender to))

(define-public (mint! (amount uint))
(token-credit! tx-sender amount))

(token-credit! tx-sender u10300)
(token-transfer 'SZ2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQ9H6DPR u10000)
(token-transfer 'SM2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQVX8X0G u300)
2 changes: 1 addition & 1 deletion sample-contracts/tokens-mint.clar
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
(as-contract
(contract-call? 'S1G2081040G2081040G2081040G208105NK8PE5.tokens mint! u100)
)
)
)
35 changes: 22 additions & 13 deletions src/blockstack_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,28 @@

extern crate blockstack_lib;

use std::convert::TryFrom;
use std::io::prelude::*;
use std::io::Read;
use std::{env, fs, io};

use blockstack_lib::address::b58;
use blockstack_lib::address::AddressHashMode;
use blockstack_lib::burnchains::bitcoin::address::{
ADDRESS_VERSION_MAINNET_SINGLESIG, ADDRESS_VERSION_TESTNET_SINGLESIG,
};
use blockstack_lib::burnchains::Address;
use blockstack_lib::chainstate::stacks::{
StacksAddress, StacksBlock, StacksMicroblock, StacksPrivateKey, StacksPublicKey,
StacksTransaction, StacksTransactionSigner, TokenTransferMemo, TransactionAnchorMode,
TransactionAuth, TransactionContractCall, TransactionPayload, TransactionSmartContract,
StacksBlock, StacksMicroblock, StacksPrivateKey, StacksPublicKey, StacksTransaction,
StacksTransactionSigner, TokenTransferMemo, TransactionAnchorMode, TransactionAuth,
TransactionContractCall, TransactionPayload, TransactionSmartContract,
TransactionSpendingCondition, TransactionVersion, C32_ADDRESS_VERSION_MAINNET_SINGLESIG,
C32_ADDRESS_VERSION_TESTNET_SINGLESIG,
};
use blockstack_lib::codec::{Error as CodecError, StacksMessageCodec};
use blockstack_lib::core::{CHAIN_ID_MAINNET, CHAIN_ID_TESTNET};
use blockstack_lib::net::{Error as NetError, StacksMessageCodec};
use blockstack_lib::net::Error as NetError;
use blockstack_lib::types::chainstate::StacksAddress;
use blockstack_lib::util::{
hash::hex_bytes, hash::to_hex, log, retry::LogReader, strings::StacksString,
};
Expand All @@ -41,15 +52,6 @@ use blockstack_lib::vm::{
types::PrincipalData,
ClarityName, ContractName, Value,
};
use std::convert::TryFrom;
use std::io::prelude::*;
use std::io::Read;
use std::{env, fs, io};

use blockstack_lib::address::b58;
use blockstack_lib::burnchains::bitcoin::address::{
ADDRESS_VERSION_MAINNET_SINGLESIG, ADDRESS_VERSION_TESTNET_SINGLESIG,
};

const USAGE: &str = "blockstack-cli (options) [method] [args...]
Expand Down Expand Up @@ -215,6 +217,12 @@ impl From<NetError> for CliError {
}
}

impl From<CodecError> for CliError {
fn from(value: CodecError) -> Self {
CliError::Message(format!("Stacks CodecError: {}", value))
}
}

impl From<std::num::ParseIntError> for CliError {
fn from(value: std::num::ParseIntError) -> Self {
CliError::Message(format!("Failed to parse integer: {}", value))
Expand Down Expand Up @@ -779,6 +787,7 @@ fn main_handler(mut argv: Vec<String>) -> Result<String, CliError> {
#[cfg(test)]
mod test {
use super::*;

#[test]
fn generate_should_work() {
assert!(main_handler(vec!["generate-sk".into(), "--testnet".into()]).is_ok());
Expand Down
19 changes: 8 additions & 11 deletions src/burnchains/bitcoin/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,16 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

use burnchains::bitcoin::BitcoinNetworkType;
use burnchains::Address;

use burnchains::bitcoin::Error as btc_error;

use util::hash::Hash160;
use util::log;

use address::b58 as base58;
use address::c32::c32_address;
use deps::bitcoin::blockdata::script::Builder as BtcScriptBuilder;

use burnchains::bitcoin::BitcoinNetworkType;
use burnchains::bitcoin::Error as btc_error;
use burnchains::Address;
use deps::bitcoin::blockdata::opcodes::All as BtcOp;
use deps::bitcoin::blockdata::script::Builder as BtcScriptBuilder;
use deps::bitcoin::blockdata::transaction::TxOut;
use util::hash::Hash160;
use util::log;

use chainstate::stacks::{
C32_ADDRESS_VERSION_MAINNET_MULTISIG, C32_ADDRESS_VERSION_MAINNET_SINGLESIG,
Expand Down Expand Up @@ -281,11 +277,12 @@ impl std::fmt::Display for BitcoinAddress {

#[cfg(test)]
mod tests {
use super::{BitcoinAddress, BitcoinAddressType};
use burnchains::bitcoin::BitcoinNetworkType;
use util::hash::{hex_bytes, Hash160};
use util::log;

use super::{BitcoinAddress, BitcoinAddressType};

struct AddressFixture {
addr: String,
result: Option<BitcoinAddress>,
Expand Down
45 changes: 20 additions & 25 deletions src/burnchains/bitcoin/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,33 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

use deps::bitcoin::blockdata::opcodes::All as btc_opcodes;
use deps::bitcoin::blockdata::opcodes::Class;
use deps::bitcoin::blockdata::script::{Builder, Instruction, Script};
use deps::bitcoin::blockdata::transaction::TxIn as BtcTxIn;
use deps::bitcoin::blockdata::transaction::TxOut as BtcTxOut;
use deps::bitcoin::util::hash::Sha256dHash;

use burnchains::bitcoin::{BitcoinInputType, BitcoinTxInput, BitcoinTxOutput};

use burnchains::{BurnchainHeaderHash, PublicKey};
use sha2::Digest;
use sha2::Sha256;

use address::public_keys_to_address_hash;
use address::AddressHashMode;
use burnchains::bitcoin::address::{BitcoinAddress, BitcoinAddressType};
use burnchains::bitcoin::keys::BitcoinPublicKey;
use burnchains::bitcoin::BitcoinNetworkType;
use burnchains::bitcoin::Error as btc_error;
use burnchains::bitcoin::{BitcoinInputType, BitcoinTxInput, BitcoinTxOutput};
use burnchains::PublicKey;
use burnchains::Txid;
use deps::bitcoin::blockdata::opcodes::All as btc_opcodes;
use deps::bitcoin::blockdata::opcodes::Class;
use deps::bitcoin::blockdata::script::{Builder, Instruction, Script};
use deps::bitcoin::blockdata::transaction::TxIn as BtcTxIn;
use deps::bitcoin::blockdata::transaction::TxOut as BtcTxOut;
use deps::bitcoin::util::hash::Sha256dHash;
use util::hash::Hash160;
use util::log;

use address::public_keys_to_address_hash;
use address::AddressHashMode;

use crate::types::chainstate::BurnchainHeaderHash;
use chainstate::stacks::{
C32_ADDRESS_VERSION_MAINNET_MULTISIG, C32_ADDRESS_VERSION_MAINNET_SINGLESIG,
C32_ADDRESS_VERSION_TESTNET_MULTISIG, C32_ADDRESS_VERSION_TESTNET_SINGLESIG,
};

use sha2::Digest;
use sha2::Sha256;

use util::hash::Hash160;
use util::log;

/// Parse a script into its structured constituant opcodes and data and collect them
pub fn parse_script<'a>(script: &'a Script) -> Vec<Instruction<'a>> {
// we will have to accept non-minimial pushdata since there's at least one OP_RETURN
Expand Down Expand Up @@ -584,20 +580,19 @@ impl BurnchainHeaderHash {

#[cfg(test)]
mod tests {
use super::parse_script;
use super::BitcoinTxInput;
use super::BitcoinTxOutput;
use util::hash::hex_bytes;

use burnchains::bitcoin::address::{BitcoinAddress, BitcoinAddressType};
use burnchains::bitcoin::keys::BitcoinPublicKey;
use burnchains::bitcoin::BitcoinInputType;
use burnchains::bitcoin::BitcoinNetworkType;
use burnchains::Txid;
use deps::bitcoin::blockdata::script::{Builder, Script};

use util::hash::hex_bytes;
use util::log;

use super::parse_script;
use super::BitcoinTxInput;
use super::BitcoinTxOutput;

struct ScriptFixture<T> {
script: Script,
result: T,
Expand Down
Loading

0 comments on commit 85f07f1

Please sign in to comment.