-
Notifications
You must be signed in to change notification settings - Fork 77
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
feat(admin): added rpc method for getL2ToL2 Message(msgHash) #265
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 for the PR - some changes requested
admin/admin.go
Outdated
} else { | ||
m.log.Error("auto relay not enabled", "args", *args) | ||
return nil | ||
} |
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 indexer runs regardless of the auto relayer. maybe some thing like "Interop is not enabled, please enable interop with --interop.enabled"
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.
also this should not be a log it should return an RPC error with the correct code
admin/admin.go
Outdated
reply := storeEntry.Message() | ||
|
||
return reply |
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.
nit
return storeEntry.Message()
@@ -23,7 +23,7 @@ func TestAdminServerBasicFunctionality(t *testing.T) { | |||
testlog := testlog.Logger(t, log.LevelInfo) | |||
|
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.
can u add a test to see that the result is returned correctly? or alternatively can be in supersim_test
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.
added to supersim_test
adminServer := &AdminServer{log: log, port: port, networkConfig: networkConfig} | ||
|
||
if networkConfig.InteropEnabled && indexer != nil { | ||
adminServer.l2ToL2MsgIndexer = indexer | ||
} |
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.
nit- if it's nil then it will be initialized correctly
adminServer := &AdminServer{log: log, port: port, networkConfig: networkConfig, l2ToL2MsgIndexer: indexer}
admin/admin.go
Outdated
if s.networkConfig.InteropEnabled { | ||
rpcMethods.l2ToL2MsgIndexer = s.l2ToL2MsgIndexer |
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.
rpcMethods.l2ToL2MsgIndexer = s.l2ToL2MsgIndexer
no need to check for interopEnabled. from the perspective of the admin server, if it gets passed a non-nil indexer it assumes it's usable
orchestrator/orchestrator.go
Outdated
func (o *Orchestrator) L2ToL2MessageIndexer() *interop.L2ToL2MessageIndexer { | ||
return o.l2ToL2MsgIndexer | ||
} | ||
|
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.
see comment on supersim.go
once the admin server start logic is moved into here, we can remove this fn
admin/admin.go
Outdated
|
||
reply := storeEntry.Message() | ||
|
||
return reply |
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.
can u verify that this returns correctly (serialized and formatted correctly) when u call the json rpc server? and add a test for it?
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.
admin/admin.go
Outdated
|
||
if m.networkConfig.InteropEnabled && m.l2ToL2MsgIndexer != nil { | ||
|
||
storeEntry, err := m.l2ToL2MsgIndexer.Get(*args) |
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.
also need to handle case if the storeEntry just doesn't exist - should end up returning nil
m.log.Error("valid msg hash not provided", "args", *args) | ||
return nil | ||
} | ||
|
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.
nit: early return is better than the if/else statement below
if m.l2ToL2MsgIndexer == nil {
m.log.Error("auto relay not enabled", "args", *args)
return nil
}
^ we should return a better error
admin/admin.go
Outdated
if args == nil { | ||
m.log.Error("valid msg hash not provided", "args", *args) | ||
return nil | ||
} |
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.
can we validate that it's a correct msgHash?
Updated example rpc response
|
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.
looks good just one nit, can u rebase? will run CI checks then
type JSONL2ToL2Message struct { | ||
Destination uint64 `json:"Destination"` | ||
Source uint64 `json:"Source"` | ||
Nonce *big.Int `json:"Nonce"` | ||
Sender common.Address `json:"Sender"` | ||
Target common.Address `json:"Target"` | ||
Message hexutil.Bytes `json:"Message"` | ||
} |
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.
nit: you can prob just import this from admin.JSONL2ToL2Message
In a future PR might make sense to unify with the indexer's message type so we don't have two types. As discussed, out of scope for this PR! just noting.
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.
noted
Description
added getL2ToL2 Message(msgHash), essentially letting devs fetch L2ToL2Message via msgHash
Metadata