Documentation
¶
Index ¶
Constants ¶
View Source
const ( FORKID_DRAGONFRUIT = 5 // EfficiencyPercentageByteLength is the length of the effective percentage in bytes EfficiencyPercentageByteLength uint64 = 1 )
Variables ¶
View Source
var ( // ErrBatchV2DontStartWithChangeL2Block is returned when the batch start directly with a trsansaction (without a changeL2Block) ErrBatchV2DontStartWithChangeL2Block = errors.New("batch v2 must start with changeL2Block before Tx (suspect a V1 Batch or a ForcedBatch?))") // ErrInvalidBatchV2 is returned when the batch is invalid. ErrInvalidBatchV2 = errors.New("invalid batch v2") // ErrInvalidRLP is returned when the rlp is invalid. ErrInvalidRLP = errors.New("invalid rlp codification") // ErrInvalidData is the error when the raw txs is unexpected ErrInvalidData = errors.New("invalid data") )
View Source
var ParseBatchL2Data = &cobra.Command{ Use: "parse-batch-l2-data [flags]", Aliases: []string{"parsebatchl2data"}, Short: "Convert batch l2 data into an ndjson stream.", Long: usage, RunE: func(cmd *cobra.Command, args []string) error { rawData, err := getInputData(cmd, args) if err != nil { return err } batchL2Data := strings.TrimSpace(strings.TrimPrefix(string(rawData), "0x")) rawBatchL2Data, err := hex.DecodeString(batchL2Data) if err != nil { log.Err(err).Msg("Unable to hex decode batch l2 data") return err } rawBatch, err := DecodeBatchV2(rawBatchL2Data) if err != nil { log.Error().Err(err).Msg("unable to decode l2 batch data") tryRawBatch(rawBatchL2Data) return err } blocks := rawBatch.Blocks for _, l2RawBlock := range blocks { blockData := struct { IndexL1InfoTree uint32 DeltaTimestamp uint32 }{l2RawBlock.IndexL1InfoTree, l2RawBlock.DeltaTimestamp} blockDataBytes, err := json.Marshal(blockData) if err != nil { log.Err(err).Msg("unable to marshal block data") return err } fmt.Println(string(blockDataBytes)) for i := range l2RawBlock.Transactions { if err := printTxData(&l2RawBlock.Transactions[i]); err != nil { log.Error().Err(err).Int("tx_index", i).Msg("Failed to print transaction data") } } } return nil }, Args: func(cmd *cobra.Command, args []string) error { return nil }, }
Functions ¶
Types ¶
type BatchRawV2 ¶
type BatchRawV2 struct {
Blocks []L2BlockRaw
}
BatchRawV2 is the representation of a batch of transactions.
func DecodeBatchV2 ¶
func DecodeBatchV2(txsData []byte) (*BatchRawV2, error)
DecodeBatchV2 decodes a batch of transactions from a byte slice.
type ForcedBatchRawV2 ¶
type ForcedBatchRawV2 struct {
Transactions []L2TxRaw
}
func DecodeForcedBatchV2 ¶
func DecodeForcedBatchV2(txsData []byte) (*ForcedBatchRawV2, error)
type L2BlockRaw ¶
L2BlockRaw is the raw representation of a L2 block.
type L2TxRaw ¶
type L2TxRaw struct {
Tx *types.Transaction
EfficiencyPercentage uint8
}
Click to show internal directories.
Click to hide internal directories.