Skip to content

Instantly share code, notes, and snippets.

@Aderks
Last active October 20, 2020 12:49
Show Gist options
  • Save Aderks/2b46e5005d9a6885c429d16e9d24c38f to your computer and use it in GitHub Desktop.
Save Aderks/2b46e5005d9a6885c429d16e9d24c38f to your computer and use it in GitHub Desktop.

Agora


Sanitized Log Files .jsonl (or your own log from qlog) conversion to single tree-buf file

  • Download the sanitized logs from the indexer announcement (https://storage.googleapis.com/sanitized-queries/sanitized-queries.zip)

  • Pull the log you wish to use

    • Eg: QmTN6gMCBCYTgbis33eSvr6sLsQoQ3R6a2KzR7CqmMABQP.jsonl will be put inside the /target/release/ directory
  • Type: ./agora --load-log ./QmTN6gMCBCYTgbis33eSvr6sLsQoQ3R6a2KzR7CqmMABQP.jsonl --sample 0.1 --save-log ./logs.treebuf

Output:

Starting 381 queries at 4.944297ms
Finished at 5.052399ms
  • You should now have your logs.treebuf file

Cost Model Simulation

  • Create a globals.json file and have the text {} inside it

  • Create a cost-model.agora file, leave it blank for now

  • Type: ./agora --load-log ./logs.treebuf --globals ./globals.json --grt-per-effort 1000 --cost ./cost-model.agora

  • With a blank cost-model.agora you should see:

Starting 99964 queries at 185.403524ms
Finished at 6.774381081s
Successes: 0 queries
Total Value: 0 GRT

Failures: 99,964
	"Query not costed" count: 99,964 total_grt: 9,847,227,000
		{ bundles(where: {id: 5}, block: {number: 38296}) { id ethPrice } }  | variables: 
		{ bundles(where: {id: 8}, block: {number: 46874}) { id ethPrice } }  | variables: 
		{ bundles(where: {id: 0}, block: {number: 6958870}) { id ethPrice } }  | variables: 
		{ bundles(where: {id: 11}, block: {number: 637129}) { id ethPrice } }  | variables: 
  • If you add default => 1; to the cost-model.agora file and re-run the simulation you should see:
Starting 99964 queries at 179.699946ms
Finished at 6.930190051s
Successes: 99,964 queries
Total Value: 571,842 GRT
Total Err: -9,846,655,158 GRT. (-98,502 GRT per query)
Mean Squared Err: 242,846,134,330 GRT²

Failures: 0
  • If you remove the default line and add a query line from one of the failures to the cost-model.agora file you should start to see some successful querys and new failures:
    • query { bundles(where: {id: $id}, block: {number: $number}) { id ethPrice } } => 1;
      • Re-run simulation will show 46 successful queries
      • Add new query ... => 1; lines if needed
Starting 99964 queries at 162.453846ms
Finished at 7.468327962s
Successes: 46 queries
Total Value: 46 GRT
Total Err: -382,954 GRT. (-8,325 GRT per query)
Mean Squared Err: 277,526,827 GRT²

Failures: 99,918
	"Query not costed" count: 99,918 total_grt: 9,846,844,000
		{ pairs(where: {id: "b1fd378a6c78179ec9584fa2"}) { id token1Price } }  | variables: 
		{ pairs(where: {id: "cf1ab14fea7d9005579756eb"}) { id token1Price } }  | variables: 
		{ token(id: "c0a9c5894737442184d0887b") { id name symbol decimals } }  | variables: 
		{ transactions(where: {id: "a0da18e7d106cc3c54007152"}) { mints { id } } }  | variables: 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment