eip712-validation-node/client-peer/aqua/demo_validation.aqua

113 lines
2.9 KiB
Plaintext
Raw Normal View History

2021-10-24 19:10:23 -05:00
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
2021-10-24 12:32:30 -05:00
data DBRecord:
signature: string
2021-10-24 12:32:30 -05:00
event_address: string
eip712_doc: string
2021-10-11 01:36:53 -05:00
peer_id: string
timestamp: u64
eip_validation: bool
ts_validation: bool
2021-10-24 12:32:30 -05:00
signed_response: string
2021-10-11 01:36:53 -05:00
2021-10-24 12:32:30 -05:00
data DBResult:
stderr: string
stdout: []DBRecord
2021-10-11 01:36:53 -05:00
2021-10-24 12:32:30 -05:00
service EIPValidator("EIPValidator"):
2021-10-24 19:10:23 -05:00
eip712_validation_string(eip_str: string, peer_id: string) -> ValidationResult
eip712_validation_url(eip_str: string, peer_id: string) -> ValidationResult
2021-10-11 01:36:53 -05:00
service DataProvider("DataProvider"):
2021-10-24 12:32:30 -05:00
get_records() -> DBResult
get_record(signature: string) -> DBResult
2021-10-24 12:32:30 -05:00
get_record_count() -> u64
2021-10-24 18:25:58 -05:00
delete_records(password: string) -> DBResult
2021-10-11 01:36:53 -05:00
2021-10-24 19:10:23 -05:00
func validate(eip712_url: string, node: string, relay:string) -> ValidationResult:
2021-10-11 01:36:53 -05:00
on node via relay:
2021-10-24 12:32:30 -05:00
res <- EIPValidator.eip712_validation_url(eip712_url, node)
2021-10-11 01:36:53 -05:00
<- res
2021-10-24 12:32:30 -05:00
func get_records(node: string, relay:string) -> DBResult:
2021-10-11 01:36:53 -05:00
on node via relay:
res <- DataProvider.get_records()
<- res
func get_record(signature: string, node: string, relay:string) -> DBResult:
2021-10-11 01:36:53 -05:00
on node via relay:
res <- DataProvider.get_record(signature)
2021-10-24 12:32:30 -05:00
<- res
func get_record_count(node: string, relay:string) -> u64:
on node via relay:
res <- DataProvider.get_record_count()
<- res
2021-10-24 18:25:58 -05:00
func delete_records(password: string, node: string, relay:string) -> DBResult:
2021-10-24 12:32:30 -05:00
on node via relay:
2021-10-24 18:25:58 -05:00
result <- DataProvider.delete_records(password)
2021-10-24 12:32:30 -05:00
<- result
2021-11-07 15:19:09 -06:00
-- Example to collect many node validations and run them through a simple frequency count
-- algorithm
data EIPLocation:
2021-11-07 18:38:20 -06:00
node_id: string
relay_id: string
data Consensus:
n: u64
threshold: f64
valid: u64
invalid: u64
consensus: bool
data CResult:
stderr: string
stdout: []Consensus
2021-11-07 15:19:09 -06:00
service ConsensusService("ConsensusService"):
2021-11-07 18:38:20 -06:00
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
2021-11-07 15:19:09 -06:00
2021-11-07 18:38:20 -06:00
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:
2021-11-07 15:19:09 -06:00
result: *bool
2021-11-07 18:38:20 -06:00
for loc <- locations par:
on loc.node_id via loc.relay_id:
2021-11-07 15:19:09 -06:00
res <- DataProvider.get_record(signature)
2021-11-07 18:38:20 -06:00
result <<- res.stdout!0.ts_validation
2021-11-07 15:19:09 -06:00
on service_node:
ConsensusService consensus_service
2021-11-07 18:38:20 -06:00
consensus <- ConsensusService.consensus(result, threshold)
2021-11-07 15:19:09 -06:00
<- consensus