Skip to content

Instantly share code, notes, and snippets.

View yoshihiro503's full-sized avatar

YOSHIHIRO Imai yoshihiro503

View GitHub Profile

Preparation

mube@euler:~/gitlab/tezos/tezos-v7-release$ git log -n 1 --pretty=oneline
51977265590ba5fbd166b921e265fa22bf9f66a6 (HEAD -> v7-release, tag: v7.1, origin/v7-release, origin/latest-release) Changelog: add version 7.1 changes
mube@euler:~/gitlab/tezos/tezos-v7-release$ mkdir mockup-base-dir
mube@euler:~/gitlab/tezos/tezos-v7-release$ ./tezos-client --base-dir mockup-base-dir/ list mockup protocols
Require Import Premise.
Fixpoint hash node :=
match node with
| Bud None => zerohash
| Bud (Some n) => h 2 (hash n)
| Leaf v => h 0 (hash_of_value v)
| Internal n1 n2 => h 1 (hash n1 ^^ hash n2)
| Extender seg n => hash n ^^ seg
end.

Install

opam switch create flextesa ocaml-base-compiler.4.07.1
eval $(opam env)
opam install dune.1.11.4
opam install -y fmt cohttp-lwt-unix dum
opam install genspio ezjsonm
opam install lwt_log ptime mtime zarith json-data-encoding-bson
opam install lwt-canceler bigstring
@yoshihiro503
yoshihiro503 / metacoin.ml
Created March 13, 2020 08:37
scaml translation of the example on page 217 of the book "ブロックチェーンアプリケーション開発の教科書"
open SCaml
type balances = (address, nat) map
type storage = balances
type parameter =
| Activate
| Send of {to_ : address; amount : nat}
let activate addr (balances : balances) =

Environment

  • Tezos 28309c81c on mainnnet

Example: Add /hoge RPC API

--- a/src/lib_shell_services/p2p_services.ml
+++ b/src/lib_shell_services/p2p_services.ml
@@ -69,6 +69,13 @@ module S = struct
Require Import List.
Import ListNotations.
Lemma fst_injective : forall {A B: Type} (p1 p2: A * B),
fst p1 <> fst p2 -> p1 <> p2.
Proof.
intros A B p1 p2. destruct p1, p2. simpl. intros Ha Hp.
elim Ha. now injection Hp.
Qed.

環境

使用マシン

  • OS: Ubuntu 18.04
  • opam : 2.0.0

使用ディレクトリ

  • ~/tezos-mainnet/ : main1 のコードベース
  • ~/tezos/ : main2 開始のためのコードベース
  • /sandisk/ : 内蔵SSD 1.8 TB
@yoshihiro503
yoshihiro503 / typeerror.ml
Created January 10, 2020 09:16
An example scaml code to fail `tezos-client typecheck script`
open SCaml
type parameter = nat * unit contract * unit
type storage = nat
let main (param: parameter) (storage: storage) =
let (counter, contr, sigs) = param in
(* let counter = counter in *) (* If this line is available then the typecheck will be passed. *)
if counter <> Nat 1 then failwith "0" else
Parameter nat : Set.
Parameter int : Set.
Parameter int_plus : int -> int -> int.
Parameter int_sub : int -> int -> int.
Infix "+" := int_plus.
Infix "-" := int_sub.
Parameter nat_plus : nat -> nat -> nat.
Parameter nat_sub : nat -> nat -> nat.
open SCaml
type action =
| Transfer of {amount: tz; dest: unit contract}
| Delegate of key_hash option
| ChangeKeys of {threshold : nat; keys : key list}
type parameter =
{counter: nat; action: action; sigs : signature option list}