Fixing create-gasleft
This commit is contained in:
parent
56c059588d
commit
48040590f5
@ -249,9 +249,10 @@ enum InstructionCost {
|
|||||||
enum InstructionResult {
|
enum InstructionResult {
|
||||||
Ok,
|
Ok,
|
||||||
UseAllGas,
|
UseAllGas,
|
||||||
|
GasLeft(U256),
|
||||||
UnusedGas(U256),
|
UnusedGas(U256),
|
||||||
JumpToPosition(U256),
|
JumpToPosition(U256),
|
||||||
StopExecutionWithGasCost(U256),
|
StopExecutionWithGasLeft(U256),
|
||||||
StopExecution
|
StopExecution
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,12 +306,15 @@ impl evm::Evm for Interpreter {
|
|||||||
InstructionResult::UseAllGas => {
|
InstructionResult::UseAllGas => {
|
||||||
current_gas = U256::zero();
|
current_gas = U256::zero();
|
||||||
},
|
},
|
||||||
|
InstructionResult::GasLeft(gas_left) => {
|
||||||
|
current_gas = gas_left;
|
||||||
|
},
|
||||||
InstructionResult::JumpToPosition(position) => {
|
InstructionResult::JumpToPosition(position) => {
|
||||||
let pos = try!(self.verify_jump(position, &valid_jump_destinations));
|
let pos = try!(self.verify_jump(position, &valid_jump_destinations));
|
||||||
reader.position = pos;
|
reader.position = pos;
|
||||||
},
|
},
|
||||||
InstructionResult::StopExecutionWithGasCost(gas_cost) => {
|
InstructionResult::StopExecutionWithGasLeft(gas_left) => {
|
||||||
current_gas = current_gas - gas_cost;
|
current_gas = gas_left;
|
||||||
reader.position = code.len();
|
reader.position = code.len();
|
||||||
},
|
},
|
||||||
InstructionResult::StopExecution => {
|
InstructionResult::StopExecution => {
|
||||||
@ -589,7 +593,7 @@ impl Interpreter {
|
|||||||
return match create_result {
|
return match create_result {
|
||||||
ContractCreateResult::Created(address, gas_left) => {
|
ContractCreateResult::Created(address, gas_left) => {
|
||||||
stack.push(address_to_u256(address));
|
stack.push(address_to_u256(address));
|
||||||
Ok(InstructionResult::UnusedGas(gas - gas_left))
|
Ok(InstructionResult::GasLeft(gas_left))
|
||||||
},
|
},
|
||||||
ContractCreateResult::Failed => {
|
ContractCreateResult::Failed => {
|
||||||
stack.push(U256::zero());
|
stack.push(U256::zero());
|
||||||
@ -657,8 +661,8 @@ impl Interpreter {
|
|||||||
let init_size = stack.pop_back();
|
let init_size = stack.pop_back();
|
||||||
let return_code = mem.read_slice(init_off, init_size);
|
let return_code = mem.read_slice(init_off, init_size);
|
||||||
let gas_left = try!(ext.ret(&gas, &return_code));
|
let gas_left = try!(ext.ret(&gas, &return_code));
|
||||||
return Ok(InstructionResult::StopExecutionWithGasCost(
|
return Ok(InstructionResult::StopExecutionWithGasLeft(
|
||||||
gas - gas_left
|
gas_left
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
instructions::STOP => {
|
instructions::STOP => {
|
||||||
@ -944,7 +948,7 @@ impl Interpreter {
|
|||||||
let (b, sign_b) = get_and_reset_sign(stack.pop_back());
|
let (b, sign_b) = get_and_reset_sign(stack.pop_back());
|
||||||
|
|
||||||
// -2^255
|
// -2^255
|
||||||
let min = U256::from_str("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap();
|
let min = (U256::one() << 255) - U256::one();
|
||||||
stack.push(if self.is_zero(&b) {
|
stack.push(if self.is_zero(&b) {
|
||||||
U256::zero()
|
U256::zero()
|
||||||
} else if a == min && b == !U256::zero() {
|
} else if a == min && b == !U256::zero() {
|
||||||
|
Loading…
Reference in New Issue
Block a user