Skip to content

Commit

Permalink
the distributor makes the signature
Browse files Browse the repository at this point in the history
  • Loading branch information
albertolerda committed Jul 20, 2023
1 parent 24cd536 commit 0de9e68
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 36 deletions.
133 changes: 125 additions & 8 deletions contracts/dao-distributor/choose-oracles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ blocks:
Given I read the content of 'keys.json'
Given I read the content of 'urls.json'
Given I have a 'string' named 'ethereum address'
Given I have a 'string' named 'caller address'
Given I have a 'string' named 'eth_url'
Given I have a 'string' named 'endpoint'
Expand All @@ -28,7 +28,6 @@ blocks:
When I create the 'string dictionary'
When I rename the 'string dictionary' to 'post'
When I rename the 'ethereum address' to 'caller address'
When I move 'caller address' in 'data'
When I move 'eth url' in 'data'
When I move 'endpoint' in 'data'
Expand Down Expand Up @@ -97,6 +96,28 @@ blocks:
zenContent: >
Rule caller restroom-mw
Scenario 'w3c':
Scenario 'ethereum':
Given I read the content of './keys.json'
Given my name is in a 'string' named 'identity'
Given I have my 'keyring'
Given I have a 'hex' named 'ethereum address'
Given I rename 'ethereum address' to 'caller address'
Given I have a 'string' named 'message'
Given I have a 'string array' named 'post'
Given I have a 'string array' named 'results' in 'output'
Expand All @@ -107,11 +128,28 @@ blocks:
Given I have a 'string' named 'api name'
Given I have a 'string array' named 'typeSpec'
When I create the 'string array'
When I rename the 'string array' to 'oracle urls'
When I create the 'hex array'
When I rename the 'hex array' to 'signatures'
When I create the 'hex array'
When I rename the 'hex array' to 'abi_encodings'
When I pickup from path 'post.data.dao_vote_id'
Foreach 'o' in 'results'
When I pickup from path 'o.result.didDocument.url'
Expand All @@ -120,15 +158,94 @@ blocks:
When I move 'url' in 'oracle urls'
When I pickup from path 'o.result.didDocument'
When I create the verificationMethod of 'didDocument'
When I pickup from path 'verificationMethod.ethereum_address'
When I create the new array
When I copy 'message' in 'new array'
When I move 'ethereum address' in 'new array'
When I copy 'caller address' in 'new array'
When I copy 'dao vote id' in 'new array'
When I create the ethereum abi encoding of 'new array' using 'typeSpec'
When I create the hash of 'ethereum abi encoding' using 'keccak256'
When I delete 'new array'
When I rename the 'hash' to 'message.keccak'
When I create the ethereum signature of 'message.keccak'
When I move 'ethereum signature' in 'signatures'
When I move 'ethereum abi encoding' in 'abi_encodings'
When I delete the 'didDocument'
When I delete the 'verificationMethod'
When I delete the 'message.keccak'
endforeach
Then print the 'oracle urls'
Then print the 'post'
Then print the 'signatures'
Then print the 'abi_encodings'
keysFile: chooseoracles2.keys
next: chooseoracles3.zen
chooseoracles3.zen:
zenContent: |
# Always use 'Rule caller restroom-mw' when using Restroom
Rule caller restroom-mw
# [R] Restroom-mw statements: state endpoints
Given I have a 'string array' named 'oracle_urls'
Given I have a 'string array' named 'signatures'
Given I have a 'string dictionary' named 'data' in 'post'
Given I rename 'data' to 'olddata'
When I create the 'string array'
When I rename the 'string array' to 'posts'
Foreach 'signature' in 'signatures'
When I copy 'olddata' to 'data'
When I move 'signature' in 'data'
When I create the 'string dictionary'
When I rename the 'string dictionary' to 'newpost'
When I move 'data' in 'newpost'
When I move 'newpost' in 'posts'
endforeach
Then print the 'posts'
Then print the 'oracle_urls'
next: chooseoracles4.zen
chooseoracles4.zen:
zenContent: >
# Always use 'Rule caller restroom-mw' when using Restroom
Expand All @@ -143,7 +260,7 @@ blocks:
# Loading input data and telling Zenroom that 'post' will be created by
Restroom-mw
Given I have a 'string dictionary' named 'post'
Given I have a 'string dictionary' named 'posts'
# Here Restroom-mw performs the REST calls and stores the output in
Expand All @@ -155,8 +272,8 @@ blocks:
Given I have a 'string dictionary' named 'output'
Given I execute parallel POST with 'post' to array 'oracle_urls' and save
the result named 'output'
Given I execute parallel POST with array 'posts' to array 'oracle_urls'
and save the result named 'output'
When I create the json escaped string of 'output'
Expand All @@ -171,8 +288,8 @@ blocks:
# Print the output
Then print the 'query params'
next: chooseoracles4.zen
chooseoracles4.zen:
next: chooseoracles5.zen
chooseoracles5.zen:
zenContent: >
Rule caller restroom-mw
Expand All @@ -197,4 +314,4 @@ blocks:
Then print the 'worker_oracles_output'
Then print the 'database_actions_result'
keysFile: chooseoracles4.keys
keysFile: chooseoracles5.keys
2 changes: 1 addition & 1 deletion contracts/dao-distributor/chooseoracles2.keys
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"dids":["did:dyne:sandbox.zenswarm:A8SvtNV9C3dELzXBZuExKXAXD3K55HrBK5XbAtZsqrV7","did:dyne:sandbox.zenswarm:8yBBtS5w7fJE1GM1VMF63LfAceBVaybVypYCm6yajyAy","did:dyne:sandbox.zenswarm:3g2SnviiUkisV2eiSjfDGj91gxTaoNGrZGM6adadqhiH","did:dyne:sandbox.zenswarm:DrY9ECLJ7Sf25qurEQK8VjHTPma7jNokTFXeTktwkT8r"],"one":1,"four":3,"base url":"https://did.dyne.org/dids/","api name":"api/worker-submit.chain"}
{"dids":["did:dyne:sandbox.zenswarm:A8SvtNV9C3dELzXBZuExKXAXD3K55HrBK5XbAtZsqrV7","did:dyne:sandbox.zenswarm:8yBBtS5w7fJE1GM1VMF63LfAceBVaybVypYCm6yajyAy","did:dyne:sandbox.zenswarm:3g2SnviiUkisV2eiSjfDGj91gxTaoNGrZGM6adadqhiH","did:dyne:sandbox.zenswarm:DrY9ECLJ7Sf25qurEQK8VjHTPma7jNokTFXeTktwkT8r"],"message":"NodeJob","typeSpec":["string","address","address","uint256"],"one":1,"four":3,"base url":"https://did.dyne.org/dids/","api name":"api/worker-submit.chain"}
1 change: 1 addition & 0 deletions contracts/dao-distributor/chooseoracles5.keys
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"database":"sqlite:///var/secrets/dids.db","insert_log":"INSERT INTO signature_verification_logs(timestamp, output) VALUES (?,?);"}
37 changes: 11 additions & 26 deletions contracts/dao-worker/worker-submit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ blocks:
Given I have a 'ethereum address' named 'caller_address'
Given I have a 'string' named 'eth_url'
Given I have a 'string' named 'endpoint'
Given I have a 'string dictionary' named 'signature'
Then print data
keysFile: worker-submit0.keys
next: worker-submit1.zen
worker-submit1.zen:
zenContent: >
Expand All @@ -28,10 +28,15 @@ blocks:
Given I read the content of 'keys.json'
Given I read the content of 'oracle.json'
Given I have a ethereum endpoint named 'eth_url'
Given I have a 'ethereum signature' named 'signature'
GIven I rename 'signature' to 'ethereum signature'
Given I have a 'string' named 'non verified'
Expand Down Expand Up @@ -74,7 +79,7 @@ blocks:
Given I have a ethereum endpoint named 'eth_url'
Given I have a 'ethereum address' named 'dao address'
Given I have a 'ethereum address' named 'oracle address'
Given I have a 'ethereum nonce'
Expand Down Expand Up @@ -127,6 +132,7 @@ blocks:
# and define that we will call each element of the arrays 'loop signature'
and 'loop address'
Foreach 'loop_signature' in 'signatures'
Foreach 'loop_address' in 'addresses'
Expand Down Expand Up @@ -185,28 +191,6 @@ blocks:
endforeach
When I create the new array
When I move 'message' in 'new array'
When I copy 'ethereum address' in 'new array'
When I move 'caller address' in 'new array'
When I move 'dao vote id' in 'new array'
When I create the ethereum abi encoding of 'new array' using 'typeSpec'
When I create the hash of 'ethereum abi encoding' using 'keccak256'
When I delete 'new array'
When I rename the 'hash' to 'message.keccak'
When I create the ethereum signature of 'message.keccak'
When I copy 'ethereum signature' to 'ethereum signature rsv'
Expand All @@ -226,8 +210,10 @@ blocks:
When I copy 'status_and' in 'new array'
When I copy 'request id' in 'new array'
When I create the ethereum transaction to 'dao address'
When I create the ethereum transaction to 'oracle address'
and I use the ethereum transaction to run 'submitMethod' using 'new array'
Expand All @@ -253,7 +239,6 @@ blocks:
Then print the 'ethereum signature'
Then print the 'ethereum abi encoding'
Then print the 'ethereum signature rsv' as 'hex'
Expand Down
2 changes: 1 addition & 1 deletion contracts/dao-worker/worker-submit1.keys
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"non verified":"non verified","verified":"verified","message":"NodeJob","typeSpec":["string","address","address","uint256"],"submitMethod":{"name":"submitVerification","input":["uint8","bytes32","bytes32","bool","uint256"],"output":[]},"dao_address":"0xd2c2E878884ebD12C9F9EBd661406Fa5bceF8972","gas_limit":50000,"chain_id":"80001"}
{"non verified":"non verified","verified":"verified","message":"NodeJob","typeSpec":["string","address","address","uint256"],"submitMethod":{"name":"submitVerification","input":["uint8","bytes32","bytes32","bool","uint256"],"output":[]},"dao_address":"0xd2c2E878884ebD12C9F9EBd661406Fa5bceF8972","gas_limit":1500000,"chain_id":"31337"}

0 comments on commit 0de9e68

Please sign in to comment.