-
Notifications
You must be signed in to change notification settings - Fork 38
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Will.
The approach is good.
Left a few comments
go/common/enclave.go
Outdated
GetBatchBySeqNo(seqNo uint64) (*ExtBatch, SystemError) | ||
|
||
// GetRollupData - retrieve the first batch sequence and start time for a given rollup. | ||
GetRollupData(internalRollup []byte) (*big.Int, *uint64, SystemError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better we return a "PublicRollupMetadata" struct (and a SystemError)
go/enclave/enclave.go
Outdated
@@ -295,6 +296,15 @@ func (e *enclaveImpl) GetBatchBySeqNo(seqNo uint64) (*common.ExtBatch, common.Sy | |||
return b, nil | |||
} | |||
|
|||
func (e *enclaveImpl) GetRollupData(internalRollup []byte) (*big.Int, *uint64, common.SystemError) { | |||
calldataRollupHeader := new(common.CalldataRollupHeader) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is perfect stuff to retrieve from the database.
They should already be written in the "rollup" table.
It's a matter of selecting them from there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
…llh/enclave-api-get-batch-start-seq
…b.com/ten-protocol/go-ten into willh/enclave-api-get-batch-start-seq
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic looks good.
One small change to the grpc conversion
@@ -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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
(one question)
@@ -76,10 +76,6 @@ func updateCanonicalValue(dbtx DBTransaction, isCanonical bool, values []common. | |||
dbtx.ExecuteSQL(updateBatches, args...) | |||
} | |||
|
|||
func FetchBlockHeader(db *sql.DB, hash common.L1BlockHash) (*types.Header, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where has this gone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was unused so just got rid of it
Why this change is needed
We need to be able to retrieve some of the internal rollup data from the enclave when storing data in the host DB.
What changes were made as part of this PR
CalldataRollupHeader
byte slice as an argument and returns theCalldataRollupHeader.FirstBatchSequence
andCalldataRollupHeader.StartTime
Testing
Can't see a simple way to unit test this so I just manually called the function
processL1BlockTransactions
and ran the full network simulation test and verified the data through console logs.PR checks pre-merging
Please indicate below by ticking the checkbox that you have read and performed the required
PR checks