Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Use VRFProof::consensus_serialize() #4121

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions stackslib/src/chainstate/stacks/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl StacksMessageCodec for TransactionPayload {
write_next(fd, &(TransactionPayloadID::NakamotoCoinbase as u8))?;
write_next(fd, buf)?;
write_next(fd, &Value::none())?;
write_next(fd, &vrf_proof.to_bytes().to_vec())?;
write_next(fd, vrf_proof)?;
}
(Some(recipient), Some(vrf_proof)) => {
write_next(fd, &(TransactionPayloadID::NakamotoCoinbase as u8))?;
Expand All @@ -293,7 +293,7 @@ impl StacksMessageCodec for TransactionPayload {
"FATAL: failed to encode recipient principal as `optional`",
),
)?;
write_next(fd, &vrf_proof.to_bytes().to_vec())?;
write_next(fd, vrf_proof)?;
}
}
}
Expand Down Expand Up @@ -387,12 +387,7 @@ impl StacksMessageCodec for TransactionPayload {
} else {
return Err(codec_error::DeserializeError("Failed to parse nakamoto coinbase transaction -- did not receive an optional recipient principal value".to_string()));
};
let vrf_proof_bytes: Vec<u8> = read_next(fd)?;
let Some(vrf_proof) = VRFProof::from_bytes(&vrf_proof_bytes) else {
return Err(codec_error::DeserializeError(
"Failed to decode coinbase VRF proof".to_string(),
));
};
let vrf_proof: VRFProof = read_next(fd)?;
TransactionPayload::Coinbase(payload, recipient_opt, Some(vrf_proof))
}
TransactionPayloadID::TenureChange => {
Expand Down Expand Up @@ -2043,11 +2038,6 @@ mod test {
0x12,
// no alt recipient, so Value::none
0x09,
// proof bytes length
0x00,
0x00,
0x00,
0x50,
// proof bytes
0x92,
0x75,
Expand Down Expand Up @@ -2227,11 +2217,6 @@ mod test {
0x61,
0x63,
0x74,
// proof bytes length
0x00,
0x00,
0x00,
0x50,
// proof bytes
0x92,
0x75,
Expand Down
3 changes: 1 addition & 2 deletions stackslib/src/core/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ use stacks_common::util::{get_epoch_time_ms, get_epoch_time_secs};
use crate::burnchains::Txid;
use crate::chainstate::burn::db::sortdb::SortitionDB;
use crate::chainstate::burn::ConsensusHash;
use crate::chainstate::nakamoto::NakamotoBlock;
use crate::chainstate::nakamoto::NakamotoChainState;
use crate::chainstate::nakamoto::{NakamotoBlock, NakamotoChainState};
use crate::chainstate::stacks::db::blocks::MemPoolRejection;
use crate::chainstate::stacks::db::{ClarityTx, StacksChainState};
use crate::chainstate::stacks::events::StacksTransactionReceipt;
Expand Down
3 changes: 1 addition & 2 deletions testnet/stacks-node/src/mockamoto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,14 @@ use stacks_common::util::hash::{Hash160, MerkleTree, Sha512Trunc256Sum};
use stacks_common::util::secp256k1::{MessageSignature, SchnorrSignature, Secp256k1PublicKey};
use stacks_common::util::vrf::{VRFPrivateKey, VRFProof, VRFPublicKey, VRF};

use self::signer::SelfSigner;
use crate::neon::Counters;
use crate::neon_node::{
Globals, PeerThread, RelayerDirective, StacksNode, BLOCK_PROCESSOR_STACK_SIZE,
};
use crate::syncctl::PoxSyncWatchdogComms;
use crate::{Config, EventDispatcher};

use self::signer::SelfSigner;

pub mod signer;
#[cfg(test)]
mod tests;
Expand Down
18 changes: 6 additions & 12 deletions testnet/stacks-node/src/mockamoto/tests.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
use std::thread;
use std::time::Duration;
use std::time::Instant;
use std::time::{Duration, Instant};

use clarity::vm::costs::ExecutionCost;
use stacks::chainstate::nakamoto::NakamotoChainState;
use stacks::chainstate::stacks::db::StacksChainState;
use stacks_common::types::chainstate::StacksAddress;
use stacks_common::types::chainstate::StacksPrivateKey;
use stacks_common::types::chainstate::{StacksAddress, StacksPrivateKey};
use stacks_common::types::StacksEpochId;
use stacks_common::util::hash::to_hex;

use crate::config::EventKeyType;
use crate::config::EventObserverConfig;
use super::MockamotoNode;
use crate::config::{EventKeyType, EventObserverConfig};
use crate::neon_node::PeerThread;
use crate::tests::make_stacks_transfer;
use crate::tests::neon_integrations::test_observer;
use crate::tests::to_addr;
use crate::Config;
use crate::ConfigFile;

use super::MockamotoNode;
use crate::tests::{make_stacks_transfer, to_addr};
use crate::{Config, ConfigFile};

#[test]
fn observe_100_blocks() {
Expand Down