Skip to content

Commit

Permalink
feat!: add sidechain eviction proof transaction (#6702)
Browse files Browse the repository at this point in the history
Description
---
sidechain eviction proof transaction
validations for eviction proof
only single validator node registration permitted

Motivation and Context
---

How Has This Been Tested?
---

What process can a PR reviewer use to test or verify this change?
---

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

- [ ] None
- [x] Requires data directory on base node to be deleted
- [x] Requires hard fork
- [ ] Other - Please specify

BREAKING CHANGE: validator node DB changed, new output features
  • Loading branch information
sdbondi authored Dec 9, 2024
1 parent 9aaa364 commit 817bacb
Show file tree
Hide file tree
Showing 89 changed files with 5,581 additions and 1,559 deletions.
277 changes: 163 additions & 114 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"base_layer/mmr",
"base_layer/p2p",
"base_layer/service_framework",
"base_layer/sidechain",
"base_layer/wallet",
"base_layer/wallet_ffi",
"base_layer/tari_mining_helper_ffi",
Expand All @@ -39,7 +40,7 @@ members = [
"applications/minotari_ledger_wallet/comms",
"applications/minotari_ledger_wallet/common",
"integration_tests",
"hashing"
"hashing",
]

[workspace.dependencies]
Expand Down
1 change: 1 addition & 0 deletions applications/minotari_app_grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ tari_core = { path = "../../base_layer/core" }
tari_crypto = { version = "0.21.0" }
tari_script = { path = "../../infrastructure/tari_script" }
tari_max_size = { path = "../../infrastructure/max_size" }
tari_sidechain = { path = "../../base_layer/sidechain" }
tari_utilities = { version = "0.8" }

argon2 = { version = "0.4.1", features = ["std", "password-hash"] }
Expand Down
36 changes: 19 additions & 17 deletions applications/minotari_app_grpc/proto/base_node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ service BaseNode {
// Returns Block Fees
rpc GetBlockFees (BlockGroupRequest) returns (BlockGroupResponse);
// Get Version
rpc GetVersion(Empty) returns (StringValue);
rpc GetVersion(Empty) returns (BaseNodeGetVersionResponse);
// Check for new updates
rpc CheckForUpdates(Empty) returns (SoftwareUpdate);
// Get coins in circulation
Expand Down Expand Up @@ -233,9 +233,9 @@ message IntegerValue {
uint64 value = 1;
}

// A generic String value
message StringValue {
string value = 1;
message BaseNodeGetVersionResponse {
string version = 1;
uint32 network = 2;
}

/// GetBlockSize / GetBlockFees Request
Expand Down Expand Up @@ -488,36 +488,38 @@ message GetActiveValidatorNodesResponse {
}

message GetValidatorNodeChangesRequest {
uint64 start_height = 1;
uint64 end_height = 2;
bytes sidechain_id = 3;
uint64 epoch = 1;
bytes sidechain_id = 2;
}

enum ValidatorNodeChangeState {
ADD = 0;
REMOVE = 1;
message ValidatorNodeChange {
oneof change {
ValidatorNodeChangeAdd add = 1;
ValidatorNodeChangeRemove remove = 2;
}
}

message ValidatorNodeChange {
message ValidatorNodeChangeAdd {
uint64 activation_epoch = 1;
ValidatorNodeRegistration registration = 2;
uint64 minimum_value_promise = 3;
}

message ValidatorNodeChangeRemove {
bytes public_key = 1;
ValidatorNodeChangeState state = 2;
uint64 start_height = 3;
ValidatorNodeRegistration registration = 4;
uint64 minimum_value_promise = 5;
}

message GetValidatorNodeChangesResponse {
repeated ValidatorNodeChange changes = 1;
}

message GetShardKeyRequest {
uint64 height = 1;
uint64 epoch = 1;
bytes public_key = 2;
}

message GetShardKeyResponse {
bytes shard_key = 1;
bool found = 2;
}

message GetTemplateRegistrationsRequest {
Expand Down
146 changes: 115 additions & 31 deletions applications/minotari_app_grpc/proto/sidechain_types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,50 +26,51 @@ package tari.rpc;
import "types.proto";

message SideChainFeature {
oneof side_chain_feature {
ValidatorNodeRegistration validator_node_registration = 1;
TemplateRegistration template_registration = 2;
ConfidentialOutputData confidential_output = 3;
}
oneof feature {
ValidatorNodeRegistration validator_node_registration = 1;
TemplateRegistration template_registration = 2;
ConfidentialOutputData confidential_output = 3;
EvictionProof eviction_proof = 4;
}
SideChainId sidechain_id = 5;
}

message SideChainId {
bytes public_key = 1;
Signature knowledge_proof = 2;
}

message ValidatorNodeRegistration {
bytes public_key = 1;
Signature signature = 2;
bytes claim_public_key = 3;
bytes sidechain_id = 4;
Signature sidechain_id_knowledge_proof = 5;
bytes public_key = 1;
Signature signature = 2;
bytes claim_public_key = 3;
}

message TemplateRegistration {
bytes author_public_key = 1;
Signature author_signature = 2;
string template_name = 3;
uint32 template_version = 4;
TemplateType template_type = 5;
BuildInfo build_info = 6;
bytes binary_sha = 7;
string binary_url = 8;
bytes sidechain_id = 9;
Signature sidechain_id_knowledge_proof = 10;
bytes author_public_key = 1;
Signature author_signature = 2;
string template_name = 3;
uint32 template_version = 4;
TemplateType template_type = 5;
BuildInfo build_info = 6;
bytes binary_sha = 7;
string binary_url = 8;
}

message ConfidentialOutputData {
bytes claim_public_key = 1;
bytes sidechain_id = 2;
Signature sidechain_id_knowledge_proof = 3;
bytes claim_public_key = 1;
}

message TemplateType {
oneof template_type {
WasmInfo wasm = 1;
FlowInfo flow = 2;
ManifestInfo manifest = 3;
}
oneof template_type {
WasmInfo wasm = 1;
FlowInfo flow = 2;
ManifestInfo manifest = 3;
}
}

message WasmInfo {
uint32 abi_version = 1;
uint32 abi_version = 1;
}

message FlowInfo {
Expand All @@ -79,6 +80,89 @@ message ManifestInfo {
}

message BuildInfo {
string repo_url = 1;
bytes commit_hash = 2;
string repo_url = 1;
bytes commit_hash = 2;
}

message EvictionProof {
CommitProof proof = 1;
}

message CommitProof {
oneof version {
CommitProofV1 v1 = 1;
}
}

message CommitProofV1 {
bytes command = 1;
SidechainBlockCommitProof commit_proof = 2;
}

message SidechainBlockCommitProof {
SidechainBlockHeader header = 1;
repeated CommitProofElement proof_elements = 2;
}

message CommitProofElement {
oneof proof_element {
QuorumCertificate quorum_certificate = 1;
DummyChain dummy_chain = 2;
}
}

message DummyChain {
repeated ChainLink chain_links = 1;
}

message ChainLink {
bytes header_hash = 1;
bytes parent_id = 2;
}

message SidechainBlockHeader {
uint32 network = 1;
bytes parent_id = 2;
bytes justify_id = 3;
uint64 height = 4;
uint64 epoch = 5;
ShardGroup shard_group = 6;
bytes proposed_by = 7;
uint64 total_leader_fee = 8;
bytes state_merkle_root = 9;
bytes command_merkle_root = 10;
bool is_dummy = 11;
bytes foreign_indexes_hash = 12;
Signature signature = 13;
uint64 timestamp = 14;
uint64 base_layer_block_height = 15;
bytes base_layer_block_hash = 16;
bytes extra_data_hash = 17;
}

message ShardGroup {
uint32 start = 1;
uint32 end_inclusive = 2;
}

message EvictAtom {
bytes public_key = 1;
}

message QuorumCertificate {
bytes header_hash = 1;
bytes parent_id = 2;
repeated ValidatorSignature signatures = 3;
QuorumDecision decision = 4;
}

enum QuorumDecision {
Accept = 0;
Reject = 1;
}

message ValidatorSignature {
bytes public_key = 1;
Signature signature = 2;
}

4 changes: 2 additions & 2 deletions applications/minotari_app_grpc/proto/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ message ConsensusConstants {
uint64 block_weight_kernels = 16;
uint64 pre_mine_value = 17;
uint64 max_script_byte_size = 18;
uint64 vn_registration_max_vns_initial_epoch = 19;
uint64 vn_registration_max_vns_per_epoch = 20;
uint32 vn_registration_max_vns_initial_epoch = 19;
uint32 vn_registration_max_vns_per_epoch = 20;
uint64 effective_from_height = 21;
Range valid_blockchain_version_range = 22;
uint64 max_randomx_seed_height = 23;
Expand Down
12 changes: 12 additions & 0 deletions applications/minotari_app_grpc/proto/wallet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ service Wallet {

// Get calculated fees for a `CreateTemplateRegistrationRequest`
rpc GetTemplateRegistrationFee(CreateTemplateRegistrationRequest) returns (GetTemplateRegistrationFeeResponse);
rpc SubmitValidatorEvictionProof(SubmitValidatorEvictionProofRequest) returns (SubmitValidatorEvictionProofResponse);
}

message GetVersionRequest {}
Expand Down Expand Up @@ -366,3 +367,14 @@ message RegisterValidatorNodeResponse {
bool is_success = 2;
string failure_message = 3;
}

message SubmitValidatorEvictionProofRequest {
EvictionProof proof = 1;
uint64 fee_per_gram = 2;
string message = 3;
bytes sidechain_deployment_key = 4;
}

message SubmitValidatorEvictionProofResponse {
uint64 tx_id = 1;
}
48 changes: 20 additions & 28 deletions applications/minotari_app_grpc/src/conversions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,26 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pub mod aggregate_body;
pub mod base_node_state;
pub mod block;
pub mod block_header;
pub mod chain_metadata;
pub mod com_and_pub_signature;
pub mod commitment_signature;
pub mod consensus_constants;
pub mod historical_block;
pub mod new_block_template;
pub mod output_features;
pub mod peer;
pub mod proof_of_work;
pub mod sidechain_feature;
pub mod signature;
pub mod transaction;
pub mod transaction_input;
pub mod transaction_kernel;
pub mod transaction_output;
pub mod unblinded_output;
pub mod validator_node_change;
pub mod validator_node_registration;
mod aggregate_body;
mod base_node_state;
mod block;
mod block_header;
mod chain_metadata;
mod com_and_pub_signature;
mod commitment_signature;
mod consensus_constants;
mod historical_block;
mod new_block_template;
mod output_features;
mod peer;
mod proof_of_work;
mod sidechain_feature;
mod signature;
mod transaction;
mod transaction_input;
mod transaction_kernel;
mod transaction_output;
mod unblinded_output;

use prost_types::Timestamp;

Expand All @@ -61,12 +59,6 @@ impl From<u64> for grpc::IntegerValue {
}
}

impl From<String> for grpc::StringValue {
fn from(value: String) -> Self {
Self { value }
}
}

impl From<grpc::BlockGroupRequest> for grpc::HeightRequest {
fn from(b: BlockGroupRequest) -> Self {
Self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ impl TryFrom<grpc::OutputFeatures> for OutputFeatures {
type Error = String;

fn try_from(features: grpc::OutputFeatures) -> Result<Self, Self::Error> {
let sidechain_feature = features
.sidechain_feature
.and_then(|f| f.side_chain_feature)
.map(SideChainFeature::try_from)
.transpose()?;
let sidechain_feature = features.sidechain_feature.map(SideChainFeature::try_from).transpose()?;

let output_type = features
.output_type
Expand Down
Loading

0 comments on commit 817bacb

Please sign in to comment.