forked from 0xPolygonHermez/zkevm-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeijoa_events.go
76 lines (65 loc) · 2 KB
/
feijoa_events.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package etherman
import (
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto/kzg4844"
)
// BlobType is the type of the blob type
type BlobType uint8
const (
// TypeCallData The data is stored on call data directly
TypeCallData BlobType = 0
// TypeBlobTransaction The data is stored on a blob
TypeBlobTransaction BlobType = 1
// TypeForcedBlob The data is a forced Blob
TypeForcedBlob BlobType = 2
)
// SequenceBlob is for each Blob inside a SequenceBlobs
type SequenceBlob struct {
Type BlobType
Params BlobCommonParams
Data []byte
// Field only valid if BlobType == BlobTransaction
BlobBlobTypeParams *BlobBlobTypeParams
}
func (s *SequenceBlob) String() string {
return fmt.Sprintf("Type: %d, Params: %v, Data: %v, BlobBlobTypeParams: %v", s.Type, s.Params, s.Data, s.BlobBlobTypeParams)
}
// BlobCommonParams is the data for a SequenceBlob
type BlobCommonParams struct {
MaxSequenceTimestamp uint64
ZkGasLimit uint64
L1InfoLeafIndex uint32
}
// BlobBlobTypeParams is the data for a SequenceBlob stored on a Blob
// case: if (currentBlob.blobType ==> BLOBTX_BLOB_TYPE)
// sames as calldata plus BlobIndex, ...
type BlobBlobTypeParams struct {
BlobIndex *big.Int
Z []byte
Y []byte
Commitment kzg4844.Commitment
Proof kzg4844.Proof
}
// SequenceBlobs is the data in the event SequenceBlobs
type SequenceBlobs struct {
Blobs []SequenceBlob
L2Coinbase common.Address // from Calldata
FinalAccInputHash common.Hash
EventData *SequenceBlobsEventData
}
// SequenceBlobsEventData is the data in the event SequenceBlobs
type SequenceBlobsEventData struct {
// LastBlobSequenced is the count of blob sequenced after process this event
// if the first event have 1 blob -> lastBlobSequenced=1
LastBlobSequenced uint64
}
func (s *SequenceBlobs) thereIsAnyBlobType() bool {
for blobIndex := range s.Blobs {
if s.Blobs[blobIndex].Type == TypeBlobTransaction {
return true
}
}
return false
}