Skip to content

Instantly share code, notes, and snippets.

@s1na
s1na / keybase.md
Created May 4, 2023 14:27
Keybase proof

Keybase proof

I hereby claim:

  • I am s1na on github.
  • I am s1na (https://keybase.io/s1na) on keybase.
  • I have a public key ASBQQGpV7qMKDBDidSZPffR8nybNpISmrpKBtgad0ismhwo

To claim this, I am signing this object:

@s1na
s1na / db.go
Last active March 3, 2023 09:32
Abigen v2
// Code generated via abigen V2 - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package db
import (
"errors"
"math/big"
"github.com/ethereum/go-ethereum/accounts/abi"
@s1na
s1na / index.js
Last active February 28, 2022 17:48
Fee history computation script for GraphQL
const { request, gql } = require('graphql-request')
const ethers = require('ethers')
const assert = require('assert')
const { writeFile } = require('fs/promises')
const endpoint = 'http://localhost:8545/graphql'
async function main() {
const count = parseInt(process.argv[2])
// Latest & pending are not supported
@s1na
s1na / index.js
Last active February 11, 2022 15:04
Ethereum GraphQL JSON spec
const { request } = require('graphql-request')
const endpoint = 'http://localhost:8545/graphql'
// Taken with modifications from:
// https://github.com/graphql/graphql-js/blob/bba149cbdd122dc7278693c91e4aa90703ca7894/src/utilities/getIntrospectionQuery.ts#L66
// Notable changes:
// - Deleted directives
// - Excluded deprecated fields and args
// - Excluded subscription type (none exists in the spec)
@s1na
s1na / ops.csv
Created March 1, 2021 14:55
BLOCKHASH and DIFFICULTY occurances in blocks of Feb 2021
OpName Address
BLOCKHASH 0xd1ceeeeee83f8bcf3bedad437202b6154e9f5405
DIFFICULTY 0xa9d4be962d5e2b2331125d423fad76b1021d301f
DIFFICULTY 0x9380a66619b5f6ca17629054bfceda879db4268c
BLOCKHASH 0x0ba45a8b5d5575935b8158a88c631e9f9c95a2e5
BLOCKHASH 0xb77feddb7e627a78140a2a32cac65a49ed1dba8e
BLOCKHASH 0x5650ca3f0289c762f83dde1894faa9b6d0d89798
BLOCKHASH 0x742fcf5ba052d9912499acf208d5410ae31d49ac
BLOCKHASH 0xb6ed7644c69416d67b522e20bc294a9a9b405b31
DIFFICULTY 0x00000000000017c75025d397b91d284bbe8fc7f2
@s1na
s1na / ee.ts
Last active September 18, 2019 13:18
Turboproof EE in JS
import * as assert from 'assert'
import BN = require('bn.js')
import { keccak256 } from 'ethereumjs-util'
import { encode, decode } from 'rlp'
import { verifyMultiproof, decodeInstructions } from './multiproof'
interface TestSuite {
preStateRoot: Buffer
blockData: Buffer
}
@s1na
s1na / README.md
Created August 7, 2019 15:02
Refreshing stale MPT proofs

Background

In the context of stateless execution, a node does not need to store the full state of the blockchain and expects each transaction to come with all the necessary parts of the state and proofs for the validity of those parts.

The responsibility of attaching the proofs falls on the transaction sender or a third party who's storing the necessary parts of the trie. If a transaction doesn't make it immediately into the next block, the blockchain advances forward, modifying the state (and the state root). This causes all the proofs that were generated against a previous state root to become stale.

Simulation

This script simulates the following scenario:

@s1na
s1na / smpt-relayer.js
Created July 2, 2019 12:40
Relayer for stateless MPT-like token (scout script)
const assert = require('assert')
const { promisify } = require('util')
const BN = require('bn.js')
const Trie = require('merkle-patricia-tree')
const Account = require('ethereumjs-account').default
const StateManager = require('ethereumjs-vm/dist/state/stateManager').default
const PStateManager = require('ethereumjs-vm/dist/state/promisified').default
const { keccak256, ecsign, stripZeros } = require('ethereumjs-util')
const { encode } = require('rlp')
@s1na
s1na / Cargo.toml
Created June 14, 2019 14:28
ZoKrates -> scout stateless script
[package]
name = "zkmul"
version = "0.0.0"
license = "Apache-2.0"
repository = "https://github.com/ewasm/scout"
description = "zero knowledge multiplication"
publish = false
edition = "2018"
[lib]
@s1na
s1na / README.md
Created June 4, 2019 12:43
Hello world scout script in assemblyscript

A simple scout script which simply increments the last byte of the pre state root, and saves that as post state root.

Build

Install assemblyscript:

npm i -D AssemblyScript/assemblyscript