eth-native 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/docs/PLAN.md +2 -2
- data/docs/RELEASE.md +55 -13
- data/docs/benchmarks/abi.md +10 -10
- data/docs/benchmarks/rlp.md +11 -11
- data/lib/eth/native/rlp.rb +2 -2
- data/lib/eth/native/version.rb +1 -1
- data/lib/eth/native.rb +8 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c655f65c6ce029735ca4c9fe15f9dae6a781a68ca0134f6ed7c8ea26ad2c2b44
|
|
4
|
+
data.tar.gz: e0ab0466f19b1ca50a595c56345a822ee11e141fec5f2996b252dc1f55840ad4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 580ef822c4ebdc89f9b21d717f2065d0f11058ef0ebed6283dd411724854d511b3f2e04ad52512b527e7809cf4b2de79a660ea6a31e410c7c961587828dcd4f1
|
|
7
|
+
data.tar.gz: 3274866472fcd8951d930a8078293c5e718757898553a58fb9fb8a886617fad00f5a9dda72919c8bd9948534121377bc40f3be8c0910cd31d745a52c5088cde5
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
`eth-native` 是 [eth.rb](https://github.com/q9f/eth.rb) 的可选 Rust 原生扩展,目标是以整包/批量方式加速 RLP 与 ABI 编解码。
|
|
4
4
|
|
|
5
|
-
> **项目状态:M0–
|
|
5
|
+
> **项目状态:M0–M5 已完成,v0.1.0 已发布 [rubygems.org](https://rubygems.org/gems/eth-native)(2026-12-06,OIDC Trusted Publishing)。** RLP 与 ABI(含 packed 编码与 fixed-point 的 Integer 值)均与 eth.rb 0.5.18 参考实现逐字节、逐错误差分一致(官方向量 + 数千随机差分用例)。Float/BigDecimal 的 fixed-point 值、标准编码器的 fixed/real 家族显式回退 Ruby;EIP-712 经 profiling 决策不 native 化。
|
|
6
6
|
|
|
7
7
|
## 约束
|
|
8
8
|
|
data/docs/PLAN.md
CHANGED
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
|
|
64
64
|
验收:以真实负载 p50/p95、吞吐、分配、RSS 决定范围;没有收益的路径不 native 化。
|
|
65
65
|
|
|
66
|
-
### M5
|
|
66
|
+
### M5:发布与分发(已完成——v0.1.0 已于 2026-12-06 经 OIDC 上线 rubygems.org)
|
|
67
67
|
|
|
68
68
|
- [x] macOS arm64/x86_64、Linux x86_64/aarch64 的 Ruby 4.0 CI。
|
|
69
|
-
- [x] 预编译 binary gem 与源码 gem 双轨;Windows
|
|
69
|
+
- [x] 预编译 binary gem 与源码 gem 双轨;Windows 未验证前不发布承诺(源码 gem 已上线;binary 流程见 docs/RELEASE.md,首次执行须人工核对)。
|
|
70
70
|
- [x] `Cargo.lock`、cargo audit/deny、gem 校验、发布签名和 Trusted Publishing(release.yml + docs/RELEASE.md)。
|
|
71
71
|
- [x] 发布 0.1.0 前完成安装、加载失败、版本不匹配和双后端 CI 矩阵。
|
|
72
72
|
|
data/docs/RELEASE.md
CHANGED
|
@@ -29,18 +29,60 @@
|
|
|
29
29
|
4. `release.yml` 校验 tag 与 `Eth::Native::VERSION` 一致,构建源码 gem,
|
|
30
30
|
通过 OIDC 推送(无需 API token)。
|
|
31
31
|
|
|
32
|
-
##
|
|
32
|
+
## v0.1.0 发布记录
|
|
33
|
+
|
|
34
|
+
2026-12-06:tag `v0.1.0` 触发 `release.yml`,测试门禁、版本校验、gem 构建
|
|
35
|
+
全绿;OIDC 推送经 `configure-rubygems-credentials@v2.2.0`(`owner: 66500`,
|
|
36
|
+
pending trusted publisher 首发必填)+ `gem push` 完成,rubygems.org 上线
|
|
37
|
+
(API 确认 version 0.1.0,非 yanked)。首发踩坑记录:
|
|
38
|
+
`release-gem@v1` 内嵌旧版 configure action 无 owner 输入,必须显式钉
|
|
39
|
+
v2.2.0;Bundler 4.x 移除 `bundle install --path`。
|
|
40
|
+
|
|
41
|
+
## 预编译 binary gem(双轨,已实施)
|
|
33
42
|
|
|
34
43
|
Windows 未进入 CI,**不发布 Windows 包,不承诺 Windows 支持**(PLAN 约束)。
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
当前发布的平台矩阵:`x86_64-linux`(macOS 与 aarch64-linux 2026-12-06 起
|
|
45
|
+
暂不构建不发布,需要时在 release.yml cross-compile 矩阵加回),针对
|
|
46
|
+
CRuby 4.0(与 gemspec `required_ruby_version` 一致;交叉编译基于
|
|
47
|
+
rake-compiler-dock 1.12.0 镜像,`RUBY_CC_VERSION` 含 Ruby 4.0.2)。
|
|
48
|
+
已知问题:aarch64-linux 交叉构建在 dock 镜像内有一段 cargo rustc 以
|
|
49
|
+
`--target aarch64` 编译却用宿主 gcc 链接,宿主 ld 不认
|
|
50
|
+
`--fix-cortex-a53-843419`(rustc 对 aarch64 目标默认附加,RUSTFLAGS /
|
|
51
|
+
CARGO_TARGET_*_RUSTFLAGS 关不掉);待上游镜像或 rb-sys 修复后再恢复。
|
|
52
|
+
|
|
53
|
+
机制:
|
|
54
|
+
|
|
55
|
+
- `Rakefile` 用 `RbSys::ExtensionTask`(rb_sys 0.9.130)。交叉编译由
|
|
56
|
+
rb-sys-dock 容器内的 `RUBY_TARGET` / `RUBY_CC_VERSION` 环境变量驱动;
|
|
57
|
+
宿主机无需任何配置,本地 `rake compile spec` 走原生路径。任务名必须与
|
|
58
|
+
`ext/eth_native/Cargo.toml` 的 `[package] name`(`eth-native`)一致。
|
|
59
|
+
rb_sys 在任务定义时从工作目录跑 `cargo metadata`,而 manifest 在
|
|
60
|
+
`ext/eth_native/`,故 Rakefile 子类只在 `init` 阶段 chdir 并把
|
|
61
|
+
source_files 绝对化。
|
|
62
|
+
- binary gem 不依赖 `rb_sys`(交叉打包时自动移除),安装零编译;
|
|
63
|
+
`.so` 位于版本化子目录,`lib/eth/native.rb` 的 loader 有
|
|
64
|
+
`require "eth/native/eth_native"` 回退。
|
|
65
|
+
- CI(`ci.yml` `binary-gem-smoke`):每次 push 都构建 x86_64-linux 包,
|
|
66
|
+
并在无 Rust 工具链的干净 `ruby:4.0.10-slim` 容器里安装、自检。
|
|
67
|
+
- 发布(`release.yml`):`cross-compile` 矩阵四平台产出 artifact,
|
|
68
|
+
release 任务统一推送;按「版本+平台已发布」精确跳过,因此
|
|
69
|
+
平台包可晚于源码 gem 补发,同版本号不需 bump(`eth-native-0.1.0
|
|
70
|
+
-x86_64-linux.gem` 等直接补 0.1.0)。
|
|
71
|
+
- 容器内 `bundle install` 通过仓库 `.bundle/config`
|
|
72
|
+
(`BUNDLE_WITHOUT=reference`)跳过 eth 0.5.18 参考组,避免容器内编译
|
|
73
|
+
rbsecp256k1 需要系统 `libsecp256k1-dev`。
|
|
74
|
+
|
|
75
|
+
本地构建与验证(等同 CI,用于首次人工核对):
|
|
76
|
+
|
|
77
|
+
```shell
|
|
78
|
+
# 构建(每个平台一次;首拉镜像约 1–2GB)
|
|
79
|
+
bundle exec rb-sys-dock -p x86_64-linux --ruby-versions 4.0 --build
|
|
80
|
+
# 干净容器无 Rust 安装 + 自检(复用 CI gem-install 脚本)
|
|
81
|
+
docker run --rm -v "$PWD/pkg:/pkg:ro" -v /tmp/selfcheck.rb:/selfcheck.rb:ro \
|
|
82
|
+
--entrypoint sh ruby:4.0.10-slim -c '
|
|
83
|
+
gem install --local /pkg/eth-native-*-x86_64-linux.gem && ruby /selfcheck.rb'
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
首次执行须人工核对每个平台产物通过上述干净环境自检(x86_64-linux
|
|
87
|
+
另需在 amd64 宿主或 CI 上真机验证;Apple Silicon 上 x86_64-linux 走
|
|
88
|
+
QEMU 模拟,仅作打包验证)。
|
data/docs/benchmarks/abi.md
CHANGED
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
|
|
15
15
|
| 场景 | 参考 ips | native ips | 速度 | native 分配/op(参考) |
|
|
16
16
|
| --- | --- | --- | --- | --- |
|
|
17
|
-
| encode uint256[1000] |
|
|
18
|
-
| encode string[1000] |
|
|
19
|
-
| encode event-tuple[1000] |
|
|
20
|
-
| encode 64KiB bytes |
|
|
21
|
-
| encode batch 1000 rows | 22.
|
|
22
|
-
| decode uint256[1000] |
|
|
23
|
-
| decode string[1000] |
|
|
24
|
-
| decode event-tuple[1000] | 23.
|
|
25
|
-
| decode 64KiB bytes |
|
|
26
|
-
| decode_many 1000 rows |
|
|
17
|
+
| encode uint256[1000] | 428.0 | 3756.5 | 8.8x | 2.9(17202.2) |
|
|
18
|
+
| encode string[1000] | 93.5 | 3300.2 | 35.3x | 1002.9(42558.8) |
|
|
19
|
+
| encode event-tuple[1000] | 28.9 | 294.9 | 10.2x | 10962.9(198116.8) |
|
|
20
|
+
| encode 64KiB bytes | 46.5k | 85.9k | 1.8x | 2.9(80.8) |
|
|
21
|
+
| encode batch 1000 rows | 22.2 | 523.7 | 23.6x | 7001.9(416252.8) |
|
|
22
|
+
| decode uint256[1000] | 559.3 | 6067.1 | 10.8x | 2.9(22075.8) |
|
|
23
|
+
| decode string[1000] | 385.6 | 14.4k | 37.5x | 1002.9(26074.8) |
|
|
24
|
+
| decode event-tuple[1000] | 23.7 | 1001.0 | 42.2x | 5978.9(452248.8) |
|
|
25
|
+
| decode 64KiB bytes | 167.5k | 118.2k | 1.4x 慢 | 4.9(66.8) |
|
|
26
|
+
| decode_many 1000 rows | 12.9 | 1008.0 | 78.2x | 4034.9(748333.8) |
|
|
27
27
|
|
|
28
28
|
## 结论
|
|
29
29
|
|
data/docs/benchmarks/rlp.md
CHANGED
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
|
|
16
16
|
| 场景 | 参考 ips | native ips | 速度 | native 分配/op(参考) |
|
|
17
17
|
| --- | --- | --- | --- | --- |
|
|
18
|
-
| encode 12
|
|
19
|
-
| encode 1k
|
|
20
|
-
| encode 1k
|
|
21
|
-
| encode 1KiB bytes |
|
|
22
|
-
| encode 64KiB bytes |
|
|
23
|
-
| encode
|
|
24
|
-
| decode 12
|
|
25
|
-
| decode 1k
|
|
26
|
-
| decode 1k
|
|
27
|
-
| decode 64KiB bytes |
|
|
28
|
-
| decode
|
|
18
|
+
| encode tx (12 fields) | 35.5k | 509.7k | 14.4x | 1.4(123.5) |
|
|
19
|
+
| encode 1k integers | 514.8 | 11.6k | 22.5x | 1.4(11140.3) |
|
|
20
|
+
| encode 1k nested | 62.9 | 716.4 | 11.4x | 1.4(91094.3) |
|
|
21
|
+
| encode 1KiB bytes | 165.6k | 1113.1k | 6.7x | 1.4(35.3) |
|
|
22
|
+
| encode 64KiB bytes | 67.6k | 354.4k | 5.2x | 1.4(35.3) |
|
|
23
|
+
| encode batch 100 tx | 405.2 | 6838.7 | 16.9x | 1.4(12422.3) |
|
|
24
|
+
| decode tx (12 fields) | 146.0k | 731.5k | 5.0x | 13.4(72.3) |
|
|
25
|
+
| decode 1k integers | 2291.0 | 20.7k | 9.0x | 1001.4(5012.3) |
|
|
26
|
+
| decode 1k nested | 289.8 | 2407.7 | 8.3x | 8001.4(36247.3) |
|
|
27
|
+
| decode 64KiB bytes | 405.0k | 247.1k | 1.6x 慢 | 2.4(23.3) |
|
|
28
|
+
| decode batch 100 tx | 1637.2 | 13.5k | 8.3x | 1301.4(6912.3) |
|
|
29
29
|
|
|
30
30
|
## 结论
|
|
31
31
|
|
data/lib/eth/native/rlp.rb
CHANGED
|
@@ -48,7 +48,7 @@ module Eth
|
|
|
48
48
|
rescue UnsupportedInput => e
|
|
49
49
|
fallback(:encode, obj, e)
|
|
50
50
|
rescue EncodingError => e
|
|
51
|
-
remap(e, ::Eth::Rlp::EncodingError)
|
|
51
|
+
remap(e, defined?(::Eth::Rlp) ? ::Eth::Rlp::EncodingError : nil)
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
# Decodes an RLP-encoded item, applying the reference string semantics
|
|
@@ -72,7 +72,7 @@ module Eth
|
|
|
72
72
|
rescue UnsupportedInput => e
|
|
73
73
|
fallback(:decode, data, e)
|
|
74
74
|
rescue DecodingError => e
|
|
75
|
-
remap(e, ::Eth::Rlp::DecodingError)
|
|
75
|
+
remap(e, defined?(::Eth::Rlp) ? ::Eth::Rlp::DecodingError : nil)
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
# Delegates an input the native encoder marked as unsupported to the
|
data/lib/eth/native/version.rb
CHANGED
data/lib/eth/native.rb
CHANGED
|
@@ -66,7 +66,14 @@ module Eth
|
|
|
66
66
|
raise LoadError, "eth-native requires CRuby >= #{MINIMUM_RUBY_VERSION}, < #{MAXIMUM_RUBY_VERSION}; got #{RUBY_ENGINE} #{RUBY_VERSION}"
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
# Source gems compile the extension into the gem extension dir, while
|
|
70
|
+
# binary platform gems ship it under a versioned lib subdirectory that
|
|
71
|
+
# only the adjusted require_paths resolve.
|
|
72
|
+
begin
|
|
73
|
+
require_relative "native/eth_native"
|
|
74
|
+
rescue LoadError
|
|
75
|
+
require "eth/native/eth_native"
|
|
76
|
+
end
|
|
70
77
|
|
|
71
78
|
@native_abi_version = ::EthNativeExt.__native_abi_version__
|
|
72
79
|
unless @native_abi_version == NATIVE_ABI_VERSION
|