softblocks

package
v0.0.0-...-554f679 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT, MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogSkipper

func LogSkipper(c echo.Context) bool

LogSkipper implements the `middleware.Skipper` interface.

Types

type BuildSoftBlockRequestBody

type BuildSoftBlockRequestBody struct {
	// @param transactionBatch TransactionBatch Transaction batch to be inserted into the soft block
	TransactionBatch *TransactionBatch `json:"transactionBatch"`
}

BuildSoftBlockRequestBody represents a request body when handling soft blocks creation requests.

type BuildSoftBlockResponseBody

type BuildSoftBlockResponseBody struct {
	// @param blockHeader types.Header of the soft block
	BlockHeader *types.Header `json:"blockHeader"`
}

CreateOrUpdateBlocksFromBatchResponseBody represents a response body when handling soft blocks creation requests.

type RemoveSoftBlocksRequestBody

type RemoveSoftBlocksRequestBody struct {
	// @param newLastBlockID uint64 New last block ID of the blockchain, it should
	// @param not smaller than the canonical chain's highest block ID.
	NewLastBlockID uint64 `json:"newLastBlockId"`
}

RemoveSoftBlocksRequestBody represents a request body when resetting the backend L2 execution engine soft head.

type RemoveSoftBlocksResponseBody

type RemoveSoftBlocksResponseBody struct {
	// @param lastBlockID uint64 Current highest block ID of the blockchain (including soft blocks)
	LastBlockID uint64 `json:"lastBlockId"`
	// @param lastProposedBlockID uint64 Highest block ID of the cnonical chain
	LastProposedBlockID uint64 `json:"lastProposedBlockID"`
	// @param headsRemoved uint64 Number of soft heads removed
	HeadsRemoved uint64 `json:"headsRemoved"`
}

RemoveSoftBlocksResponseBody represents a response body when resetting the backend L2 execution engine soft head.

type SoftBlockAPIServer

type SoftBlockAPIServer struct {
	// contains filtered or unexported fields
}

@license.name MIT @license.url https://github.com/taikoxyz/taiko-mono/blob/main/LICENSE.md SoftBlockAPIServer represents a soft blcok server instance.

func New

func New(
	cors string,
	jwtSecret []byte,
	chainSyncer softBlockChainSyncer,
	cli *rpc.Client,
	checkSig bool,
) (*SoftBlockAPIServer, error)

New creates a new soft blcok server instance, and starts the server.

func (*SoftBlockAPIServer) BuildSoftBlock

func (s *SoftBlockAPIServer) BuildSoftBlock(c echo.Context) error

BuildSoftBlock handles a soft block creation request, if the soft block transactions batch in request are valid, it will insert or reorg the correspoinding the soft block to the backend L2 execution engine and return a success response.

	@Summary		  Insert a soft block with a batch of given transactions for preconfirmation.
	@Description	Insert a batch of transactions into a soft block for preconfirmation. If the batch is the
	@Description	first for a block, a new soft block will be created. Otherwise, the transactions will
	@Description	be appended to the existing soft block. The API will fail if:
	@Description	1) the block is not soft
  @Description	2) block-level parameters are invalid or do not match the current soft block’s parameters
  @Description	3) the batch ID is not exactly 1 greater than the previous one
  @Description	4) the last batch of the block indicates no further transactions are allowed
	@Param  	body body BuildSoftBlockRequestBody true "soft block creation request body"
	@Accept	  json
	@Produce	json
	@Success	200		{object} BuildSoftBlockResponseBody
	@Router		/softBlocks [post]

func (*SoftBlockAPIServer) HealthCheck

func (s *SoftBlockAPIServer) HealthCheck(c echo.Context) error

HealthCheck is the endpoints for probes.

@Summary		Get current server health status
@ID			   	health-check
@Accept			json
@Produce		json
@Success		200	{object} string
@Router			/healthz [get]

func (*SoftBlockAPIServer) RemoveSoftBlocks

func (s *SoftBlockAPIServer) RemoveSoftBlocks(c echo.Context) error

RemoveSoftBlocks removes the backend L2 execution engine soft head.

	@Summary		  Remove the soft blocks beyond the specified block height.
	@Description	Remove all soft blocks from the blockchain beyond the specified block height,
  @Description	ensuring the latest block ID does not exceed the given height. This method will fail if
  @Description	the block with an ID one greater than the specified height is not a soft block. If the
  @Description	specified block height is greater than the latest soft block ID, the method will succeed
  @Description	without modifying the blockchain.
	@Param      body body RemoveSoftBlocksRequestBody true "soft blocks removing request body"
	@Accept			json
	@Produce		json
	@Success		200	{object} RemoveSoftBlocksResponseBody
	@Router			/softBlocks [delete]

func (*SoftBlockAPIServer) Shutdown

func (s *SoftBlockAPIServer) Shutdown(ctx context.Context) error

Shutdown shuts down the HTTP server.

func (*SoftBlockAPIServer) Start

func (s *SoftBlockAPIServer) Start(port uint64) error

Start starts the HTTP server.

type SoftBlockParams

type SoftBlockParams struct {
	// @param timestamp uint64 Timestamp of the soft block
	Timestamp uint64 `json:"timestamp"`
	// @param coinbase string Coinbase of the soft block
	Coinbase common.Address `json:"coinbase"`

	// @param anchorBlockID uint64 `_anchorBlockId` parameter of the `anchorV2` transaction in soft block
	AnchorBlockID uint64 `json:"anchorBlockID"`
	// @param anchorStateRoot string `_anchorStateRoot` parameter of the `anchorV2` transaction in soft block
	AnchorStateRoot common.Hash `json:"anchorStateRoot"`
}

SoftBlockParams represents the parameters for building a soft block.

type TransactionBatch

type TransactionBatch struct {
	// @param blockId uint64 Block ID of the soft block
	BlockID uint64 `json:"blockId"`
	// @param batchId uint64 ID of this transaction batch
	ID uint64 `json:"batchId"`
	// @param transactions string zlib compressed RLP encoded bytes of a transactions list
	TransactionsList []byte `json:"transactions"`
	// @param batchType TransactionBatchMarker Marker of the transaction batch,
	// @param either `end_of_block`, `end_of_preconf` or empty
	BatchMarker TransactionBatchMarker `json:"batchType"`
	// @param signature string Signature of this transaction batch
	Signature string `json:"signature" rlp:"-"`
	// @param blockParams SoftBlockParams Block parameters of the soft block
	BlockParams *SoftBlockParams `json:"blockParams"`
}

TransactionBatch represents a soft block group.

func (*TransactionBatch) ValidateSignature

func (b *TransactionBatch) ValidateSignature() (bool, error)

ValidateSignature validates the signature of the transaction batch.

type TransactionBatchMarker

type TransactionBatchMarker string

TransactionBatchMarker represents the status of a soft block transactions group.

const (
	BatchMarkerEmpty TransactionBatchMarker = ""
	BatchMarkerEOB   TransactionBatchMarker = "endOfBlock"
	BatchMarkerEOP   TransactionBatchMarker = "endOfPreconf"
)

BatchMarker valid values.

Jump to

Keyboard shortcuts

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