rinkeby deploy
問題点
これに毎度やられている。他のropstenとか使ったり、infura使っても良いんだけど、なんとか対策したい。
基本的な懸念ポイント
% truffle migrate --network rinkeby Using network 'rinkeby'. Running migration: 1_initial_migration.js Deploying Migrations... ... undefined Error encountered, bailing. Network state unknown. Review successful transactions manually. Error: insufficient funds for gas * price + value
問題はgasが足りないこと?
ただ、既存のgethtestnet上のgetBalanceもetherscan上は増えているのだけれどもcli上には反映されない。
原因っぽいところ。
WARN [08-21|17:20:35.730] Rolled back headers count=22 header=2851299->2851277 fast=2851213->2851213 block=0->0 INFO [08-21|17:20:35.735] Imported new state entries count=768 elapsed=4.430ms processed=14674025 pending=10082 retry=0 duplicate=0 unexpected=657 WARN [08-21|17:20:35.735] Synchronisation failed, dropping peer peer=eb941411bbf432b1 err="retrieved hash chain is invalid"
おそらくこのerrorが原因を表している。
例えば、今は
geth --rinkeby --rpc --rpcaddr "localhost" --rpcport "8545" --unlock="0xf90fd9c529b52e82e50b67ca3612eaad7781647b" --fast
このコマンドを起動してgethノードを立ち上げている。
--fast
は任意。
unlock="0xf90fd9c529b52e82e50b67ca3612eaad7781647b"
をしないと
truffle migrate --network rinkeby Using network 'rinkeby'. Running migration: 1_initial_migration.js Deploying Migrations... ... undefined Error encountered, bailing. Network state unknown. Review successful transactions manually. Error: authentication needed: password or unlock
こう行った風に別のエラーが出るので考えなくてはいけない。
とりあえず今解決しないといけないこと。
geth上でのtestネットアカウントのbalanceを増やすこと。
ここを解決できれば他の部分も全て解決される気がするので、解決方法を特定することが必要っぽい。
infuraでの実装
infuraでやってみたところなんの問題もなく動くっぽい?
truffle migrate --network rinkeby Using network 'rinkeby'. Running migration: 1_initial_migration.js Deploying Migrations... ... 0x308a5eb49faf41f0006b1a837953619ccd7ef396fc9a8bdeca612f43278a49e4 Migrations: 0x655213695fcb5fd1b2cfb4dd9631091c16ba3388 Saving artifacts... Running migration: 2_deploy_contracts.js Deploying TutorialToken... ... 0xc79a2db32bbfca9e098c526c6a58a19c2584e22fc2caf2dcefe7fdbea6a4bb6b TutorialToken: 0xaa09a1adcd5f4e481234c746d3a3adc37d366ace Saving artifacts...
と思いきや新しい問題に遭遇。
erc20trackerでは
errorが出てしまう。
Sorry, We were unable to locate any valid Token Transfer Events for Contract
と出てくるので
おそらくこの辺を参考にする感じかと思われる。
cf. 原因として考えられるもの
直接の原因としてあるのかはわからないが,
- デプロイの起点となっているアカウントのbalanceが0の状態でmigrateしたこと
- 操作するアカウントをtruffle compileする時に表示されたアカウントをmetamaskで操作したこと
などが少し影響しているかもしれないなあとも感じているので、
使用アカウントはコンソール上で作ったものかメタマスク上で作ったユニークなものだけを使うことにしようと感じた。
- p.s
myetherwalletやメタマスクにつなげて、トークンのやり取りをしたら表記が変わって正常に扱われるようになった。
balanceとholderの部分はあとで調整をしたい。
参考
Ethereum Clients — Ethereum Homestead 0.1 documentation
How to Import Account? · Issue #3475 · ethereum/mist · GitHub
習慣を整える(食事、睡眠、運動、開発、事業、計画、行動)
人生は短いので無駄な時間を使わないように、目標設定とそれに対してのアクションの中になるべく不純物を含まないようにきちんと仕組み作りをしたい。
今の場合は
エンジニアとして能力を高める。
- どの職場、プロジェクトでも価値を創り出せる
- 世界中どこの国に行っても価値を創り出せる
- OSSできちんと価値を創り出せる
事業家として能力を高める。
- 今の場合はblockchain技術に張っているので
- マネタイズポイントを見つける - プロトコルにキャッチアップできる技術力を持つ - アプリケーションレイヤーではプロトをすぐに作れる力を持つ - プロジェクトに関しては手元でアプリケーション、プロトコルを動かせること - etherresear.chや日本の掲示板の中でビジネス的な観点、protocolやdappsやlappsなどの技術的な観点で議論することができる - 海外の技術者と英語で技術的なコミュニケーション、日常会話を円滑に行える。 - キャッシュフローを構築し、サステイナブルに運用し、そのキャッシュをR&Dに回してさらなる技術革新をうめる仕組みを作る。 - 英語でビジネス交渉ができる - ベーシックなwebビジネス、C to C、B to BやB to C、O to Oのような今までのビジネスのB/S, P/L, cashフローをきちんと見れる
- 今まで掲げてきたの中で、状況に応じて優先順位を立て、明確なkgi/kpi/kdi/todoとそれを振り返るkpt/okrなどの設計をして、PDCAを一回でも多く高速で回すこと。
- やるべきコアポイントに集中して、やる必要のないことを一つでも多く切り捨てること
- 命を削って、全力でコミットすること。質より量を意識して、最低レベルの量的目標、最低レベルのインプットとアウトプットをしてから思考に入ること
- あらゆることは言葉より行動で示すこと
- 今の場合はblockchain技術に張っているので
意識的に取り込みたいのは、技術向上、事業選定とマネタイズモデルの設計、定常的なキャッシュフローの構築と長期的な意味での本質的価値、健康管理のためのジム(食事、睡眠、運動)、あとは英語(reading/listening/writing/speaking全て)。
基本的には、今日で自分の人生が終わるつもりでコミットして、人生が永遠に続くつもりで人に対しては関わるようにする。
day1:EIP1,100,101
ethtereumのプロトコル改良提案書。 これから定期的に読んでいこうと思う。
EIP1: EIP Purpose and Guidelines
Rationale:EIPsの決定のためのworkflowや意思決定者に関して書かれたもの
EIP100: Change difficulty adjustment to target mean block time including uncles difficultyの公式変更
Rationale:This new formula ensures that the difficulty adjustment algorithm targets a constant average rate of blocks produced including uncles, and so ensures a highly predictable issuance rate that cannot be manipulated upward by manipulating the uncle rate. A formula that accounts for the exact number of included uncles:
EIP101: Serenity Currency and Crypto Abstraction
Rationale This allows for a large increase in generality, particularly in a few areas: Cryptographic algorithms used to secure accounts (we could reasonably say that Ethereum is quantum-safe, as one is perfectly free to secure one's account with Lamport signatures). The nonce-incrementing approach is now also open to revision on the part of account holders, allowing for experimentation in k-parallelizable nonce techniques, UTXO schemes, etc. Moving ether up a level of abstraction, with the particular benefit of allowing ether and sub-tokens to be treated similarly by contracts Reducing the level of indirection required for custom-policy accounts such as multisigs It also substantially simplifies and purifies the underlying Ethereum protocol, reducing the minimal consensus implementation complexity.
ipfs
fileをipfsにadd
% ipfs add -r ipfs-test added QmU6psGKi96BE3XWSHpYsiiCNj9GK6686YrC1rUxvRi9g4 ipfs-test/test.jpg added QmQzsxYVNK3Nhg2A5Zx94hStZXy2ZBdJZg3rF3M3JJRyEC ipfs-test 5.78 KiB / 5.87 KiB [=======================================================] 98.40%
p2pネットワークに繋げて外部公開
% ipfs daemon Initializing daemon... Successfully raised file descriptor limit to 2048. Swarm listening on /ip4/10.200.2.190/tcp/4001 Swarm listening on /ip4/127.0.0.1/tcp/4001 Swarm listening on /ip6/::1/tcp/4001 Swarm listening on /p2p-circuit/ipfs/hash値 Swarm announcing /ip4/10.200.2.190/tcp/4001 Swarm announcing /ip4/127.0.0.1/tcp/4001 Swarm announcing /ip6/::1/tcp/4001 API server listening on /ip4/127.0.0.1/tcp/5001 Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080 Daemon is ready ここで //[https://gateway.ipfs.io/ipfs/:title]でアクセスできる
IPNSにpublish
編集するたびにハッシュ値が変わるので $ ipfs name publish <元のhash値> Published to <元のhash値>: /ipfs/<新しいhash値>
編集作業の時は add/daemon/publishを繰り返す
help
USAGE ipfs - Global p2p merkle-dag filesystem. ipfs [--config=<config> | -c] [--debug=<debug> | -D] [--help=<help>] [-h=<h>] [--local=<local> | -L] [--api=<api>] <command> ... SUBCOMMANDS BASIC COMMANDS init Initialize ipfs local configuration add <path> Add a file to IPFS cat <ref> Show IPFS object data get <ref> Download IPFS objects ls <ref> List links from an object refs <ref> List hashes of links from an object DATA STRUCTURE COMMANDS block Interact with raw blocks in the datastore object Interact with raw dag nodes files Interact with objects as if they were a unix filesystem dag Interact with IPLD documents (experimental) ADVANCED COMMANDS daemon Start a long-running daemon process mount Mount an IPFS read-only mountpoint resolve Resolve any type of name name Publish and resolve IPNS names key Create and list IPNS name keypairs dns Resolve DNS links pin Pin objects to local storage repo Manipulate the IPFS repository stats Various operational stats p2p Libp2p stream mounting filestore Manage the filestore (experimental) NETWORK COMMANDS id Show info about IPFS peers bootstrap Add or remove bootstrap peers swarm Manage connections to the p2p network dht Query the DHT for values or peers ping Measure the latency of a connection diag Print diagnostics TOOL COMMANDS config Manage configuration version Show ipfs version information update Download and apply go-ipfs updates commands List all available commands Use 'ipfs <command> --help' to learn more about each command. ipfs uses a repository in the local file system. By default, the repo is located at ~/.ipfs. To change the repo location, set the $IPFS_PATH environment variable: export IPFS_PATH=/path/to/ipfsrepo EXIT STATUS The CLI will exit with one of the following values: 0 Successful execution. 1 Failed executions.
geth: private netでのaccount作成、ノード起動、アカウント間送金
genesis fileを初期化
% geth --datadir ~/eth_private_net init ~/eth_private_net/myGenesis.json INFO [08-20|15:07:30.950] Maximum peer count ETH=25 LES=0 total=25 INFO [08-20|15:07:30.957] Allocated cache and file handles database=/Users/---/eth_private_net/geth/chaindata cache=16 handles=16 INFO [08-20|15:07:30.964] Writing custom genesis block INFO [08-20|15:07:30.965] Persisted trie from memory database nodes=0 size=0.00B time=389.117µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B INFO [08-20|15:07:30.965] Successfully wrote genesis state database=chaindata hash=7b2e8b…7e0432 INFO [08-20|15:07:30.965] Allocated cache and file handles database=/Users/----/eth_private_net/geth/lightchaindata cache=16 handles=16 INFO [08-20|15:07:30.968] Writing custom genesis block INFO [08-20|15:07:30.968] Persisted trie from memory database nodes=0 size=0.00B time=1.699µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B INFO [08-20|15:07:30.968] Successfully wrote genesis state database=lightchaindata hash=7b2e8b…7e0432
node起動コマンド
geth --networkid "1515" --nodiscover --datadir "~/eth_private_net" console 2>> ~/eth_private_net/geth_err.log Welcome to the Geth JavaScript console! instance: Geth/v1.8.13-stable/darwin-amd64/go1.10.3 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
アカウント作成とmining start/stop
> eth.accounts [] > personal.newAccount("<password>") "0x69f74bfd79fbd227362be370ffc457096275a7e2" > eth.account undefined > eth.accounts ["0x69f74bfd79fbd227362be370ffc457096275a7e2"] > personal.newAccount("password") "0xeaf421b7d87e68954ea194242e86ce1e99472c60" > eth.accounts ["0x69f74bfd79fbd227362be370ffc457096275a7e2", "0xeaf421b7d87e68954ea194242e86ce1e99472c60"] > eth.coinbase "0x69f74bfd79fbd227362be370ffc457096275a7e2" > miner.start() null > eth.blockNumber 0 > eth.blockNumber 18 > eth.mining true > miner.stop() true > eth.getBalance(eth.accounts[1]) 0 > eth.getBalance(eth.accounts[0]) 140000000000000000000 > web3.fromWei(eth.getBalance(eth.accounts[1]),"ether") 0 > web3.fromWei(eth.getBalance(eth.accounts[0]),"ether") 140 > eth.accounts ["0x69f74bfd79fbd227362be370ffc457096275a7e2", "0xeaf421b7d87e68954ea194242e86ce1e99472c60"]
accountアンロックとアカウント間送金
### account unlock #### 初期化 初回のみ 18000sアカウントを解除 personal.unlockAccount("account","<YOUR_PASSPHRASE>", 18000) ### account balance確認 > eth.getBalance(eth.accounts[0]) 140000000000000000000 > eth.getBalance(eth.accounts[1]) 0 #### account間での送金 > eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value:web3.toWei(5,"ether")}) "0x75de0968b0dc4a4598b45f0a7e454d6720ef6e10d928b6457d4ca35ac169ef05" //ここでminingされないとtxがblockに入ったのを自分のアカウントの変化に反映できないので、 > miner.start() null > eth.blockNumber 0 > eth.blockNumber 18 > eth.mining true // miningできているときはここが`true`。miningが止まってるときは`false` 。 確認するときは、`eth.mining`/`eth.hashrate`などで確認する。 > eth.getBalance(eth.accounts[0]) 195000000000000000000 //miningしたのでちょっと増えてる。 もともとbalanceが0だった`eth.accounts[1]`も > eth.getBalance(eth.accounts[1]) 5000000000000000000 //miningすることによって、きちんと送金処理が完了
miningしている様子(privatenet)
% tail -f geth_err.log INFO [08-20|15:08:12.112] Disk storage enabled for ethash caches dir=/Users/---/eth_private_net/geth/ethash count=3 INFO [08-20|15:08:12.112] Disk storage enabled for ethash DAGs dir=/Users/---/.ethash count=2 INFO [08-20|15:08:12.112] Initialising Ethereum protocol versions="[63 62]" network=1515 INFO [08-20|15:08:12.113] Loaded most recent local header number=0 hash=7b2e8b…7e0432 td=16384 INFO [08-20|15:08:12.113] Loaded most recent local full block number=0 hash=7b2e8b…7e0432 td=16384 INFO [08-20|15:08:12.113] Loaded most recent local fast block number=0 hash=7b2e8b…7e0432 td=16384 INFO [08-20|15:08:12.114] Regenerated local transaction journal transactions=0 accounts=0 INFO [08-20|15:08:12.116] Starting P2P networking INFO [08-20|15:08:12.117] RLPx listener up self="enode://42bf0b1200deb53b98338ee313a40b514ed2d134297a9657b9e7009247a2ba16d2ca956cd850c67bea9ac78bda66d7bdb6de075c1fbec486880835168c232d31@[::]:30303?discport=0" INFO [08-20|15:08:12.120] IPC endpoint opened url=/Users/---/eth_private_net/geth.ipc INFO [08-20|15:09:53.140] IPC endpoint closed endpoint=/Users/---/eth_private_net/geth.ipc INFO [08-20|15:09:53.141] Blockchain manager stopped INFO [08-20|15:09:53.141] Stopping Ethereum protocol INFO [08-20|15:09:53.141] Ethereum protocol stopped INFO [08-20|15:09:53.141] Transaction pool stopped INFO [08-20|15:09:53.142] Database closed database=/Users/---/eth_private_net/geth/chaindata INFO [08-20|15:09:55.063] Maximum peer count ETH=25 LES=0 total=25 INFO [08-20|15:09:55.070] Starting peer-to-peer node instance=Geth/v1.8.13-stable/darwin-amd64/go1.10.3 INFO [08-20|15:09:55.070] Allocated cache and file handles database=/Users/---/eth_private_net/geth/chaindata cache=768 handles=128 INFO [08-20|15:09:55.084] Initialised chain configuration config="{ChainID: 1515 Homestead: <nil> DAO: <nil> DAOSupport: false EIP150: <nil> EIP155: <nil> EIP158: <nil> Byzantium: <nil> Constantinople: <nil> Engine: unknown}" INFO [08-20|15:09:55.084] Disk storage enabled for ethash caches dir=/Users/---/eth_private_net/geth/ethash count=3 INFO [08-20|15:09:55.084] Disk storage enabled for ethash DAGs dir=/Users/---/.ethash count=2 INFO [08-20|15:09:55.084] Initialising Ethereum protocol versions="[63 62]" network=1515 INFO [08-20|15:09:55.085] Loaded most recent local header number=0 hash=7b2e8b…7e0432 td=16384 INFO [08-20|15:09:55.085] Loaded most recent local full block number=0 hash=7b2e8b…7e0432 td=16384 INFO [08-20|15:09:55.085] Loaded most recent local fast block number=0 hash=7b2e8b…7e0432 td=16384 INFO [08-20|15:09:55.086] Loaded local transaction journal transactions=0 dropped=0 INFO [08-20|15:09:55.086] Regenerated local transaction journal transactions=0 accounts=0 INFO [08-20|15:09:55.087] Starting P2P networking INFO [08-20|15:09:55.088] RLPx listener up self="enode://42bf0b1200deb53b98338ee313a40b514ed2d134297a9657b9e7009247a2ba16d2ca956cd850c67bea9ac78bda66d7bdb6de075c1fbec486880835168c232d31@[::]:30303?discport=0" INFO [08-20|15:09:55.090] IPC endpoint opened url=/Users/---/eth_private_net/geth.ipc INFO [08-20|15:11:04.161] Etherbase automatically configured address=0x69F74BFD79fbD227362BE370Ffc457096275a7e2 INFO [08-20|15:11:08.930] Updated mining threads threads=0 INFO [08-20|15:11:08.930] Transaction pool price threshold updated price=18000000000 INFO [08-20|15:11:08.930] Starting mining operation INFO [08-20|15:11:08.932] Commit new mining work number=1 txs=0 uncles=0 elapsed=1.350ms INFO [08-20|15:11:14.158] Successfully sealed new block number=1 hash=44b46b…cbf3bf INFO [08-20|15:11:14.163] 🔨 mined potential block number=1 hash=44b46b…cbf3bf INFO [08-20|15:11:14.166] Commit new mining work number=2 txs=0 uncles=0 elapsed=2.434ms INFO [08-20|15:11:14.315] Successfully sealed new block number=2 hash=0ae50d…dc42a6 INFO [08-20|15:11:14.315] 🔨 mined potential block number=2 hash=0ae50d…dc42a6 INFO [08-20|15:11:14.316] Commit new mining work number=3 txs=0 uncles=0 elapsed=276.959µs INFO [08-20|15:11:14.561] Successfully sealed new block number=3 hash=25c5c1…a3edca INFO [08-20|15:11:14.562] 🔨 mined potential block number=3 hash=25c5c1…a3edca INFO [08-20|15:11:14.562] Mining too far in the future wait=2s INFO [08-20|15:11:16.565] Commit new mining work number=4 txs=0 uncles=0 elapsed=2.003s INFO [08-20|15:11:16.980] Successfully sealed new block number=4 hash=5ab0ed…43851a
node情報を管理
nodeのconfigデータを管理するのに参考にした。
- cf: .gitignore(vagrantfileと.gitignoreを管理するときにやるやり方)
/* !config !.gitignore !Vagrantfile .DS_store *~
mining/geth/開発環境
今日は基本的にはtestnet上でのgethの調整をしていた。
反省点
- 開発始める前の時点で明確な完成像がぼやけていた気もする。
- kpiが以前に比べて不明確。
- 目標設定の具体化と定期的な振り返りのタイミングを明確化した方が良いなと感じた。kgi/kpi/kdi/todoとpdcaを複数年、年次、四半期、月次、週次、日毎に見返すために大枠をしっかりと形作り直した方が良い気もした。
- わかっていると思っているようなことでも、いざコードレベルで分析をしたり、実際に実装をしてみると理解のぼやけてるポイントがわかってきたりする。関連している事柄の何が重要な意味を持っているのかもわかるようになる。
geth
今日はgethを結構触っていた。deploy時のgas不足を多く指摘されていた。また、miningの同期がしっくりいくときといかない時があるので、その部分の解像度をあげる努力をした方が良いなとも感じた。
見るところ
- gas不足
- security
- 一つ一つのwordの意味
- go-etherのレポジトリとsled
parity
parityに関してはerrorが出るのはいつも同じところで
このparity signer:pending
というところ。parityもpolkadotへの事も考えて深く調べていきたい。また、チェーンの同期自体はこちらの方が早いので、gethやinfuraとの特性も深掘りしつつ、それぞれを実装している中で使い分けていきたい。
vyper
vyperに関しては、まだ発展途上な感は否めないが、一応コントラクトの実装例などもあるのでpythonベースという事で触っていきたい。
全体の開発
- nodeの同期のことも考えてクラウド(aws)などでチェーン同期することを検討したい。プライベート、テストネットくらいなら良いが、メインネットくらいになってくると結構きつい
- コンテナ化するかとか、macos、linux上で開発するかなど考える。gaeベースでインフラを構築しつつ、web部分はpython(django)かruby(rails)でサーバーサイドで作って、データもs3とかで持たせておく?gcsとかでも良いかも。また、コンテナ化することを考えてdockerfileでまとめておくか、vagrantでbox単位で管理するか、gkeで全てgcp上で管理するかなども考えても良いかもしれない。
- contractの発行や検証に関しては、vimやatomのようなeditorよりもremixの方が良いので、細かい作業はbrowser-solidityでやる。そのため接続手順を復習。
- コードを多めにかく場合はatomやvimでかく。
- 全体のアーキテクチャーテンプレート(基本形)は自分の中で作っておく。
やること
アーキテクチャーに関して
基本的なwebサービスと比べて、blockchainで実装されたDappsも自分の理解ではコントラクト部分以外のクライアント、サーバーサイドやデータの持たせ方などはwebと変わらないので、基本的にアプリケーション自体に幅を持たせるのはweb developmentとそこまで変わらないなあと思った。
ただ、その場合、dappsを量産させたり、早く実装させるためにはコントラクトの部分以外は変わらないので満遍なくやれる方が良いなという考え方であることにはまちがいない。
一方で、限られた時間的リソースをどこに注入するべきかと考えたときに、プロトコルレイヤー、コントラクトやapi呼び込みや関連開発ツールをossベースで追っていきつつ、長期的にプロトコル開発と同時並行で自分のdapps?、もしくはトークン設計や、コントラクトの特性を活かしたアーキテクチャを深く考えて実装した方が良いかもしれないなとも感じてきた。
いずれにせよ、アウトプット→思考という流れには変わりはないんだけれども、良いdappsを作れるようにという考え方よりはプロトコルや、どんな意味をもたらすのか、アプリケーションレイヤーよりもっと低レイヤーのところでこれからどんなアプリケーションが乗っかっていってどのような価値を生み出すのか。どういったところが他のプロトコルとの差別化要素なのか。どうしてこのプロトコルをみんな使うのか。何がバイラル要素なのか。ということを考えながら開発を進めていった方が賢い。
理由は簡単で、みんなが理解できないけど、本当に意味のあるものを作った方が、ファストファッション競争みたいな無駄な戦をせずに、価値に気付いた時にはそれを作り出したプロセスの理解もなく、ナレッジの蓄積もないので他の人たちの戦意喪失させつつ、競争に巻き込まれないで自分の本当に取り組むべきプロダクト開発、事業推進に集中することができるからと思った。
現状は、dapps開発にはcontract以外の多くのweb開発要素、分散化してない部分が多く影響している。ただ、開発が進むにつれて、データの持たせ方はipfsやswarmのように非分散化していくし、eosの上に全てのアプリケーションが乗っかっていったり、cosmos sdkの上にアプリケーションを実装していく世界観も見えていくし、polkadotのように全てがつながりあう世界観も見えていくので、長期的にどういった要素が必要になりうるのかということをきちんと自分の頭で考えつつ、手を動かしながら、みんなが盛り上がっている部分よりも本質的な価値にのみ目をむけつつ開発を進めていきたいなと思った。