-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1421 lines (1038 loc) · 65.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.2.0">
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
<link rel="mask-icon" href="/images/logo.svg" color="#222">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic|Pacifico:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">
<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
<script id="hexo-configurations">
var NexT = window.NexT || {};
var CONFIG = {"hostname":"imzy.vip","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
</script>
<meta name="description" content="每一篇文章都是一种进步,每一句感慨都是一次思考">
<meta property="og:type" content="website">
<meta property="og:title" content="TID's Blog">
<meta property="og:url" content="https://imzy.vip/index.html">
<meta property="og:site_name" content="TID's Blog">
<meta property="og:description" content="每一篇文章都是一种进步,每一句感慨都是一次思考">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="TigerInYourDream">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="https://imzy.vip/">
<script id="page-configurations">
// https://hexo.io/docs/variables.html
CONFIG.page = {
sidebar: "",
isHome : true,
isPost : false,
lang : 'zh-CN'
};
</script>
<title>TID's Blog</title>
<noscript>
<style>
.use-motion .brand,
.use-motion .menu-item,
.sidebar-inner,
.use-motion .post-block,
.use-motion .pagination,
.use-motion .comments,
.use-motion .post-header,
.use-motion .post-body,
.use-motion .collection-header { opacity: initial; }
.use-motion .site-title,
.use-motion .site-subtitle {
opacity: initial;
top: initial;
}
.use-motion .logo-line-before i { left: initial; }
.use-motion .logo-line-after i { right: initial; }
</style>
</noscript>
</head>
<body itemscope itemtype="http://schema.org/WebPage">
<div class="container use-motion">
<div class="headband"></div>
<header class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-container">
<div class="site-nav-toggle">
<div class="toggle" aria-label="切换导航栏">
<span class="toggle-line toggle-line-first"></span>
<span class="toggle-line toggle-line-middle"></span>
<span class="toggle-line toggle-line-last"></span>
</div>
</div>
<div class="site-meta">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<h1 class="site-title">TID's Blog</h1>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<div class="site-nav-right">
<div class="toggle popup-trigger">
</div>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="main-menu menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>
</li>
<li class="menu-item menu-item-categories">
<a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>
</li>
<li class="menu-item menu-item-一言">
<a href="/motto" rel="section"><i class="fa fa-camera fa-fw"></i>一言</a>
</li>
<li class="menu-item menu-item-友链">
<a href="/friends" rel="section"><i class="fa fa-american-sign-language-interpreting fa-fw"></i>友链</a>
</li>
</ul>
</nav>
</div>
</header>
<div class="back-to-top">
<i class="fa fa-arrow-up"></i>
<span>0%</span>
</div>
<main class="main">
<div class="main-inner">
<div class="content-wrap">
<div class="content index posts-expand">
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://imzy.vip/posts/12714/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.jpg">
<meta itemprop="name" content="TigerInYourDream">
<meta itemprop="description" content="每一篇文章都是一种进步,每一句感慨都是一次思考">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="TID's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/posts/12714/" class="post-title-link" itemprop="url">为 C++程序写 rustbinding</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-08-12 23:24:49 / 修改时间:16:01:47" itemprop="dateCreated datePublished" datetime="2024-08-12T23:24:49+00:00">2024-08-12</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/rust/" itemprop="url" rel="index"><span itemprop="name">rust</span></a>
</span>
</span>
<br>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>5.5k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>5 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="为-C-程序写-rustbinding"><a href="#为-C-程序写-rustbinding" class="headerlink" title="为 C++程序写 rustbinding"></a>为 C++程序写 rustbinding</h1><h2 id="AutoCxx-与-CWrapper-Bindgen"><a href="#AutoCxx-与-CWrapper-Bindgen" class="headerlink" title="AutoCxx 与 CWrapper+Bindgen"></a>AutoCxx 与 CWrapper+Bindgen</h2><p><a target="_blank" rel="noopener" href="https://www.notion.so/c-ruts-binding-d617fe66712241ca830107a1c2020761?pvs=21">为 c++程序写 ruts-binding</a></p>
<p>在代码的世界中,还是 c和 cpp站绝大多数,现在提一个比较常见的需求:提供一个 c++的程序,最终需要再 rust中调用 c++程序提供的接口。</p>
<p>一般来说有两个方法</p>
<ol>
<li>直接使用 cxx autocxx为 rust代码生成一份 unsafe的代码,然后直接调用</li>
<li>第二种方法比较路径稍长,先针对 c++代码的 header 写一份 c风格的头文件cwrapper,然后针对 c的头文件写一份 c头文件的实现。接下来编译自己的cwrapper,生成一份新的动态库。接下来使用 bindgen 根据 cwrapper生成一份 unsafe rust。最后在 rust代码中调用。</li>
</ol>
<p>总体来说 cxx 或者 autocxx 可能性能会更好一些,但是 autocxx并不能搞定一切。第二种方法胜在稳定,毕竟 c的 abi比较稳定。本文将采用后一种方法。</p>
<h2 id="速成材料"><a href="#速成材料" class="headerlink" title="速成材料"></a>速成材料</h2><p>技术基础是:会 rust,不会 c++或者 c。所以需要速成,了解 c和 c++。如果彻底不会 c++,写 bingen 无从谈起。</p>
<p>下面是一些材料</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/posts/12714/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://imzy.vip/posts/43396/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.jpg">
<meta itemprop="name" content="TigerInYourDream">
<meta itemprop="description" content="每一篇文章都是一种进步,每一句感慨都是一次思考">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="TID's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/posts/43396/" class="post-title-link" itemprop="url">sonala合约</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-06-12 20:00:49" itemprop="dateCreated datePublished" datetime="2024-06-12T20:00:49+00:00">2024-06-12</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2024-08-12 16:01:47" itemprop="dateModified" datetime="2024-08-12T16:01:47+00:00">2024-08-12</time>
</span>
<br>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>3.3k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>3 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="solana合约学习"><a href="#solana合约学习" class="headerlink" title="solana合约学习"></a>solana合约学习</h1><p>本文是对 solan相关问题介绍,主要用于记录solana合约的学习过程。因为现阶段还没有十分深入的学习 solana的细节,所以目标限定在 solana的简单合约编写,环境搭建,测试。</p>
<h2 id="基础"><a href="#基础" class="headerlink" title="基础"></a>基础</h2><p>因为是学习指南,所以会先强调学习的基础。本文的基础建立在会 rust基础上,明白 rust的语法,可以达到 rust编写简单代码的基础之上。因为 solana 合约是直接使用 rust编写的。如果不具备简单的 rust基础,请先学习 rust book,至少了解 rust的基本语法。</p>
<h2 id="solana环境"><a href="#solana环境" class="headerlink" title="solana环境"></a>solana环境</h2><p>因为 solana有自己的介绍文档,不再重复介绍solana概念。下面主要讲剩余部分。</p>
<ol>
<li>开发环境<ol>
<li>主要就是 rust环境,可以去 rust官网上直接安装 rust环境。因为 rust已经比较成熟,没有特别的问题,直接安装最新环境。</li>
<li>编辑器,因为是直接使用 rust开发solana 合约的,所以主流的 VSCODE Rustrover vim zed emacs都可以。选择自己喜欢的就好。</li>
<li>solana cli工具。<a target="_blank" rel="noopener" href="https://solana.com/developers/guides/getstarted/local-rust-hello-world">https://solana.com/developers/guides/getstarted/local-rust-hello-world</a></li>
<li>cli工具是生成地址,链接 solana节点,部署合约的基础。后面会继续提到一些注意事项,请务必参考安装的的注意事项。</li>
<li>anchor anchor是 solana 的“框架”,可以去 anchor官网安装 solana框架。后面也有注意事项。</li>
<li>以上的套件理论上是全部需要的。如果你只是使用solana native开发,可以不使用 anchor。也就可以不用安装 anchor 套件。</li>
</ol>
</li>
</ol>
<h2 id="环境安装中的特殊问题"><a href="#环境安装中的特殊问题" class="headerlink" title="环境安装中的特殊问题"></a>环境安装中的特殊问题</h2><ol>
<li>根据目前 2024年06月08日20:17:14 时间 solana 是 v1.18.15。 solana 本身并不是直接安装最新版本就好了。最新版本可能出现编译不过,获取有一些更加具体的字节超量的编译问题。这时候就需要回退到历史版本。可以看下面的链接。当然如果你非常幸运,安装之后完全没有问题就不必折腾。事实是,我安装了最新版之后一直无法通过编译,然后不得不安装下面的方案回退。</li>
<li><a target="_blank" rel="noopener" href="https://www.notion.so/cd22ecfe315d4acbb83c68ca8a3d7b30?pvs=21">https://www.notion.so/alvinvip/cd22ecfe315d4acbb83c68ca8a3d7b30?pvs=4#14fa26df7432402ebf18529fecf20e40</a></li>
<li>anchor也存在以上问题,最新版无法运行。这样采用上面的办法即可,直接退版本。</li>
<li><a target="_blank" rel="noopener" href="https://book.anchor-lang.com/getting_started/installation.html">https://book.anchor-lang.com/getting_started/installation.html</a></li>
<li>注意查看版本关系 anchor 0.30需要使用最新的 solana v1.18.15(务必注意时间,后续升级必须兼顾 solana版本和 anchor版本)</li>
</ol>
<h3 id="测试问题"><a href="#测试问题" class="headerlink" title="测试问题"></a>测试问题</h3>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/posts/43396/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://imzy.vip/posts/44402/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.jpg">
<meta itemprop="name" content="TigerInYourDream">
<meta itemprop="description" content="每一篇文章都是一种进步,每一句感慨都是一次思考">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="TID's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/posts/44402/" class="post-title-link" itemprop="url">REVM代码阅读 02</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-05-28 20:23:51" itemprop="dateCreated datePublished" datetime="2024-05-28T20:23:51+00:00">2024-05-28</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2024-08-12 16:01:47" itemprop="dateModified" datetime="2024-08-12T16:01:47+00:00">2024-08-12</time>
</span>
<br>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>2k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>2 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="REVM代码阅读-02"><a href="#REVM代码阅读-02" class="headerlink" title="REVM代码阅读 02"></a>REVM代码阅读 02</h1><h2 id="前文介绍"><a href="#前文介绍" class="headerlink" title="前文介绍"></a>前文介绍</h2><p>在 01章节,对阅读 revm做了一些预先的准备工作,主要包括了解solidity语言,学习 OPCODES以及自顶向下了解 evm的基本结构三部分。其中第三部分最好大致实现征战虚拟机栈的运行过程加深理解。现在开始阅读 revm代码。阅读代码的过程比较枯燥,请保持耐心。</p>
<p>针对单独实现的 evm不在少数,使用 rust编写的 evm也不是唯一的。有下面的两个</p>
<p><a target="_blank" rel="noopener" href="https://github.com/rust-ethereum/evm">https://github.com/rust-ethereum/evm</a></p>
<p>以上是 rust-ethereum名下的 evm项目,他是 parity名下的项目,在项目中提到 polkdot项目就使用该虚拟机。</p>
<p>另外一个就是我们看的 evm revm</p>
<p><a target="_blank" rel="noopener" href="https://github.com/bluealloy/revm">https://github.com/bluealloy/revm</a></p>
<p>也有众多的以太坊生态项目使用该虚拟机。该项目拥有一本 books来介绍虚拟机的设计思路。在初步阅读代码之前,我们先阅读文档来了解 revm的整体设计思路。</p>
<p><a target="_blank" rel="noopener" href="https://bluealloy.github.io/revm/">https://bluealloy.github.io/revm/</a></p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/posts/44402/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://imzy.vip/posts/44082/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.jpg">
<meta itemprop="name" content="TigerInYourDream">
<meta itemprop="description" content="每一篇文章都是一种进步,每一句感慨都是一次思考">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="TID's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/posts/44082/" class="post-title-link" itemprop="url">REVM代码阅读 01</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-05-15 14:51:16" itemprop="dateCreated datePublished" datetime="2024-05-15T14:51:16+00:00">2024-05-15</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2024-08-12 16:01:47" itemprop="dateModified" datetime="2024-08-12T16:01:47+00:00">2024-08-12</time>
</span>
<br>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>1.6k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>1 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="REVM代码阅读-01"><a href="#REVM代码阅读-01" class="headerlink" title="REVM代码阅读 01"></a>REVM代码阅读 01</h1><p>经过一些时间的准备,现在进行 REVM代码的阅读</p>
<h3 id="准备环节"><a href="#准备环节" class="headerlink" title="准备环节"></a>准备环节</h3><p>这些准备主要包括一下的方面</p>
<ol>
<li>速览 《精通以太坊》,有一个全局的认识</li>
<li><a target="_blank" rel="noopener" href="https://github.com/WTFAcademy/WTF-Solidity">https://github.com/WTFAcademy/WTF-Solidity</a> 通过这些资料来了解 solidity的语法。我的标准是学习完上面的课程并且完成习题,通过认证。</li>
<li><a target="_blank" rel="noopener" href="https://www.wtf.academy/docs/evm-opcodes-101">https://www.wtf.academy/docs/evm-opcodes-101</a> 通过这些资料来学习以太坊的操作码 OPCODE, 因为不会 python, 所以使用 rust实现了其中其中的逻辑。可以参考这个链接<a target="_blank" rel="noopener" href="https://github.com/TigerInYourDream/naive/_evm">https://github.com/TigerInYourDream/naive\_evm</a> 。主要需要跑通其中的用例(执行其中的 bytecode)。(至少做完 101 和 102)</li>
</ol>
<p>做出了以上的准备之后,可以对以太坊虚拟机有一个整体性认识。其中改的代码可以参考上面的链接阅读。</p>
<h3 id="总体概览"><a href="#总体概览" class="headerlink" title="总体概览"></a>总体概览</h3><p>经过以上的准备,对以太坊虚拟机有了一个感性的认识。从最简单的模型,以太坊虚拟机就是一个栈的数据结构,每次把b solidit编译成对应的 bytecode,然后拆分成一个又一个的 op code。把 op code按照栈的方式一次执行就完成了“虚拟机”的工作。</p>
<p>下面图来自于 WFT Academy的 op code 101教程,从高层次展示了以太坊虚拟机的结构</p>
<p><img src="https://image-bucket-for-alvin.oss-cn-beijing.aliyuncs.com/img/evm_overview.png" alt="https://image-bucket-for-alvin.oss-cn-beijing.aliyuncs.com/img/evm\_overview.png"></p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/posts/44082/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://imzy.vip/posts/35993/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.jpg">
<meta itemprop="name" content="TigerInYourDream">
<meta itemprop="description" content="每一篇文章都是一种进步,每一句感慨都是一次思考">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="TID's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/posts/35993/" class="post-title-link" itemprop="url">diesel使用小要点</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2021-10-14 18:39:14" itemprop="dateCreated datePublished" datetime="2021-10-14T18:39:14+00:00">2021-10-14</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2024-08-12 16:01:47" itemprop="dateModified" datetime="2024-08-12T16:01:47+00:00">2024-08-12</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/%E6%8A%80%E6%9C%AF%E7%AC%94%E8%AE%B0/" itemprop="url" rel="index"><span itemprop="name">技术笔记</span></a>
</span>
</span>
<br>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>1.6k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>1 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="diesel使用的一些小知识点"><a href="#diesel使用的一些小知识点" class="headerlink" title="diesel使用的一些小知识点"></a>diesel使用的一些小知识点</h1><p>最近因为使用diesel,大致看了diesel的文档同时结合自己两天内写代码的经验,总结出下面几条要点,作为参考。严格来说,这些知识点比较琐碎不能够成为一篇文章,但是想到可以为自己以后使用diesel作参考还是写出来。</p>
<ol>
<li><p>设置好.env之后 diesel setup 是创建数据库的 </p>
</li>
<li><p>diesel migration generate create_posts 最后一个参数是创建migration的文件夹名的 它会生成一个带时间的migration文件 里面有个up和down的sql up 里面负责创建数据库表的 down 里面负责撤回车操作的 </p>
</li>
<li><p>up 和 down 里面的sql要自己创建 </p>
</li>
<li><p>diesel migration run 执行migration里面的up.sql的操作的 确切的说就是建表 5. diesel migration redo 执行migration里面的down.sql的操作 确切的拉说是删除表 </p>
</li>
<li><p>注意了 setup是会创建数据库和直接运行migration run中的建表数据的 但是如果数据库存在是不会运行的。如果在 migration中添加,后续这个也是不会运行的 </p>
</li>
<li><p>这一步进行之后schema文件也会生成。这个文件是可以改的 ,但是不建议改 </p>
</li>
<li><p>如果升级数据库,请使用新的migration文件 </p>
</li>
<li><p>注意使用extern crate diesel 和#[marco use],不然schema下的东西又是找不到的</p>
<p> 以上的条目中需要补充的还有如下</p>
<blockquote>
<p>本来以为在rust2018版本以后,就完全不使用extern crate了。但是事实证明还是需要extern crate diesel和#[marco_use]的,不然会有很多东西找不到</p>
</blockquote>
<blockquote>
<p>使用diesel尽量引入prelude::* 虽然我不喜欢这样引入,但是自己精确引入会很麻烦</p>
</blockquote>
<blockquote>
<p>一定要注意schema文件</p>
</blockquote>
</li>
</ol>
<h2 id="如果使用只是使用diesel查询和写入如何简化代码"><a href="#如果使用只是使用diesel查询和写入如何简化代码" class="headerlink" title="如果使用只是使用diesel查询和写入如何简化代码"></a>如果使用只是使用diesel查询和写入如何简化代码</h2><p>这个问题会显的很奇怪,因为作为一个ORM,本来就是辅助我们进行增删改查的。其实我们看了diesel的官方指引之后就会觉得这个问题很合理。重新表述如下</p>
<blockquote>
<p>根据diesel的官方指引,我们是用建立连接,建立数据库,设计表这几个步骤一路走下来的。实际上,大多数时候,数据表并不是我们建立的。我们只需要使用diesel的库,连接数据库CRUD即可。这种情况下,如何简化操作呢?</p>
</blockquote>
<p>根据我的尝试大致需要如下</p>
<ol>
<li><p>引入库,这个是必须的</p>
</li>
<li><p>设置sql路径,这个是必须的</p>
</li>
<li><p>无需diesel setup因为我们不需要建立数据库,数据库是存在的</p>
</li>
<li><p>无需diesle migration run 因为表也不是我们建立的。</p>
</li>
<li><p>没有建表,没运行diesel migration run,则diesel不会为我们自动建立schema.rs文件,也不会在schema.rs中生成table宏的语法。所以我们需要手动去建立schema.rs的文件,src/schema.rs。就是必须建立的在src路径下面。这样才不会出错。然后我们在schema.rs中手动写入 table!宏。这样才可以正常使用。</p>
</li>
<li><p>以上的步骤是可以正常使用的,也是文件最少的情况。还有下面的情况补充</p>
<blockquote>
<p>如果我们运行了diesel set 如果数据库存在,是不会建立数据库的。会产生一个migrations文件。一个和Cargo.toml同级别的diesel.toml文件,里面配置了schema.rs文件的位置。 所以上一步中如果不运行diesel set,需要我们手动把schema文件放在指定的位置。</p>
<p>同时,因为我们 不建表,所以不运行diesel migration run。schema里面是空的,为了正确使用orm的方便特性,我们得去手动补全这个文件,自己写table!宏。当然这个很容易。看example即可</p>
</blockquote>
<p> 一些零碎的知识,其他的正常使用参考文档即可。这个算是在文档之外的补充备查!</p>
</li>
</ol>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/posts/35993/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://imzy.vip/posts/26767/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.jpg">
<meta itemprop="name" content="TigerInYourDream">
<meta itemprop="description" content="每一篇文章都是一种进步,每一句感慨都是一次思考">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="TID's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/posts/26767/" class="post-title-link" itemprop="url">占星与星座计算 morinus house system</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2021-08-10 22:37:53" itemprop="dateCreated datePublished" datetime="2021-08-10T22:37:53+00:00">2021-08-10</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2024-08-12 16:01:47" itemprop="dateModified" datetime="2024-08-12T16:01:47+00:00">2024-08-12</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/%E5%A4%A9%E6%96%87%E5%AD%A6/" itemprop="url" rel="index"><span itemprop="name">天文学</span></a>
</span>
</span>
<br>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>2.7k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>2 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="占星与星座计算-morinus-house-system"><a href="#占星与星座计算-morinus-house-system" class="headerlink" title="占星与星座计算 morinus house system"></a>占星与星座计算 morinus house system</h1><p>在系列前三节,已经基本介绍了和占星有关的模型,基本的分宫制的原理和占星以及天文中所出现的术语,这一节将带大家进行一次实际的占星计算。本文仅涉及星盘的计算,不涉及其他。</p>
<p>本文的重点是星盘的计算。本文将采用莫林分宫制morinus house system!至于为什么选择莫林分宫制,是因为莫林分宫制可以找到具体的数学计算公式,便于计算。且莫林分宫制在高纬度地区受到的扭曲小。至于分宫制的基本原理,可以查看上一节分宫制基本原理。</p>
<blockquote>
<p>对于“morinus house system”是有专门的计算方法,通过一系列的加减乘除算出一个人出生时的MC、Asc以及每个宫头所在得度数,就可以排出一个近乎完整的星图了。</p>
</blockquote>
<blockquote>
<p>ASC:东升点是在诞生时刻在诞生地点的东面地平与黄道交接的一点</p>
</blockquote>
<blockquote>
<p>MC:天顶</p>
</blockquote>
<p>我们在计算的时候需要以下参数</p>
<ol>
<li>当事人的出生位置,需要从具体地点转化成经纬度</li>
<li>出生时间,需要转化为恒星时</li>
<li>黄赤交角,这个是固定值。关于黄赤交角可以看第一节天球部分。23°27′</li>
<li>以及如下公式</li>
</ol>
<blockquote>
<p>MC = arctan(tan(RAMC) / cos(e))</p>
</blockquote>
<blockquote>
<p>RAMC为上中天的赤经度数</p>
</blockquote>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/posts/26767/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://imzy.vip/posts/3102/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.jpg">
<meta itemprop="name" content="TigerInYourDream">
<meta itemprop="description" content="每一篇文章都是一种进步,每一句感慨都是一次思考">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="TID's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/posts/3102/" class="post-title-link" itemprop="url">占星与星座计算 儒略历和恒星时计算</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2021-08-07 22:35:15" itemprop="dateCreated datePublished" datetime="2021-08-07T22:35:15+00:00">2021-08-07</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2024-08-12 16:01:47" itemprop="dateModified" datetime="2024-08-12T16:01:47+00:00">2024-08-12</time>
</span>
<br>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>2.2k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>2 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="占星与星座计算-儒略历和恒星时计算"><a href="#占星与星座计算-儒略历和恒星时计算" class="headerlink" title="占星与星座计算 儒略历和恒星时计算"></a>占星与星座计算 儒略历和恒星时计算</h1><p>在前两节的文章基础之上,我们开始进行真正的计算。在介绍计算星盘之前,我们需要一个预先准备的数据。儒略历和恒星时。网上的现成代码似乎没有说的很清楚,公式不够统一,结果也难以验证,为此参考了很多资料。其中有两个资料确定是对的。</p>
<p><a target="_blank" rel="noopener" href="https://zh.wikipedia.org/wiki/%E6%81%92%E6%98%9F%E6%97%B6">https://zh.wikipedia.org/wiki/恒星时</a></p>
<p>上面公式中关于儒略历的转化公式是正确的,请注意其中的高斯符号。高斯符号相当于代码中的floor()函数。</p>
<p>后面关于恒星时的计算不确定正确性。</p>
<p>然后参考一份关于天文算法的论文,或者是一本翻译的PDF。感谢“冯剑和他的译友”翻译了这本天文算法,使我得到了确切的公式。</p>
<p>关于什么是恒星时可以也可以参考上面的wiki。</p>
<p>关于结果,分别得到了多项式T,算出来以角度为单位的恒星时,以时间hour为单位的恒星时,以时分秒为单位的恒星时。</p>
<blockquote>
<p>现在公历纪元的年表示为Y、月为M、日为D、时为h、分为m、秒为s,1月、2月分别当做上一年的13月、14月。(例:2010年1月1日时Y=2009, M=13, D=1),然后求出儒略日</p>
</blockquote>
<p>计算儒略历请注意以上的重点。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/posts/3102/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://imzy.vip/posts/13704/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.jpg">
<meta itemprop="name" content="TigerInYourDream">
<meta itemprop="description" content="每一篇文章都是一种进步,每一句感慨都是一次思考">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="TID's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/posts/13704/" class="post-title-link" itemprop="url">占星与星座计算 黄道十二宫与分宫原理</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2021-08-06 20:29:32" itemprop="dateCreated datePublished" datetime="2021-08-06T20:29:32+00:00">2021-08-06</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2024-08-12 16:01:47" itemprop="dateModified" datetime="2024-08-12T16:01:47+00:00">2024-08-12</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/%E5%A4%A9%E6%96%87/" itemprop="url" rel="index"><span itemprop="name">天文</span></a>
</span>
</span>
<br>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>1.7k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>2 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="占星与星座计算-黄道十二宫与分宫原理"><a href="#占星与星座计算-黄道十二宫与分宫原理" class="headerlink" title="占星与星座计算 黄道十二宫与分宫原理"></a>占星与星座计算 黄道十二宫与分宫原理</h1><p>在占星与星座计算的第一篇文章中,尽可能详细的介绍了天球的构建过程原理和相关的概念。这一节我来介绍何为黄道12宫以及分工制的基本原理,不涉及具体分宫制。</p>
<h2 id="黄道带"><a href="#黄道带" class="headerlink" title="黄道带"></a>黄道带</h2><p>上一节的天球示意图中,我们已经标注出来了黄道,就是假定地球不动,太阳绕地球运动所形成的面,就是黄道。因为地球自转和地球公转是有一定角度偏差的。所以黄道和赤道是有一个23.5度的夹角的。</p>
<blockquote>
<p>黄道带(或是黄道十二宫)的概念起源于巴比伦占星术,巴比伦人注意到了与太阳同时升起的星星,在黎明之前,可以观察到靠近太阳位置的星星升起,这些星星以一个似乎规则的圆周来回运动。他们将这些星星分为十二组,并给其命名。希腊人从巴比伦人那里继承了这一习惯,才有了黄道十二宫,这个词来源于希腊文zodion,意为“小动物”。</p>
</blockquote>
<p>具体的黄道带的概念如下</p>
<blockquote>