-
Notifications
You must be signed in to change notification settings - Fork 241
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
Get signature endpoint: alternative PR with different packaging #507
Changes from 73 commits
e6219a2
b054615
183a5cd
6043c13
24fe40e
dc3e441
7820ec1
a2fa3a3
ff4d54d
4f0403e
c729040
618a0de
738d19e
8d33345
be5a4d6
e8ac670
bd75e6d
5d61bb0
7b650b6
41b86bf
2cdd440
887fd6f
7c8e06f
b0f2ff3
8fc39cd
76a8a0e
4dc1d23
c745420
17d1101
4582f47
6a44563
fb76223
b7bfa17
3d47a86
ba6ee49
cffb9cc
005d90b
66a8238
1389af4
9a99797
67b7e6f
70e1d00
de89d5b
562c8f0
6d86d97
76febba
48513b1
ce25575
9d93fd1
cfd843e
4b636e9
9755d4f
cf5c907
656f286
fc668f9
dfcc95e
cfcb650
0d4e895
cee8aa0
93a43d0
453e543
ae7cdcf
6b46ff4
329dcb8
b0efb9d
8626fc4
caa66f7
a3430ad
5c441cb
2eed37f
587559c
8428f03
555da6e
b61f981
1a7c1e7
99229ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// (c) 2023, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package warp | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/ava-labs/avalanchego/ids" | ||
"github.com/ava-labs/subnet-evm/rpc" | ||
"github.com/ethereum/go-ethereum/common/hexutil" | ||
) | ||
|
||
var _ WarpClient = (*warpClient)(nil) | ||
|
||
type WarpClient interface { | ||
GetSignature(ctx context.Context, signatureRequest ids.ID) ([]byte, error) | ||
darioush marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// warpClient implementation for interacting with EVM [chain] | ||
type warpClient struct { | ||
client *rpc.Client | ||
} | ||
|
||
// NewWarpClient returns a WarpClient for interacting with EVM [chain] | ||
func NewWarpClient(uri, chain string) (WarpClient, error) { | ||
client, err := rpc.Dial(fmt.Sprintf("%s/ext/bc/%s/rpc", uri, chain)) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to dial client. err: %w", err) | ||
} | ||
return &warpClient{ | ||
client: client, | ||
}, nil | ||
} | ||
|
||
// GetSignature requests the BLS signature associated with a messageID | ||
func (c *warpClient) GetSignature(ctx context.Context, messageID ids.ID) ([]byte, error) { | ||
var res hexutil.Bytes | ||
err := c.client.CallContext(ctx, &res, "warp_getSignature", messageID[:]) | ||
if err != nil { | ||
return nil, fmt.Errorf("call to warp_getSignature failed. err: %w", err) | ||
} | ||
return res, err | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// (c) 2023, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package warp | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/ava-labs/avalanchego/ids" | ||
"github.com/ethereum/go-ethereum/common/hexutil" | ||
) | ||
|
||
// WarpAPI introduces snowman specific functionality to the evm | ||
type WarpAPI struct { | ||
Backend WarpBackend | ||
} | ||
|
||
// GetSignature returns the BLS signature associated with a messageID. | ||
func (api *WarpAPI) GetSignature(ctx context.Context, messageID ids.ID) (hexutil.Bytes, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just confirming that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Testing locally with modified code to get a response: curl --location --request POST 'http://127.0.0.1:9652/ext/bc/2ioeFdBb3qMEfnTQc9kd3CqXBmTmxqh96GyCY49b8X3UmZx5fZ/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "warp_getSignature",
"params": [
"11111111111111111111111111111111LpoYY"
],
"id": 1
}' Output: {
"jsonrpc": "2.0",
"id": 1,
"result": "0x0000000000000000000000000000000000000000000000000000000000000000"
} with a different response output: {
"jsonrpc": "2.0",
"id": 1,
"result": "0x6d0d36349f470af56409c02b53d5dfcc1a78071961f456321d9c707489d7116f"
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it needs to be |
||
signature, err := api.Backend.GetSignature(ctx, messageID) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to get signature for with error %w", err) | ||
} | ||
return signature[:], 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.
wondering if we should keep the packaging to
stats
for consistency with the sync stats.