-
Notifications
You must be signed in to change notification settings - Fork 211
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
Oracle client #479
Conversation
hare/algorithm.go
Outdated
@@ -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)) { |
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.
don't use bytes as id, set specific type
hare/algorithm.go
Outdated
@@ -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()) { |
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.
Is the verifier the public key and identity? if so, lets rename it to that
hare/mock_oracle.go
Outdated
@@ -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 { |
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.
rename to validateEligibility
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.
That was the original name I didn't change it. refactoring is out of this PR scope :)
miner/block_builder.go
Outdated
} | ||
t.network.Broadcast(meshSync.NewBlock, bytes) | ||
}() | ||
if t.blockOracle.Validate(id, t.minerID) { |
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.
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 { |
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.
just accept string
oracle/oracle.go
Outdated
} | ||
} | ||
|
||
type stringerer string |
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.
use simple string as input
} | ||
|
||
type hareOracle struct { | ||
oc *OracleClient |
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.
you can embed OracleClient
oracle/rolacle_client.go
Outdated
|
||
func (hr *HTTPRequester) Get(api, data string) []byte { | ||
var jsonStr = []byte(data) | ||
spew.Println(string(jsonStr)) |
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.
you can just print data
oracle/rolacle_client.go
Outdated
|
||
|
||
// 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 { |
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.
ValidateElegibility
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.
its Validate
for following the hare Rolacle interface.
dd9ab25
to
0be9995
Compare
get rid of "stringer"
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