Skip to content

Commit 1a2e7c6

Browse files
birchmdaleksuss
andauthored
Release 3.0.0 (#828)
### Fixes - Updated sputnikvm dependency with bugfix in the `returndatacopy` implementation and a performance improvement in accessing EVM memory. (#826) ### Changes - BREAKING: `engine-standalone-storage` no longer automatically writes to the DB when `consume_message` is called. It is up to downstream users of the library to commit the diff (after doing any validation for correctness). (#825) ### Additions - New crate for the so-called "hashchain" implementation. It will enable verification of Aurora blocks by light clients in the future. (#816) --------- Co-authored-by: Oleksandr Anyshchenko <[email protected]>
1 parent 17b6d69 commit 1a2e7c6

File tree

19 files changed

+1191
-41
lines changed

19 files changed

+1191
-41
lines changed

CHANGES.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [3.0.0] 2023-08-28
11+
12+
### Fixes
13+
14+
- Updated sputnikvm dependency with bugfix in the `returndatacopy` implementation and a performance improvement in accessing EVM memory. [@birchmd] ([#826])
15+
16+
### Changes
17+
18+
- BREAKING: `engine-standalone-storage` no loonger automatically writes to the DB when `consume_message` is called. It is up to downstream users of the library to commit the diff (after doing any validation for correctness). [@birchmd] ([#825])
19+
20+
### Additions
21+
22+
- New crate for the so-called "hashchain" implementation. It will enable verification of Aurora blocks by light clients in the future. [@birchmd] ([#816])
23+
24+
[#816]: https://github.com/aurora-is-near/aurora-engine/pull/816
25+
[#825]: https://github.com/aurora-is-near/aurora-engine/pull/825
26+
[#826]: https://github.com/aurora-is-near/aurora-engine/pull/826
27+
1028
## [2.10.2] 2023-08-10
1129

1230
### Changes
@@ -465,6 +483,7 @@ struct SubmitResult {
465483
## [1.0.0] - 2021-05-12
466484

467485
[Unreleased]: https://github.com/aurora-is-near/aurora-engine/compare/2.10.2...develop
486+
[3.0.0]: https://github.com/aurora-is-near/aurora-engine/compare/2.10.2...3.0.0
468487
[2.10.2]: https://github.com/aurora-is-near/aurora-engine/compare/2.10.1...2.10.2
469488
[2.10.1]: https://github.com/aurora-is-near/aurora-engine/compare/2.10.0...2.10.1
470489
[2.10.0]: https://github.com/aurora-is-near/aurora-engine/compare/2.9.3...2.10.0

Cargo.lock

Lines changed: 14 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ byte-slice-cast = { version = "1", default-features = false }
3131
criterion = "0.5"
3232
digest = "0.10"
3333
ethabi = { version = "18", default-features = false }
34-
evm = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.38.0-aurora", default-features = false }
35-
evm-core = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.38.0-aurora", default-features = false, features = ["std"] }
36-
evm-gasometer = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.38.0-aurora", default-features = false, features = ["std", "tracing"] }
37-
evm-runtime = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.38.0-aurora", default-features = false, features = ["std", "tracing"] }
34+
evm = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.38.3-aurora", default-features = false }
35+
evm-core = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.38.3-aurora", default-features = false, features = ["std"] }
36+
evm-gasometer = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.38.3-aurora", default-features = false, features = ["std", "tracing"] }
37+
evm-runtime = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.38.3-aurora", default-features = false, features = ["std", "tracing"] }
38+
fixed-hash = { version = "0.8.0", default-features = false}
3839
git2 = "0.17"
3940
hex = { version = "0.4", default-features = false, features = ["alloc"] }
4041
ibig = { version = "0.3", default-features = false, features = ["num-traits"] }
42+
impl-serde = { version = "0.4.0", default-features = false}
4143
lazy_static = "1"
4244
libsecp256k1 = { version = "0.7", default-features = false }
4345
near-crypto = "0.17"
@@ -71,6 +73,7 @@ workspaces = "0.7"
7173
resolver = "2"
7274
members = [
7375
"engine",
76+
"engine-hashchain",
7477
"engine-test-doubles",
7578
"engine-modexp",
7679
"engine-precompiles",

Makefile.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ args = [
342342
"--release",
343343
"--features",
344344
"${CARGO_FEATURES_TEST}",
345-
"bench_modexp_standalone",
345+
"bench_m",
346346
"--",
347347
"--ignored",
348348
]

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.10.2
1+
3.0.0

engine-hashchain/Cargo.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
name = "aurora-engine-hashchain"
3+
version = "1.0.0"
4+
authors.workspace = true
5+
edition.workspace = true
6+
readme.workspace = true
7+
homepage.workspace = true
8+
repository.workspace = true
9+
license.workspace = true
10+
publish.workspace = true
11+
autobenches = false
12+
13+
[dependencies]
14+
aurora-engine-types.workspace = true
15+
aurora-engine-sdk.workspace = true
16+
fixed-hash.workspace = true
17+
impl-serde.workspace = true
18+
19+
[features]
20+
default = ["std"]
21+
std = ["aurora-engine-types/std", "aurora-engine-sdk/std", "fixed-hash/std", "impl-serde/std"]
22+
borsh-compat = ["aurora-engine-types/borsh-compat", "aurora-engine-sdk/borsh-compat"]

engine-hashchain/src/bloom.rs

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
//! Based on Parity Common Eth Bloom implementation
2+
//! Link: <https://github.com/paritytech/parity-common/blob/master/ethbloom/src/lib.rs>
3+
//!
4+
//! Reimplemented here since there is a large mismatch in types and dependencies.
5+
#![allow(clippy::expl_impl_clone_on_copy)]
6+
7+
use aurora_engine_sdk::keccak;
8+
use aurora_engine_types::borsh::{self, BorshDeserialize, BorshSerialize};
9+
use aurora_engine_types::parameters::engine::ResultLog;
10+
use fixed_hash::construct_fixed_hash;
11+
use impl_serde::impl_fixed_hash_serde;
12+
13+
const BLOOM_SIZE: usize = 256;
14+
const BLOOM_BITS: u32 = 3;
15+
16+
construct_fixed_hash! {
17+
/// Bloom hash type with 256 bytes (2048 bits) size.
18+
#[derive(BorshSerialize, BorshDeserialize)]
19+
pub struct Bloom(BLOOM_SIZE);
20+
}
21+
22+
impl_fixed_hash_serde!(Bloom, BLOOM_SIZE);
23+
24+
/// Returns log2.
25+
const fn log2(x: usize) -> u32 {
26+
if x <= 1 {
27+
return 0;
28+
}
29+
30+
let n = x.leading_zeros();
31+
usize::BITS - n
32+
}
33+
34+
impl Bloom {
35+
/// Add a new element to the bloom filter
36+
#[allow(clippy::as_conversions)]
37+
pub fn accrue(&mut self, input: &[u8]) {
38+
let m = self.0.len();
39+
let bloom_bits = m * 8;
40+
let mask = bloom_bits - 1;
41+
let bloom_bytes = (log2(bloom_bits) + 7) / 8;
42+
let hash = keccak(input);
43+
let mut ptr = 0;
44+
45+
for _ in 0..BLOOM_BITS {
46+
let mut index = 0;
47+
for _ in 0..bloom_bytes {
48+
index = (index << 8) | hash[ptr] as usize;
49+
ptr += 1;
50+
}
51+
index &= mask;
52+
self.0[m - 1 - index / 8] |= 1 << (index % 8);
53+
}
54+
}
55+
56+
/// Merge two bloom filters
57+
pub fn accrue_bloom(&mut self, bloom: &Self) {
58+
for i in 0..BLOOM_SIZE {
59+
self.0[i] |= bloom.0[i];
60+
}
61+
}
62+
}
63+
64+
#[must_use]
65+
pub fn get_logs_bloom(logs: &[ResultLog]) -> Bloom {
66+
let mut logs_bloom = Bloom::default();
67+
68+
for log in logs {
69+
logs_bloom.accrue_bloom(&get_log_bloom(log));
70+
}
71+
72+
logs_bloom
73+
}
74+
75+
#[must_use]
76+
pub fn get_log_bloom(log: &ResultLog) -> Bloom {
77+
let mut log_bloom = Bloom::default();
78+
79+
log_bloom.accrue(log.address.as_bytes());
80+
for topic in &log.topics {
81+
log_bloom.accrue(&topic[..]);
82+
}
83+
84+
log_bloom
85+
}

engine-hashchain/src/error.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
pub const ERR_STATE_NOT_FOUND: &[u8; 19] = b"ERR_STATE_NOT_FOUND";
2+
pub const ERR_STATE_SERIALIZATION_FAILED: &[u8; 26] = b"ERR_STATE_SERIALIZE_FAILED";
3+
pub const ERR_STATE_CORRUPTED: &[u8; 19] = b"ERR_STATE_CORRUPTED";
4+
pub const ERR_BLOCK_HEIGHT_INCORRECT: &[u8; 26] = b"ERR_BLOCK_HEIGHT_INCORRECT";
5+
pub const ERR_REQUIRES_FEATURE_INTEGRATION_TEST: &[u8; 37] =
6+
b"ERR_REQUIRES_FEATURE_INTEGRATION_TEST";
7+
8+
#[derive(Debug)]
9+
/// Blockchain Hashchain Error
10+
pub enum BlockchainHashchainError {
11+
/// The state is missing from storage, need to initialize with contract `new` method.
12+
NotFound,
13+
/// The state serialized had failed.
14+
SerializationFailed,
15+
/// The state is corrupted, possibly due to failed state migration.
16+
DeserializationFailed,
17+
/// The block height is incorrect regarding the current block height.
18+
BlockHeightIncorrect,
19+
/// Some functionality requires integration-test feature.
20+
RequiresFeatureIntegrationTest,
21+
}
22+
23+
impl AsRef<[u8]> for BlockchainHashchainError {
24+
fn as_ref(&self) -> &[u8] {
25+
match self {
26+
Self::NotFound => ERR_STATE_NOT_FOUND,
27+
Self::SerializationFailed => ERR_STATE_SERIALIZATION_FAILED,
28+
Self::DeserializationFailed => ERR_STATE_CORRUPTED,
29+
Self::BlockHeightIncorrect => ERR_BLOCK_HEIGHT_INCORRECT,
30+
Self::RequiresFeatureIntegrationTest => ERR_REQUIRES_FEATURE_INTEGRATION_TEST,
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)