Aura eip155 validation transition (#5362)
* add eip155 validation * add transition block
This commit is contained in:
parent
83fea78d38
commit
84abf5d84f
@ -24,7 +24,8 @@
|
|||||||
"0x00a0a24b9f0e5ec7aa4c7389b8302fd0123194de"
|
"0x00a0a24b9f0e5ec7aa4c7389b8302fd0123194de"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"validateScoreTransition": 1000000
|
"validateScoreTransition": 1000000,
|
||||||
|
"eip155Transition": 1000000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -27,12 +27,13 @@ use block::*;
|
|||||||
use spec::CommonParams;
|
use spec::CommonParams;
|
||||||
use engines::{Engine, Seal, EngineError};
|
use engines::{Engine, Seal, EngineError};
|
||||||
use header::Header;
|
use header::Header;
|
||||||
use error::{Error, BlockError};
|
use error::{Error, TransactionError, BlockError};
|
||||||
use evm::Schedule;
|
use evm::Schedule;
|
||||||
use ethjson;
|
use ethjson;
|
||||||
use io::{IoContext, IoHandler, TimerToken, IoService};
|
use io::{IoContext, IoHandler, TimerToken, IoService};
|
||||||
use env_info::EnvInfo;
|
use env_info::EnvInfo;
|
||||||
use builtin::Builtin;
|
use builtin::Builtin;
|
||||||
|
use transaction::UnverifiedTransaction;
|
||||||
use client::{Client, EngineClient};
|
use client::{Client, EngineClient};
|
||||||
use state::CleanupMode;
|
use state::CleanupMode;
|
||||||
use super::signer::EngineSigner;
|
use super::signer::EngineSigner;
|
||||||
@ -55,6 +56,8 @@ pub struct AuthorityRoundParams {
|
|||||||
pub validators: ethjson::spec::ValidatorSet,
|
pub validators: ethjson::spec::ValidatorSet,
|
||||||
/// Chain score validation transition block.
|
/// Chain score validation transition block.
|
||||||
pub validate_score_transition: u64,
|
pub validate_score_transition: u64,
|
||||||
|
/// Number of first block where EIP-155 rules are validated.
|
||||||
|
pub eip155_transition: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ethjson::spec::AuthorityRoundParams> for AuthorityRoundParams {
|
impl From<ethjson::spec::AuthorityRoundParams> for AuthorityRoundParams {
|
||||||
@ -67,6 +70,7 @@ impl From<ethjson::spec::AuthorityRoundParams> for AuthorityRoundParams {
|
|||||||
registrar: p.registrar.map_or_else(Address::new, Into::into),
|
registrar: p.registrar.map_or_else(Address::new, Into::into),
|
||||||
start_step: p.start_step.map(Into::into),
|
start_step: p.start_step.map(Into::into),
|
||||||
validate_score_transition: p.validate_score_transition.map_or(0, Into::into),
|
validate_score_transition: p.validate_score_transition.map_or(0, Into::into),
|
||||||
|
eip155_transition: p.eip155_transition.map_or(0, Into::into),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,6 +93,7 @@ pub struct AuthorityRound {
|
|||||||
/// Is this Engine just for testing (prevents step calibration).
|
/// Is this Engine just for testing (prevents step calibration).
|
||||||
calibrate_step: bool,
|
calibrate_step: bool,
|
||||||
validate_score_transition: u64,
|
validate_score_transition: u64,
|
||||||
|
eip155_transition: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn header_step(header: &Header) -> Result<usize, ::rlp::DecoderError> {
|
fn header_step(header: &Header) -> Result<usize, ::rlp::DecoderError> {
|
||||||
@ -130,6 +135,7 @@ impl AuthorityRound {
|
|||||||
validators: new_validator_set(our_params.validators),
|
validators: new_validator_set(our_params.validators),
|
||||||
calibrate_step: our_params.start_step.is_none(),
|
calibrate_step: our_params.start_step.is_none(),
|
||||||
validate_score_transition: our_params.validate_score_transition,
|
validate_score_transition: our_params.validate_score_transition,
|
||||||
|
eip155_transition: our_params.eip155_transition,
|
||||||
});
|
});
|
||||||
// Do not initialize timeouts for tests.
|
// Do not initialize timeouts for tests.
|
||||||
if should_timeout {
|
if should_timeout {
|
||||||
@ -352,6 +358,18 @@ impl Engine for AuthorityRound {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn verify_transaction_basic(&self, t: &UnverifiedTransaction, header: &Header) -> result::Result<(), Error> {
|
||||||
|
t.check_low_s()?;
|
||||||
|
|
||||||
|
if let Some(n) = t.network_id() {
|
||||||
|
if header.number() >= self.eip155_transition && n != self.params().chain_id {
|
||||||
|
return Err(TransactionError::InvalidNetworkId.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn register_client(&self, client: Weak<Client>) {
|
fn register_client(&self, client: Weak<Client>) {
|
||||||
*self.client.write() = Some(client.clone());
|
*self.client.write() = Some(client.clone());
|
||||||
self.validators.register_contract(client);
|
self.validators.register_contract(client);
|
||||||
|
@ -43,6 +43,9 @@ pub struct AuthorityRoundParams {
|
|||||||
/// Block at which score validation should start.
|
/// Block at which score validation should start.
|
||||||
#[serde(rename="validateScoreTransition")]
|
#[serde(rename="validateScoreTransition")]
|
||||||
pub validate_score_transition: Option<Uint>,
|
pub validate_score_transition: Option<Uint>,
|
||||||
|
/// See main AuthorityRoundParams docs.
|
||||||
|
#[serde(rename="eip155Transition")]
|
||||||
|
pub eip155_transition: Option<Uint>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Authority engine deserialization.
|
/// Authority engine deserialization.
|
||||||
@ -67,7 +70,8 @@ mod tests {
|
|||||||
"list" : ["0xc6d9d2cd449a754c494264e1809c50e34d64562b"]
|
"list" : ["0xc6d9d2cd449a754c494264e1809c50e34d64562b"]
|
||||||
},
|
},
|
||||||
"blockReward": "0x50",
|
"blockReward": "0x50",
|
||||||
"startStep" : 24
|
"startStep" : 24,
|
||||||
|
"eip155Transition": "0x42"
|
||||||
}
|
}
|
||||||
}"#;
|
}"#;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user