Use of Lotus design documents and nodes
1. Official documents
Reference: Lotus design documents
Filecoin logic sorting and source code Guide
Understand the message operation process in Lotus network
2. Noun interpretation
2.1 what does CID mean?
Self-describing content-addressed identifiers for distributed systems
Self describing content addressing identifier in distributed system
CID official document
2.2 what does StateTree mean?
Reference: Section 2.3.2 of design document
The State Tree is the output of the execution of any operation applied on the Filecoin Blockchain.
The state tree is the output of any operation implemented on the Filecoin blockchain after execution.
The on-chain (i.e., VM) state data structure is a map (in the form of a Hash Array Mapped Trie - HAMT) that binds addresses to actor states.
The on chain state data structure is a map (in the form of hash array map tree HAMT) used to bind the address to the state of the actor.
The current State Tree function is called by the VM upon every actor method invocation.
The current state tree function is called by the virtual machine when each actor method is implemented.
//lotus/chain/state/statetree. The go file defines: //StateTree stores actors state by their ID. type StateTree struct { root adt.Map version types.StateTreeVersion info cid.Cid Store cbor.IpldStore lookupIDFun func(address.Address) (address.Address, error) snaps *stateSnaps }
2.3 what does Actor mean?
Reference: Section 1.3 of design document
Actors are virtual entities embodied in the state of the Filecoin VM. Protocol actors are analogous to participants in smart contracts; an actor carries a FIL currency balance and can interact with other actors via the operations of the VM, but does not necessarily correspond to any particular node or software component.
Actor is a virtual entity embodied in the Filecoin VM state. Protocol participants are similar to participants in smart contracts. A participant has a FIL currency balance and can interact with other participants through the operation of VM, but it does not necessarily correspond to any specific node or software component.
//Lotus/chain/types/actor.go type Actor struct { // Identifies the type of actor (string coded as a CID), see `chain/actors/actors.go`. Code cid.Cid Head cid.Cid Nonce uint64 Balance BigInt//balance }
5.2,Actor
The Actor is the Filecoin equivalent of the smart contract in Ethereum.
The Actor on Filecoin is equivalent to the smart contract on Ethereum Ethereum.
An actor is an on-chain object with its own state and set of methods. An actor's state is persisted in the on-chain state tree, keyed by its address.
An Actor is an object on the chain, which has its own state and setting method. The state of the participant is persisted in the state tree on the chain, with its address as the key value. (the state of an Actor is saved in the state tree on the chain. We find the state of the Actor by using the address of the Actor as the key.)
All actors (miner actors, the storage market actor, account actors) have an address. Actor's methods are invoked by crafting messages and getting miners to include them in blocks.
All actors (miner actor, storage market actor, account Actor) have an address. Actor's method is called by creating messages and having miners include them in blocks.
There eleven (11) builtin System Actors in total in the Filecoin System.
There are a total of 11 built-in system actors in the Filecoin system.
2.4 what is the relationship between StateTree and Actor?
2.5 what does DAG mean?
2.6. What is a car file (. car)?
Content Addressable aRchives
Content addressable file
CAR official document
2.7 what is HAMT?
Document 6.2.2
See the draft IPLD hash map specfor details on implementing the HAMT used for the global state tree map and throughout the actor code.
For details, please refer to the draft IPLD hash mapping specification to implement the code of HAMT for global state tree mapping and the whole Actor.
2.8. How to understand TipSet
3. Node usage
Proof parameter path: /var/tmp/filecoin-proof-parameters chaindata route: ~/.lotus/datastore/chain 1,Generate address and view lotus wallet new bls Generated three test online wallet addresses,use lotus wallet list see: Address Balance Nonce Default t3suzgpfqm6ofdk4olqoszlyqckfkn7himxdqphn44kjcen7kilzxg2q6l4hkqpndejebmgnjglcolrnrkkgwa 0 FIL 0 t3tb2womxekgq5mha2yzgujndi5x6fy5pocsf4xjt6bldpajrc362kjqblog43hf4h5gbtwajipifiury5szwa 0 FIL 0 X t3wzcvnv7w3m7scgyzhkbxc2bgpzjk73ve6labtg323bcixn7es4f63tyvzaz5krgydqquyv7ekxm34coilrda 0 FIL 0 2,Apply for coins from faucet open VPN address t3tb2womxekgq5mha2yzgujndi5x6fy5pocsf4xjt6bldpajrc362kjqblog43hf4h5gbtwajipifiury5szwa Apply for coins from faucet send fund After: received cid bafy2bzaceaz6uet7qimrqtpkdw55vrmcwebvlmowrea52zervg4ka5rwr4zoq 3,Check the balance use balance Order balance check: lotus wallet balance t3tb2womxekgq5mha2yzgujndi5x6fy5pocsf4xjt6bldpajrc362kjqblog43hf4h5gbtwajipifiury5szwa 5000fil 4,transfer accounts root@iZ8vbfh73l8663gu8trbveZ:~# lotus send --from t3tb2womxekgq5mha2yzgujndi5x6fy5pocsf4xjt6bldpajrc362kjqblog43hf4h5gbtwajipifiury5szwa t3wzcvnv7w3m7scgyzhkbxc2bgpzjk73ve6labtg323bcixn7es4f63tyvzaz5krgydqquyv7ekxm34coilrda 3.1415 bafy2bzacecr2poxbw2xvkn2qvrkycb2ii25i3bkflejjvf3fntw7ebxiyo7iu 5,Export private key lotus wallet export t3rxcf2xuohit4it6jtymwetwfeh4u2lrcjdqnc2t5obxoeatldtj6hfk7ouoskygjgrucexjbz7szw6q7saga 7b2254797065223a22626c73222c22507269766174654b6579223a2247664c4d784f51376c594c6b4a3262397047746667456a55627430464e376a694d59386b46572f6130544d3d227d lotus wallet export t3tb2womxekgq5mha2yzgujndi5x6fy5pocsf4xjt6bldpajrc362kjqblog43hf4h5gbtwajipifiury5szwa 7b2254797065223a22626c73222c22507269766174654b6579223a2277536c4e78654632636b7256365444732b682b34794f524f30626c32716568537a6f56627255764248416b3d227d 6,Look up the data on the chain root@iZ8vbfh73l8663gu8trbveZ:~# lotus chain getblock bafy2bzacedzkpx5fbs2ioeozy4hqapxo443gq7wdutn7cogsujpfv4xh6ybes { "Miner": "t01220", "Ticket": { "VRFProof": "oVQwZUxHSME7i98vuEMkmHAPEym852OvB/JQshXpNKxfhtAGNLN3whuQe2yQIAsnCPHqngCAyvnzLoR0iNFB31bImhIKzIFkCv3M1O3j79pTxAzCgMWr+Ydk9QEiH9ZB" }, "ElectionProof": { "WinCount": 1, "VRFProof": "sQEBJ/4AB8EE4XIe/EOaaghT2dK3Y0KdmsQNHl4QhnbkSz+/uQzRqWhsjS4VOaV1Cjf5VuL49c2W0wyqh9cmmdGZ4OUpLVB6r0Ovj58BoxdR+qrx5QI49BJlTs5qHDNC" }, "BeaconEntries": [ { "Round": 831373, "Data": "ofjINvG0OKahp4rBmFUJE4YSXxFi386IlBufJTtBPqVeMxR+x4GgiztR+lQT9Y/EBozsbvi58NfArId6+5btIjW3kPahBnvyceex6bFzSV5qvdGBePMJHCvD0g77Zxbd" } ], "WinPoStProof": [ { "PoStProof": 3, "ProofBytes": "uaQUF2wsOEKr2MiE1hUOIdkQ+eaC97FsEsT0jJZWA3Tc4Iko/iXu7DXrTHUJJTgpq04yVDX4VyhRUlrMfziy53FMATF/P498t3rC1DKpABPQZP3uigKZBmmASG4wHHnuELNJUrDVMR2eUy2gyfonKQ1Bmenm2J57RFhhLPZDOSrTczVIn6fhdrX+/7o39mjVtpJ47SCDPn6xjDiOT7ZI9ABtw+tab0J6LYiLn9FABQ5bXvQuY8V1zEB8MuVQZp/E" } ], "Parents": [ { "/": "bafy2bzacedwgoam5wvghx7x5n6gjz67m3scs5xtvuvtifbgxi5mod5pdh3d2i" }, { "/": "bafy2bzacebmbrpicw3qcua4kizkajw6dvogejhcfbkp7owq7qkqjj7fgpgktk" } ], "ParentWeight": "4019853704", "Height": 219869, "ParentStateRoot": { "/": "bafy2bzacecqkaitzs4hrrmnc5qpphfukigav5tbf5tqzjoes5rgbuhb6sec2o" }, "ParentMessageReceipts": { "/": "bafy2bzacedswlcz5ddgqnyo3sak3jmhmkxashisnlpq6ujgyhe4mlobzpnhs6" }, "Messages": { "/": "bafy2bzacecmda75ovposbdateg7eyhwij65zklgyijgcjwynlklmqazpwlhba" }, "BLSAggregate": { "Type": 2, "Data": "wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" }, "Timestamp": 1620372270, "BlockSig": { "Type": 2, "Data": "kyBg94RtHPzxWWv44YBi7jihhMxa9ULEJ5sFnavS4EcZZe1kigwYjuePpeDBUD/2BUFAcIGZdSN5RC0C4h4LJrpqEDJ2ozlyqyOs5ikzNcCoiInsqpv0zxBBE1n5moHV" }, "ForkSignaling": 0, "ParentBaseFee": "100", "BlsMessages": [], "SecpkMessages": [], "ParentReceipts": null, "ParentMessages": [] } === === === === root@iZ8vbfh73l8663gu8trbveZ:~# lotus chain getblock bafy2bzacecixmekx6roukx33qhf7dck3fezsfv3hs3pnw75tqib3lmycta7ym { "Miner": "t01002", "Ticket": { "VRFProof": "he+QLexh/+oZ2w+tDdRneLCzJZ8xdU5KOcnA/nOZzv7auZC2o9I52z6Rt/Wf+rjHB3cSdjnmAxJeJjPGT5LTCSqHRiSyLtKv714dKLnrZs6KKptetWc06h35yp2TcSZd" }, "ElectionProof": { "WinCount": 2, "VRFProof": "hfxbUuCZgiLcR9ojO+TcA2Q11qmK16EJOyehhewC7hAZUZx4eM1B/TZBRAJIi/yQFLlOA2lu1YahpHHBDYH2xx9836qKHSt8rPuVHnWELYV0c7bRcMIZ0SlhAZptySej" }, "BeaconEntries": [ { "Round": 831399, "Data": "gsrC16vVY+bRcpWu92wPqPRfA5Vc9KNO4Ny1U8ZD+XhdpYPPH3gLPyTVS/k/qLhdGSXpkPn/Y72rInW1FXzQ3A8yDkSEBwvbOIX8Bnul4uLtlyV2ZIs7mCTQF/F1d32G" } ], "WinPoStProof": [ { "PoStProof": 3, "ProofBytes": "kTSCPzGC0y8BHGgCkF/LoLDBe2yWwRePmzVA729klYhMSQct36EijJacmAb+EaK1sCYWrXYMPlgPmUu0q1Ka68tyPlzBfQZ4Sgyie6X6YahXtuUMJ/ODrtDvEv90KCWHDRkEqVJJsc177iTQez6BjSRi2xxXLO/xOioLVPRJE674/14V6R2wtkC0pjRdhrwyllXuMTFOWz3FKV7xoUzkcEuTLXJ6lXCay/nuSjFA8wK4afFYSbr+U/3a2E/QOGMM" } ], "Parents": [ { "/": "bafy2bzaceaoettifgvquvngbz6ijlbr3wnefzcnwlizbm2ouh5xcqorkyvn74" }, { "/": "bafy2bzaced7antoasz4ultdcjhqbuudjaqzfmh44gjwvooup7yxfybnhqit24" } ], "ParentWeight": "4020324091", "Height": 219895, "ParentStateRoot": { "/": "bafy2bzacedr4wsubkve7yjm7tjdxdhoozig74vbqhi2cl656jsrb2gnzfnzj4" }, "ParentMessageReceipts": { "/": "bafy2bzacedswlcz5ddgqnyo3sak3jmhmkxashisnlpq6ujgyhe4mlobzpnhs6" }, "Messages": { "/": "bafy2bzacecioubc4o7f7ushan3xbkxvghcbd4ck7eodp2oe2iyxefhegygrza" }, "BLSAggregate": { "Type": 2, "Data": "rXdjE7v00eVu78ly0LAD4UwRbMQ2mbMvNGs/e7uT4bMnz+Wy+UA4DhwC4kF2C4umC3CFbpnIy/lxX6Cc83SK90snRvcFNrWuPvI1jHX1fTcaBVIIWzJox6Ia7izwCUSx" }, "Timestamp": 1620373050, "BlockSig": { "Type": 2, "Data": "sPvm3j06UgylOUEkpgK4e/lqdNbrmqKo/VMEQ+ybNY7t4JTb/p0Id/I6Rfwt6JCvFDZu3bUZD2REsNLaoer0yIFcaH469h2fUawSL4CA+kvfsEQ8sEvSfatQThk6N0ny" }, "ForkSignaling": 0, "ParentBaseFee": "100", "BlsMessages": [ { "Version": 0, "To": "t05", "From": "t3v6dlxsu26rnqrrjdenx73knuse5bsb3poiajrvcshljdwxb6pecbf55dy36lcgrtuftubmmwitc64pshio5q", "Nonce": 1880, "Value": "0", "GasLimit": 42812733, "GasFeeCap": "100273", "GasPremium": "99219", "Method": 4, "Params": "gYGCi9gqWCgAAYHiA5IgIKn7EHcSjx5Xj2ZoQZX4mVO+CcHR2WXtfHZEiQzWwlkLGUAA9FgxA6vklQoZdiZ/pY5z5WzGYqnqZdpNXdA5HgYjzCjG5iBsSImiIh57PiBkCSVagpyM+0MAxAl4NG1BVldnNUFJZzUyWkZsb1M1akUrOWtVVklGaGczM0kxc0xXZjVvYVdkQmVrb2tuVGp5b1EaAANx7BoADD+nQEYAB9xUoL5AWGECrcebdKcqVCdSbKeAX6/N+Pei25jnR1DzQWVkyzw+5kDBILopYO3algMDJt+BRazPE/nKnVqQHFLbNHwoKyIt1kRp2L0mJHlmMtzRhHv8LkVF3VzV+babLZuMZ/wtywSu", "CID": { "/": "bafy2bzacean6ykdfirj23rf5epz6f6rctummpfdg6csikxizop2gmjtotr3pq" } } ], "SecpkMessages": [], "ParentReceipts": null, "ParentMessages": [] } 7,according to cid Query transaction root@iZ8vbfh73l8663gu8trbveZ:~# lotus chain getmessage bafy2bzaceaz6uet7qimrqtpkdw55vrmcwebvlmowrea52zervg4ka5rwr4zoq { "Message": { "Version": 0, "To": "t3tb2womxekgq5mha2yzgujndi5x6fy5pocsf4xjt6bldpajrc362kjqblog43hf4h5gbtwajipifiury5szwa", "From": "t1ocoat2yl2pmu2t5i7hlssdlylbp6tp5eapetv5y", "Nonce": 5898, "Value": "5000000000000000000000", "GasLimit": 2729022, "GasFeeCap": "100812", "GasPremium": "99758", "Method": 0, "Params": null, "CID": { "/": "bafy2bzacea7clkwxhajbjq5tqvjhztnrpdtsb2hficcl4rsjwphveq36eclq2" } }, "Signature": { "Type": 1, "Data": "11/MvWQzBhBuRNRgpaApQl9Rdby/NHK+pNHsMQBC41VxszsBDVNYSVDy6K+txpfmSi6ZKxRBpprVn7zWdZUVnAE=" }, "CID": { "/": "bafy2bzaceaz6uet7qimrqtpkdw55vrmcwebvlmowrea52zervg4ka5rwr4zoq" } } === === === === root@iZ8vbfh73l8663gu8trbveZ:~# lotus chain getmessage bafy2bzacecr2poxbw2xvkn2qvrkycb2ii25i3bkflejjvf3fntw7ebxiyo7iu { "Version": 0, "To": "t3wzcvnv7w3m7scgyzhkbxc2bgpzjk73ve6labtg323bcixn7es4f63tyvzaz5krgydqquyv7ekxm34coilrda", "From": "t3tb2womxekgq5mha2yzgujndi5x6fy5pocsf4xjt6bldpajrc362kjqblog43hf4h5gbtwajipifiury5szwa", "Nonce": 0, "Value": "3141500000000000000", "GasLimit": 2657522, "GasFeeCap": "101106", "GasPremium": "100052", "Method": 0, "Params": null, "CID": { "/": "bafy2bzacecr2poxbw2xvkn2qvrkycb2ii25i3bkflejjvf3fntw7ebxiyo7iu" } } === === === === root@iZ8vbfh73l8663gu8trbveZ:~# lotus chain getmessage bafy2bzacean6ykdfirj23rf5epz6f6rctummpfdg6csikxizop2gmjtotr3pq { "Version": 0, "To": "t05", "From": "t3v6dlxsu26rnqrrjdenx73knuse5bsb3poiajrvcshljdwxb6pecbf55dy36lcgrtuftubmmwitc64pshio5q", "Nonce": 1880, "Value": "0", "GasLimit": 42812733, "GasFeeCap": "100273", "GasPremium": "99219", "Method": 4, "Params": "gYGCi9gqWCgAAYHiA5IgIKn7EHcSjx5Xj2ZoQZX4mVO+CcHR2WXtfHZEiQzWwlkLGUAA9FgxA6vklQoZdiZ/pY5z5WzGYqnqZdpNXdA5HgYjzCjG5iBsSImiIh57PiBkCSVagpyM+0MAxAl4NG1BVldnNUFJZzUyWkZsb1M1akUrOWtVVklGaGczM0kxc0xXZjVvYVdkQmVrb2tuVGp5b1EaAANx7BoADD+nQEYAB9xUoL5AWGECrcebdKcqVCdSbKeAX6/N+Pei25jnR1DzQWVkyzw+5kDBILopYO3algMDJt+BRazPE/nKnVqQHFLbNHwoKyIt1kRp2L0mJHlmMtzRhHv8LkVF3VzV+babLZuMZ/wtywSu", "CID": { "/": "bafy2bzacean6ykdfirj23rf5epz6f6rctummpfdg6csikxizop2gmjtotr3pq" } } root@iZ8vbfh73l8663gu8trbveZ:~# 8,use curl Request more information 8.1,Official example: get the latest block curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $(cat ~/.lotus/token)" \ --data '{ "jsonrpc": "2.0", "method": "Filecoin.ChainHead", "params": [], "id": 1 }' \ 'http://127.0.0.1:1234/rpc/v0' 8.2,By message cid Query message (a transaction) Input: bafy2bzacecr2poxbw2xvkn2qvrkycb2ii25i3bkflejjvf3fntw7ebxiyo7iu bafy2bzacecmda75ovposbdateg7eyhwij65zklgyijgcjwynlklmqazpwlhba curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $(cat ~/.lotus/token)" \ --data '{ "jsonrpc": "2.0", "method": "Filecoin.StateSearchMsg", "params": [{ "/": "bafy2bzacecr2poxbw2xvkn2qvrkycb2ii25i3bkflejjvf3fntw7ebxiyo7iu"}], "id": 1 }' \ 'http://127.0.0.1:1234/rpc/v0' result: {"jsonrpc":"2.0","result":{"Message":{"/":"bafy2bzacecr2poxbw2xvkn2qvrkycb2ii25i3bkflejjvf3fntw7ebxiyo7iu"},"Receipt":{"ExitCode":0,"Return":null,"GasUsed":2126018},"ReturnDec":null,"TipSet":[{"/":"bafy2bzacebttztgti4auou5k3zsguhq3iukyn7fhhlgnn753ak33qrw6cjsyg"},{"/":"bafy2bzacea6ke6xtf2odiqueomsrtbd3jat2lrbhrtfqqrpv4qfq42jqmp34m"}],"Height":219139},"id":1} 8.3,Query block set by block height( TipSet) curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $(cat ~/.lotus/token)" \ --data '{ "jsonrpc": "2.0", "method": "Filecoin.ChainGetTipSetByHeight", "params": [219139,null], "id": 1 }' \ 'http://127.0.0.1:1234/rpc/v0' result: {"jsonrpc":"2.0","result":{"Cids":[{"/":"bafy2bzacebttztgti4auou5k3zsguhq3iukyn7fhhlgnn753ak33qrw6cjsyg"},{"/":"bafy2bzacea6ke6xtf2odiqueomsrtbd3jat2lrbhrtfqqrpv4qfq42jqmp34m"}],"Blocks":[{"Miner":"t01002","Ticket":{"VRFProof":"iO/HB1JXixfwwsGLbWZVktcADmJCR0h5RO20YMekmuc/ohfiX+F+1yWFh6EoGzxiC0ZGLsJTKxN0J9z6xUm5FKF2RKFzcoOWvQk1205Wc5jzy2Ser2bG41jvm8flRZNV"},"ElectionProof":{"WinCount":2,"VRFProof":"rUPTm3ZW17zvV/1Xqis/Qj5S7asvVkdzwmQ3RAroHDzw76MnMpML506L05xVLNyrGBEGi6As/sa4R1N9YIf9SXp5Abhz+J+u2nSSFIR3uibMz2ENZmjEuuDgPT2fEgzh"},"BeaconEntries":[{"Round":830643,"Data":"l2AdE/wUm9wTx3nMHoWUNiwE2RPqOc+oTX3ob0z11K0uUsRX+NKUfkUCYmYtwgWkDeBRXYZPASFC8+oxMHp+nyVJmLvRYuylcOOdzWxBfAOrzRA9F1GZdQnrLPwwKUNK"}],"WinPoStProof":[{"PoStProof":3,"ProofBytes":"rfwDM8itmevUPI/Xear1WEwRTipz/5XLtj3h0IZYRay1NcDx6SF2HNhLMpY1D01korJaECirKt3jz3Q3vmkWL9SAwSorV7BygGCrr2brWkOxlumt1uks536Luw7oHywSDbWMfTvz6VdqrIxxcClBgKmeRCju9oIxekmiD9TKO5z4UXIOf7jyC+9YoH/Lkoq2r1o+GWkC5YnX4mQYvggwjNPUtmgkohZ9zm7TCWsS8TLlWmdMa7+BqjcCTmIQ96u2"}],"Parents":[{"/":"bafy2bzacebbkrm7yhpfhmwlmjcp2byjcnod24cpae6p4ur2z27zug6tsvfjuk"},{"/":"bafy2bzacecewcbb4m6t3aazffwlv2rik66uaycm6b6uwjxjkzqkuvqyg63svk"},{"/":"bafy2bzaceavevvmoz32navv4fw47nhm2u3l7ogqt6nme67t6qwv6r2pbyk3i2"},{"/":"bafy2bzacebfeebawuutmsyg5lm655fp5xrffofiixgmngnlbrzmyy2mrebirg"}],"ParentWeight":"4006662714","Height":219139,"ParentStateRoot":{"/":"bafy2bzaceaq6zrnh2xwypbvpkprymyqx2744nf5teaezl6b7ea3rthwji2ib4"},"ParentMessageReceipts":{"/":"bafy2bzaceaq3rlk5k6waekfjnfottdc3lq4blswd3jtgb3lzt6434nv4xidbm"},"Messages":{"/":"bafy2bzacecmda75ovposbdateg7eyhwij65zklgyijgcjwynlklmqazpwlhba"},"BLSAggregate":{"Type":2,"Data":"wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"},"Timestamp":1620350370,"BlockSig":{"Type":2,"Data":"hOG62MxgNoT+IgPKi5Iq7E38qJM6DY1rSV253dQt6ymvvwaZ7Cowzd4c4qilziFNFmOdok6eks0QcaxWJpSxZsIi3Jpb6AtDuyLQ8f9RFV8zsbzwcYYsOmkC9CmohOXk"},"ForkSignaling":0,"ParentBaseFee":"100"},{"Miner":"t01220","Ticket":{"VRFProof":"h6Z8DTSsXn3w6UEyxW6X5zrALPXg8TzRn5D+YJRy63EojmdmIjnUNvIPSwOo3aoMABk9laVWilSSSUZzrQkQkndDhTh0BVN+r1/jLkMMlETX8xLrud61crskVAW8pmq3"},"ElectionProof":{"WinCount":2,"VRFProof":"r6iyyRoycjLsvazLG+CK9fj7hJ4FidPh5uju1Au6lXz5nc/7Qb8NUlUmrDP6I5t2FC/Az51GFEOqzT3uwBfcJz9Uu3M1Y5J7Yppz6Ty2N7CBc7uFobsKEWSAMv20Kz9M"},"BeaconEntries":[{"Round":830643,"Data":"l2AdE/wUm9wTx3nMHoWUNiwE2RPqOc+oTX3ob0z11K0uUsRX+NKUfkUCYmYtwgWkDeBRXYZPASFC8+oxMHp+nyVJmLvRYuylcOOdzWxBfAOrzRA9F1GZdQnrLPwwKUNK"}],"WinPoStProof":[{"PoStProof":3,"ProofBytes":"jNO6sYCD3hI112tJJIJey98nHuBvL6e5qRmjuI7ZVPqsBXKDYV5+8TRV8TR3SscWi/va2k3fkFVU1S7fpkuicT9agZglnZMpQ2URT576xumXRIJAJPL1vcVnvI1TjROCEFqp2qF3vRgmeNKpxIXU9UROG/i2vBuH5PHLHqdMABhfVDKyLDuIGlF2WvQ82JAKtak55zvZXImieSBEqYEG/HqGscv/zdQtodRO0CVyXd6nBNtJwT99wZvUoGepzzZK"}],"Parents":[{"/":"bafy2bzacebbkrm7yhpfhmwlmjcp2byjcnod24cpae6p4ur2z27zug6tsvfjuk"},{"/":"bafy2bzacecewcbb4m6t3aazffwlv2rik66uaycm6b6uwjxjkzqkuvqyg63svk"},{"/":"bafy2bzaceavevvmoz32navv4fw47nhm2u3l7ogqt6nme67t6qwv6r2pbyk3i2"},{"/":"bafy2bzacebfeebawuutmsyg5lm655fp5xrffofiixgmngnlbrzmyy2mrebirg"}],"ParentWeight":"4006662714","Height":219139,"ParentStateRoot":{"/":"bafy2bzaceaq6zrnh2xwypbvpkprymyqx2744nf5teaezl6b7ea3rthwji2ib4"},"ParentMessageReceipts":{"/":"bafy2bzaceaq3rlk5k6waekfjnfottdc3lq4blswd3jtgb3lzt6434nv4xidbm"},"Messages":{"/":"bafy2bzacecmda75ovposbdateg7eyhwij65zklgyijgcjwynlklmqazpwlhba"},"BLSAggregate":{"Type":2,"Data":"wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"},"Timestamp":1620350370,"BlockSig":{"Type":2,"Data":"tIrJr6M8rwMZ3sZgQlwUjKJR2QPZkIe7kg+HNN7YAtYmYVXonnF1YHwIePmgKQAnGA2u6rDpRw5SoGrU/biVn6Plbe1zQBBfY4xcaPm/47PLtVc5WOG6LXiKD8zifPD9"},"ForkSignaling":0,"ParentBaseFee":"100"}],"Height":219139},"id":1} 8.4,Pass block cid Query all messages in the block?? curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $(cat ~/.lotus/token)" \ --data '{ "jsonrpc": "2.0", "method": "Filecoin.ChainGetBlockMessages", "params": [{ "/": "bafy2bzacebfeebawuutmsyg5lm655fp5xrffofiixgmngnlbrzmyy2mrebirg"}], "id": 1 }' \ 'http://127.0.0.1:1234/rpc/v0' result: {"jsonrpc":"2.0","result":{"BlsMessages":[{"Version":0,"To":"t3wzcvnv7w3m7scgyzhkbxc2bgpzjk73ve6labtg323bcixn7es4f63tyvzaz5krgydqquyv7ekxm34coilrda","From":"t3tb2womxekgq5mha2yzgujndi5x6fy5pocsf4xjt6bldpajrc362kjqblog43hf4h5gbtwajipifiury5szwa","Nonce":0,"Value":"3141500000000000000","GasLimit":2657522,"GasFeeCap":"101106","GasPremium":"100052","Method":0,"Params":null,"CID":{"/":"bafy2bzacecr2poxbw2xvkn2qvrkycb2ii25i3bkflejjvf3fntw7ebxiyo7iu"}}],"SecpkMessages":[],"Cids":[{"/":"bafy2bzacecr2poxbw2xvkn2qvrkycb2ii25i3bkflejjvf3fntw7ebxiyo7iu"}]},"id":1} update MySQL.user set authentication_string=password('root') where user='root' ;
4. filecoin data structure
//TODO
1, Command line urfave/cli
1. Quick start
Open goland and copy the following code to testcli In the go file, run go mod init and go mod tidy to pull dependencies.
package main import ( "fmt" "github.com/urfave/cli" "log" "os" ) func main() { //Instantiate a command line program oApp := cli.NewApp() //Program name oApp.Name = "GoTool" //Purpose description of the program oApp.Usage = "To save the world" //Version number of the program oApp.Version = "1.0.0" //Set multiple command processing functions oApp.Commands = []cli.Command{ { //Full name of command Name: "lang", //Command abbreviation Aliases: []string{"l"}, //Detailed description of the command Usage: "Setting language", //Command processing function Action: func(c *cli.Context) { // Through C. args () First() get command line parameters fmt.Printf("language=%v \n", c.Args().First()) }, }, { Name: "encode", Aliases: []string{"e"}, Usage: "Setting encoding", Action: func(c *cli.Context) { fmt.Printf("encoding=%v \n", c.Args().First()) }, }, } //start-up if err := oApp.Run(os.Args); err != nil { log.Fatal(err) } /* [root@localhost cli]# go run main.go l english language=english [root@localhost cli]# go run main.go e utf8 encoding=utf8 [root@localhost cli]# go run main.go help NAME: GoTool - To save the world USAGE: main [global options] command [command options] [arguments...] VERSION: 1.0.0 COMMANDS: lang, l Setting language encode, e Setting encoding help, h Shows a list of commands or help for one command GLOBAL OPTIONS: --help, -h show help --version, -v print the version */ }
Command line: go run testcli go lang English
Display result: language=English
2. Application of cli package based on Lotus source code
2.1,cli.Context passes the parameter value given in cli command line.
Action can be extracted from the through ctx.
2.2. Flag specifies the parameters of the command line.
There are two types of flags commonly used in Lotus: StringFlag and BoolFlag.
Flags: []cli.Flag{ &cli.StringFlag{ Name: "actor", Usage: "specify the address of an already created miner actor", }, //... }
2.3miner Flag:
init command:
Flags: []cli.Flag{ &cli.StringFlag{ Name: "actor", Usage: "specify the address of an already created miner actor", }, &cli.BoolFlag{ Name: "genesis-miner", Usage: "enable genesis mining (DON'T USE ON BOOTSTRAPPED NETWORK)", Hidden: true, }, &cli.BoolFlag{ Name: "create-worker-key", Usage: "create separate worker key", }, &cli.StringFlag{ Name: "worker", Aliases: []string{"w"}, Usage: "worker key to use (overrides --create-worker-key)", }, &cli.StringFlag{ Name: "owner", Aliases: []string{"o"}, Usage: "owner key to use", }, &cli.StringFlag{ Name: "sector-size", Usage: "specify sector size to use", Value: units.BytesSize(float64(policy.GetDefaultSectorSize())), }, &cli.StringSliceFlag{ Name: "pre-sealed-sectors", Usage: "specify set of presealed sectors for starting as a genesis miner", }, &cli.StringFlag{ Name: "pre-sealed-metadata", Usage: "specify the metadata file for the presealed sectors", }, &cli.BoolFlag{ Name: "nosync", Usage: "don't check full-node sync status", }, &cli.BoolFlag{ Name: "symlink-imported-sectors", Usage: "attempt to symlink to presealed sectors instead of copying them into place", }, &cli.BoolFlag{ Name: "no-local-storage", Usage: "don't use storageminer repo for sector storage", }, &cli.StringFlag{ Name: "gas-premium", Usage: "set gas premium for initialization messages in AttoFIL", Value: "0", }, &cli.StringFlag{ Name: "from", Usage: "select which address to send actor creation message from", }, },
2, Jaeger
Lotus source code in storage miner's main In go:
import "go.opencensus.io/trace" //... jaeger := tracing.SetupJaegerTracing("lotus") defer func() { if jaeger != nil { jaeger.Flush() } }()
The method here calls setup Methods in go
import "contrib.go.opencensus.io/exporter/jaeger" //... func SetupJaegerTracing(serviceName string) *jaeger.Exporter { if _, ok := os.LookupEnv("LOTUS_JAEGER"); !ok { return nil } agentEndpointURI := os.Getenv("LOTUS_JAEGER") je, err := jaeger.NewExporter(jaeger.Options{ AgentEndpoint: agentEndpointURI, ServiceName: serviceName, }) if err != nil { log.Errorw("Failed to create the Jaeger exporter", "error", err) return nil } trace.RegisterExporter(je) trace.ApplyConfig(trace.Config{ DefaultSampler: trace.AlwaysSample(), }) return je }
Question: what is Jaeger? Its function and use method?
Jaeger is a distributed call link tracking and monitoring system
This problem is complex, important but not urgent, and can be shelved for the time being.
3, Other
1. Empty object
err := gen.WriteTupleEncodersToFile("./chain/types/cbor_gen.go", "types", types.BlockHeader{}, types.Ticket{}, //... ) //What is passed in here is not a structure, but an instantiated object, which is just an empty object.