EIP-2930 spec change for signature hash (#261)

* EIP-2930 spec change for signature hash
* Removing eip2930 test blocks
This commit is contained in:
rakita 2021-02-10 15:58:35 +01:00 committed by GitHub
parent 6b4e56b214
commit dbf9a1cd98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 7 additions and 3259 deletions

View File

@ -1,69 +0,0 @@
{
"name": "YoloEIP2930",
"engine": {
"Ethash": {
"params": {
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x1BC16D674EC80000",
"homesteadTransition": "0x0",
"eip100bTransition": "0x0",
"difficultyBombDelays": {
"0": 5000000
}
}
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"registrar": "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID": "0x1",
"maxCodeSize": 24576,
"maxCodeSizeTransition": "0x0",
"eip150Transition": "0x0",
"eip160Transition": "0x0",
"eip161abcTransition": "0x0",
"eip161dTransition": "0x0",
"eip140Transition": "0x0",
"eip211Transition": "0x0",
"eip214Transition": "0x0",
"eip155Transition": "0x0",
"eip658Transition": "0x0",
"eip145Transition": "0x0",
"eip1014Transition": "0x0",
"eip1052Transition": "0x0",
"eip1283Transition": "0x0",
"eip1283DisableTransition": "0x0",
"eip1283ReenableTransition": "0x0",
"eip1344Transition": "0x0",
"eip1706Transition": "0x0",
"eip1884Transition": "0x0",
"eip2028Transition": "0x0",
"eip2315Transition": "0x0",
"eip2929Transition": "0x0",
"eip2930Transition": "0x0"
},
"genesis": {
"seal": {
"ethereum": {
"nonce": "0x0000000000000539",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
"difficulty": "0x20000",
"gasLimit": "0x47e7c4"
},
"accounts": {
"000000000000000000000000000000000000aaaa": {
"balance": "0",
"code": "0x5854505854503231"
},
"71562b71999873db5b286df957af199ec94617f7": {
"balance": "0x3b9aca00"
}
}
}

View File

@ -6,10 +6,6 @@
}
],
"chain": [
{
"path": "res/local_tests/chain",
"skip": []
},
{
"path": "res/json_tests/BlockchainTests",
"skip": []

File diff suppressed because one or more lines are too long

View File

@ -99,7 +99,6 @@ impl<'a> EvmTestClient<'a> {
ForkSpec::Homestead => Some(ethereum::new_homestead_test()),
ForkSpec::EIP150 => Some(ethereum::new_eip150_test()),
ForkSpec::EIP158 => Some(ethereum::new_eip161_test()),
ForkSpec::EIP2930 => Some(ethereum::new_eip2930_test()),
ForkSpec::Byzantium => Some(ethereum::new_byzantium_test()),
ForkSpec::Constantinople => Some(ethereum::new_constantinople_test()),
ForkSpec::ConstantinopleFix => Some(ethereum::new_constantinople_fix_test()),

View File

@ -274,14 +274,6 @@ pub fn new_berlin_test() -> Spec {
)
}
/// Create a new Foundation Berlin era spec.
pub fn new_eip2930_test() -> Spec {
load(
None,
include_bytes!("../../res/chainspec/test/eip2930_test.json"),
)
}
/// Create a new Musicoin-MCIP3-era spec.
pub fn new_mcip3_test() -> Spec {
load(

View File

@ -142,11 +142,6 @@ pub struct Transaction {
}
impl Transaction {
/// The message hash of the transaction. This hash is used for signing transaction
pub fn signature_hash(&self, chain_id: Option<u64>) -> H256 {
keccak(self.encode(chain_id, None))
}
/// encode raw transaction
fn encode(&self, chain_id: Option<u64>, signature: Option<&SignatureComponents>) -> Vec<u8> {
let mut stream = RlpStream::new();
@ -321,21 +316,14 @@ impl AccessListTx {
fn encode_payload(
&self,
tx_type: Option<u8>, //used only for signature hashing for EIP-2930
chain_id: Option<u64>,
signature: Option<&SignatureComponents>,
) -> RlpStream {
let mut stream = RlpStream::new();
let mut list_size = if signature.is_some() { 11 } else { 8 };
list_size += if tx_type.is_some() { 1 } else { 0 };
let list_size = if signature.is_some() { 11 } else { 8 };
stream.begin_list(list_size);
// append tx_type at beggining of list, this is used only for data hash for signature.
if let Some(tx_type) = tx_type {
stream.append(&tx_type);
}
// append chain_id. from EIP-2930: chainId is defined to be an integer of arbitrary size.
stream.append(&(if let Some(n) = chain_id { n } else { 0 }));
@ -353,7 +341,7 @@ impl AccessListTx {
}
}
// append signature
// append signature if any
if let Some(signature) = signature {
signature.rlp_append(&mut stream);
}
@ -366,7 +354,7 @@ impl AccessListTx {
chain_id: Option<u64>,
signature: Option<&SignatureComponents>,
) -> Vec<u8> {
let stream = self.encode_payload(None, chain_id, signature);
let stream = self.encode_payload(chain_id, signature);
// make as vector of bytes
[&[TypedTxId::AccessList as u8], stream.as_raw()].concat()
}
@ -379,14 +367,6 @@ impl AccessListTx {
) {
rlp.append(&self.encode(chain_id, Some(signature)));
}
pub fn signature_hash(&self, chain_id: Option<u64>) -> H256 {
keccak(
&self
.encode_payload(Some(TypedTxId::AccessList as u8), chain_id, None)
.as_raw(),
)
}
}
#[derive(Debug, Clone, Eq, PartialEq)]
@ -406,10 +386,10 @@ impl TypedTransaction {
/// The message hash of the transaction.
pub fn signature_hash(&self, chain_id: Option<u64>) -> H256 {
match self {
Self::Legacy(tx) => tx.signature_hash(chain_id),
Self::AccessList(tx) => tx.signature_hash(chain_id),
}
keccak(match self {
Self::Legacy(tx) => tx.encode(chain_id, None),
Self::AccessList(tx) => tx.encode(chain_id, None),
})
}
/// Signs the transaction as coming from `sender`.

View File

@ -25,7 +25,6 @@ use std::io::Read;
pub enum ForkSpec {
EIP150,
EIP158,
EIP2930,
Frontier,
Homestead,
Byzantium,