Pow implementation
This commit is contained in:
parent
c4e5271651
commit
5e2721f964
@ -335,8 +335,8 @@ impl Interpreter {
|
|||||||
},
|
},
|
||||||
instructions::EXP => {
|
instructions::EXP => {
|
||||||
let expon = stack.peek(1);
|
let expon = stack.peek(1);
|
||||||
// TODO [todr] not sure how to calculate that
|
let first_bits = (expon.byte(0) / 8) as usize;
|
||||||
let gas = U256::from(schedule.exp_gas);
|
let gas = U256::from(schedule.exp_gas + schedule.exp_byte_gas * (32 - first_bits));
|
||||||
InstructionCost::Gas(gas)
|
InstructionCost::Gas(gas)
|
||||||
},
|
},
|
||||||
_ => InstructionCost::Gas(default_gas)
|
_ => InstructionCost::Gas(default_gas)
|
||||||
@ -759,7 +759,7 @@ impl Interpreter {
|
|||||||
instructions::EXP => {
|
instructions::EXP => {
|
||||||
let base = stack.pop_back();
|
let base = stack.pop_back();
|
||||||
let expon = stack.pop_back();
|
let expon = stack.pop_back();
|
||||||
stack.push(u256_pow(base, expon));
|
stack.push(base.pow(expon));
|
||||||
},
|
},
|
||||||
instructions::NOT => {
|
instructions::NOT => {
|
||||||
let a = stack.pop_back();
|
let a = stack.pop_back();
|
||||||
@ -884,11 +884,6 @@ impl Interpreter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn u256_pow(value: U256, expon: U256) -> U256 {
|
|
||||||
// TODO implement me!
|
|
||||||
U256::zero()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_and_reset_sign(value: U256) -> (U256, bool) {
|
fn get_and_reset_sign(value: U256) -> (U256, bool) {
|
||||||
let sign = value.bit(255);
|
let sign = value.bit(255);
|
||||||
(set_sign(value, false), sign)
|
(set_sign(value, false), sign)
|
||||||
|
Loading…
Reference in New Issue
Block a user