Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new GetRollupData API to enclave client #1815

Merged
merged 15 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion go/common/enclave.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ type Enclave interface {
// GetBatch - retrieve a batch if existing within the enclave db.
GetBatch(hash L2BatchHash) (*ExtBatch, SystemError)

// GetBatchBySeqNo - retrieve batch by sequencer number if it's in the db
// GetBatchBySeqNo - retrieve batch by sequencer number if it's in the db.
GetBatchBySeqNo(seqNo uint64) (*ExtBatch, SystemError)

// GetRollupData - retrieve the first batch sequence and start time for a given rollup.
GetRollupData(hash L2RollupHash) (*PublicRollupMetadata, SystemError)

// CreateBatch - creates a new head batch extending the previous one for the latest known L1 head if the node is
// a sequencer. Will panic otherwise.
CreateBatch(skipIfEmpty bool) SystemError
Expand Down
18 changes: 18 additions & 0 deletions go/common/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,24 @@ type CalldataRollupHeader struct {
ReOrgs [][]byte `rlp:"optional"` // sparse list of reorged headers - non null only for reorgs.
}

// PublicRollupMetadata contains internal rollup data that can be requested from the enclave.
type PublicRollupMetadata struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is one way to marshal the metadata object.
The other way (which is what we've mostly done) is to use the "converters" in the grpc classes).

You can have a look at CrossChainMsg , as an example

FirstBatchSequence *big.Int
StartTime uint64
}

func (r *PublicRollupMetadata) Encoded() ([]byte, error) {
return rlp.EncodeToBytes(r)
}

func DecodePublicRollupMetadata(encoded []byte) (*PublicRollupMetadata, error) {
var rollupMetadata PublicRollupMetadata
if err := rlp.DecodeBytes(encoded, &rollupMetadata); err != nil {
return nil, err
}
return &rollupMetadata, nil
}

// MarshalJSON custom marshals the RollupHeader into a json
func (r *RollupHeader) MarshalJSON() ([]byte, error) {
type Alias RollupHeader
Expand Down
Loading
Loading