Skip to content

Commit ebe96d2

Browse files
authored
Merge branch 'testnet3' into fix/from-bytes-bounds
2 parents 3e4717b + 320ac64 commit ebe96d2

File tree

16 files changed

+54
-46
lines changed

16 files changed

+54
-46
lines changed

console/program/src/request/serialize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl<N: Network> Serialize for Request<N> {
2121
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2222
match serializer.is_human_readable() {
2323
true => {
24-
let mut transition = serializer.serialize_struct("Request", 9)?;
24+
let mut transition = serializer.serialize_struct("Request", 10)?;
2525
transition.serialize_field("signer", &self.signer)?;
2626
transition.serialize_field("network", &self.network_id)?;
2727
transition.serialize_field("program", &self.program_id)?;

ledger/block/src/helpers/target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub const fn block_reward(total_supply: u64, block_time: u16, coinbase_reward: u
2727
// Compute the expected block height at year 1.
2828
let block_height_at_year_1 = block_height_at_year(block_time, 1);
2929
// Compute the annual reward: (0.05 * S).
30-
let annual_reward = (total_supply / 1000) * 50;
30+
let annual_reward = total_supply / 20;
3131
// Compute the block reward: (0.05 * S) / H_Y1.
3232
let block_reward = annual_reward / block_height_at_year_1 as u64;
3333
// Return the sum of the block reward, coinbase reward, and transaction fees.

ledger/block/src/serialize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl<N: Network> Serialize for Block<N> {
1919
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2020
match serializer.is_human_readable() {
2121
true => {
22-
let mut block = serializer.serialize_struct("Block", 6)?;
22+
let mut block = serializer.serialize_struct("Block", 7 + self.solutions.is_some() as usize)?;
2323
block.serialize_field("block_hash", &self.block_hash)?;
2424
block.serialize_field("previous_hash", &self.previous_hash)?;
2525
block.serialize_field("header", &self.header)?;

ledger/block/src/transaction/execution/serialize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl<N: Network> Serialize for Execution<N> {
1919
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2020
match serializer.is_human_readable() {
2121
true => {
22-
let mut execution = serializer.serialize_struct("Execution", 3)?;
22+
let mut execution = serializer.serialize_struct("Execution", 2 + self.proof.is_some() as usize)?;
2323
execution
2424
.serialize_field("transitions", &self.transitions.values().collect::<Vec<&Transition<N>>>())?;
2525
execution.serialize_field("global_state_root", &self.global_state_root)?;

ledger/block/src/transaction/fee/serialize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl<N: Network> Serialize for Fee<N> {
1919
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2020
match serializer.is_human_readable() {
2121
true => {
22-
let mut fee = serializer.serialize_struct("Fee", 3)?;
22+
let mut fee = serializer.serialize_struct("Fee", 2 + self.proof.is_some() as usize)?;
2323
fee.serialize_field("transition", &self.transition)?;
2424
fee.serialize_field("global_state_root", &self.global_state_root)?;
2525
if let Some(proof) = &self.proof {

ledger/block/src/transaction/serialize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<N: Network> Serialize for Transaction<N> {
2929
transaction.end()
3030
}
3131
Self::Execute(id, execution, fee) => {
32-
let mut transaction = serializer.serialize_struct("Transaction", 4)?;
32+
let mut transaction = serializer.serialize_struct("Transaction", 3 + fee.is_some() as usize)?;
3333
transaction.serialize_field("type", "execute")?;
3434
transaction.serialize_field("id", &id)?;
3535
transaction.serialize_field("execution", &execution)?;

ledger/block/src/transition/input/serialize.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl<N: Network> Serialize for Input<N> {
2020
match serializer.is_human_readable() {
2121
true => match self {
2222
Self::Constant(id, value) => {
23-
let mut input = serializer.serialize_struct("Input", 3)?;
23+
let mut input = serializer.serialize_struct("Input", 2 + value.is_some() as usize)?;
2424
input.serialize_field("type", "constant")?;
2525
input.serialize_field("id", &id)?;
2626
if let Some(value) = value {
@@ -29,7 +29,7 @@ impl<N: Network> Serialize for Input<N> {
2929
input.end()
3030
}
3131
Self::Public(id, value) => {
32-
let mut input = serializer.serialize_struct("Input", 3)?;
32+
let mut input = serializer.serialize_struct("Input", 2 + value.is_some() as usize)?;
3333
input.serialize_field("type", "public")?;
3434
input.serialize_field("id", &id)?;
3535
if let Some(value) = value {
@@ -38,7 +38,7 @@ impl<N: Network> Serialize for Input<N> {
3838
input.end()
3939
}
4040
Self::Private(id, value) => {
41-
let mut input = serializer.serialize_struct("Input", 3)?;
41+
let mut input = serializer.serialize_struct("Input", 2 + value.is_some() as usize)?;
4242
input.serialize_field("type", "private")?;
4343
input.serialize_field("id", &id)?;
4444
if let Some(value) = value {

ledger/block/src/transition/output/serialize.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl<N: Network> Serialize for Output<N> {
2020
match serializer.is_human_readable() {
2121
true => match self {
2222
Self::Constant(id, value) => {
23-
let mut output = serializer.serialize_struct("Output", 3)?;
23+
let mut output = serializer.serialize_struct("Output", 2 + value.is_some() as usize)?;
2424
output.serialize_field("type", "constant")?;
2525
output.serialize_field("id", &id)?;
2626
if let Some(value) = value {
@@ -29,7 +29,7 @@ impl<N: Network> Serialize for Output<N> {
2929
output.end()
3030
}
3131
Self::Public(id, value) => {
32-
let mut output = serializer.serialize_struct("Output", 3)?;
32+
let mut output = serializer.serialize_struct("Output", 2 + value.is_some() as usize)?;
3333
output.serialize_field("type", "public")?;
3434
output.serialize_field("id", &id)?;
3535
if let Some(value) = value {
@@ -38,7 +38,7 @@ impl<N: Network> Serialize for Output<N> {
3838
output.end()
3939
}
4040
Self::Private(id, value) => {
41-
let mut output = serializer.serialize_struct("Output", 3)?;
41+
let mut output = serializer.serialize_struct("Output", 2 + value.is_some() as usize)?;
4242
output.serialize_field("type", "private")?;
4343
output.serialize_field("id", &id)?;
4444
if let Some(value) = value {
@@ -47,7 +47,7 @@ impl<N: Network> Serialize for Output<N> {
4747
output.end()
4848
}
4949
Self::Record(id, checksum, value) => {
50-
let mut output = serializer.serialize_struct("Output", 5)?;
50+
let mut output = serializer.serialize_struct("Output", 3 + value.is_some() as usize)?;
5151
output.serialize_field("type", "record")?;
5252
output.serialize_field("id", &id)?;
5353
output.serialize_field("checksum", &checksum)?;
@@ -63,7 +63,7 @@ impl<N: Network> Serialize for Output<N> {
6363
output.end()
6464
}
6565
Self::Future(id, value) => {
66-
let mut output = serializer.serialize_struct("Output", 3)?;
66+
let mut output = serializer.serialize_struct("Output", 2 + value.is_some() as usize)?;
6767
output.serialize_field("type", "future")?;
6868
output.serialize_field("id", &id)?;
6969
if let Some(value) = value {

ledger/block/src/verify.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,11 @@ impl<N: Network> Block<N> {
137137
previous_height: u32,
138138
current_committee: &Committee<N>,
139139
) -> Result<(u64, u32, i64)> {
140+
#[cfg(not(any(test, feature = "test")))]
141+
ensure!(self.authority.is_quorum(), "The next block must be a quorum block");
142+
140143
// Determine the expected height.
141144
let expected_height = previous_height.saturating_add(1);
142-
// Ensure the block type is correct.
143-
match expected_height == 0 {
144-
true => ensure!(self.authority.is_beacon(), "The genesis block must be a beacon block"),
145-
false => {
146-
#[cfg(not(any(test, feature = "test")))]
147-
ensure!(self.authority.is_quorum(), "The next block must be a quorum block");
148-
}
149-
}
150145

151146
// Determine the expected round.
152147
let expected_round = match &self.authority {

ledger/coinbase/src/helpers/prover_solution/serialize.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ impl<N: Network> Serialize for ProverSolution<N> {
2121
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2222
match serializer.is_human_readable() {
2323
true => {
24-
let mut prover_solution = serializer.serialize_struct("ProverSolution", 3)?;
24+
let mut prover_solution =
25+
serializer.serialize_struct("ProverSolution", 2 + self.proof.random_v.is_some() as usize)?;
2526
prover_solution.serialize_field("partial_solution", &self.partial_solution)?;
2627
prover_solution.serialize_field("proof.w", &self.proof.w)?;
2728
if let Some(random_v) = &self.proof.random_v {

0 commit comments

Comments
 (0)