Skip to content
This repository was archived by the owner on Oct 9, 2022. It is now read-only.

Commit 6796933

Browse files
authored
Support Berlin upgrade AccessListTxType (#153)
1 parent a0ef546 commit 6796933

12 files changed

Lines changed: 536 additions & 54 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "darwinia-shadow"
3-
version = "0.4.0"
3+
version = "0.5.0"
44
authors = ["clearloop <udtrokia@gmail.com>"]
55
edition = "2018"
66
description = "The shadow service for relayers and verify workers to retrieve header data and generate proof."

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The shadow service for relayers and verify workers to retrieve header data and g
1111
## Usage
1212

1313
```sh
14-
shadow 0.4.0
14+
shadow 0.5.0
1515

1616
USAGE:
1717
shadow <SUBCOMMAND>

api/src/ethereum/mmr_leaf.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ use serde::{Serialize};
1010
/// MMR leaf result
1111
#[derive(Clone, Debug, Serialize, PartialEq, Eq)]
1212
#[serde(untagged)]
13-
pub enum MMRLeafResult {
14-
MMRLeaf { mmr_leaf: String },
13+
pub enum MmrLeafResult {
14+
MmrLeaf { mmr_leaf: String },
1515
Error { error: String }
1616
}
1717

1818
/// Get target mmr
1919
#[allow(clippy::eval_order_dependence)]
2020
pub async fn handle(block: Path<String>, app_data: Data<AppData>) -> impl Responder {
2121
match mmr_leaf(block, &app_data.mmr_db) {
22-
Ok(leaf) => Json(MMRLeafResult::MMRLeaf { mmr_leaf: format!("0x{}", leaf) }),
23-
Err(err) => Json(MMRLeafResult::Error { error: err.to_string() })
22+
Ok(leaf) => Json(MmrLeafResult::MmrLeaf { mmr_leaf: format!("0x{}", leaf) }),
23+
Err(err) => Json(MmrLeafResult::Error { error: err.to_string() })
2424
}
2525
}
2626

api/src/ethereum/parent_mmr_root.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use serde::Serialize;
1010
/// MMR root result
1111
#[derive(Clone, Debug, Serialize, PartialEq, Eq)]
1212
#[serde(untagged)]
13-
pub enum MMRRootResult {
13+
pub enum MmrRootResult {
1414
MmrRoot { mmr_root: String },
1515
Error { error: String }
1616
}
@@ -19,8 +19,8 @@ pub enum MMRRootResult {
1919
#[allow(clippy::eval_order_dependence)]
2020
pub async fn handle(block: Path<String>, app_data: Data<AppData>) -> impl Responder {
2121
match parent_mmr_root(block, &app_data.mmr_db) {
22-
Ok(root) => Json(MMRRootResult::MmrRoot { mmr_root: format!("0x{}", root) }),
23-
Err(err) => Json(MMRRootResult::Error { error: err.to_string() })
22+
Ok(root) => Json(MmrRootResult::MmrRoot { mmr_root: format!("0x{}", root) }),
23+
Err(err) => Json(MmrRootResult::Error { error: err.to_string() })
2424
}
2525
}
2626

ffi/go.mod

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ module github.com/darwinia-network/shadow/ffi
33
go 1.14
44

55
require (
6+
github.com/btcsuite/btcd v0.21.0-beta // indirect
67
github.com/deckarep/golang-set v1.7.1
78
github.com/edsrzf/mmap-go v1.0.0
8-
github.com/ethereum/go-ethereum v1.9.15
9-
github.com/fatih/color v1.3.0
9+
github.com/ethereum/go-ethereum v1.10.2
10+
github.com/fatih/color v1.7.0
1011
github.com/go-logfmt/logfmt v0.4.0 // indirect
11-
github.com/golang/protobuf v1.3.3 // indirect
12-
github.com/golang/snappy v0.0.1
13-
github.com/hashicorp/golang-lru v0.5.4
12+
github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3
13+
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
1414
github.com/huandu/xstrings v1.3.2
1515
github.com/mattn/go-isatty v0.0.12 // indirect
1616
github.com/mitchellh/mapstructure v1.3.2
@@ -19,10 +19,10 @@ require (
1919
github.com/prometheus/tsdb v0.7.1 // indirect
2020
github.com/regcostajr/go-web3 v0.0.0-20180609031449-555e83b623dd
2121
github.com/shopspring/decimal v1.2.0
22-
github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d
22+
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954
2323
github.com/ttacon/builder v0.0.0-20170518171403-c099f663e1c2 // indirect
2424
github.com/ttacon/libphonenumber v1.1.0
2525
github.com/tuvistavie/securerandom v0.0.0-20140719024926-15512123a948
26-
golang.org/x/crypto v0.0.0-20200707235045-ab33eee955e0
27-
gopkg.in/yaml.v2 v2.2.8 // indirect
26+
golang.org/x/crypto v0.0.0-20210415154028-4f45737414dc
27+
golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe // indirect
2828
)

ffi/go.sum

Lines changed: 503 additions & 0 deletions
Large diffs are not rendered by default.

ffi/pkg/ethashproof/ethash/consensus.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -562,17 +562,6 @@ func (ethash *Ethash) Prepare(chain consensus.ChainReader, header *types.Header)
562562
return nil
563563
}
564564

565-
// Finalize implements consensus.Engine, accumulating the block and uncle rewards,
566-
// setting the final state and assembling the block.
567-
func (ethash *Ethash) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
568-
// Accumulate any block and uncle rewards and commit the final state root
569-
accumulateRewards(chain.Config(), state, header, uncles)
570-
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
571-
572-
// Header seems complete, assemble into a block and return
573-
return types.NewBlock(header, txs, uncles, receipts), nil
574-
}
575-
576565
// SealHash returns the hash of a block prior to it being sealed.
577566
func (ethash *Ethash) SealHash(header *types.Header) (hash common.Hash) {
578567
hasher := sha3.NewLegacyKeccak256()

ffi/pkg/shadow/eth/receipt.go

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -189,32 +189,24 @@ func GetReceiptRlpEncode(api string, tx string) (*types.Receipt, error) {
189189
func trieFromReceipts(receipts map[string]interface{}) (*trie.Trie, error) {
190190
tr := new(trie.Trie)
191191

192-
for i, r := range receipts {
193-
path, err := rlp.EncodeToBytes(uint(util.StringToInt(i)))
194-
if err != nil {
195-
return nil, err
196-
}
192+
var receiptList types.Receipts
193+
for i := 0; i < len(receipts); i++ {
194+
receiptList = append(receiptList, receipts[util.IntToString(i)].(*types.Receipt))
195+
}
197196

198-
rawReceipt, err := encodeReceipt(r.(*types.Receipt))
197+
for i := range receipts {
198+
path, err := rlp.EncodeToBytes(uint(util.StringToInt(i)))
199199
if err != nil {
200200
return nil, err
201201
}
202-
203-
tr.Update(path, rawReceipt)
202+
w := new(bytes.Buffer)
203+
receiptList.EncodeIndex(util.StringToInt(i), w)
204+
tr.Update(path, w.Bytes())
204205
}
205206

206207
return tr, nil
207208
}
208209

209-
func encodeReceipt(r *types.Receipt) ([]byte, error) {
210-
buf := new(bytes.Buffer)
211-
if err := r.EncodeRLP(buf); err != nil {
212-
return nil, err
213-
}
214-
215-
return buf.Bytes(), nil
216-
}
217-
218210
func rlpLength(dataLen int, offset byte) []byte {
219211
if dataLen < 56 {
220212
return []byte{byte(dataLen) + offset}

mmr/src/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ use thiserror::Error;
22
use anyhow::Result as AnyResult;
33

44
#[derive(Error, Debug)]
5-
pub enum MMRError {
5+
pub enum MmrError {
66
#[error(transparent)]
77
Io(#[from] std::io::Error),
88

99
#[error(transparent)]
10-
CMMRError(#[from] cmmr::Error),
10+
CmmrError(#[from] cmmr::Error),
1111

1212
#[error(transparent)]
1313
MysqlError(#[from] mysql::Error),
@@ -23,4 +23,4 @@ pub enum MMRError {
2323

2424
}
2525

26-
pub type Result<T> = AnyResult<T, MMRError>;
26+
pub type Result<T> = AnyResult<T, MmrError>;

mmr/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ mod mmr_client_trait;
1616
mod mmr_client_for_rocksdb;
1717

1818
pub use self::{
19-
error::{Result, MMRError as Error},
19+
error::{Result, MmrError as Error},
2020
hash::{MergeHash, H256},
2121
rocksdb_store::RocksdbStore,
2222
rocksdb_batchstore::RocksBatchStore,

0 commit comments

Comments
 (0)