Skip to content

Commit

Permalink
Feat/optimise oracle (#6)
Browse files Browse the repository at this point in the history
* add chainID to signing of oracle votes

* update gossip interval to 250ms

* add lifecycle hook for checking if oracle result exist

* add pruning oracle vote logic for already committed results

* add sig prefix for oracle votes signing

* add signType to sigPrefix

* add configs and init for oracle subaccount signing

* update oracle votes signing and verification flow with new sig prefixes wip

* add hook to check if subaccount belongs to val

* update oracle votes signing and verification flow with new sig prefixes done

* update subAccount and pubKey fields with proper camel casing

* abstract out getter and creation of sig prefix

* fix lint on signer test

* remove naming of updateMtx field to improve code readability

* add helper func to get signature without prefix, and handle signature index errors

---------

Co-authored-by: yan-soon <[email protected]>
  • Loading branch information
yan-soon and yan-soon authored Jul 23, 2024
1 parent 388af56 commit 532def2
Show file tree
Hide file tree
Showing 29 changed files with 2,297 additions and 681 deletions.
8 changes: 8 additions & 0 deletions abci/client/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,11 @@ func (cli *grpcClient) FetchOracleVotes(ctx context.Context, req *types.RequestF
func (cli *grpcClient) ValidateOracleVotes(ctx context.Context, req *types.RequestValidateOracleVotes) (*types.ResponseValidateOracleVotes, error) {
return cli.client.ValidateOracleVotes(ctx, types.ToRequestValidateOracleVotes(req).GetValidateOracleVotes(), grpc.WaitForReady(true))
}

func (cli *grpcClient) DoesOracleResultExist(ctx context.Context, req *types.RequestDoesOracleResultExist) (*types.ResponseDoesOracleResultExist, error) {
return cli.client.DoesOracleResultExist(ctx, types.ToRequestDoesOracleResultExist(req).GetDoesOracleResultExist(), grpc.WaitForReady(true))
}

func (cli *grpcClient) DoesSubAccountBelongToVal(ctx context.Context, req *types.RequestDoesSubAccountBelongToVal) (*types.ResponseDoesSubAccountBelongToVal, error) {
return cli.client.DoesSubAccountBelongToVal(ctx, types.ToRequestDoesSubAccountBelongToVal(req).GetDoesSubAccountBelongToVal(), grpc.WaitForReady(true))
}
156 changes: 104 additions & 52 deletions abci/client/mocks/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions abci/client/socket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,28 @@ func (cli *socketClient) ValidateOracleVotes(ctx context.Context, req *types.Req
return reqRes.Response.GetValidateOracleVotes(), cli.Error()
}

func (cli *socketClient) DoesOracleResultExist(ctx context.Context, req *types.RequestDoesOracleResultExist) (*types.ResponseDoesOracleResultExist, error) {
reqRes, err := cli.queueRequest(ctx, types.ToRequestDoesOracleResultExist(req))
if err != nil {
return nil, err
}
if err := cli.Flush(ctx); err != nil {
return nil, err
}
return reqRes.Response.GetDoesOracleResultExist(), cli.Error()
}

func (cli *socketClient) DoesSubAccountBelongToVal(ctx context.Context, req *types.RequestDoesSubAccountBelongToVal) (*types.ResponseDoesSubAccountBelongToVal, error) {
reqRes, err := cli.queueRequest(ctx, types.ToRequestDoesSubAccountBelongToVal(req))
if err != nil {
return nil, err
}
if err := cli.Flush(ctx); err != nil {
return nil, err
}
return reqRes.Response.GetDoesSubAccountBelongToVal(), cli.Error()
}

func (cli *socketClient) queueRequest(ctx context.Context, req *types.Request) (*ReqRes, error) {
reqres := NewReqRes(req)

Expand Down
10 changes: 10 additions & 0 deletions abci/types/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type Application interface {
CreateOracleResultTx(context.Context, *RequestCreateOracleResultTx) (*ResponseCreateOracleResultTx, error)
FetchOracleVotes(context.Context, *RequestFetchOracleVotes) (*ResponseFetchOracleVotes, error)
ValidateOracleVotes(context.Context, *RequestValidateOracleVotes) (*ResponseValidateOracleVotes, error)
DoesOracleResultExist(context.Context, *RequestDoesOracleResultExist) (*ResponseDoesOracleResultExist, error)
DoesSubAccountBelongToVal(context.Context, *RequestDoesSubAccountBelongToVal) (*ResponseDoesSubAccountBelongToVal, error)
}

//-------------------------------------------------------
Expand Down Expand Up @@ -136,3 +138,11 @@ func (BaseApplication) FetchOracleVotes(_ context.Context, req *RequestFetchOrac
func (BaseApplication) ValidateOracleVotes(_ context.Context, req *RequestValidateOracleVotes) (*ResponseValidateOracleVotes, error) {
return &ResponseValidateOracleVotes{}, nil
}

func (BaseApplication) DoesOracleResultExist(_ context.Context, req *RequestDoesOracleResultExist) (*ResponseDoesOracleResultExist, error) {
return &ResponseDoesOracleResultExist{}, nil
}

func (BaseApplication) DoesSubAccountBelongToVal(_ context.Context, req *RequestDoesSubAccountBelongToVal) (*ResponseDoesSubAccountBelongToVal, error) {
return &ResponseDoesSubAccountBelongToVal{}, nil
}
12 changes: 12 additions & 0 deletions abci/types/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ func ToRequestValidateOracleVotes(req *RequestValidateOracleVotes) *Request {
}
}

func ToRequestDoesOracleResultExist(req *RequestDoesOracleResultExist) *Request {
return &Request{
Value: &Request_DoesOracleResultExist{req},
}
}

func ToRequestDoesSubAccountBelongToVal(req *RequestDoesSubAccountBelongToVal) *Request {
return &Request{
Value: &Request_DoesSubAccountBelongToVal{req},
}
}

//----------------------------------------

func ToResponseException(errStr string) *Response {
Expand Down
Loading

0 comments on commit 532def2

Please sign in to comment.