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

feat(drive)!: provide protocol version in epoch info query #1778

Merged
merged 44 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
56f97d7
feat(drive): consistent versioning based on consensus app version
shumkov Mar 13, 2024
b1c77f2
fix: global cache might be cleaned on failed round
shumkov Mar 13, 2024
f7902db
refactor: reuse version from block platform state
shumkov Mar 13, 2024
fc14163
refactor: remove unnecessary field
shumkov Mar 13, 2024
f759116
refactor: remove unused import
shumkov Mar 13, 2024
f611ff6
fix: compilation errors
shumkov Mar 13, 2024
4f1373f
fix: clean first block proposed version
shumkov Mar 14, 2024
e5f1acc
feat: use version from genesis to run init chain
shumkov Mar 15, 2024
4f155f7
feat: provide protocol version in epoch info query
shumkov Mar 15, 2024
fb470b5
style: revert formatting
shumkov Mar 19, 2024
69e4dc8
docs: typo in comment
shumkov Mar 19, 2024
f19be27
fix: invalid error messages
shumkov Mar 19, 2024
8905380
Merge branch 'v1.0-dev' into feat/drive/use-app-version-param
shumkov Mar 26, 2024
bdbe90d
fix: first block of epoch processed by previous version
shumkov Mar 26, 2024
c38df52
Merge branch 'feat/drive/use-app-version-param' into feat/drive/epoch…
shumkov Mar 26, 2024
dc9bf06
chore: update app hash
shumkov Mar 26, 2024
b08beb5
chore: remove unnecessary functions and move current version to aux
shumkov Mar 26, 2024
e58d2ab
style: unused import
shumkov Mar 26, 2024
2ac3f8c
chore: use previous block hpmn count
shumkov Mar 27, 2024
edff6cb
fix: missing a version proposal on epoch change
shumkov Mar 27, 2024
1343d99
style: unused imports
shumkov Mar 27, 2024
a3d57e6
fix: votes are missing for next round and others
shumkov Mar 28, 2024
6d994eb
chore: update tenderdash to v0.14.0-dev.5
shumkov Mar 28, 2024
c404e2a
feat: warn user about outdated software
shumkov Mar 28, 2024
2f357a6
fix: process block with the previous version of EpochInfo
shumkov Mar 28, 2024
2d35fe6
refactor: rename variable
shumkov Mar 28, 2024
f78465a
refactor: move code blocks to reduce changes
shumkov Mar 28, 2024
6e3dcf2
refactor: rename methods for better readability
shumkov Mar 28, 2024
6d0ed9b
Merge branch 'feat/drive/use-app-version-param' into feat/drive/epoch…
shumkov Mar 28, 2024
db25ef7
test: update root hash asserts
shumkov Mar 28, 2024
627ba60
chore: fix comments
shumkov Mar 28, 2024
4956590
test: propose a new protocol version on epoch change
shumkov Apr 1, 2024
b6b6b6f
style: remove unused mut
shumkov Apr 1, 2024
ad45126
Merge branch 'v1.0-dev' into feat/drive/use-app-version-param
QuantumExplorer Apr 2, 2024
93b3bd7
test: call remove_validators_proposed_app_versions on epoch change
shumkov Apr 2, 2024
e9a1be1
refactor: extract protocol upgrade logic to a separate function
shumkov Apr 2, 2024
f934d79
refactor: move `protocol_version_upgrade_percentage_needed` to versions
shumkov Apr 2, 2024
50cd26e
Merge branch 'feat/drive/use-app-version-param' into feat/drive/epoch…
shumkov Apr 2, 2024
90c52f8
test: update app hashes
shumkov Apr 2, 2024
1e17b59
docs: fix typo in comments
shumkov Apr 4, 2024
5d5beaf
Merge branch 'v1.0-dev' into feat/drive/epoch-protocol-version
shumkov Apr 4, 2024
ecd6e31
test(sdk): update epoch info fixtures
shumkov Apr 4, 2024
bf7b68c
Merge branch 'v1.0-dev' into feat/drive/epoch-protocol-version
shumkov Apr 4, 2024
59355f3
test: update app hash asserts after merge
shumkov Apr 4, 2024
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
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 @@ -8,12 +8,13 @@

use crate::execution::types::block_fees::BlockFees;

use crate::execution::types::block_state_info::BlockStateInfo;

Check warning on line 11 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::execution::types::block_state_info::BlockStateInfo`

warning: unused import: `crate::execution::types::block_state_info::BlockStateInfo` --> packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/mod.rs:11:5 | 11 | 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;

impl<CoreRPCLike> Platform<CoreRPCLike> {
Expand Down Expand Up @@ -41,8 +42,7 @@
///
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 @@
.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
Loading