Skip to content

Instantly share code, notes, and snippets.

View tzaffi's full-sized avatar
🐙
Octopii are cool

Zeph Grunschlag tzaffi

🐙
Octopii are cool
View GitHub Profile
@tzaffi
tzaffi / wrong.md
Last active July 21, 2022 17:26
Indexer Min-Balance for Apps with Boxes Description (Wrong)

An Aside about Minimum Balance Calculation and App-Boxes

NOTE: THIS IS ALL WRONG BUT I'M KEEPING IT FOR FUTURE REFERENCE

It would be nice to solve the long-standing issue #808 and provide minimum balance information for accounts, including app-accounts. App-Boxes affect the min balance calculation for an app-account holding boxes, and as this PR introduces their basic information to indexer, it is worthwhile to consider implications of various design choices.

The New Minimum Balance Calculation

The new boxes-included min-balance calculation requires knowing:

  • the number of boxes for an app (totalBoxes)
@tzaffi
tzaffi / github.curl
Created June 17, 2022 18:59
Use the github api to figure out when people starred a particular repo
# notable query params:
# * no auth token for this public, read-only information
# * json response type
# * specialized star-info (to get fields such as `starred_at`)
# page=3 has been specified
# per_page=70 has been specified (max of 100)
curl -H "Accept: application/vnd.github.v3+json" \
-H "Accept: application/vnd.github.v3.star+json" \
"https://api.github.com/repos/algorand/pyteal/stargazers?page=3&per_page=70" | grep starred_at
@tzaffi
tzaffi / Justfile
Last active January 2, 2023 05:13
`just create_and_start` to bring up a quick network
set export
set shell := ["zsh", "-cu"]
NETWORKS := `echo $HOME` + "/networks"
# NAME := "indexerboxes"
NAME := "niftynetwork"
TEMP_NETWORK := NETWORKS + "/" + NAME
# GO_ALGORAND := "../../.."
GO_ALGORAND := ".."
NODE_TEMPLATE := GO_ALGORAND + "/test/testdata/nettemplates/OneNodeFuture.json"
@tzaffi
tzaffi / bigOne.json
Last active March 9, 2022 18:52
More Recent Dry-Run Response
{
"error": "",
"protocol-version": "future",
"txns": [
{
"app-call-messages": [
"ApprovalProgram",
"PASS"
],
"app-call-trace": [
@tzaffi
tzaffi / Makefile
Created February 3, 2022 19:11
Using AST's in Go together with git submodules to Detect Incoming Structs
# includes indexer-v-algod (cf. my json_diff gist)
nightly-setup:
cd third_party/go-algorand && git pull origin master
nightly-teardown:
git submodule update
indexer-v-algod-swagger:
pytest -sv parity
@tzaffi
tzaffi / json_diff.py
Last active February 3, 2022 19:04
YAYD - Yet Another YAML (or JSON) Differ
from collections import OrderedDict
from copy import deepcopy
import json
from typing import List, Union
L, R = "left", "right"
def deep_diff(
@tzaffi
tzaffi / monster.json
Last active January 14, 2022 20:27
Alas, poor Yorick! I knew him, Horatio.
[
{
"spin(application,application)(byte[3],byte[17],byte[17],byte[17])": [
{ "appl": "appl" },
{ "appl": "appl" },
{ "appl": "appl" }
]
},
{
"spin(application,application)(byte[3],byte[17],byte[17],byte[17])": [
@tzaffi
tzaffi / example_session.py
Created December 23, 2021 03:39
TEAL Program Diff
>>> progx = '#pragma version 5\ncallsub sub0\nint 1\nreturn\nsub0: // _impl\nint 0\nstore 0\nsub0_l1:\nload 0\nint 10\n<\nbz sub0_l3\nbyte "a"\nlog\nload 0\nint 1\n+\nstore 0\nb sub0_l1\nsub0_l3:\nretsub'
>>> progy = '#pragma version 5\ncallsub sub0\nint 1\nreturn\nsub0: // <lambda>\nint 0\nstore 0\nsub0_l1:\nload 0\nint 10\n<\nbz sub0_l3\nbyte "a"\nlog\nload 0\nint 1\n+\nstore 0\nb sub0_l1\nsub0_l3:\nretsub'
>>> td1 = TEALDiff(progx, progy)
>>> td1.assert_equals(msg=td1.first_diff())
# ... no problems ...
>>> td2 = TEALDiff(progx, progy, strip_comments=False)
>>> td2.assert_equals(td2.first_diff())
---------------------------------------------------------------------------
@tzaffi
tzaffi / OpCodePrTemplate.md
Last active December 8, 2021 02:35
Pull Request Template for OpCodes

opcode TODO List

  • Add op???() to eval.go
  • Add unit tests to eval_test.go
  • In the case of non-integer Immediate arguments:
    • Added assembleBase??? in assembler.go
    • Added dis??? in assembler.go
    • Pass the stateful test data/transactions/logic/evalStateful_test.go by providing a special TEAL sequence in the specialCmd map
    • Add enum to fields.go and modified go:generate comment
    • Ran go generate inside of data/transactions/logic to modify fields_string.go
@tzaffi
tzaffi / swapASliceInAStruct_test.go
Created November 22, 2021 15:11
Go: Faster to assign / swap slice fields in structs than parent structs
type aStruct struct {
aSlice []byte
}
func BenchmarkStructSwapping(b *testing.B) {
ssize := 500
b.Run("naive", func(b *testing.B) {
theStructs := make([]aStruct, b.N*2)
for i := 0; i < b.N; i++ {