eth-native 0.1.0
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 +7 -0
- data/LICENSE +202 -0
- data/README.md +84 -0
- data/docs/ARCHITECTURE.md +162 -0
- data/docs/PLAN.md +90 -0
- data/docs/RELEASE.md +46 -0
- data/docs/benchmarks/abi.md +41 -0
- data/docs/benchmarks/e2e.md +46 -0
- data/docs/benchmarks/rlp.md +44 -0
- data/ext/eth_native/Cargo.lock +281 -0
- data/ext/eth_native/Cargo.toml +22 -0
- data/ext/eth_native/README.md +15 -0
- data/ext/eth_native/extconf.rb +6 -0
- data/ext/eth_native/src/abi.rs +2169 -0
- data/ext/eth_native/src/lib.rs +35 -0
- data/ext/eth_native/src/rlp.rs +694 -0
- data/lib/eth/native/abi.rb +267 -0
- data/lib/eth/native/rlp.rb +147 -0
- data/lib/eth/native/version.rb +7 -0
- data/lib/eth/native.rb +82 -0
- metadata +123 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
mod abi;
|
|
2
|
+
mod rlp;
|
|
3
|
+
|
|
4
|
+
use magnus::{function, Object, Ruby};
|
|
5
|
+
|
|
6
|
+
/// Native ABI version exported to Ruby.
|
|
7
|
+
///
|
|
8
|
+
/// The value is compared against `Eth::Native::NATIVE_ABI_VERSION` during
|
|
9
|
+
/// extension load so a mismatched binary fails before any accelerated method
|
|
10
|
+
/// can be called.
|
|
11
|
+
#[magnus::init]
|
|
12
|
+
fn init(ruby: &Ruby) -> Result<(), magnus::Error> {
|
|
13
|
+
let module = ruby.define_module("EthNativeExt")?;
|
|
14
|
+
module.define_singleton_method("__native_abi_version__", function!(native_abi_version, 0))?;
|
|
15
|
+
module.define_singleton_method("__rlp_encode__", function!(rlp::encode_entry, 1))?;
|
|
16
|
+
module.define_singleton_method("__rlp_decode__", function!(rlp::decode_entry, 1))?;
|
|
17
|
+
module.define_singleton_method("__abi_compile__", function!(abi::compile_entry, 1))?;
|
|
18
|
+
module.define_singleton_method("__abi_encode__", function!(abi::encode_entry, 2))?;
|
|
19
|
+
module.define_singleton_method("__abi_decode__", function!(abi::decode_entry, 2))?;
|
|
20
|
+
module.define_singleton_method("__abi_decode_many__", function!(abi::decode_many_entry, 2))?;
|
|
21
|
+
module.define_singleton_method(
|
|
22
|
+
"__abi_packed_compile__",
|
|
23
|
+
function!(abi::packed_compile_entry, 1),
|
|
24
|
+
)?;
|
|
25
|
+
module.define_singleton_method(
|
|
26
|
+
"__abi_packed_encode__",
|
|
27
|
+
function!(abi::packed_encode_entry, 2),
|
|
28
|
+
)?;
|
|
29
|
+
abi::init(ruby)?;
|
|
30
|
+
Ok(())
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
fn native_abi_version() -> u64 {
|
|
34
|
+
1
|
|
35
|
+
}
|