Merge pull request #279 from ethcore/fixstatetests
Fix CALLDATACOPY (and bonus CODECOPY, too!).
This commit is contained in:
commit
484c2599b7
@ -27,6 +27,6 @@ lazy_static = "0.1"
|
||||
[features]
|
||||
default = ["json-tests"]
|
||||
jit = ["evmjit"]
|
||||
evm_debug = []
|
||||
evm-debug = []
|
||||
json-tests = []
|
||||
test-heavy = []
|
||||
|
@ -791,23 +791,30 @@ impl Interpreter {
|
||||
Ok(InstructionResult::Ok)
|
||||
}
|
||||
|
||||
fn copy_data_to_memory(&self,
|
||||
mem: &mut Memory,
|
||||
stack: &mut Stack<U256>,
|
||||
data: &[u8]) {
|
||||
let offset = stack.pop_back();
|
||||
let index = stack.pop_back();
|
||||
fn copy_data_to_memory(&self, mem: &mut Memory, stack: &mut Stack<U256>, data: &[u8]) {
|
||||
let dest_offset = stack.pop_back();
|
||||
let source_offset = stack.pop_back();
|
||||
let size = stack.pop_back();
|
||||
let data_size = data.len();
|
||||
let source_size = U256::from(data.len());
|
||||
|
||||
if index < U256::from(data_size) {
|
||||
let u_index = index.low_u64() as usize;
|
||||
let bound_size = match size + index > U256::from(data_size) {
|
||||
true => data_size,
|
||||
false => size.low_u64() as usize + u_index
|
||||
};
|
||||
let output_end = match source_offset > source_size || size > source_size || source_offset + size > source_size {
|
||||
true => {
|
||||
let zero_slice = if source_offset > source_size {
|
||||
mem.writeable_slice(dest_offset, size)
|
||||
} else {
|
||||
mem.writeable_slice(dest_offset + source_size - source_offset, source_offset + size - source_size)
|
||||
};
|
||||
for i in zero_slice.iter_mut() {
|
||||
*i = 0;
|
||||
}
|
||||
data.len()
|
||||
},
|
||||
false => (size.low_u64() + source_offset.low_u64()) as usize
|
||||
};
|
||||
|
||||
mem.write_slice(offset, &data[u_index..bound_size]);
|
||||
if source_offset < source_size {
|
||||
let output_begin = source_offset.low_u64() as usize;
|
||||
mem.write_slice(dest_offset, &data[output_begin..output_end]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
|
||||
|
||||
declare_test!{StateTests_stBlockHashTest, "StateTests/stBlockHashTest"}
|
||||
declare_test!{StateTests_stCallCodes, "StateTests/stCallCodes"}
|
||||
//declare_test!{StateTests_stCallCreateCallCodeTest, "StateTests/stCallCreateCallCodeTest"}
|
||||
declare_test!{StateTests_stCallCreateCallCodeTest, "StateTests/stCallCreateCallCodeTest"}
|
||||
declare_test!{StateTests_stDelegatecallTest, "StateTests/stDelegatecallTest"}
|
||||
declare_test!{StateTests_stExample, "StateTests/stExample"}
|
||||
declare_test!{StateTests_stInitCodeTest, "StateTests/stInitCodeTest"}
|
||||
@ -297,7 +297,7 @@ declare_test!{StateTests_RandomTests_st201503181357CPPJIT, "StateTests/RandomTes
|
||||
declare_test!{StateTests_RandomTests_st201503181358CPPJIT, "StateTests/RandomTests/st201503181358CPPJIT"}
|
||||
declare_test!{StateTests_RandomTests_st201503181358GO, "StateTests/RandomTests/st201503181358GO"}
|
||||
declare_test!{StateTests_RandomTests_st201503181359GO, "StateTests/RandomTests/st201503181359GO"}
|
||||
//declare_test!{StateTests_RandomTests_st201503181402CPPJIT, "StateTests/RandomTests/st201503181402CPPJIT"}
|
||||
declare_test!{StateTests_RandomTests_st201503181402CPPJIT, "StateTests/RandomTests/st201503181402CPPJIT"}
|
||||
declare_test!{StateTests_RandomTests_st201503181403GO, "StateTests/RandomTests/st201503181403GO"}
|
||||
declare_test!{StateTests_RandomTests_st201503181406CPPJIT, "StateTests/RandomTests/st201503181406CPPJIT"}
|
||||
declare_test!{StateTests_RandomTests_st201503181406GO, "StateTests/RandomTests/st201503181406GO"}
|
||||
@ -569,7 +569,7 @@ declare_test!{StateTests_RandomTests_st201503181929GO, "StateTests/RandomTests/s
|
||||
declare_test!{StateTests_RandomTests_st201503181931CPPJIT, "StateTests/RandomTests/st201503181931CPPJIT"}
|
||||
declare_test!{StateTests_RandomTests_st201503181931GO, "StateTests/RandomTests/st201503181931GO"}
|
||||
declare_test!{StateTests_RandomTests_st201503181931PYTHON, "StateTests/RandomTests/st201503181931PYTHON"}
|
||||
//declare_test!{StateTests_RandomTests_st201503191646GO, "StateTests/RandomTests/st201503191646GO"}
|
||||
declare_test!{StateTests_RandomTests_st201503191646GO, "StateTests/RandomTests/st201503191646GO"}
|
||||
declare_test!{StateTests_RandomTests_st201503200837JS, "StateTests/RandomTests/st201503200837JS"}
|
||||
declare_test!{StateTests_RandomTests_st201503200838JS, "StateTests/RandomTests/st201503200838JS"}
|
||||
declare_test!{StateTests_RandomTests_st201503200841JS, "StateTests/RandomTests/st201503200841JS"}
|
||||
|
@ -147,14 +147,14 @@ pub fn verify_block_final(expected: &Header, got: &Header) -> Result<(), Error>
|
||||
if expected.gas_used != got.gas_used {
|
||||
return Err(From::from(BlockError::InvalidGasUsed(Mismatch { expected: expected.gas_used, found: got.gas_used })))
|
||||
}
|
||||
if expected.receipts_root != got.receipts_root {
|
||||
return Err(From::from(BlockError::InvalidReceiptsStateRoot(Mismatch { expected: expected.receipts_root.clone(), found: got.receipts_root.clone() })))
|
||||
if expected.log_bloom != got.log_bloom {
|
||||
return Err(From::from(BlockError::InvalidLogBloom(Mismatch { expected: expected.log_bloom.clone(), found: got.log_bloom.clone() })))
|
||||
}
|
||||
if expected.state_root != got.state_root {
|
||||
return Err(From::from(BlockError::InvalidStateRoot(Mismatch { expected: expected.state_root.clone(), found: got.state_root.clone() })))
|
||||
}
|
||||
if expected.log_bloom != got.log_bloom {
|
||||
return Err(From::from(BlockError::InvalidLogBloom(Mismatch { expected: expected.log_bloom.clone(), found: got.log_bloom.clone() })))
|
||||
if expected.receipts_root != got.receipts_root {
|
||||
return Err(From::from(BlockError::InvalidReceiptsStateRoot(Mismatch { expected: expected.receipts_root.clone(), found: got.receipts_root.clone() })))
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user