Merge pull request #257 from ethcore/testnet_block_542
fix verification of testnet block 542
This commit is contained in:
commit
ffd306d4a5
|
@ -57,7 +57,7 @@ pub struct VerificationFlags {
|
||||||
/// support CHECKSEQUENCEVERIFY opcode
|
/// support CHECKSEQUENCEVERIFY opcode
|
||||||
///
|
///
|
||||||
/// See BIP112 for details
|
/// See BIP112 for details
|
||||||
pub verify_chechsequenceverify: bool,
|
pub verify_checksequenceverify: bool,
|
||||||
|
|
||||||
/// Support segregated witness
|
/// Support segregated witness
|
||||||
pub verify_witness: bool,
|
pub verify_witness: bool,
|
||||||
|
|
|
@ -454,10 +454,6 @@ pub fn eval_script(
|
||||||
},
|
},
|
||||||
Opcode::OP_NOP => break,
|
Opcode::OP_NOP => break,
|
||||||
Opcode::OP_CHECKLOCKTIMEVERIFY => {
|
Opcode::OP_CHECKLOCKTIMEVERIFY => {
|
||||||
if flags.verify_discourage_upgradable_nops {
|
|
||||||
return Err(Error::DiscourageUpgradableNops);
|
|
||||||
}
|
|
||||||
|
|
||||||
if flags.verify_clocktimeverify {
|
if flags.verify_clocktimeverify {
|
||||||
// Note that elsewhere numeric opcodes are limited to
|
// Note that elsewhere numeric opcodes are limited to
|
||||||
// operands in the range -2**31+1 to 2**31-1, however it is
|
// operands in the range -2**31+1 to 2**31-1, however it is
|
||||||
|
@ -485,13 +481,12 @@ pub fn eval_script(
|
||||||
if !checker.check_lock_time(lock_time) {
|
if !checker.check_lock_time(lock_time) {
|
||||||
return Err(Error::UnsatisfiedLocktime);
|
return Err(Error::UnsatisfiedLocktime);
|
||||||
}
|
}
|
||||||
|
} else if flags.verify_discourage_upgradable_nops {
|
||||||
|
return Err(Error::DiscourageUpgradableNops);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Opcode::OP_CHECKSEQUENCEVERIFY => {
|
Opcode::OP_CHECKSEQUENCEVERIFY => {
|
||||||
if !flags.verify_chechsequenceverify && flags.verify_discourage_upgradable_nops {
|
if flags.verify_checksequenceverify {
|
||||||
return Err(Error::DiscourageUpgradableNops);
|
|
||||||
}
|
|
||||||
|
|
||||||
let sequence = try!(Num::from_slice(try!(stack.last()), flags.verify_minimaldata, 5));
|
let sequence = try!(Num::from_slice(try!(stack.last()), flags.verify_minimaldata, 5));
|
||||||
|
|
||||||
if sequence.is_negative() {
|
if sequence.is_negative() {
|
||||||
|
@ -501,6 +496,10 @@ pub fn eval_script(
|
||||||
if (sequence & (SEQUENCE_LOCKTIME_DISABLE_FLAG as i64).into()).is_zero() && !checker.check_sequence(sequence) {
|
if (sequence & (SEQUENCE_LOCKTIME_DISABLE_FLAG as i64).into()).is_zero() && !checker.check_sequence(sequence) {
|
||||||
return Err(Error::UnsatisfiedLocktime);
|
return Err(Error::UnsatisfiedLocktime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if flags.verify_discourage_upgradable_nops {
|
||||||
|
return Err(Error::DiscourageUpgradableNops);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Opcode::OP_NOP1 |
|
Opcode::OP_NOP1 |
|
||||||
Opcode::OP_NOP4 |
|
Opcode::OP_NOP4 |
|
||||||
|
@ -1944,5 +1943,26 @@ mod tests {
|
||||||
let result = Ok(true);
|
let result = Ok(true);
|
||||||
basic_test(&script, result, vec![vec![1].into()].into());
|
basic_test(&script, result, vec![vec![1].into()].into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_skipping_sequencetimeverify() {
|
||||||
|
let script = Builder::default()
|
||||||
|
.push_opcode(Opcode::OP_1)
|
||||||
|
.push_opcode(Opcode::OP_NOP1)
|
||||||
|
.push_opcode(Opcode::OP_CHECKLOCKTIMEVERIFY)
|
||||||
|
.push_opcode(Opcode::OP_CHECKSEQUENCEVERIFY)
|
||||||
|
.push_opcode(Opcode::OP_NOP4)
|
||||||
|
.push_opcode(Opcode::OP_NOP5)
|
||||||
|
.push_opcode(Opcode::OP_NOP6)
|
||||||
|
.push_opcode(Opcode::OP_NOP7)
|
||||||
|
.push_opcode(Opcode::OP_NOP8)
|
||||||
|
.push_opcode(Opcode::OP_NOP9)
|
||||||
|
.push_opcode(Opcode::OP_NOP10)
|
||||||
|
.push_opcode(Opcode::OP_1)
|
||||||
|
.push_opcode(Opcode::OP_EQUAL)
|
||||||
|
.into_script();
|
||||||
|
let result = Ok(true);
|
||||||
|
basic_test(&script, result, vec![vec![1].into()].into());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue