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

Oracle client #479

Merged
merged 8 commits into from Jan 29, 2019

Conversation

Projects
None yet
2 participants
@y0sher
Copy link
Collaborator

y0sher commented Jan 23, 2019

server code is in https://github.com/y0sher/oracle_server for now.

This lets use a server as the authority of eligibility for testing.
we use the json api in order to not pollute the node with server pb files

@y0sher y0sher requested a review from gavraz Jan 24, 2019

@@ -213,7 +213,7 @@ func (proc *ConsensusProcess) validateRole(m *pb.HareMessage) bool {
// TODO: validate role proof

// validate role
if !proc.oracle.Validate(proc.expectedCommitteeSize(m.Message.K), Signature(m.Message.RoleProof)) {
if !proc.oracle.Validate(proc.instanceId.Bytes(), int(m.Message.K), proc.expectedCommitteeSize(m.Message.K), proc.signing.Verifier(), Signature(m.Message.RoleProof)) {

This comment has been minimized.

@antonlerner

antonlerner Jan 24, 2019

Collaborator

don't use bytes as id, set specific type

@@ -514,7 +514,7 @@ func (proc *ConsensusProcess) endOfRound3() {
}

func (proc *ConsensusProcess) currentRole() Role {
if proc.oracle.Validate(proc.expectedCommitteeSize(proc.k), proc.roleProof()) {
if proc.oracle.Validate(proc.instanceId.Bytes(), int(proc.k), proc.expectedCommitteeSize(proc.k), proc.signing.Verifier(), proc.roleProof()) {

This comment has been minimized.

@antonlerner

antonlerner Jan 24, 2019

Collaborator

Is the verifier the public key and identity? if so, lets rename it to that

@@ -96,7 +96,7 @@ func (mock *MockHashOracle) calcThreshold(committeeSize int) uint32 {
}

// Validate if a proof is valid for a given committee size
func (mock *MockHashOracle) Validate(committeeSize int, proof Signature) bool {
func (mock *MockHashOracle) Validate(instanceID []byte, K int, committeeSize int, pubKey Stringer, proof []byte) bool {

This comment has been minimized.

@antonlerner

antonlerner Jan 24, 2019

Collaborator

rename to validateEligibility

This comment has been minimized.

@y0sher

y0sher Jan 28, 2019

Author Collaborator

That was the original name I didn't change it. refactoring is out of this PR scope :)

}
t.network.Broadcast(meshSync.NewBlock, bytes)
}()
if t.blockOracle.Validate(id, t.minerID) {

This comment has been minimized.

@antonlerner

antonlerner Jan 24, 2019

Collaborator

invert the if -
if !Validate {
break
}

return bo.Validate(block.LayerIndex, stringerer(block.MinerID))
}

func (bo *blockOracle) Validate(id mesh.LayerID, pubKey fmt.Stringer) bool {

This comment has been minimized.

@antonlerner

antonlerner Jan 24, 2019

Collaborator

just accept string

}
}

type stringerer string

This comment has been minimized.

@antonlerner

antonlerner Jan 24, 2019

Collaborator

use simple string as input

}

type hareOracle struct {
oc *OracleClient

This comment has been minimized.

@antonlerner

antonlerner Jan 24, 2019

Collaborator

you can embed OracleClient


func (hr *HTTPRequester) Get(api, data string) []byte {
var jsonStr = []byte(data)
spew.Println(string(jsonStr))

This comment has been minimized.

@antonlerner

antonlerner Jan 24, 2019

Collaborator

you can just print data



// Validate checks whether a given ID is in the eligible list or not. it fetches the list once and gives answers locally after that.
func (oc *OracleClient) Validate(instanceID []byte, K int, committeeSize int, pubKey fmt.Stringer) bool {

This comment has been minimized.

@antonlerner

antonlerner Jan 24, 2019

Collaborator

ValidateElegibility

This comment has been minimized.

@y0sher

y0sher Jan 28, 2019

Author Collaborator

its Validate for following the hare Rolacle interface.

Show resolved Hide resolved oracle/rolacle_client.go Outdated

@y0sher y0sher force-pushed the oracle_client branch 2 times, most recently from dd9ab25 to 0be9995 Jan 28, 2019

@y0sher y0sher force-pushed the oracle_client branch from 5692594 to c016920 Jan 29, 2019

@y0sher y0sher merged commit d5c7412 into develop Jan 29, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@y0sher y0sher deleted the oracle_client branch Jan 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment