Skip to content

Commit

Permalink
feat(drive)!: provide protocol version in epoch info query (#1778)
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov authored Apr 4, 2024
1 parent 7cb35e8 commit a12abe6
Show file tree
Hide file tree
Showing 58 changed files with 369 additions and 459 deletions.
22 changes: 22 additions & 0 deletions packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25767,6 +25767,7 @@ $root.org = (function() {
* @property {number|null} [firstCoreBlockHeight] EpochInfo firstCoreBlockHeight
* @property {number|Long|null} [startTime] EpochInfo startTime
* @property {number|null} [feeMultiplier] EpochInfo feeMultiplier
* @property {number|null} [protocolVersion] EpochInfo protocolVersion
*/

/**
Expand Down Expand Up @@ -25824,6 +25825,14 @@ $root.org = (function() {
*/
EpochInfo.prototype.feeMultiplier = 0;

/**
* EpochInfo protocolVersion.
* @member {number} protocolVersion
* @memberof org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo
* @instance
*/
EpochInfo.prototype.protocolVersion = 0;

/**
* Creates a new EpochInfo instance using the specified properties.
* @function create
Expand Down Expand Up @@ -25858,6 +25867,8 @@ $root.org = (function() {
writer.uint32(/* id 4, wireType 0 =*/32).uint64(message.startTime);
if (message.feeMultiplier != null && Object.hasOwnProperty.call(message, "feeMultiplier"))
writer.uint32(/* id 5, wireType 1 =*/41).double(message.feeMultiplier);
if (message.protocolVersion != null && Object.hasOwnProperty.call(message, "protocolVersion"))
writer.uint32(/* id 6, wireType 0 =*/48).uint32(message.protocolVersion);
return writer;
};

Expand Down Expand Up @@ -25907,6 +25918,9 @@ $root.org = (function() {
case 5:
message.feeMultiplier = reader.double();
break;
case 6:
message.protocolVersion = reader.uint32();
break;
default:
reader.skipType(tag & 7);
break;
Expand Down Expand Up @@ -25957,6 +25971,9 @@ $root.org = (function() {
if (message.feeMultiplier != null && message.hasOwnProperty("feeMultiplier"))
if (typeof message.feeMultiplier !== "number")
return "feeMultiplier: number expected";
if (message.protocolVersion != null && message.hasOwnProperty("protocolVersion"))
if (!$util.isInteger(message.protocolVersion))
return "protocolVersion: integer expected";
return null;
};

Expand Down Expand Up @@ -25996,6 +26013,8 @@ $root.org = (function() {
message.startTime = new $util.LongBits(object.startTime.low >>> 0, object.startTime.high >>> 0).toNumber(true);
if (object.feeMultiplier != null)
message.feeMultiplier = Number(object.feeMultiplier);
if (object.protocolVersion != null)
message.protocolVersion = object.protocolVersion >>> 0;
return message;
};

Expand Down Expand Up @@ -26026,6 +26045,7 @@ $root.org = (function() {
} else
object.startTime = options.longs === String ? "0" : 0;
object.feeMultiplier = 0;
object.protocolVersion = 0;
}
if (message.number != null && message.hasOwnProperty("number"))
object.number = message.number;
Expand All @@ -26043,6 +26063,8 @@ $root.org = (function() {
object.startTime = options.longs === String ? $util.Long.prototype.toString.call(message.startTime) : options.longs === Number ? new $util.LongBits(message.startTime.low >>> 0, message.startTime.high >>> 0).toNumber(true) : message.startTime;
if (message.feeMultiplier != null && message.hasOwnProperty("feeMultiplier"))
object.feeMultiplier = options.json && !isFinite(message.feeMultiplier) ? String(message.feeMultiplier) : message.feeMultiplier;
if (message.protocolVersion != null && message.hasOwnProperty("protocolVersion"))
object.protocolVersion = message.protocolVersion;
return object;
};

Expand Down
32 changes: 31 additions & 1 deletion packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24494,7 +24494,8 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep
firstBlockHeight: jspb.Message.getFieldWithDefault(msg, 2, 0),
firstCoreBlockHeight: jspb.Message.getFieldWithDefault(msg, 3, 0),
startTime: jspb.Message.getFieldWithDefault(msg, 4, 0),
feeMultiplier: jspb.Message.getFloatingPointFieldWithDefault(msg, 5, 0.0)
feeMultiplier: jspb.Message.getFloatingPointFieldWithDefault(msg, 5, 0.0),
protocolVersion: jspb.Message.getFieldWithDefault(msg, 6, 0)
};

if (includeInstance) {
Expand Down Expand Up @@ -24551,6 +24552,10 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep
var value = /** @type {number} */ (reader.readDouble());
msg.setFeeMultiplier(value);
break;
case 6:
var value = /** @type {number} */ (reader.readUint32());
msg.setProtocolVersion(value);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -24615,6 +24620,13 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep
f
);
}
f = message.getProtocolVersion();
if (f !== 0) {
writer.writeUint32(
6,
f
);
}
};


Expand Down Expand Up @@ -24708,6 +24720,24 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep
};


/**
* optional uint32 protocol_version = 6;
* @return {number}
*/
proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getProtocolVersion = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 6, 0));
};


/**
* @param {number} value
* @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this
*/
proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setProtocolVersion = function(value) {
return jspb.Message.setProto3IntField(this, 6, value);
};


/**
* optional EpochInfos epochs = 1;
* @return {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3271,6 +3271,9 @@ export namespace GetEpochsInfoResponse {
getFeeMultiplier(): number;
setFeeMultiplier(value: number): void;

getProtocolVersion(): number;
setProtocolVersion(value: number): void;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): EpochInfo.AsObject;
static toObject(includeInstance: boolean, msg: EpochInfo): EpochInfo.AsObject;
Expand All @@ -3288,6 +3291,7 @@ export namespace GetEpochsInfoResponse {
firstCoreBlockHeight: number,
startTime: number,
feeMultiplier: number,
protocolVersion: number,
}
}

Expand Down
32 changes: 31 additions & 1 deletion packages/dapi-grpc/clients/platform/v0/web/platform_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -24494,7 +24494,8 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep
firstBlockHeight: jspb.Message.getFieldWithDefault(msg, 2, 0),
firstCoreBlockHeight: jspb.Message.getFieldWithDefault(msg, 3, 0),
startTime: jspb.Message.getFieldWithDefault(msg, 4, 0),
feeMultiplier: jspb.Message.getFloatingPointFieldWithDefault(msg, 5, 0.0)
feeMultiplier: jspb.Message.getFloatingPointFieldWithDefault(msg, 5, 0.0),
protocolVersion: jspb.Message.getFieldWithDefault(msg, 6, 0)
};

if (includeInstance) {
Expand Down Expand Up @@ -24551,6 +24552,10 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep
var value = /** @type {number} */ (reader.readDouble());
msg.setFeeMultiplier(value);
break;
case 6:
var value = /** @type {number} */ (reader.readUint32());
msg.setProtocolVersion(value);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -24615,6 +24620,13 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep
f
);
}
f = message.getProtocolVersion();
if (f !== 0) {
writer.writeUint32(
6,
f
);
}
};


Expand Down Expand Up @@ -24708,6 +24720,24 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep
};


/**
* optional uint32 protocol_version = 6;
* @return {number}
*/
proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getProtocolVersion = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 6, 0));
};


/**
* @param {number} value
* @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this
*/
proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setProtocolVersion = function(value) {
return jspb.Message.setProto3IntField(this, 6, value);
};


/**
* optional EpochInfos epochs = 1;
* @return {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos}
Expand Down
1 change: 1 addition & 0 deletions packages/dapi-grpc/protos/platform/v0/platform.proto
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ message GetEpochsInfoResponse {
uint32 first_core_block_height = 3;
uint64 start_time = 4;
double fee_multiplier = 5;
uint32 protocol_version = 6;
}

oneof result {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,8 @@ pub mod get_epochs_info_response {
pub start_time: u64,
#[prost(double, tag = "5")]
pub fee_multiplier: f64,
#[prost(uint32, tag = "6")]
pub protocol_version: u32,
}
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[serde(rename_all = "snake_case")]
Expand Down
7 changes: 7 additions & 0 deletions packages/rs-dpp/src/block/extended_epoch_info/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pub mod v0;
use crate::block::epoch::EpochIndex;
use crate::block::extended_epoch_info::v0::{ExtendedEpochInfoV0, ExtendedEpochInfoV0Getters};
use crate::protocol_error::ProtocolError;
use crate::util::deserializer::ProtocolVersion;
use bincode::{Decode, Encode};
use derive_more::From;
use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize};
Expand Down Expand Up @@ -56,4 +57,10 @@ impl ExtendedEpochInfoV0Getters for ExtendedEpochInfo {
ExtendedEpochInfo::V0(v0) => v0.fee_multiplier,
}
}

fn protocol_version(&self) -> ProtocolVersion {
match self {
ExtendedEpochInfo::V0(v0) => v0.protocol_version,
}
}
}
6 changes: 6 additions & 0 deletions packages/rs-dpp/src/block/extended_epoch_info/v0/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::block::epoch::EpochIndex;
use crate::util::deserializer::ProtocolVersion;
use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};

Expand All @@ -15,6 +16,8 @@ pub struct ExtendedEpochInfoV0 {
pub first_core_block_height: u32,
/// Fee multiplier
pub fee_multiplier: f64,
/// Protocol version
pub protocol_version: u32,
}

/// Trait defining getters for `ExtendedEpochInfoV0`.
Expand All @@ -33,4 +36,7 @@ pub trait ExtendedEpochInfoV0Getters {

/// Returns the fee multiplier.
fn fee_multiplier(&self) -> f64;

/// Protocol version
fn protocol_version(&self) -> ProtocolVersion;
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ where
initial_platform_state
.set_current_protocol_version_in_consensus(request.initial_protocol_version);

self.drive.store_current_protocol_version(
request.initial_protocol_version,
Some(transaction),
&platform_version.drive,
)?;

if tracing::enabled!(tracing::Level::TRACE) {
tracing::trace!(
platform_state_fingerprint = hex::encode(initial_platform_state.fingerprint()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,7 @@ where

// Process fees
let processed_block_fees = self.process_block_fees(
block_execution_context.block_state_info(),
&epoch_info,
&block_execution_context,
block_fees_v0.into(),
transaction,
platform_version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::execution::types::block_state_info::BlockStateInfo;
use crate::execution::types::storage_fee_distribution_outcome;

use crate::error::execution::ExecutionError;
use crate::execution::types::block_execution_context::BlockExecutionContext;

use crate::platform_types::epoch_info::EpochInfo;

Check warning on line 17 in packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (drive-abci) / Linting

unused import: `crate::platform_types::epoch_info::EpochInfo`

warning: unused import: `crate::platform_types::epoch_info::EpochInfo` --> packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/mod.rs:17:5 | 17 | use crate::platform_types::epoch_info::EpochInfo; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
use crate::platform_types::platform::Platform;
Expand Down Expand Up @@ -41,8 +42,7 @@ impl<CoreRPCLike> Platform<CoreRPCLike> {
///
pub fn add_process_epoch_change_operations(
&self,
block_info: &BlockStateInfo,
epoch_info: &EpochInfo,
block_execution_context: &BlockExecutionContext,
block_fees: &BlockFees,
transaction: &Transaction,
batch: &mut Vec<DriveOperation>,
Expand All @@ -56,8 +56,7 @@ impl<CoreRPCLike> Platform<CoreRPCLike> {
.add_process_epoch_change_operations
{
0 => self.add_process_epoch_change_operations_v0(
block_info,
epoch_info,
block_execution_context,
block_fees,
transaction,
batch,
Expand Down
Loading

0 comments on commit a12abe6

Please sign in to comment.