Skip to content

Instantly share code, notes, and snippets.

🤓

Alex Beregszaszi axic

🤓
Block or report user

Report or block axic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@axic
axic / README.md
Last active Jun 1, 2019
Eth 2 Phase Crossover EE
View README.md

"Crossover" EE

The "crossover" execution environment aka Eth1-esque abstraction over Phase2

The current proposals for Eth 2 Phase 2 revolve around a purely stateless architecture, where the only stored information is the state root of each "execution environment" on a shard. This is in stark contrast to the stateful mode of operation on Eth1.

This model expects higher level abstractions to be built atop this simple system. Here follows one proposal to achieve a familiar environment as a higher level abstraction.

View qimalloc.c
/*
* QIMalloc - Quick, incremental malloc.
*
* This is a dummy malloc implementation, without the option to free memory space.
*/
static int __malloc_ptr = 0;
static int __malloc_end = 0;
void *malloc(size_t size) {
@axic
axic / Create2Proxy.sol
Created Feb 28, 2019
CREATE2 proxy for constantinople/petersburg
View Create2Proxy.sol
// CREATE2 proxy for constantinople/petersburg which allows easy deploying of
// contracts using the same address on multiple chains.
//
// Idea by @Arachnid. Some code by @axic.
pragma solidity ^0.5.0;
contract Create2Proxy {
function() external payable {
assembly {
@axic
axic / HandshakeKeys.md
Created Jan 9, 2019
Handshake - Keys and Addresses
View HandshakeKeys.md

Handshake - Keys and Addresses

DISCLAIMER: There is no warranty for any of the below be correct, up to date, or valid in any form. This is not a specification, only the braindump of some code digging. In fact it is very likely all of this is incorrect and useless. DO NOT PUT TOKENS INTO ADDRESSES GENERATED USING THE INFORMATION BELOW.

From their website:

Decentralized certificate authority and naming

An experimental peer-to-peer root DNS.

Handshake aims to "airdrop" a large quantity of the tokens to developers (backed by Github and Freenode profiles) or well known people (backed by PGP WoT).

@axic
axic / README.md
Last active Jul 17, 2019
ewasm “WRC20” token contract coding challenge
View README.md

ewasm “WRC20” token contract coding challenge

This document describes a simple contract in pseudocode and gives a couple of test cases for it.

The challenge is designed to be fairly easy to implement in a language of choice, compiled to wasm and interacted with. It is loosely based on the ERC20 token standard, named "WRC20", where the W stands for WebAssembly.

External interface

The contract has two features:

View gist:cc094cf1c339d3fbd5351687ea475cdc
eWASM and Backwards Compatibility
=================================
High Level
----------
Pros:
- ease transition: legacy EVM compatible with eWASM
Cons:
@axic
axic / ERC20SafeTransfer.sol
Last active Jan 26, 2019
Safe transfer workaround for not fully ERC20 compatible tokens.
View ERC20SafeTransfer.sol
/*
* WARNING: Proof of concept. Do not use in production. No warranty.
*
* Safe transfer workaround for not fully ERC20 compatible tokens.
* Well, ERC20 had a lot of revision, who I am to say something is not compatible :)
*
* Read the following for more explanation: https://github.com/ethereum/solidity/issues/4116
*
* In short:
* The final ERC20 standard (IIRC) requires the transfer function to return a boolean. Some tokens do not return anything
@axic
axic / contracthelper.sol
Created Apr 16, 2018
Check if a Solidity contract function is running as part of a constuctor
View contracthelper.sol
/*
* This is a helper to check if a Solidity contract function is running as part of a constructor.
*/
library ContractHelper {
function runningInConstructor() internal view returns (bool ret) {
assembly {
ret := iszero(iszero(extcodesize(address)))
}
}
}
@axic
axic / hello.bf.wast
Last active Jan 26, 2018
"Hello World" in Brainf* compiled to eWASM using https://github.com/axic/bf-compiler-webassembly/tree/ewasm
View hello.bf.wast
;; "Hello World" in Brainf* compiled to eWASM using https://github.com/axic/bf-compiler-webassembly/tree/ewasm
(module
(func $callDataCopy (import "ethereum" "callDataCopy") (param i32 i32 i32))
(func $return (import "ethereum" "return") (param i32 i32))
(global $writeptr (mut i32) (i32.const 1))
(global $readptr (mut i32) (i32.const 0))
(func $getchar
(result i32)
@axic
axic / dummymetering.wasmhex
Last active Jan 21, 2018
Dummy eWASM sentinel contract
View dummymetering.wasmhex
0061736d0100000001170560017e006000017f60037f7f7f0060027f7f0060000002580408657468657265756d06757365476173000008657468657265756d0f67657443616c6c4461746153697a65000108657468657265756d0c63616c6c44617461436f7079000208657468657265756d0672657475726e0003030201040503010001071102066d656d6f72790200046d61696e00040a25012301017f1001210042ba022000ad7e42e40080100041004100200010024100200010030b
You can’t perform that action at this time.