aggregation

package
v0.0.0-...-4e93fa3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PackInMiniTrees

func PackInMiniTrees(l2MsgHashes []string) []string

Hash the L2 messages into Merkle trees or arity 2 and depth `l2MsgMerkleTreeDepth`. The leaves are zero-padded on the right.

func PackOffsets

func PackOffsets(unpacked []bool) []byte

Pack an array of boolean into an offset list. The offset list encodes the position of all the boolean whose value is true. Each position is encoded as a big-endian uint16.

Types

type CollectedFields

type CollectedFields struct {

	// Shnarf to be used for the public input generation. Corresponds to the
	// last submitted blob that is part of the aggregation. Given in hexstring
	// format.
	FinalShnarf                  string
	ParentAggregationFinalShnarf string

	// Parent data hash and the list of data hashes to be finalized
	DataHashes     []string
	DataParentHash string

	// Parent zk root hash of the state over which we want to finalize. In 0x
	// prefixed hexstring.
	ParentStateRootHash string

	// Timestamp of the last already finalized L2 block
	ParentAggregationLastBlockTimestamp uint

	// Timestamp of the last L2 block to be finalized
	FinalTimestamp uint

	// Rolling hash of the L1 messages received on L2 so far for the state to be
	// currently finalized. In 0x prefixed Hexstring
	LastFinalizedL1RollingHash string
	L1RollingHash              string

	// Number of L1 messages received on L2 so far for the state to be currently
	// finalized. Messaging Feedback loop messaging number - part of public
	// input
	LastFinalizedL1RollingHashMessageNumber uint
	L1RollingHashMessageNumber              uint

	// L2 Merkle roots for L2 -> L1 messages - The prover will be calculating
	// Merkle roots for trees of a set depth
	HowManyL2Msgs uint

	// The root hashes of the L2 messages being sent on L2. These are the root
	// (possibly) several merkle trees of depth `self.L2MsgTreeDepth`. The root
	// hashes are hextring encoded.
	L2MsgRootHashes []string

	// The depth of the Merkle tree for the Merkle roots being anchored. This is
	// not used as part of the public inputs but is nonetheless helpful on the
	// contracts
	L2MsgTreeDepth uint

	// Bytes array indicating which L2 blocks have “MessageSent” events. The
	// index starting from 1 + currentL2BlockNumber. If the value contains 1,
	// it means that that block has events. The field is 0x prefixed encoded.
	L2MessagingBlocksOffsets string

	// Last block number being finalized and the last one already finalized.
	LastFinalizedBlockNumber uint
	FinalBlockNumber         uint

	// IsProoflessJob marks that the job is proofless and that the
	// response is to be written in a dedicated folder.
	IsProoflessJob bool

	// The proof claims for the execution prover
	ProofClaims []aggregation.ProofClaimAssignment

	ExecutionPI       []public_input.Execution
	DecompressionPI   []blobdecompression.Request
	InnerCircuitTypes []pi_interconnection.InnerCircuitType // a hint to the aggregation circuit detailing which public input correspond to which actual public input
}

This struct contains a collection of fields that are to be extracted from the files passed in the requets. These fields are used to generate the response.

func (CollectedFields) AggregationPublicInput

func (cf CollectedFields) AggregationPublicInput(cfg *config.Config) public_input.Aggregation

type Request

type Request struct {

	// List of execution proofs prover responses containing the proofs to
	// aggregate.
	ExecutionProofs []string `json:"executionProofs"`

	// List of the compression proofs prover responses containing the
	// compression proofs to aggregate.
	DecompressionProofs []string `json:"compressionProofs"`

	// Non-serialized fields. Theses are used for testing but must not be
	// used during the actual processing of the request. In particular, they
	// are used to help infer the L2 block range of the aggregation when the
	// filename is not available right away.
	Start_, End_ int

	// Last finalized timestamp. It cannot be infered from the other files. It is
	// used to compute the public inputs of the
	ParentAggregationLastBlockTimestamp uint64 `json:"parentAggregationLastBlockTimestamp"`

	// Last finalized rolling hash. If no L1 messages have been finalized, the
	// prover cannot infer what finalL1RollingHash to supply. That's why we need
	// this field.
	ParentAggregationLastL1RollingHash              string `json:"parentAggregationLastL1RollingHash"`
	ParentAggregationLastL1RollingHashMessageNumber int    `json:"parentAggregationLastL1RollingHashMessageNumber"`
}

Request collects all the fields used to perform an aggregation request.

type Response

type Response struct {

	// Shnarf to be used for the public input generation. Corresponds to the
	// last submitted blob that is part of the aggregation. Given in hexstring
	// format.
	FinalShnarf                  string `json:"finalShnarf"`
	ParentAggregationFinalShnarf string `json:"parentAggregationFinalShnarf"`

	// Aggregation proof in hexstring format
	AggregatedProof         string `json:"aggregatedProof"`
	AggregatedProverVersion string `json:"aggregatedProverVersion"`
	AggregatedVerifierIndex int    `json:"aggregatedVerifierIndex"`

	// Modulo reduced public input to be used to verify the proof.
	AggregatedProofPublicInput string `json:"aggregatedProofPublicInput"`

	// Parent data hash and the list of data hashes to be finalized
	DataHashes     []string `json:"dataHashes"`
	DataParentHash string   `json:"dataParentHash"`

	// ParentStateRootHash is the root hash of the last finalized state.
	// 0x-prefixed hexstring
	ParentStateRootHash string `json:"parentStateRootHash"`

	// The timestamp before and after what is finalized
	ParentAggregationLastBlockTimestamp uint `json:"parentAggregationLastBlockTimestamp"`
	LastFinalizedBlockNumber            uint `json:"lastFinalizedBlockNumber"`
	FinalTimestamp                      uint `json:"finalTimestamp"`
	FinalBlockNumber                    uint `json:"finalBlockNumber"`

	// L1RollingHash stores the last rolling hash found in a rolling hash event
	// during the execution.
	L1RollingHash string `json:"l1RollingHash"`
	// L1RollingHashNumber stores the number of the last rolling hash event
	// occuring in the frame of the current aggregation.
	L1RollingHashMessageNumber uint `json:"l1RollingHashMessageNumber"`

	// L2 messages related messages. L2MerkleRoots stores a sequences of Merkle
	// roots containing the hashes of the messages emitted on layer 2.
	L2MerkleRoots   []string `json:"l2MerkleRoots"` // 0x hexstring
	L2MsgTreesDepth uint     `json:"l2MerkleTreesDepth"`

	// Hexstring encoding a bitmap of the block containing “MessageSent” events.
	// events
	L2MessagingBlocksOffsets string `json:"l2MessagingBlocksOffsets"`
}

Response contains all the fields returned by the prover to run the aggregation. Reflects the data to be sent to the smart-contract for finalization

struct FinalizationData {
   bytes32 parentStateRootHash;
   bytes32[] dataHashes;
   bytes32 dataParentHash;
   uint256 finalBlockNumber;
   uint256 lastFinalizedTimestamp;
   uint256 finalTimestamp;
   bytes32 l1RollingHash;
   uint256 l1RollingHashMessageNumber;
   bytes32[] l2MerkleRoots;
   uint256 l2MerkleTreesDepth;
   uint256[] l2MessagingBlocksOffsets;
 }

func CraftResponse

func CraftResponse(cfg *config.Config, cf *CollectedFields) (resp *Response, err error)

Prepare the response without running the actual proof TODO @gbotrel well, this is a bit of a lie, we do run the proof, don't we?

func Prove

func Prove(cfg *config.Config, req *Request) (*Response, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL