- 理解以太坊的底层运行机制
- 本文主要关注为什么这么做、基本原理、实现效果,2/8法则,花 20% 的精力掌握 80% 的内容
- 细节实现会留 reference,如果想研究,建议用以下方式:1. 走一遍 demo,搞清楚所有的细节,例如 EVM 合约的执行流程;2. 自己实现一遍,比如 MPT、EVM,甚至整个以太坊客户端。
- 概览以太坊生态全景
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# disable keyboard | |
sc config i8042prt start= disabled | |
# enable keyboard | |
sc config i8042prt start= auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# define proxy address | |
$addr='0.0.0.0'; | |
$port=22222 | |
# Get wsl2 ip addres | |
$wsl_ip_all = wsl.exe hostname -I | |
$wsl_ip = $wsl_ip_all.Split(" ")[0] | |
$wsl_ssh_port = 22222 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::Write; | |
use std::sync::atomic::{self, AtomicU8}; | |
use std::sync::Arc; | |
use std::thread::{self}; | |
struct SpinLock { | |
flag: AtomicU8, | |
} | |
impl SpinLock { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Based on: | |
# https://github.com/Powerlevel9k/powerlevel9k/wiki/Install-Instructions | |
# https://github.com/ohmyzsh/ohmyzsh | |
# https://powerline.readthedocs.io/en/latest/installation/linux.html#fonts-installation | |
# https://gist.github.com/dogrocker/1efb8fd9427779c827058f873b94df95 | |
# https://linuxhint.com/install_zsh_shell_ubuntu_1804/ | |
echo "*********************************************" | |
echo " zsh fancifier" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
int main() { | |
std::string s("ABCCDDEEFF"); | |
int l = 0; | |
int r = s.size() - 1; | |
int mid; | |
char c = 'G'; | |
while (l <= r) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// see https://stackoverflow.com/questions/26212397/references-to-traits-in-structs | |
#![allow(unused)] | |
use std::borrow::Borrow; | |
trait Type { | |
fn type_to_string(&self) -> String; | |
} | |
struct BoolType {} | |
impl Type for BoolType { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(unused)] | |
fn to_mut_ptr(data: Vec<u8>) -> *mut u8 { | |
unsafe { data.to_owned().as_mut_ptr() } | |
} | |
fn main() { | |
let s = String::from("hello world"); | |
let mut storage = vec![0; s.len()]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// idea from https://docs.rs/byteorder/1.4.3/src/byteorder/lib.rs.html | |
#![allow(unused)] | |
fn main() { | |
let mut x: Vec<u8> = Vec::new(); | |
x.reserve(16); | |
let y: u32 = 12; | |
unsafe { | |
// write y to byte array |
NewerOlder