-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Checkpointing] JSON RPC point for generating exit proofs (#844)
* JSON RPC point for generating exit proofs * Comments fix
- Loading branch information
1 parent
a6cbda3
commit 213aa83
Showing
13 changed files
with
104 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package jsonrpc | ||
|
||
import ( | ||
"github.com/0xPolygon/polygon-edge/types" | ||
) | ||
|
||
// bridgeStore interface provides access to the methods needed by bridge endpoint | ||
type bridgeStore interface { | ||
GenerateExitProof(exitID, epoch, checkpointBlock uint64) ([]types.Hash, error) | ||
} | ||
|
||
// Bridge is the bridge jsonrpc endpoint | ||
type Bridge struct { | ||
store bridgeStore | ||
} | ||
|
||
// GenerateExitProof generates exit proof for given exit event | ||
func (b *Bridge) GenerateExitProof(exitID, epoch, checkpointBlock argUint64) (interface{}, error) { | ||
return b.store.GenerateExitProof(uint64(exitID), uint64(epoch), uint64(checkpointBlock)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package jsonrpc | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/hashicorp/go-hclog" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestBridgeEndpoint(t *testing.T) { | ||
store := newMockStore() | ||
|
||
dispatcher := newDispatcher( | ||
hclog.NewNullLogger(), | ||
store, | ||
&dispatcherParams{ | ||
chainID: 0, | ||
priceLimit: 0, | ||
jsonRPCBatchLengthLimit: 20, | ||
blockRangeLimit: 1000, | ||
}, | ||
) | ||
|
||
mockConnection, _ := newMockWsConnWithMsgCh() | ||
|
||
msg := []byte(`{ | ||
"method": "bridge_generateExitProof", | ||
"params": ["0x0001", "0x0001", "0x0002"], | ||
"id": 1 | ||
}`) | ||
|
||
data, err := dispatcher.HandleWs(msg, mockConnection) | ||
require.NoError(t, err) | ||
|
||
resp := new(SuccessResponse) | ||
require.NoError(t, json.Unmarshal(data, resp)) | ||
require.Nil(t, resp.Error) | ||
require.NotNil(t, resp.Result) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters