From 1a7343b50a77d8cc02a73846402f94db9a341690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A1n=20Di=20Pietro?= Date: Fri, 5 Nov 2021 18:06:51 -0300 Subject: [PATCH] Upd README + changes to Pyteal for calling from deployer --- README.md | 26 +++++++++++++++++++++++++- teal/wormhole/pyteal/vaa-processor.py | 16 ++++++++++++++-- teal/wormhole/pyteal/vaa-verify.py | 16 ++++++++++++++-- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 654019c12..ee9ed29fb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ + # Pricecaster Service +## Introduction + This service consumes prices from "price fetchers" and feeds blockchain publishers. There are two basic flows implemented: * A basic Algorand publisher class with a TEAL program for messages containing signed price data. The program code validates signature and message validity, and if successful, subsequently stores the price information in the global application information for other contracts to retrieve. For the description of the data format used, see below. @@ -161,9 +164,30 @@ The exponent is stored as a byte array containing a signed, two-complement 64-bi const val = bufExp.readBigInt64BE() ``` +## Installation + +Prepare all Node packages with: + +``` +npm install +``` + +## Deployment of Applications + +Use the deployment tools in `tools` subdirectory. + +* To deploy the proof-of-concept "Pricekeeper" system, use the `deploy` tool with proper arguments, and later point the settings file to the deployed Appid. + +* To deploy the VAA processor to use with Wormhole, make sure you have Python environment running (preferably >=3.7.0), and `pyteal` installed with `pip3`. + + ## Backend Configuration -The backend will read configuration from a `settings.ts` file pointed by the `PRICECASTER_SETTINGS` environment variable. +The backend will read configuration from a `settings.ts` file pointed by the `PRICECASTER_SETTINGS` environment variable. + +## Running the system + +Check the `package.json` file for `npm run tart-xxx` automated commands. ## Tests diff --git a/teal/wormhole/pyteal/vaa-processor.py b/teal/wormhole/pyteal/vaa-processor.py index 8f589aba6..0f35cdb10 100644 --- a/teal/wormhole/pyteal/vaa-processor.py +++ b/teal/wormhole/pyteal/vaa-processor.py @@ -241,12 +241,24 @@ def clear_state_program(): if __name__ == "__main__": - with open("teal/wormhole/build/vaa-processor-approval.teal", "w") as f: + + approval_outfile = "teal/wormhole/build/vaa-processor-approval.teal" + clear_state_outfile = "teal/wormhole/build/vaa-processor-clear.teal" + + print("VAA Processor Program, (c) 2021-22 Randlabs Inc. ") + print("Compiling approval program...") + + with open(approval_outfile, "w") as f: compiled = compileTeal(vaa_processor_program(), mode=Mode.Application, version=5) f.write(compiled) - with open("teal/wormhole/build/vaa-processor-clear.teal", "w") as f: + print("Written to " + approval_outfile) + print("Compiling clear state program...") + + with open(clear_state_outfile, "w") as f: compiled = compileTeal(clear_state_program(), mode=Mode.Application, version=5) f.write(compiled) + + print("Written to " + clear_state_outfile) \ No newline at end of file diff --git a/teal/wormhole/pyteal/vaa-verify.py b/teal/wormhole/pyteal/vaa-verify.py index 18eb353e1..63dfffce5 100644 --- a/teal/wormhole/pyteal/vaa-verify.py +++ b/teal/wormhole/pyteal/vaa-verify.py @@ -20,6 +20,8 @@ from pyteal.compiler import * from pyteal.ir import * from globals import get_sig_count_in_step, get_group_size +import sys + @Subroutine(TealType.uint64) def sig_check(signatures, digest, keys): @@ -79,7 +81,17 @@ def vaa_verify_program(vaa_processor_app_id): if __name__ == "__main__": - with open("teal/wormhole/build/vaa-verify.teal", "w") as f: + + print("VAA Verify Stateless Program, (c) 2021-22 Randlabs Inc. ") + print("Compiling...") + if len(sys.argv) != 2: + print ("No appid argument provided") + exit(1) + + outfile = "teal/wormhole/build/vaa-verify.teal" + with open(outfile, "w") as f: compiled = compileTeal(vaa_verify_program( - 333), mode=Mode.Signature, version=5) + int(sys.argv[1])), mode=Mode.Signature, version=5) f.write(compiled) + + print("Written to " + outfile)