Skip to content

Commit

Permalink
feat!: add sidechain eviction proof transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
sdbondi committed Nov 26, 2024
1 parent 9005c11 commit d4c5d5a
Show file tree
Hide file tree
Showing 80 changed files with 4,152 additions and 1,479 deletions.
244 changes: 134 additions & 110 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
18 changes: 8 additions & 10 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,9 +488,8 @@ 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 {
Expand All @@ -501,7 +500,7 @@ enum ValidatorNodeChangeState {
message ValidatorNodeChange {
bytes public_key = 1;
ValidatorNodeChangeState state = 2;
uint64 start_height = 3;
uint64 activation_epoch = 3;
ValidatorNodeRegistration registration = 4;
uint64 minimum_value_promise = 5;
}
Expand All @@ -511,13 +510,12 @@ message GetValidatorNodeChangesResponse {
}

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
141 changes: 110 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,84 @@ 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;
uint32 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 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 @@ -80,6 +80,7 @@ service Wallet {
rpc StreamTransactionEvents(TransactionEventRequest) returns (stream TransactionEventResponse);

rpc RegisterValidatorNode(RegisterValidatorNodeRequest) returns (RegisterValidatorNodeResponse);
rpc SubmitValidatorEvictionProof(SubmitValidatorEvictionProofRequest) returns (SubmitValidatorEvictionProofResponse);
}

message GetVersionRequest {}
Expand Down Expand Up @@ -359,3 +360,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 d4c5d5a

Please sign in to comment.