Ethereum Simulator Node

tags: Ethereum Simulator Only use the data of the mainnet to simulate transaction, and DONOT commit the final transaction to the mainnet. Relay To identify our transactions that need to simulate, if it’s failed then drop that tx, otherwise commit the final transaction to the mainnet. Things need to consider: How to limit or identify transactions that need to simulate? Only execute the transactions from local txpool. Where to execute the transction previously? ...

June 12, 2023 · 1 min · Gray King

How to Write a Technical Article

tags: Essay Writing Guide List outlines Explore the resources and documentation to understand Taking notes during the exploring Use the method of How to Take Smart Notes

June 8, 2023 · 1 min · Gray King

English Words

tags: Learning English, Journal

June 8, 2023 · 1 min · Gray King

Journal

June 8, 2023 · 0 min · Gray King

coherent

tags: English Words Adjective (of an argument , theory, or policy) logical and consistent: they failed to develop a coherent economic strategy. united as or forming a whole: divided into a number of geographically coherent kingdoms. Physics (of waves) having a constant phase relationship.

June 8, 2023 · 1 min · Gray King

Essay Writing Guide

source: https://jordanbpeterson.com/wp-content/uploads/2018/02/Essay_Writing_Guide.docx tags: How to Write PART I: INTRODUCTION Why are we need to learn how to write an essay? Writing an essay is to think by writing, formulate and organize ideas. Writing an essay is also to learn or explore a new topic. How to get things done? If you don’t have a big chunk of time in your daily life, then don’t relay your success on it, take 15 minutes every day is still powerful: 「日拱一卒,功不唐捐」. ...

June 8, 2023 · 2 min · Gray King

PostgresQL autovacuum & ANALYZE

tags: PostgresQL Recently, I met a problem in PostgresQL: the index mismatched after batch rows inserted. Run ANALYZE on the table solved this problem after batch rows inerted. Turns out autovacuum has been disabled on the PostgresQL instance: show autovacuum_analyze_scale_factor; show autovacuum_analyze_threshold ; SELECT * FROM pg_settings WHERE name LIKE '%autovacuum%';

May 29, 2023 · 1 min · Gray King

Met Eddie

tags: On The Road https://www.google.com/maps/dir/New+York/Joliet/Rock+Island,+IL/Rapids+City,+IL/Des+Moines,+IA/Adel,+Iowa/Stuart,+Iowa/Council+Bluffs,+Iowa/Omaha,+NE/Grand+Island,+NE/@40.7489186,-96.7492412,5z/data=!3m1!4b1!4m62!4m61!1m5!1m1!1s0x89c24fa5d33f083b:0xc80b8f06e177fe62!2m2!1d-74.0059728!2d40.7127753!1m5!1m1!1s0x880e456bec363d7d:0x9f9e66f7a36bc042!2m2!1d-88.0817251!2d41.525031!1m5!1m1!1s0x87e232c357044b77:0xecc19371d71475f1!2m2!1d-90.5787476!2d41.5094771!1m5!1m1!1s0x87e23f0ad2e7aeb3:0x43aab678fe9e328d!2m2!1d-90.3434615!2d41.5817!1m5!1m1!1s0x87ee99a4c1611ee7:0x710028512691e4b2!2m2!1d-93.6249593!2d41.5868353!1m5!1m1!1s0x87ec39285c3540b9:0x84581d5d4142c1ec!2m2!1d-94.017453!2d41.6144325!1m5!1m1!1s0x87ec60c99a9a7d0f:0xb0c00a66d8103978!2m2!1d-94.3183715!2d41.5034243!1m5!1m1!1s0x879381cfa109322f:0xbe4e81fa5222799e!2m2!1d-95.8608333!2d41.2619444!1m5!1m1!1s0x87938dc8b50cfced:0x46424d4fae37b604!2m2!1d-95.9345034!2d41.2565369!1m5!1m1!1s0x87998644ec7765f7:0xa12d5b784951b17b!2m2!1d-98.3420118!2d40.9263957!3e0

May 8, 2023 · 1 min · Gray King

On The Road

May 8, 2023 · 0 min · Gray King

Emacs on Macos: Too Many Files Open

tags: Emacs, macOS source: Simon, Ben. “Gotcha: Emacs on Mac OS: Too Many Files Open.” Accessed April 18, 2023. https://www.blogbyben.com/2022/05/gotcha-emacs-on-mac-os-too-many-files.html. Add below code snippet to your init.el: (defun file-notify-rm-all-watches () "Remove all existing file notification watches from Emacs." (interactive) (maphash (lambda (key _value) (file-notify-rm-watch key)) file-notify-descriptors)) Then just execute M-x file-notify-rm-all-watches when you meet this problem next time.

April 18, 2023 · 1 min · Gray King

NLTK Data

tags: AI Clone nltk_data git clone https://github.com/nltk/nltk_data.git ~/.local/nltk_data Link nltk_data ln -sf ~/.local/nltk_data/packages ~/nltk_data Unzip cd ~/nltk_data/path unzip xx.zip

April 18, 2023 · 1 min · Gray King

Bash

tags: Linux

April 17, 2023 · 1 min · Gray King

Bash scripting cheatsheet

tags: Cheatsheet, Bash source: Devhints.io cheatsheets. “Bash Scripting Cheatsheet.” Accessed April 17, 2023. https://devhints.io/bash.

April 17, 2023 · 1 min · Gray King

Searchable Linux Syscall Table for x86 and x86_64

tags: Cheatsheet, Linux source: “Searchable Linux Syscall Table for X86 and X86_64 | PyTux.” Accessed April 17, 2023. https://filippo.io/linux-syscall-table/.

April 17, 2023 · 1 min · Gray King

Starcoin Signing Message

tags: Starcoin Web3 StarTrek, Sign Message Invocation Path Dapp request personal_sign1 const msg = `0x${Buffer.from(exampleMessage, 'utf8').toString('hex')}` console.log({ msg }) const networkId = networkDiv.innerHTML const extraParams = { networkId } const sign = await window.starcoin.request({ method: 'personal_sign', // params: [msg, from, 'Example password'], // extraParams = params[2] || {}; means it should be an object: // params: [msg, from, { pwd: 'Example password' }], params: [msg, from, extraParams], }) Starmask handling request signPersonalMessage keyringController.signPersonalMessage(cleanMsgParams) 2 , 3 3 types of keyring:4 SimpleKeyring.signPersonalMessage HdKeyring.signPersonalMessage HdKeyringAptos.signPersonalMessage utils.signedMessage.generateSignedMessage5 ...

April 12, 2023 · 2 min · Gray King

pyenv

tags: Python

April 11, 2023 · 1 min · Gray King

Speedup Python Installation of pyenv

tags: Python, pyenv export PYTHON_BUILD_MIRROR_URL_SKIP_CHECKSUM=1 export PYTHON_BUILD_MIRROR_URL="https://mirrors.huaweicloud.com/python/"

April 11, 2023 · 1 min · Gray King

Aptos Signing Message

tags: Sign Message The starmask has implemented about signing message of APTOS.

April 11, 2023 · 1 min · Gray King

Pyright Type Stubs

tags: Python, LSP source: https://emacs-lsp.github.io/lsp-pyright/#usage-notes Download Default Type Stubs git clone https://github.com/microsoft/python-type-stubs $HOME/.local/src/python-type-stubs Use it in Emacs (setq lsp-pyright-stub-path (concat (getenv "HOME") "/.local//src/python-type-stubs")) ;; example Add Django Type Stubs git clone git@github.com:typeddjango/django-stubs.git ~/.local/src/django-stubs ln -sf ~/.local/src/django-stubs/django-stubs ~/.local/src/python-type-stubs/django Add Celery Type Stubs git clone https://github.com/sbdchd/celery-types ~/.local/src/celery-types ln -sf ~/.local/src/celery-types/amqp-stubs ~/.local/src/python-type-stubs/amqp ln -sf ~/.local/src/celery-types/billiard-stubs ~/.local/src/python-type-stubs/billiard ln -sf ~/.local/src/celery-types/celery-stubs ~/.local/src/python-type-stubs/celery ln -sf ~/.local/src/celery-types/django_celery_results-stubs ~/.local/src/python-type-stubs/django_celery_results ln -sf ~/.local/src/celery-types/ephem-stubs ~/.local/src/python-type-stubs/ephem ln -sf ~/.local/src/celery-types/kombu-stubs ~/.local/src/python-type-stubs/kombu ln -sf ~/.local/src/celery-types/vine-stubs ~/.local/src/python-type-stubs/vine

April 10, 2023 · 1 min · Gray King

jemalloc

tags: Memory Management, Heap Fragmentation

April 7, 2023 · 1 min · Gray King

Memory Management

tags: Memory Model

April 7, 2023 · 1 min · Gray King

Heap Fragmentation

tags: Memory Management

April 7, 2023 · 1 min · Gray King

Spotting and Avoiding Heap Fragmentation in Rust Applications

tags: Heap Fragmentation, jemalloc source:Svix Blog. “Spotting and Avoiding Heap Fragmentation in Rust Applications,” April 4, 2023. https://www.svix.com/blog/heap-fragmentation-in-rust-applications/. Heap fragmentation cause stair-step memeory usage, use jemalloc to solve heap fragmentation.

April 7, 2023 · 1 min · Gray King

Sign Message

tags: Blockchain

April 7, 2023 · 1 min · Gray King

Tron Signing Data

tags: Tron, Sign Message Three methods tronweb.trx.signMessageV11 tronweb.trx.signMessageV22 tronweb.trx._signtypeddata3, 4 https://github.com/tronprotocol/tronweb/blob/859253856c79d3aff26ec6c89afefc73840d648d/src/lib/trx.js#L727-L739 ↩︎ https://github.com/tronprotocol/tronweb/blob/859253856c79d3aff26ec6c89afefc73840d648d/src/utils/message.js#L8-L18 ↩︎ https://github.com/tronprotocol/tronweb/blob/859253856c79d3aff26ec6c89afefc73840d648d/src/utils/crypto.js#L89 ↩︎ TIP 104 ↩︎

April 7, 2023 · 1 min · Gray King

Ethereum Signing Data

tags: Ethereum, Sign Message source: “Signing Data | MetaMask Docs.” Accessed April 6, 2023. https://docs.metamask.io/guide/signing-data.html#signtypeddata-v4. Five Methods1 eth_sign allow to sign arbitrary hash.2 personal_sign add prefix to data and human readable text that encoded UFT-8.3 signTypedData or signTypedData_v1 first release that lacked some later security improvements. signTypedData_v3 signTypedData_v4 compatible with V3. Differences Between V3 and V44 Some input types that V3 doesn’t support but V4 does: Custom type array Custom type with null input Some input types that V4 doesn’t support but V3 does: ...

April 6, 2023 · 1 min · Gray King

Use GDB to Debug Cgo Segmentation Fault

tags: Go, GDB Enable Core Dumps ulimit -S -c unlimited Confirm or Change The Location of Core Dumps sysctl -w kernel.core_pattern=/tmp/core.%e.%p # Or echo '/tmp/core.%e.%p' | tee /proc/sys/kernel/core_pattern Set GOTRACEBACK Environment Variable to Let Go Program Core Dumps when Panic export GOTRACEBACK=crash Run Go Program and Wait Segmentation Fault Use GDB to Debug gdb /path/to/goprogram /tmp/core-xx-xx Then use thread apply all bt to see all backtraces, include compiled C code. Note: -g option should be applied to the compiled C code to generate debug symbols.

April 5, 2023 · 1 min · Gray King

ScrollL2: How to Caculate L1Fee

tags: Ethereum Layer 2 Background You may meet the below error when you’re trying to transfer all your ETH from one address to another address: invalid transaction: insufficient funds for l1fee + gas * price + value The reason is that the Layer 1 fee are included in Scroll’s gas fee system, but the wallet only exclude the Layer 2 gas fee to do so when you transfer all your ETH. 1 ...

March 23, 2023 · 2 min · Gray King

How to Yubikey: a configuration cheatsheet

tags: Yubikey source: “How to Yubikey: A Configuration Cheatsheet,” March 1, 2023. https://debugging.works/blog/yubikey-cheatsheet/.

March 11, 2023 · 1 min · Gray King

Overhead of Python asyncio Tasks: 260K/s

tags: Python, High Performance source: Textual Documentation. “Textual - Overhead of Python Asyncio Tasks,” March 8, 2023. https://textual.textualize.io/blog/2023/03/08/overhead-of-python-asyncio-tasks/. Tasks of asyncio from create to run, then shutdown is about: 260K tasks per second.

March 9, 2023 · 1 min · Gray King

Yubikey

February 25, 2023 · 0 min · Gray King

How to Weaponize the Yubikey

tags: Yubikey source: BHIS. “How to Weaponize the Yubikey.” Black Hills Information Security (blog), May 2, 2019. https://www.blackhillsinfosec.com/how-to-weaponize-the-yubikey/.

February 25, 2023 · 1 min · Gray King

优质免费服务

tags: Online Tools,Microstartup source: https://twitter.com/vikingmute/status/1597417185470992384 HTTPS: Let’s Encrypt(acme.sh) 企业邮箱: ym.163.coom(3G 容量) zoho.com.cn/mail/ landing page 搭建 https://tailblocks.cc/ https://landing.ant.design/ 图标素材 fontawesome.com iconfinder.com 音乐素材 https://uppbeat.io 插画 https://undraw.co/illustrations https://www.manypixels.co/gallery storyset.com CDN cloudflare.com jsdelivr.com 静态托管 pages.cloudflare.com(无限请求和无线带宽) vercel.com(1G 带宽限制) 免费域名 freenom.com 免费 PS photopea.com 非关系数据库 AWS DynamoDB 25GB 存储 + 1G 传输,https://aws.amazon.com/cn/dynamodb/ Azure CosmosDB 25GB 存储,兼容 MongoDB 以及 PostgresQL 关系型数据库 https://planetscale.com 5GB 存储,每月 10亿行读,1000万行写。 监控工具 https://uptimerobot.com/ 对象存储 网易云 nos https://163yun.com/nos/free 50GB 存储,20GB下行流量/月 又拍云联盟 https://upyun.com/league 10GB 存储,25GB流量/月 https://cloudinary.com/(国外),易用、强大、25GB存储,每月 25,000 次图片转换,25GB 流量。 客户信息 ...

February 24, 2023 · 1 min · Gray King

EIP 1559

tags: Ethereum Before EIP 1559 The miner receive both fees and block reward. After EIP 1559 The fee divide to 2 parts: Base Fee Priority Fee The miner receive priority fee and block reward, the base fee will be burned.

February 21, 2023 · 1 min · Gray King

Papers We Love

source: https://github.com/papers-we-love/papers-we-love tags: Papers

February 20, 2023 · 1 min · Gray King

The Refreshingly Rewarding Realm of Research Papers

source: The Refreshingly Rewarding Realm of Research Papers, 2015. https://www.youtube.com/watch?v=8eRx5Wo3xYA. tags: Papers Finding Something to Read Sources: Colleagues Papers We Love the morning paper With some topics/categories, to search on ACM Classification System(Require membership) Librarian Reading & Comprehending 3 Passes: Go though: title/sections/concclusions/references. (10min) Read more closely (1-2 hours) Mark unread References Step though closely Summarize in 1-2 sentences; outline major contributes; note strengths/weaknesses (couple hours) Implementing Use familar tools, except the paper used specific tool. Be aware to pseudo code. Prepare to work and results Test early. Test often. Interacting with the authors.

February 20, 2023 · 1 min · Gray King

MPC

February 18, 2023 · 0 min · Gray King

Five Tips For a Healthier Postgres Database in the New Year

tags: Database, PostgresQL source: Crunchy Data. “Five Tips For a Healthier Postgres Database in the New Year.” Accessed February 13, 2023. https://crunchydata.com/blog/five-tips-for-a-healthier-postgres-database-in-the-new-year.

February 13, 2023 · 1 min · Gray King

Decode input data of Ethereum

tags: Ethereum,Blockchain,Tron source: https://ethereum.stackexchange.com/a/110498 const data = '0x7ff36ab50000000000000000000000000000000000000000000000bc18ba4144048bbab00000000000000000000000000000000000000000000000000000000000000080000000000000000000000000c0c5eb43e2df059e3be6e4fb0284c283caa5991900000000000000000000000000000000000000000000000000000000614d87a80000000000000000000000000000000000000000000000000000000000000002000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00000000000000000000000008ba0619b1e7a582e0bce5bbe9843322c954c340'; ethers.utils.defaultAbiCoder.decode( ['uint256', 'address[]', 'address', 'uint256'], ethers.utils.hexDataSlice(data, 4) ) // gives: [e, ["0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", "0x08ba0619b1e7A582E0BCe5BBE9843322C954C340"], "0xC0C5eb43E2dF059e3Be6E4fb0284C283CAa59919", e] (4) Online tools: Playground.

February 3, 2023 · 1 min · Gray King

Tron

tags: Blockchain

February 3, 2023 · 1 min · Gray King

Hypertext in Emacs: find-file-at-point

tags: Emacs source: http://bjornwestergard.com/log/2022-04-19-hypertext-emacs.gmi C-x C-f M-n to find-file-at-point.

January 31, 2023 · 1 min · Gray King

Solana PDA

tags: Solana, Solana 101: 2. Anchor What is Program Derived Address(PDA)?1 A Program Derived Address is simply an account owned by the program, but has no private key. Instead it’s signature is obtained by a set of seeds and a bump (a nonce which makes sure it’s off curve). “Generating” a Program Address is different from “creating” it. Generating One can generate a PDA using Pubkey::find_program_address in Rust or PublicKey.findProgramAddressSync in JavaScript; Creating a PDA essentially means to initialize the address with space and set the state to it. #+end_quote ...

December 26, 2022 · 2 min · Gray King

Reverse Proxy to bypass Network Issue of Solana RPC Node

tags: Nginx One Endpoint for Both WebSocket and Normal Requests,Solana,Solana 101: Create an Escrow dApp I met a lot network issues about connecting to RPC node of Solana, so I’m using a nginx server as a reverse proxy to bypass this problem: location / { # https://serverfault.com/a/923254 try_files /nonexistent @$http_upgrade; } location @ { proxy_pass https://api.testnet.solana.com; proxy_read_timeout 300s; proxy_send_timeout 300s; proxy_set_header Host "api.testnet.solana.com"; } location @websocket { proxy_redirect off; proxy_pass https://api.testnet.solana.com; proxy_http_version 1.1; proxy_read_timeout 300s; proxy_send_timeout 300s; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; }

December 24, 2022 · 1 min · Gray King

Nginx

tags: Linux

December 24, 2022 · 1 min · Gray King

Nginx One Endpoint for Both WebSocket and Normal Requests

tags: Nginx source: https://serverfault.com/a/923254 server { # ... location / { # If "Websocket" is in Upgrade header, then @websocket will take effect, # otherwise @ will take effect. try_files /nonexistent @$http_upgrade; } location @websocket { # websocket related stuff } location @ { # web related stuff } }

December 24, 2022 · 1 min · Gray King

Decoration

参考 https://github.com/RobbieXie/2020DecorationNote Ideas 在马桶旁边要留一个插座,用于智能马桶垫; 厨房油烟机机一个光滑斜面可以在餐厅坐着看锅里的情况; 全屋六类线预留 AP 和插座,最好能扩大弱电箱能放进去个 NAS; 面向扫地机器人装修;

December 24, 2022 · 1 min · Gray King

Ethereum Layer 2

tags: Ethereum Knowning Layer 2 Chain Rollup(or bundle) transactions off-chain to reduce fee and scale capacity, such as Bitcoin Lightning. Two layer 2 rollups Optimistic Rollups Zero-Knowledge Rollups Record on-chain state by writing calldata to L1(Ethereum), which more cheaper than change state on L1 chain. Fees Some layer 2 chain like Optimism should plus l1 fee when executing transaction on layer 1.1 Many Ethereum applications display estimated fees to users by multiplying the gas price by the gas limit. However, as discussed earlier, users on Optimism are charged both an L2 execution fee and an L1 data fee. As a result, you should display the sum of both of these fees to give users the most accurate estimate of the total cost of a transaction. ...

December 23, 2022 · 1 min · Gray King

Go Reflect

tags: Go Elem() Returns Value type T struct { } t := &T{} v := reflect.New(reflect.TypeOf(t)).Elem() // type of v is `T` Interface() Returns Pointer type T struct { } t := &T{} v := reflect.New(reflect.TypeOf(t)).Interface() // type of v is `&T`

November 23, 2022 · 1 min · Gray King

Solana 101: 5. Escrow dApp

tags: Solana 101: Create an Escrow dApp

November 22, 2022 · 1 min · Gray King

Solana 101: 3. SPL Token

tags: Solana 101: Create an Escrow dApp 连接钱包 安装 Phantom 钱包; 使用 @solana/wallet-adapter 连接钱包。官方提供了 React 相关的实现,Vue 可以通过社区提供的库:https://github.com/lorisleiva/solana-wallets-vue。 npm install solana-wallets-vue @solana/wallet-adapter-wallets 创建 SPL Token 安装依赖 npm install --save @solana/spl-token 创建代币 通过 Token Program 创建 Token,Solana 通过其特有的账号机制,通过创建一个账号并将 Owner 设置为一个统一的 Token Program 即可发行一种代币。1 发行代币 要持有代币必须创建一个对应的 Associated Token Account(ATA),也就是要接收一个代币首先要检查有没有对应代币的 ATA,没有则创建,然后给对应的 ATA 转移代币。 代币转帐 燃烧代币 SPL Token 交互:授权 Program 转帐 Libraries: spl_associated_token_account Steps: Delegate token to Program – in frontend. Create a Associated Token Account for Program to hold token. Q: How to avoid duplicated initialization? A: data size of account. Program: Transfer token from wallet to Program USDT ↩︎ ...

November 22, 2022 · 1 min · Gray King