syntax = "proto3";
package blockchain;

import "types/account.proto";
import "types/primitives.proto";

// BLOCK
// ================================================================================================

// Represents a block.
message Block {
    // Block data encoded using [winter_utils::Serializable] implementation for
    // [miden_protocol::block::Block].
    bytes block = 1;
}

// Represents a proposed block.
message ProposedBlock {
    // Block data encoded using [winter_utils::Serializable] implementation for
    // [miden_protocol::block::ProposedBlock].
    bytes proposed_block = 1;
}

// Represents a block or nothing.
message MaybeBlock {
    // The requested block data encoded using [winter_utils::Serializable] implementation for
    // [miden_protocol::block::Block].
    optional bytes block = 1;
}

// Represents a block number.
message BlockNumber {
    // The block number of the target block.
    fixed32 block_num = 1;
}

// Represents a block number or nothing.
message MaybeBlockNumber {
    // The block number of the target block.
    optional fixed32 block_num = 1;
}

// Represents a block header.
message BlockHeader {
    // Specifies the version of the protocol.
    uint32 version = 1;

    // The commitment of the previous blocks header.
    primitives.Digest prev_block_commitment = 2;

    // A unique sequential number of the current block.
    fixed32 block_num = 3;

    // A commitment to an MMR of the entire chain where each block is a leaf.
    primitives.Digest chain_commitment = 4;

    // A commitment to account database.
    primitives.Digest account_root = 5;

    // A commitment to the nullifier database.
    primitives.Digest nullifier_root = 6;

    // A commitment to all notes created in the current block.
    primitives.Digest note_root = 7;

    // A commitment to a set of IDs of transactions which affected accounts in this block.
    primitives.Digest tx_commitment = 8;

    // The validator's ECDSA public key.
    ValidatorPublicKey validator_key = 9;

    // A commitment to all transaction kernels supported by this block.
    primitives.Digest tx_kernel_commitment = 10;

    // Fee parameters for block processing.
    FeeParameters fee_parameters = 11;

    // The time when the block was created.
    fixed32 timestamp = 12;
}

// PUBLIC KEY
// ================================================================================================

// Validator ECDSA public key.
message ValidatorPublicKey {
    // Signature encoded using [winter_utils::Serializable] implementation for
    // [crypto::dsa::ecdsa_k256_keccak::PublicKey].
    bytes validator_key = 1;
}

// BLOCK SIGNATURE
// ================================================================================================

// Block ECDSA Signature.
message BlockSignature {
    // Signature encoded using [winter_utils::Serializable] implementation for
    // [crypto::dsa::ecdsa_k256_keccak::Signature].
    bytes signature = 1;
}


// FEE PARAMETERS
// ================================================================================================

// Definition of the fee parameters.
message FeeParameters {
    // The faucet account ID which is used for native fee assets.
    account.AccountId native_asset_id = 1;
    // The base fee (in base units) capturing the cost for the verification of a transaction.
    fixed32 verification_base_fee = 2;
}

// BLOCK BODY
// ================================================================================================

// Represents a block body.
message BlockBody {
    // Block body data encoded using [winter_utils::Serializable] implementation for
    // [miden_protocol::block::BlockBody].
    bytes block_body = 1;
}
