-
Notifications
You must be signed in to change notification settings - Fork 32
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
Sinner: resolvers and updating db read functions #1514
Conversation
WalkthroughThe changes primarily revolve around the shift from using Changes
TipsChat with CodeRabbit Bot (
|
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## feat/sinner #1514 +/- ##
=====================================================
- Coverage 50.83841% 49.62568% -1.21274%
=====================================================
Files 369 366 -3
Lines 25465 24578 -887
Branches 268 268
=====================================================
- Hits 12946 12197 -749
- Misses 11257 11311 +54
+ Partials 1262 1070 -192
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
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.
Review Status
Actionable comments generated: 2
Configuration used: CodeRabbit UI
Files selected for processing (17)
- services/sinner/api/resolver_test.go (2} hunks)
- services/sinner/contracts/origin/parser.go (1} hunks)
- services/sinner/db/event.go (1} hunks)
- services/sinner/db/mocks/event_db.go (2} hunks)
- services/sinner/db/model/model.go (3} hunks)
- services/sinner/db/read_test.go (2} hunks)
- services/sinner/db/sql/base/read.go (3} hunks)
- services/sinner/graphql/client/client.go (8} hunks)
- services/sinner/graphql/client/queries/queries.graphql (2} hunks)
- services/sinner/graphql/server/graph/helper.go (2} hunks)
- services/sinner/graphql/server/graph/model/models_gen.go (2} hunks)
- services/sinner/graphql/server/graph/queries.resolvers.go (1} hunks)
- services/sinner/graphql/server/graph/resolver/server.go (41} hunks)
- services/sinner/graphql/server/graph/schema/queries.graphql (1} hunks)
- services/sinner/graphql/server/graph/schema/types.graphql (3} hunks)
- services/sinner/graphql/server/graph/types.resolvers.go (1} hunks)
- services/sinner/service/indexer.go (1} hunks)
Files not summarized due to errors (1)
- services/sinner/graphql/server/graph/resolver/server.go: Error: Message exceeds token limit
Files skipped from review due to trivial changes (4)
- services/sinner/contracts/origin/parser.go
- services/sinner/db/sql/base/read.go
- services/sinner/graphql/server/graph/helper.go
- services/sinner/service/indexer.go
Additional comments: 50
services/sinner/graphql/server/graph/schema/queries.graphql (4)
7-8: The
getOriginInfo
function signature has been updated to takemessageHash
as a parameter instead oftxHash
andchainID
. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that themessageHash
is being correctly generated and passed to this function.10-12: The
getDestinationInfo
function signature has been updated in a similar manner togetOriginInfo
. The same considerations apply here.14-17: The new
getOriginInfos
function retrieves multipleOriginInfo
records based ontxHash
andchainID
. Ensure that the function implementation correctly handles the retrieval of multiple records and that the returned data is correctly processed by the caller.19-22: The new
getDestinationInfos
function retrieves multipleDestinationInfo
records based ontxHash
andchainID
. The same considerations as forgetOriginInfos
apply here.services/sinner/db/model/model.go (3)
67-67: The
TxHash
field is no longer a primary key in theOriginSent
struct. This change is consistent with the PR summary, which mentions thatMessageHash
is now the primary key. Ensure that this change is reflected in all related database operations and queries.79-79: The
MessageHash
field is now a primary key in theOriginSent
struct. This change is consistent with the PR summary. Ensure that this change is reflected in all related database operations and queries.117-121: The
TxHash
field is no longer a primary key in theExecuted
struct, andMessageHash
is now the primary key. This change is consistent with the PR summary. Ensure that this change is reflected in all related database operations and queries.services/sinner/graphql/client/queries/queries.graphql (4)
14-37: The
GetOriginInfo
query has been updated to takemessageHash
as a parameter instead oftxHash
andchainID
. This change aligns with the PR's goal of refactoring the handling of transaction and message hashes. Ensure that all calls to this query throughout the codebase have been updated to match the new signature.39-40: The
GetOriginInfos
query has been introduced to retrieve multiple records based ontxHash
andchainID
. This is a new addition and does not replace any existing functionality. Ensure that this new query is used appropriately in the codebase.66-77: The
GetDestinationInfo
query has been updated to takemessageHash
as a parameter instead oftxHash
andchainID
. This change aligns with the PR's goal of refactoring the handling of transaction and message hashes. Ensure that all calls to this query throughout the codebase have been updated to match the new signature.80-81: The
GetDestinationInfos
query has been introduced to retrieve multiple records based ontxHash
andchainID
. This is a new addition and does not replace any existing functionality. Ensure that this new query is used appropriately in the codebase.services/sinner/graphql/server/graph/schema/types.graphql (4)
11-13: The comment for the
OriginInfo
type has been updated to specify that it provides information on an origin sent event. This change is more descriptive and provides better context for the type.22-34: The types of several fields in the
OriginInfo
type have been changed fromString
toInt
. This includesoriginChainID
,destinationChainID
,optimisticSeconds
, andmessageFlag
. This change is likely due to the underlying data for these fields being numerical. Ensure that these changes are reflected in the corresponding database schema and any code that interacts with these fields.35-36: Two new fields,
messageStatus
anddestinationInfo
, have been added to theOriginInfo
type. These fields are linked to theMessageStatus
andDestinationInfo
types respectively using the@goField
directive. This change allows for more detailed information to be retrieved when querying forOriginInfo
.51-52: Two new fields,
messageStatus
andoriginInfo
, have been added to theDestinationInfo
type. These fields are linked to theMessageStatus
andOriginInfo
types respectively using the@goField
directive. This change allows for more detailed information to be retrieved when querying forDestinationInfo
.services/sinner/graphql/server/graph/queries.resolvers.go (4)
26-33: The function signature for
GetOriginInfo
has been updated to take amessageHash
instead oftxHash
andchainID
. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that theRetrieveOriginSent
function has been updated to handlemessageHash
as an argument.36-43: The function signature for
GetDestinationInfo
has been updated to take amessageHash
instead oftxHash
andchainID
. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that theRetrieveExecuted
function has been updated to handlemessageHash
as an argument.46-56: The new function
GetOriginInfos
retrieves multiple records based ontxHash
andchainID
. Ensure that theRetrieveOriginSents
function is implemented correctly to handle these parameters and return the expected results. Also, verify that thedbToGraphqlModelOrigin
function can handle multiple records.59-70: The new function
GetDestinationInfos
retrieves multiple records based ontxHash
andchainID
. Ensure that theRetrieveExecuteds
function is implemented correctly to handle these parameters and return the expected results. Also, verify that thedbToGraphqlModelDestination
function can handle multiple records.services/sinner/db/mocks/event_db.go (4)
26-45: The
RetrieveExecuted
function has been updated to take amessageHash
instead ofchainID
andtxHash
. This change aligns with the updated database schema whereMessageHash
is now the primary key. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.47-59: The
RetrieveExecuteds
function is a new addition that retrieves multiple executed events based on the providedchainID
andtxHash
. This function could be useful in scenarios where multiple events are associated with the same transaction. Ensure that the function is used appropriately in the codebase.112-130: The
RetrieveOriginSent
function has been updated to take amessageHash
instead ofchainID
andtxHash
. This change aligns with the updated database schema whereMessageHash
is now the primary key. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.133-145: The
RetrieveOriginSents
function is a new addition that retrieves multiple origin sent events based on the providedchainID
andtxHash
. This function could be useful in scenarios where multiple events are associated with the same transaction. Ensure that the function is used appropriately in the codebase.services/sinner/graphql/server/graph/model/models_gen.go (2)
13-22: The
DestinationInfo
struct has been updated with two new fields:MessageStatus
andOriginInfo
. These fields provide additional context about the status of a message and its origin, respectively. Ensure that these fields are populated correctly wherever this struct is used. Also, verify that the GraphQL schema has been updated to reflect these changes.35-55: The
OriginInfo
struct has been significantly updated. The types ofOriginChainID
andDestinationChainID
have been changed from*string
to*int
. This change should be verified across the codebase to ensure compatibility. TheOptimisticSeconds
andMessageFlag
fields have also been changed from*string
to*int
, which should be more appropriate for these fields.New fields
MessageStatus
andDestinationInfo
have been added. These fields provide additional context about the status of a message and its destination, respectively. Ensure that these fields are populated correctly wherever this struct is used. Also, verify that the GraphQL schema has been updated to reflect these changes.Lastly, the fields
SummitTip
,AttestationTip
,ExecutionTip
, andDeliveryTip
have been added. Ensure that these fields are populated correctly wherever this struct is used.services/sinner/graphql/server/graph/types.resolvers.go (6)
16-23: The
MessageStatus
resolver function retrieves the message status from the database using theMessageHash
field of theDestinationInfo
model. The error handling is done correctly, wrapping the original error with context. This is a good practice as it helps in debugging if an error occurs.26-32: The
OriginInfo
resolver function retrieves the origin sent data from the database using theMessageHash
field of theDestinationInfo
model. The error handling is done correctly, wrapping the original error with context. The functiondbToGraphqlModelOrigin
is used to convert the database model to the GraphQL model. Ensure that this function handles all necessary conversions and edge cases.34-42: The
MessageStatus
resolver function for theOriginInfo
model retrieves the message status from the database using theMessageHash
field of theOriginInfo
model. The error handling is done correctly, wrapping the original error with context.44-51: The
DestinationInfo
resolver function retrieves the executed data from the database using theMessageHash
field of theOriginInfo
model. The error handling is done correctly, wrapping the original error with context. The functiondbToGraphqlModelDestination
is used to convert the database model to the GraphQL model. Ensure that this function handles all necessary conversions and edge cases.54-59: The
DestinationInfo
andOriginInfo
functions return the corresponding resolver implementations. This is a standard practice in GraphQL to provide a way to resolve specific fields on types.61-62: The
destinationInfoResolver
andoriginInfoResolver
types are defined, embedding theResolver
type. This is a common pattern in Go and GraphQL to provide methods on these types that can resolve the corresponding fields.services/sinner/db/event.go (1)
- 34-41: The
RetrieveOriginSent
andRetrieveExecuted
methods have been updated to retrieve records based onmessageHash
instead ofchainID
andtxHash
. This change aligns with the updated database schema whereMessageHash
is now the primary key.New methods
RetrieveOriginSents
andRetrieveExecuteds
have been added to retrieve multiple records based onchainID
andtxHash
. This could be useful in scenarios where multiple events are tied to a single transaction.Ensure that all calls to these methods throughout the codebase have been updated to match the new signatures and that the new methods are used appropriately.
---new hunk for review---
// //nolint:interfacebloat type EventDBWriter interface { 47: // StoreOriginSent stores an OriginSent event. 48: StoreOriginSent(ctx context.Context, event model.OriginSent) error 49: // StoreExecuted stores an Executed event. 50: StoreExecuted(ctx context.Context, event model.Executed) error 51: // UpdateMessageStatus updates the status of a message. 52: UpdateMessageStatus(ctx context.Context, messageHash string, status graphqlModel.MessageStatus) error 53: // StoreLastStoredBlock stores the last block stored in sinner. 54: StoreLastStoredBlock(ctx context.Context, chainID uint32, address common.Address, blockNumber uint64) error } // EventDB combines EventDBReader and EventDBWriter.
---old hunk for context---
// //nolint:interfacebloat type EventDBWriter interface { // StoreOriginSent stores an OriginSent event. StoreOriginSent(ctx context.Context, event model.OriginSent) error // StoreExecuted stores an Executed event. StoreExecuted(ctx context.Context, event model.Executed) error // UpdateMessageStatus updates the status of a message. UpdateMessageStatus(ctx context.Context, messageHash string, status graphqlModel.MessageStatus) error // StoreLastStoredBlock stores the last block stored in sinner. StoreLastStoredBlock(ctx context.Context, chainID uint32, address common.Address, blockNumber uint64) error } // EventDB combines EventDBReader and EventDBWriter.
---end hunk---
services/sinner/graphql/server/graph/resolver/server.go (9)
39-40: The
ResolverRoot
interface has been extended with two new methods:DestinationInfo()
andOriginInfo()
. Ensure that all implementations of this interface have been updated to include these new methods.74-75: New functions
MessageStatus
andOriginInfo
have been added to theDestinationInfo
andOriginInfo
interfaces respectively. Make sure these functions are implemented wherever these interfaces are used.93-98: The
Query
struct has been extended with new functionsGetDestinationInfo
,GetDestinationInfos
,GetMessageStatus
,GetOriginInfo
, andGetOriginInfos
. Ensure that these functions are implemented and used correctly.101-108: New interfaces
DestinationInfoResolver
andOriginInfoResolver
have been introduced. Make sure these interfaces are implemented correctly wherever they are used.314-320: New cases have been added to handle
DestinationInfo.messageStatus
,DestinationInfo.originInfo
,OriginInfo.destinationInfo
, andOriginInfo.messageStatus
. Ensure that these cases are handled correctly in the switch statement.423-435: New cases have been added to handle
Query.getDestinationInfo
,Query.getDestinationInfos
,Query.getOriginInfo
, andQuery.getOriginInfos
. Ensure that these cases are handled correctly in the switch statement.542-557: The GraphQL schema has been updated with new queries
getOriginInfo
,getDestinationInfo
,getOriginInfos
, andgetDestinationInfos
. Make sure these queries are implemented and used correctly.580-605: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [572-598]
The
OriginInfo
andDestinationInfo
types in the GraphQL schema have been updated with new fieldsmessageStatus
anddestinationInfo
/originInfo
respectively. Ensure that these fields are handled correctly in the GraphQL resolvers.
- 1103-1237: New resolvers have been added for
DestinationInfo.messageStatus
,DestinationInfo.originInfo
,OriginInfo.messageStatus
, andOriginInfo.destinationInfo
. Make sure these resolvers are implemented correctly and return the expected data.1672, 1713:
The return type of theOriginInfo.originChainID
andOriginInfo.destinationChainID
fields has been changed fromstring
toint
. Ensure that this change is reflected in all places where these fields are used.services/sinner/api/resolver_test.go (2)
- 30-38: The test
TestGetOrigin()
has been updated to test the newGetOriginInfo()
function that takes amessageHash
instead oftxHash
andchainID
. It also tests the newGetOriginInfos()
function. Ensure that themessageHash
is correctly generated and used in these tests. Also, consider adding a check to verify the length of theresults
slice to ensure that theGetOriginInfos()
function is returning the correct number of results.+ Equal(t.T(), txHash, *result.Response.OriginTxHash) + results, err := t.sinnerAPI.GetOriginInfos(t.GetTestContext(), txHash, int(chainID)) + Nil(t.T(), err) + NotNil(t.T(), results) + Equal(t.T(), txHash, *results.Response[0].OriginTxHash)Committable suggestion (Beta)
result, err := t.sinnerAPI.GetOriginInfo(t.GetTestContext(), messageHash) Nil(t.T(), err) NotNil(t.T(), result) Equal(t.T(), txHash, *result.Response.OriginTxHash) results, err := t.sinnerAPI.GetOriginInfos(t.GetTestContext(), txHash, int(chainID)) Nil(t.T(), err) NotNil(t.T(), results) Equal(t.T(), 1, len(results.Response)) Equal(t.T(), txHash, *results.Response[0].OriginTxHash)
- 59-67: The test
TestGetExecuted()
has been updated to test the newGetDestinationInfo()
function that takes amessageHash
instead oftxHash
andchainID
. It also tests the newGetDestinationInfos()
function. Ensure that themessageHash
is correctly generated and used in these tests. Also, consider adding a check to verify the length of theresults
slice to ensure that theGetDestinationInfos()
function is returning the correct number of results.+ Equal(t.T(), txHash, *result.Response.TxHash) + results, err := t.sinnerAPI.GetDestinationInfos(t.GetTestContext(), txHash, int(chainID)) + Nil(t.T(), err) + NotNil(t.T(), results) + Equal(t.T(), txHash, *results.Response[0].TxHash)Committable suggestion (Beta)
result, err := t.sinnerAPI.GetDestinationInfo(t.GetTestContext(), messageHash) Nil(t.T(), err) NotNil(t.T(), result) Equal(t.T(), txHash, *result.Response.TxHash) results, err := t.sinnerAPI.GetDestinationInfos(t.GetTestContext(), txHash, int(chainID)) Nil(t.T(), err) NotNil(t.T(), results) Equal(t.T(), 1, len(results.Response)) Equal(t.T(), txHash, *results.Response[0].TxHash)
services/sinner/graphql/client/client.go (7)
22-26: The
Query
struct has been updated to include two new fields:GetOriginInfos
andGetDestinationInfos
. These fields correspond to the new GraphQL queries for retrieving multiple records based on the chain ID and transaction hash. The types of these fields are slices of pointers tomodel.OriginInfo
andmodel.DestinationInfo
, respectively, indicating that the queries return multiple records.61-72: The
GetOriginInfo
andGetOriginInfos
structs have been updated with new fields and type changes. TheOriginChainID
,DestinationChainID
,OptimisticSeconds
,MessageFlag
,Version
, andGasLimit
fields have been changed from*string
to*int
. This change aligns the types with the expected data types in the GraphQL schema. TheMessageHash
field has been added to both structs, reflecting the change in the primary key fromTxHash
toMessageHash
in theOriginSent
table.94-103: A new struct
GetDestinationInfos
has been added to handle the response from thegetDestinationInfos
GraphQL query. This struct is similar toGetDestinationInfo
but is designed to handle multiple records in the response.155-157: The
GetOriginInfo
function and the corresponding GraphQL query document have been updated to replace thetxHash
andchainID
parameters withmessageHash
. This change reflects the update in the primary key fromTxHash
toMessageHash
in theOriginSent
table.193-196: New GraphQL query documents and functions have been added for the
getOriginInfos
andgetDestinationInfos
queries. These queries retrieve multiple records from theOriginSent
andExecuted
tables based on the chain ID and transaction hash. The functions take a context, transaction hash, chain ID, and optional HTTP request options, and return the corresponding response struct.221-223: The
GetDestinationInfo
function and the corresponding GraphQL query document have been updated to replace thetxHash
andchainID
parameters withmessageHash
. This change reflects the update in the primary key fromTxHash
toMessageHash
in theExecuted
table.248-251: New GraphQL query documents and functions have been added for the
getDestinationInfos
queries. These queries retrieve multiple records from theExecuted
table based on the chain ID and transaction hash. The functions take a context, transaction hash, chain ID, and optional HTTP request options, and return the corresponding response struct.
// TxIndex is the index of the tx in a block. | ||
TxIndex uint `gorm:"column:tx_index"` | ||
// MessageHash is the message hash. | ||
MessageHash string `gorm:"column:message_hash"` | ||
MessageHash string `gorm:"column:message_hash;primaryKey"` |
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.
should be a foreign key constraint to message table
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.
Is this for data integrity if deleting from the db? currently the messagestatus table is updated concurrently w/origin/destination table insert while indexing.
An idea could be to do a has many relationship, but the idea of the message status table was to be a lite as possible on query side so it could be pinged a lot for quick updates.
type MessageStatus struct {
MessageHash string `gorm:"column:message_hash;uniqueIndex:idx_message_hash_status"`
OriginTxHash string `gorm:"column:origin_txhash"`
DestinationTxHash string `gorm:"column:destination_txhash"`
OriginSentMessages []OriginSent `gorm:"foreignKey:MessageHash;references:MessageHash;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
ExecutedMessages []Executed `gorm:"foreignKey:MessageHash;references:MessageHash;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
}
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.
has many would be the idea yeah, this will also speed up joins, etc
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.
destination tx hash is many to may
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.
Review Status
Actionable comments generated: 2
Configuration used: CodeRabbit UI
Files selected for processing (1)
- services/sinner/db/sql/base/read.go (3} hunks)
Additional comments: 3
services/sinner/db/sql/base/read.go (3)
59-106: The
RetrieveOriginSent()
,RetrieveOriginSents()
,RetrieveExecuted()
, andRetrieveExecuteds()
functions have been updated to usemessageHash
instead ofchainID
andtxHash
. This change aligns with the updated database schema whereMessageHash
is now the primary key. Ensure that all calls to these functions throughout the codebase have been updated to match the new signatures. Also, verify that themessageHash
is being correctly generated and used in the upstream code.72-83: The new function
RetrieveOriginSents()
has been added to retrieve multipleOriginSent
records based onchainID
andtxHash
. This function can be useful when there are multipleOriginSent
events associated with a single transaction. However, it's important to note that this function may return a large number of records for transactions with many events, which could impact performance. Consider adding pagination or limiting the number of records returned if this becomes an issue.98-106: The new function
RetrieveExecuteds()
has been added to retrieve multipleExecuted
records based onchainID
andtxHash
. Similar to theRetrieveOriginSents()
function, this function may return a large number of records for transactions with many executed events. Consider adding pagination or limiting the number of records returned if this becomes an issue.
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- services/sinner/db/sql/base/read.go (3} hunks)
Files skipped from review due to trivial changes (1)
- services/sinner/db/sql/base/read.go
// TxIndex is the index of the tx in a block. | ||
TxIndex uint `gorm:"column:tx_index"` | ||
// MessageHash is the message hash. | ||
MessageHash string `gorm:"column:message_hash"` | ||
MessageHash string `gorm:"column:message_hash;primaryKey"` |
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.
destination tx hash is many to may
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to filter (1)
- services/sinner/go.mod
Files selected for processing (1)
- services/sinner/db/event.go (1 hunks)
Additional comments: 1
services/sinner/db/event.go (1)
- 33-46: The changes to the
EventDBReader
interface look good. The new methodsRetrieveOriginSents
andRetrieveExecuteds
have been added correctly and the existing methodsRetrieveOriginSent
andRetrieveExecuted
have been updated to usemessageHash
instead ofchainID
andtxHash
. Ensure that all implementations of this interface have been updated to reflect these changes.
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (1)
- services/sinner/api/server.go (2 hunks)
Additional comments: 8
services/sinner/api/server.go (8)
24-25: The introduction of
errNoPort
is a good practice for error handling. It provides a clear and specific error message when the port is not specified.33-34: The use of
ginhelper.New(logger)
to create a new router is good for maintainability and modularity. It abstracts the creation of a new router into a helper function, which can be reused in other parts of the code.2-8: > Note: This review was outside of the patch, but no patch was found that overlapped with it. Original lines [36-41]
The error handling here is well done. If there is an error initializing the database, the function returns immediately with a wrapped error message. This is a good practice as it provides more context about the error.
- 2-8: > Note: This review was outside of the patch, but no patch was found that overlapped with it. Original lines [43-44]
The use of
gqlServer.EnableGraphql(router, eventDB, cfg, handler)
to enable GraphQL on the router is good for modularity. It abstracts the process of enabling GraphQL into a separate function, which can be reused in other parts of the code.
- 2-8: > Note: This review was outside of the patch, but no patch was found that overlapped with it. Original lines [46-47]
The creation of a new listener is well handled. If there is an error creating the listener, the function returns immediately with a wrapped error message. This is a good practice as it provides more context about the error.
- 2-8: > Note: This review was outside of the patch, but no patch was found that overlapped with it. Original lines [49-58]
The use of an error group to handle the serving of HTTP requests is a good practice. It allows for the handling of multiple goroutines that return an error. If any of the goroutines return an error, the error group will return that error.
- 2-8: > Note: This review was outside of the patch, but no patch was found that overlapped with it. Original lines [60-65]
The error handling here is well done. If there is an error with the server, the function returns immediately with a wrapped error message. This is a good practice as it provides more context about the error.
- 2-8: > Note: This review was outside of the patch, but no patch was found that overlapped with it. Original lines [67-130]
The
InitDB
function is well structured and handles errors appropriately. It checks the database type and initializes the appropriate database accordingly. If there is an error at any point, it returns immediately with a wrapped error message. This is a good practice as it provides more context about the error.
if cfg.HTTPPort == 0 { | ||
return errNoPort | ||
} |
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.
The check for cfg.HTTPPort == 0
is a good addition. It ensures that the server does not start without a valid port. However, it might be beneficial to also check if the port is within the valid range (1-65535). If the port is outside this range, it should also return an error.
if cfg.HTTPPort <= 0 || cfg.HTTPPort > 65535 {
return errNoPort
}
* init * stashing at prev checkpoint to resolve build issues * updating graphql * live filling updates * stash prev changes before tests * update queries w/tests * update api and cli * stash before deploy * api tests * lint * lint * lint + gen * code cov * gen * adding code cov * lint + test + coderabbit suggestions * symlink * edits * hold * Update go.mod * sinner docker + main.go * sinner test flake, bytes -> hex string update, update assert use, lint * update logging * deprecate port flag * updating fetch ceil * adding concurrency during parse store * add comments * gen (stringer) * add build to .goreleaser.yml * build * Revert "build" [goreleaser] This reverts commit 8c61076. * fix goreleaser [goreleaser] * fix replacement issue * [sinner] add start readme (#1499) * add start readme * fix https://github.com/synapsecns/sanguine/pull/1380/files#r1371810612 --------- Co-authored-by: Trajan0x <[email protected]> * sinner strings for contract_type (#1498) Co-authored-by: Trajan0x <[email protected]> * trajan edits * nits * explorer update * Sinner: resolvers and updating db read functions (#1514) * init staging * add more db read functions * update model to where * update filters * hash * Revert "hash" This reverts commit 9b159df. * remove unused db mocks * handle invalid port --------- Co-authored-by: Trajan0x <[email protected]> * type fix * simplify w generics * add go error group to unified command + updated read.go * code rabbit nit * logger fix * Parser, API, and config updates * tests, sinner/indexer updates, db updates * lint + refactor graphql + db * Add log range asc to API * [goreleaser] * Update README.md * refactor indexer * exit 1 on fail * update scribe fetcher and pagination behavior * mysql context * mysql + refresh rate * update config and readme + [goreleaser] * update tests * typo + [goreleaser] * prom exporter gen * revert abi - [goreleaser] * [goreleaser] * specify varchar length for indexing [goreleaser] * update 64 to 66 to account for 0x [goreleaser] * update api * [goreleaser] * gen * update comment * [goreleaser] * add asc flag * [goroutine] * [goreleaser] --------- Co-authored-by: Trajan0x <[email protected]> Co-authored-by: trajan0x <[email protected]>
* init * stashing at prev checkpoint to resolve build issues * updating graphql * live filling updates * stash prev changes before tests * update queries w/tests * update api and cli * stash before deploy * api tests * lint * lint * lint + gen * code cov * gen * adding code cov * lint + test + coderabbit suggestions * symlink * edits * hold * Update go.mod * sinner docker + main.go * sinner test flake, bytes -> hex string update, update assert use, lint * update logging * deprecate port flag * updating fetch ceil * adding concurrency during parse store * add comments * gen (stringer) * add build to .goreleaser.yml * build * Revert "build" [goreleaser] This reverts commit 8c61076. * fix goreleaser [goreleaser] * fix replacement issue * [sinner] add start readme (#1499) * add start readme * fix https://github.com/synapsecns/sanguine/pull/1380/files#r1371810612 --------- Co-authored-by: Trajan0x <[email protected]> * sinner strings for contract_type (#1498) Co-authored-by: Trajan0x <[email protected]> * trajan edits * nits * explorer update * Sinner: resolvers and updating db read functions (#1514) * init staging * add more db read functions * update model to where * update filters * hash * Revert "hash" This reverts commit 9b159df. * remove unused db mocks * handle invalid port --------- Co-authored-by: Trajan0x <[email protected]> * type fix * simplify w generics * add go error group to unified command + updated read.go * code rabbit nit * logger fix * Parser, API, and config updates * tests, sinner/indexer updates, db updates * lint + refactor graphql + db * Add log range asc to API * [goreleaser] * Update README.md * refactor indexer * exit 1 on fail * update scribe fetcher and pagination behavior * mysql context * mysql + refresh rate * update config and readme + [goreleaser] * init * mod lint * omnirpc version bump * chart bump * Update values.yaml * lint * rm omnirpc dependacy * update op rpc (ratelimited) * rev --------- Co-authored-by: Trajan0x <[email protected]> Co-authored-by: trajan0x <[email protected]>
Summary by CodeRabbit
New Features:
GetOriginInfos
andGetDestinationInfos
functions to retrieve multiple origin and destination information respectively, enhancing data retrieval capabilities.Refactor:
txHash
andchainID
withmessageHash
for single record retrieval and vice versa for multiple records, improving the specificity of data queries.OriginSent
andExecuted
database models, changing the primary key toMessageHash
and adding an index toChainID
, optimizing database operations.New Feature:
dbToGraphqlModelOrigin
anddbToGraphqlModelDestination
functions to convert database models to GraphQL models, improving data handling between different systems.Refactor:
DestinationInfo
andOriginInfo
GraphQL models, adding new fields and changing the types of several existing fields, enhancing the granularity of data representation.