mirror of
https://github.com/fluencelabs/eip712-validation-node
synced 2025-06-03 02:01:20 +00:00
113 lines
2.9 KiB
Plaintext
113 lines
2.9 KiB
Plaintext
data Response:
|
|
peer_id: string
|
|
timestamp: u64
|
|
eip_validation: bool
|
|
ts_validation: bool
|
|
|
|
data EipResponse:
|
|
signature: string
|
|
validation: Response
|
|
|
|
data ValidationResult:
|
|
stderr: string
|
|
stdout: EipResponse
|
|
|
|
|
|
data DBRecord:
|
|
signature: string
|
|
event_address: string
|
|
eip712_doc: string
|
|
peer_id: string
|
|
timestamp: u64
|
|
eip_validation: bool
|
|
ts_validation: bool
|
|
signed_response: string
|
|
|
|
data DBResult:
|
|
stderr: string
|
|
stdout: []DBRecord
|
|
|
|
service EIPValidator("EIPValidator"):
|
|
eip712_validation_string(eip_str: string, peer_id: string) -> ValidationResult
|
|
eip712_validation_url(eip_str: string, peer_id: string) -> ValidationResult
|
|
|
|
service DataProvider("DataProvider"):
|
|
get_records() -> DBResult
|
|
get_record(signature: string) -> DBResult
|
|
get_record_count() -> u64
|
|
delete_records(password: string) -> DBResult
|
|
|
|
|
|
func validate(eip712_url: string, node: string, relay:string) -> ValidationResult:
|
|
on node via relay:
|
|
res <- EIPValidator.eip712_validation_url(eip712_url, node)
|
|
<- res
|
|
|
|
func get_records(node: string, relay:string) -> DBResult:
|
|
on node via relay:
|
|
res <- DataProvider.get_records()
|
|
<- res
|
|
|
|
func get_record(signature: string, node: string, relay:string) -> DBResult:
|
|
on node via relay:
|
|
res <- DataProvider.get_record(signature)
|
|
<- res
|
|
|
|
func get_record_count(node: string, relay:string) -> u64:
|
|
on node via relay:
|
|
res <- DataProvider.get_record_count()
|
|
<- res
|
|
|
|
func delete_records(password: string, node: string, relay:string) -> DBResult:
|
|
on node via relay:
|
|
result <- DataProvider.delete_records(password)
|
|
<- result
|
|
|
|
|
|
-- Example to collect many node validations and run them through a simple frequency count
|
|
-- algorithm
|
|
data EIPLocation:
|
|
node_id: string
|
|
relay_id: string
|
|
|
|
data Consensus:
|
|
n: u64
|
|
threshold: f64
|
|
valid: u64
|
|
invalid: u64
|
|
consensus: bool
|
|
|
|
data CResult:
|
|
stderr: string
|
|
stdout: []Consensus
|
|
|
|
service ConsensusService("ConsensusService"):
|
|
consensus(validations: []bool, threshold: f64) -> CResult
|
|
|
|
|
|
|
|
func eip_consensus_halfway(signature: string, locations:[]EIPLocation, service_node: string, consensus_service: string, threshold: f64) -> []bool:
|
|
result: *bool
|
|
|
|
for loc <- locations:
|
|
on loc.node_id via loc.relay_id:
|
|
res <- DataProvider.get_record(signature)
|
|
result <<- res.stdout!0.ts_validation
|
|
<- result
|
|
|
|
func eip_consensus(signature: string, locations:[]EIPLocation, service_node: string, consensus_service: string, threshold: f64) -> CResult:
|
|
result: *bool
|
|
|
|
for loc <- locations par:
|
|
on loc.node_id via loc.relay_id:
|
|
res <- DataProvider.get_record(signature)
|
|
result <<- res.stdout!0.ts_validation
|
|
|
|
on service_node:
|
|
ConsensusService consensus_service
|
|
consensus <- ConsensusService.consensus(result, threshold)
|
|
<- consensus
|
|
|
|
|
|
|