Skip to content
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
Merged

Oracle client #479

merged 8 commits into from
Jan 29, 2019

Conversation

y0sher
Copy link
Contributor

@y0sher 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 January 24, 2019 09:00
@@ -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)) {
Copy link
Contributor

@antonlerner antonlerner Jan 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to validateEligibility

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invert the if -
if !Validate {
break
}

oracle/oracle.go Outdated
return bo.Validate(block.LayerIndex, stringerer(block.MinerID))
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just accept string

oracle/oracle.go Outdated
}
}

type stringerer string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use simple string as input

}

type hareOracle struct {
oc *OracleClient
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can embed OracleClient


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ValidateElegibility

Copy link
Contributor Author

@y0sher y0sher Jan 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its Validate for following the hare Rolacle interface.

@y0sher y0sher force-pushed the oracle_client branch 2 times, most recently from dd9ab25 to 0be9995 Compare January 28, 2019 15:37
@y0sher y0sher merged commit d5c7412 into develop Jan 29, 2019
@y0sher y0sher deleted the oracle_client branch January 29, 2019 16:15
@y0sher y0sher restored the oracle_client branch May 29, 2019 18:44
@y0sher y0sher deleted the oracle_client branch May 29, 2019 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants