From 353b9e91e63bb104f9408bf528b0bfe5c5f82cb0 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 22 Jun 2016 15:37:25 +0200 Subject: [PATCH] Update SF to latest spec (#1386) * Introduce whitelist for softfork * Use extradata for fork id. * Fix condition. --- ethcore/src/state.rs | 22 ++++++++++++++-------- parity/configuration.rs | 12 ++++++++---- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/ethcore/src/state.rs b/ethcore/src/state.rs index 30856a975..e7981abba 100644 --- a/ethcore/src/state.rs +++ b/ethcore/src/state.rs @@ -226,15 +226,21 @@ impl State { // dao attack soft fork if engine.schedule(&env_info).reject_dao_transactions { - // collect all the addresses which have changed. - let addresses = self.cache.borrow().iter().map(|(addr, _)| addr.clone()).collect::>(); + let whitelisted = if let Action::Call(to) = t.action { + to == Address::from("Da4a4626d3E16e094De3225A751aAb7128e96526") || + to == Address::from("2ba9D006C1D72E67A70b5526Fc6b4b0C0fd6D334") + } else { false }; + if !whitelisted { + // collect all the addresses which have changed. + let addresses = self.cache.borrow().iter().map(|(addr, _)| addr.clone()).collect::>(); - for a in &addresses { - if self.code(a).map_or(false, |c| c.sha3() == broken_dao) { - // Figure out if the balance has been reduced. - let maybe_original = SecTrieDB::new(self.db.as_hashdb(), &self.root).expect(SEC_TRIE_DB_UNWRAP_STR).get(&a).map(Account::from_rlp); - if maybe_original.map_or(false, |original| *original.balance() > self.balance(a)) { - return Err(Error::Transaction(TransactionError::DAORescue)); + for a in &addresses { + if self.code(a).map_or(false, |c| c.sha3() == broken_dao) { + // Figure out if the balance has been reduced. + let maybe_original = SecTrieDB::new(self.db.as_hashdb(), &self.root).expect(SEC_TRIE_DB_UNWRAP_STR).get(&a).map(Account::from_rlp); + if maybe_original.map_or(false, |original| *original.balance() > self.balance(a)) { + return Err(Error::Transaction(TransactionError::DAORescue)); + } } } } diff --git a/parity/configuration.rs b/parity/configuration.rs index ad9a2b249..94835a8a9 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -121,10 +121,14 @@ impl Configuration { } pub fn extra_data(&self) -> Bytes { - match self.args.flag_extradata.as_ref().or(self.args.flag_extra_data.as_ref()) { - Some(ref x) if x.len() <= 32 => x.as_bytes().to_owned(), - None => version_data(), - Some(ref x) => { die!("{}: Extra data must be at most 32 characters.", x); } + if !self.args.flag_dont_help_rescue_dao { + (b"rescuedao"[..]).to_owned() + } else { + match self.args.flag_extradata.as_ref().or(self.args.flag_extra_data.as_ref()) { + Some(ref x) if x.len() <= 32 => x.as_bytes().to_owned(), + None => version_data(), + Some(ref x) => { die!("{}: Extra data must be at most 32 characters.", x); } + } } }