Polish formatting
The sources affected by this commit have drifted in style since earlier polishing commits such asf34d1f4
anda155518
. The shared IDEA style configuration file can help avoid this drift in the future. Simply run Code->Reformat Code at the project level prior to committing. Note that this code style configuration is not perfect, and not every change it makes should be checked in. The ideal is to simply always write code that conforms to the style conventions, but the automated settings are there as a helping hand when necessary. The churn caused by drifting style and the commits that fix it damage the utility of git over time. Reviewing changes, analyzing history, surgically reverting commits, and many other use cases with git simply do not work as well when styles get mixed and fixed. Let's work toward a common style.
This commit is contained in:
parent
38c241f9e6
commit
9127c01890
|
@ -30,8 +30,8 @@ ext.generatedSrcDir = file('src/gen/java')
|
|||
sourceSets.main.java.srcDirs += generatedSrcDir
|
||||
|
||||
antlr4 {
|
||||
extraArgs = ['-package', 'org.ethereum.serpent']
|
||||
output = file("${generatedSrcDir}/org/ethereum/serpent")
|
||||
extraArgs = ['-package', 'org.ethereum.serpent']
|
||||
output = file("${generatedSrcDir}/org/ethereum/serpent")
|
||||
}
|
||||
|
||||
compileJava.dependsOn antlr4
|
||||
|
@ -42,7 +42,7 @@ test {
|
|||
}
|
||||
|
||||
configurations {
|
||||
compile.extendsFrom antlr4
|
||||
compile.extendsFrom antlr4
|
||||
}
|
||||
|
||||
ext {
|
||||
|
@ -79,7 +79,7 @@ dependencies {
|
|||
compile "redis.clients:jedis:2.6.0"
|
||||
|
||||
compile("com.googlecode.json-simple:json-simple:1.1.1") {
|
||||
exclude group:'junit', module:'junit'
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
optional "commons-logging:commons-logging:1.0"
|
||||
optional "org.slf4j:jcl-over-slf4j:${slf4jVersion}"
|
||||
|
@ -95,8 +95,8 @@ javadoc {
|
|||
options.addStringOption('Xdoclint:all,-missing', '-quiet')
|
||||
options.encoding = "UTF-8"
|
||||
options.links(
|
||||
"http://docs.oracle.com/javase/8/docs/api/",
|
||||
"http://netty.io/4.0/api/"
|
||||
"http://docs.oracle.com/javase/8/docs/api/",
|
||||
"http://netty.io/4.0/api/"
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ artifactory {
|
|||
contextUrl = 'http://oss.jfrog.org/artifactory'
|
||||
publish {
|
||||
repository {
|
||||
repoKey = 'oss-snapshot-local'
|
||||
repoKey = 'oss-snapshot-local'
|
||||
username = bintrayUsername
|
||||
password = bintrayPassword
|
||||
}
|
||||
|
|
|
@ -274,7 +274,7 @@ public class SystemProperties {
|
|||
}
|
||||
|
||||
|
||||
public String getKeyValueDataSource(){
|
||||
public String getKeyValueDataSource() {
|
||||
if (prop.isEmpty()) return DEFAULT_KEY_VALUE_DATA_SOURCE;
|
||||
return prop.getProperty("keyvalue.datasource");
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class TransactionExecutor {
|
|||
private Block currentBlock;
|
||||
|
||||
|
||||
public TransactionExecutor(Transaction tx, byte[] coinbase, Repository track,BlockStore blockStore,
|
||||
public TransactionExecutor(Transaction tx, byte[] coinbase, Repository track, BlockStore blockStore,
|
||||
ProgramInvokeFactory programInvokeFactory, Block currentBlock) {
|
||||
|
||||
this.tx = tx;
|
||||
|
|
|
@ -10,13 +10,18 @@ import java.util.Set;
|
|||
public interface KeyValueDataSource {
|
||||
|
||||
public void init();
|
||||
|
||||
public void setName(String name);
|
||||
|
||||
public byte[] get(byte[] key);
|
||||
|
||||
public void put(byte[] key, byte[] value);
|
||||
|
||||
public void delete(byte[] key);
|
||||
|
||||
public Set<byte[]> keys();
|
||||
public void updateBatch( Map<byte[], byte[]> rows);
|
||||
|
||||
public void updateBatch(Map<byte[], byte[]> rows);
|
||||
|
||||
public void close();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import static org.iq80.leveldb.impl.Iq80DBFactory.factory;
|
|||
* @author Roman Mandeleil
|
||||
* @since 18.01.2015
|
||||
*/
|
||||
public class LevelDbDataSource implements KeyValueDataSource{
|
||||
public class LevelDbDataSource implements KeyValueDataSource {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger("db");
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class LevelDbDataSource implements KeyValueDataSource{
|
|||
|
||||
DBIterator dbIterator = db.iterator();
|
||||
Set<byte[]> keys = new HashSet<>();
|
||||
while (dbIterator.hasNext()){
|
||||
while (dbIterator.hasNext()) {
|
||||
|
||||
Map.Entry<byte[], byte[]> entry = dbIterator.next();
|
||||
keys.add(entry.getKey());
|
||||
|
@ -109,7 +109,7 @@ public class LevelDbDataSource implements KeyValueDataSource{
|
|||
WriteBatch batch = db.createWriteBatch();
|
||||
|
||||
for (Map.Entry<byte[], byte[]> row : rows.entrySet())
|
||||
batch.put(row.getKey(), row.getValue());
|
||||
batch.put(row.getKey(), row.getValue());
|
||||
|
||||
db.write(batch);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import redis.clients.jedis.Pipeline;
|
|||
* @author Roman Mandeleil
|
||||
* @since 18.01.2015
|
||||
*/
|
||||
public class RedisDataSource implements KeyValueDataSource{
|
||||
public class RedisDataSource implements KeyValueDataSource {
|
||||
|
||||
String name;
|
||||
int index;
|
||||
|
@ -68,7 +68,7 @@ public class RedisDataSource implements KeyValueDataSource{
|
|||
Pipeline pipeline = jedis.pipelined();
|
||||
|
||||
Iterator<Map.Entry<byte[], byte[]>> iterator = rows.entrySet().iterator();
|
||||
while(iterator.hasNext()){
|
||||
while (iterator.hasNext()) {
|
||||
|
||||
Map.Entry<byte[], byte[]> row = iterator.next();
|
||||
byte[] key = row.getKey();
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||
* @author Roman Mandeleil
|
||||
* @since 08.01.2015
|
||||
*/
|
||||
public class BlockStoreDummy implements BlockStore{
|
||||
public class BlockStoreDummy implements BlockStore {
|
||||
|
||||
@Override
|
||||
public byte[] getBlockHashByNumber(long blockNumber) {
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||
*/
|
||||
@Repository("blockStore")
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public class BlockStoreImpl implements BlockStore{
|
||||
public class BlockStoreImpl implements BlockStore {
|
||||
|
||||
@Autowired
|
||||
private SessionFactory sessionFactory;
|
||||
|
|
|
@ -32,15 +32,15 @@ public class DatabaseImpl implements Database {
|
|||
|
||||
public DatabaseImpl(String name) {
|
||||
|
||||
if (CONFIG.getKeyValueDataSource().equals("redis") ){
|
||||
dataSource = new RedisDataSource();
|
||||
if (CONFIG.getKeyValueDataSource().equals("redis")) {
|
||||
dataSource = new RedisDataSource();
|
||||
dataSource.setName(name);
|
||||
dataSource.init();
|
||||
return;
|
||||
}
|
||||
|
||||
if (CONFIG.getKeyValueDataSource().equals("leveldb") ){
|
||||
dataSource = new LevelDbDataSource();
|
||||
if (CONFIG.getKeyValueDataSource().equals("leveldb")) {
|
||||
dataSource = new LevelDbDataSource();
|
||||
dataSource.setName(name);
|
||||
dataSource.init();
|
||||
return;
|
||||
|
|
|
@ -65,9 +65,11 @@ public class EthereumImpl implements Ethereum {
|
|||
worldManager.loadBlockchain();
|
||||
if (CONFIG.listenPort() > 0) {
|
||||
Executors.newSingleThreadExecutor().submit(
|
||||
new Runnable() { public void run() {
|
||||
peerServer.start(CONFIG.listenPort());
|
||||
}}
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
peerServer.start(CONFIG.listenPort());
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,8 +68,8 @@ public class JSONHelper {
|
|||
}
|
||||
|
||||
public static void dumpBlock(ObjectNode blockNode, Block block,
|
||||
long gasUsed, byte[] state, List<ByteArrayWrapper> keys,
|
||||
Repository repository) {
|
||||
long gasUsed, byte[] state, List<ByteArrayWrapper> keys,
|
||||
Repository repository) {
|
||||
|
||||
blockNode.put("coinbase", Hex.toHexString(block.getCoinbase()));
|
||||
blockNode.put("difficulty", new BigInteger(1, block.calcDifficulty()).toString());
|
||||
|
|
|
@ -113,7 +113,7 @@ public class AccountState {
|
|||
results.add(formattedString);
|
||||
}
|
||||
|
||||
if (!Arrays.equals(details.getCode(),this.getCode())) {
|
||||
if (!Arrays.equals(details.getCode(), this.getCode())) {
|
||||
String formattedString = String.format("Account: %s: has unexpected nonce, expected nonce: %s found nonce: %s",
|
||||
Hex.toHexString(this.address), Hex.toHexString(this.getCode()), Hex.toHexString(details.getCode()));
|
||||
results.add(formattedString);
|
||||
|
|
|
@ -74,7 +74,7 @@ public class Logs {
|
|||
String postBloom = Hex.toHexString(postLog.getBloom().getData());
|
||||
String realBloom = Hex.toHexString(realLog.getBloom().getData());
|
||||
|
||||
if (!postData.equals(realData)){
|
||||
if (!postData.equals(realData)) {
|
||||
|
||||
String formattedString = String.format("Log: %s: has unexpected bloom, expected bloom: %s found bloom: %s",
|
||||
i, postBloom, realBloom);
|
||||
|
|
|
@ -63,7 +63,7 @@ public class TestCase {
|
|||
JSONObject preJSON = (JSONObject) testCaseJSONObj.get("pre");
|
||||
JSONObject postJSON = new JSONObject();
|
||||
if (testCaseJSONObj.containsKey("post")) // in cases where there is no post dictionary (when testing for
|
||||
// exceptions for example)
|
||||
// exceptions for example)
|
||||
postJSON = (JSONObject) testCaseJSONObj.get("post");
|
||||
JSONArray callCreates = new JSONArray();
|
||||
if (testCaseJSONObj.containsKey("callcreates"))
|
||||
|
|
|
@ -39,7 +39,7 @@ public class TestProgramInvokeFactory implements ProgramInvokeFactory {
|
|||
}
|
||||
|
||||
|
||||
private ProgramInvoke generalInvoke(Transaction tx, Repository repository ,BlockStore blockStore) {
|
||||
private ProgramInvoke generalInvoke(Transaction tx, Repository repository, BlockStore blockStore) {
|
||||
|
||||
/*** ADDRESS op ***/
|
||||
// YP: Get address of currently executing account.
|
||||
|
|
|
@ -61,7 +61,7 @@ public class TestRunner {
|
|||
|
||||
public List<String> runTestCase(StateTestCase testCase) {
|
||||
|
||||
List<String> results = new ArrayList<>();;
|
||||
List<String> results = new ArrayList<>();
|
||||
logger.info("\n***");
|
||||
logger.info(" Running test case: [" + testCase.getName() + "]");
|
||||
logger.info("***\n");
|
||||
|
@ -89,7 +89,7 @@ public class TestRunner {
|
|||
|
||||
Repository track = repository.startTracking();
|
||||
TransactionExecutor executor =
|
||||
new TransactionExecutor(tx, coinbase, track, new BlockStoreDummy(),
|
||||
new TransactionExecutor(tx, coinbase, track, new BlockStoreDummy(),
|
||||
invokeFactory, blockchain.getBestBlock());
|
||||
executor.execute();
|
||||
track.commit();
|
||||
|
@ -240,9 +240,9 @@ public class TestRunner {
|
|||
continue;
|
||||
}
|
||||
|
||||
long actualNonce = repository.getNonce(key.getData()).longValue();
|
||||
long actualNonce = repository.getNonce(key.getData()).longValue();
|
||||
BigInteger actualBalance = repository.getBalance(key.getData());
|
||||
byte[] actualCode = repository.getCode(key.getData());
|
||||
byte[] actualCode = repository.getCode(key.getData());
|
||||
if (actualCode == null) actualCode = "".getBytes();
|
||||
|
||||
if (expectedNonce != actualNonce) {
|
||||
|
@ -487,7 +487,7 @@ public class TestRunner {
|
|||
|
||||
String output =
|
||||
String.format("Gas remaining is different. Expected gas remaining: [ %s ], actual gas remaining: [ %s ]",
|
||||
expectedGas.toString() ,
|
||||
expectedGas.toString(),
|
||||
actualGas.toString());
|
||||
logger.info(output);
|
||||
results.add(output);
|
||||
|
|
|
@ -82,7 +82,7 @@ public class BlockQueue {
|
|||
return;
|
||||
|
||||
logger.info("BlockQueue size: {}", blockReceivedQueue.size());
|
||||
while(!blockReceivedQueue.isEmpty()){
|
||||
while (!blockReceivedQueue.isEmpty()) {
|
||||
Block block = blockReceivedQueue.poll();
|
||||
|
||||
logger.info("Processing block index: {}", block.getNumber());
|
||||
|
|
|
@ -73,6 +73,6 @@ public class GetBlocksMessage extends EthMessage {
|
|||
|
||||
public String toString() {
|
||||
final String hashListShort = Utils.getHashListShort(getBlockHashes());
|
||||
return "[" + this.getCommand().name() + hashListShort+ "] (" + blockHashes.size() + ")";
|
||||
return "[" + this.getCommand().name() + hashListShort + "] (" + blockHashes.size() + ")";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class HelloMessage extends P2pMessage {
|
|||
}
|
||||
|
||||
public HelloMessage(byte p2pVersion, String clientId,
|
||||
List<Capability> capabilities, int listenPort, String peerId) {
|
||||
List<Capability> capabilities, int listenPort, String peerId) {
|
||||
this.p2pVersion = p2pVersion;
|
||||
this.clientId = clientId;
|
||||
this.capabilities = capabilities;
|
||||
|
|
|
@ -264,7 +264,7 @@ public class P2pHandler extends SimpleChannelInboundHandler<P2pMessage> {
|
|||
msgQueue.sendMessage(msg);
|
||||
}
|
||||
|
||||
public void sendDisconnect(){
|
||||
public void sendDisconnect() {
|
||||
msgQueue.disconnect();
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ public class Channel {
|
|||
|
||||
}
|
||||
|
||||
public HelloMessage getHandshakeHelloMessage(){
|
||||
public HelloMessage getHandshakeHelloMessage() {
|
||||
return getP2pHandler().getHandshakeHelloMessage();
|
||||
}
|
||||
|
||||
|
|
|
@ -49,12 +49,12 @@ public class ChannelManager {
|
|||
}
|
||||
|
||||
|
||||
public Channel getChannel(String peerId){
|
||||
public Channel getChannel(String peerId) {
|
||||
|
||||
for (Channel channel : channels){
|
||||
for (Channel channel : channels) {
|
||||
String tablePeerId = channel.getP2pHandler().getHandshakeHelloMessage().getPeerId();
|
||||
if (tablePeerId != null &&
|
||||
peerId.equals(tablePeerId)){
|
||||
peerId.equals(tablePeerId)) {
|
||||
return channel;
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ public class ChannelManager {
|
|||
}, 2000, 5000);
|
||||
}
|
||||
|
||||
public void reconnect(){
|
||||
public void reconnect() {
|
||||
for (Channel channel : channels)
|
||||
channel.p2pHandler.sendDisconnect();
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ public class ByteUtil {
|
|||
// check if the string is numeric
|
||||
if (arg.toString().trim().matches("-?\\d+(\\.\\d+)?"))
|
||||
data = new BigInteger(arg.toString().trim()).toByteArray();
|
||||
// check if it's hex number
|
||||
// check if it's hex number
|
||||
else if (arg.toString().trim().matches("0[xX][0-9a-fA-F]+"))
|
||||
data = new BigInteger(arg.toString().trim().substring(2), 16).toByteArray();
|
||||
else
|
||||
|
|
|
@ -10,13 +10,13 @@ import org.ethereum.util.ByteUtil;
|
|||
*/
|
||||
public class PrecompiledContracts {
|
||||
|
||||
private static ECRecover ecRecover = new ECRecover();
|
||||
private static Sha256 sha256 = new Sha256();
|
||||
private static ECRecover ecRecover = new ECRecover();
|
||||
private static Sha256 sha256 = new Sha256();
|
||||
private static Ripempd160 ripempd160 = new Ripempd160();
|
||||
private static Identity identity = new Identity();
|
||||
private static Identity identity = new Identity();
|
||||
|
||||
|
||||
public static PrecompiledContract getContractForAddress(DataWord address){
|
||||
public static PrecompiledContract getContractForAddress(DataWord address) {
|
||||
|
||||
if (address == null) return identity;
|
||||
if (address.isHex("0000000000000000000000000000000000000000000000000000000000000001")) return ecRecover;
|
||||
|
@ -28,12 +28,13 @@ public class PrecompiledContracts {
|
|||
}
|
||||
|
||||
|
||||
public static abstract class PrecompiledContract{
|
||||
public static abstract class PrecompiledContract {
|
||||
public abstract long getGasForData(byte[] data);
|
||||
|
||||
public abstract byte[] execute(byte[] data);
|
||||
}
|
||||
|
||||
public static class Identity extends PrecompiledContract{
|
||||
public static class Identity extends PrecompiledContract {
|
||||
|
||||
public Identity() {
|
||||
}
|
||||
|
@ -53,7 +54,7 @@ public class PrecompiledContracts {
|
|||
}
|
||||
}
|
||||
|
||||
public static class Sha256 extends PrecompiledContract{
|
||||
public static class Sha256 extends PrecompiledContract {
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -74,7 +75,7 @@ public class PrecompiledContracts {
|
|||
}
|
||||
|
||||
|
||||
public static class Ripempd160 extends PrecompiledContract{
|
||||
public static class Ripempd160 extends PrecompiledContract {
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -98,7 +99,7 @@ public class PrecompiledContracts {
|
|||
}
|
||||
|
||||
|
||||
public static class ECRecover extends PrecompiledContract{
|
||||
public static class ECRecover extends PrecompiledContract {
|
||||
|
||||
@Override
|
||||
public long getGasForData(byte[] data) {
|
||||
|
@ -115,8 +116,8 @@ public class PrecompiledContracts {
|
|||
|
||||
DataWord out = null;
|
||||
|
||||
try{
|
||||
System.arraycopy(data, 0, h, 0, 32);
|
||||
try {
|
||||
System.arraycopy(data, 0, h, 0, 32);
|
||||
System.arraycopy(data, 32, v, 0, 32);
|
||||
System.arraycopy(data, 64, r, 0, 32);
|
||||
System.arraycopy(data, 96, s, 0, 32);
|
||||
|
@ -126,7 +127,8 @@ public class PrecompiledContracts {
|
|||
|
||||
ECKey key = ECKey.signatureToKey(h, signature.toBase64());
|
||||
out = new DataWord(key.getAddress());
|
||||
} catch (Throwable any){}
|
||||
} catch (Throwable any) {
|
||||
}
|
||||
|
||||
if (out == null) out = new DataWord(0);
|
||||
|
||||
|
@ -135,5 +137,4 @@ public class PrecompiledContracts {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -221,10 +221,10 @@ public class Program {
|
|||
memorySave(addr, value.length, value);
|
||||
}
|
||||
|
||||
public void memoryExpand(DataWord outDataOffs, DataWord outDataSize){
|
||||
public void memoryExpand(DataWord outDataOffs, DataWord outDataSize) {
|
||||
|
||||
int maxAddress = outDataOffs.intValue() + outDataSize.intValue();
|
||||
if (getMemSize() < maxAddress){
|
||||
if (getMemSize() < maxAddress) {
|
||||
memorySave(maxAddress, new byte[]{0});
|
||||
}
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ public class Program {
|
|||
|
||||
public void createContract(DataWord value, DataWord memStart, DataWord memSize) {
|
||||
|
||||
if (invokeData.getCallDeep() == MAX_DEPTH){
|
||||
if (invokeData.getCallDeep() == MAX_DEPTH) {
|
||||
stackPushZero();
|
||||
return;
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ public class Program {
|
|||
}
|
||||
|
||||
if (result != null &&
|
||||
result.getException() != null) {
|
||||
result.getException() != null) {
|
||||
logger.debug("contract run halted by Exception: contract: [{}], exception: [{}]",
|
||||
Hex.toHexString(newAddress),
|
||||
result.getException());
|
||||
|
@ -430,7 +430,7 @@ public class Program {
|
|||
*/
|
||||
public void callToAddress(MessageCall msg) {
|
||||
|
||||
if (invokeData.getCallDeep() == MAX_DEPTH){
|
||||
if (invokeData.getCallDeep() == MAX_DEPTH) {
|
||||
stackPushZero();
|
||||
return;
|
||||
}
|
||||
|
@ -590,8 +590,8 @@ public class Program {
|
|||
|
||||
public DataWord getBlockHash(int index) {
|
||||
|
||||
return index < this.getNumber().longValue() && index >= Math.max(256, this.getNumber().intValue()) - 256?
|
||||
new DataWord(this.invokeData.getBlockStore().getBlockHashByNumber(index)):
|
||||
return index < this.getNumber().longValue() && index >= Math.max(256, this.getNumber().intValue()) - 256 ?
|
||||
new DataWord(this.invokeData.getBlockStore().getBlockHashByNumber(index)) :
|
||||
DataWord.ZERO;
|
||||
|
||||
}
|
||||
|
@ -861,15 +861,15 @@ public class Program {
|
|||
return programTrace;
|
||||
}
|
||||
|
||||
public void precompile(){
|
||||
for (int i = 0; i < ops.length; ++i){
|
||||
public void precompile() {
|
||||
for (int i = 0; i < ops.length; ++i) {
|
||||
|
||||
OpCode op = OpCode.code(ops[i]);
|
||||
if (op == null) continue;
|
||||
|
||||
if (op.equals(OpCode.JUMPDEST)) jumpdest.add(i);
|
||||
|
||||
if (op.asInt() >= OpCode.PUSH1.asInt() && op.asInt() <= OpCode.PUSH32.asInt()){
|
||||
if (op.asInt() >= OpCode.PUSH1.asInt() && op.asInt() <= OpCode.PUSH32.asInt()) {
|
||||
i += op.asInt() - OpCode.PUSH1.asInt() + 1;
|
||||
}
|
||||
}
|
||||
|
@ -915,13 +915,13 @@ public class Program {
|
|||
|
||||
public void callToPrecompiledAddress(MessageCall msg, PrecompiledContract contract) {
|
||||
|
||||
byte[] data = this.memoryChunk( msg.getInDataOffs(), msg.getInDataSize()).array();
|
||||
byte[] data = this.memoryChunk(msg.getInDataOffs(), msg.getInDataSize()).array();
|
||||
|
||||
this.result.getRepository().addBalance(this.getOwnerAddress().getLast20Bytes(), msg.getEndowment().value().negate());
|
||||
this.result.getRepository().addBalance(msg.getCodeAddress().getLast20Bytes(), msg.getEndowment().value());
|
||||
|
||||
long requiredGas = contract.getGasForData(data);
|
||||
if (requiredGas > msg.getGas().longValue()){
|
||||
long requiredGas = contract.getGasForData(data);
|
||||
if (requiredGas > msg.getGas().longValue()) {
|
||||
|
||||
this.spendGas(msg.getGas().longValue(), "call pre-compiled");
|
||||
this.stackPushZero();
|
||||
|
@ -930,7 +930,7 @@ public class Program {
|
|||
this.spendGas(requiredGas, "call pre-compiled");
|
||||
byte[] out = contract.execute(data);
|
||||
|
||||
this.memorySave( msg.getOutDataOffs().intValue(), out);
|
||||
this.memorySave(msg.getOutDataOffs().intValue(), out);
|
||||
this.stackPushOne();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class ProgramInvokeImpl implements ProgramInvoke {
|
|||
byte[] gasPrice, byte[] gas, byte[] callValue, byte[] msgData,
|
||||
byte[] lastHash, byte[] coinbase, long timestamp, long number, byte[] difficulty,
|
||||
long gaslimit,
|
||||
Repository repository, BlockStore blockStore,boolean byTestingSuite) {
|
||||
Repository repository, BlockStore blockStore, boolean byTestingSuite) {
|
||||
this(address, origin, caller, balance, gasPrice, gas, callValue, msgData, lastHash, coinbase,
|
||||
timestamp, number, difficulty, gaslimit, repository, blockStore);
|
||||
this.byTestingSuite = byTestingSuite;
|
||||
|
@ -141,8 +141,8 @@ public class ProgramInvokeImpl implements ProgramInvoke {
|
|||
return callValue;
|
||||
}
|
||||
|
||||
/*****************/
|
||||
/*** msg data ***/
|
||||
/*****************/
|
||||
/*** msg data ***/
|
||||
/*****************/
|
||||
/* NOTE: In the protocol there is no restriction on the maximum message data,
|
||||
* However msgData here is a byte[] and this can't hold more than 2^32-1
|
||||
|
|
|
@ -164,8 +164,8 @@ public class VM {
|
|||
throw program.new OutOfGasException();
|
||||
}
|
||||
callGas = callGasWord.longValue();
|
||||
BigInteger in = memNeeded(stack.get(stack.size()-4), stack.get(stack.size()-5)); // in offset+size
|
||||
BigInteger out = memNeeded(stack.get(stack.size()-6), stack.get(stack.size()-7)); // out offset+size
|
||||
BigInteger in = memNeeded(stack.get(stack.size() - 4), stack.get(stack.size() - 5)); // in offset+size
|
||||
BigInteger out = memNeeded(stack.get(stack.size() - 6), stack.get(stack.size() - 7)); // out offset+size
|
||||
newMemSize = in.max(out);
|
||||
break;
|
||||
case CREATE:
|
||||
|
|
|
@ -141,8 +141,8 @@ public class TransactionTest {
|
|||
String RLP_ENCODED_SIGNED_TX = "f86b8085e8d4a510008227109413978aee95f38490e9769c39b2773ed763d9cd5f872386f26fc10000801ba0eab47c1a49bf2fe5d40e01d313900e19ca485867d462fe06e139e3a536c6d4f4a014a569d327dcda4b29f74f93c0e9729d2f49ad726e703f9cd90dbb0fbf6649f1";
|
||||
String KEY = "c85ef7d79691fe79573b1a7064c19c1a9819ebdbd1faaab1a8ec92344438aaf4";
|
||||
byte[] testNonce = Hex.decode("");
|
||||
byte[] testGasPrice = BigIntegers.asUnsignedByteArray(BigInteger.valueOf(1000000000000L));;
|
||||
byte[] testGasLimit = BigIntegers.asUnsignedByteArray(BigInteger.valueOf(10000));;
|
||||
byte[] testGasPrice = BigIntegers.asUnsignedByteArray(BigInteger.valueOf(1000000000000L));
|
||||
byte[] testGasLimit = BigIntegers.asUnsignedByteArray(BigInteger.valueOf(10000));
|
||||
byte[] testReceiveAddress = Hex.decode("13978aee95f38490e9769c39b2773ed763d9cd5f");
|
||||
byte[] testValue = BigIntegers.asUnsignedByteArray(BigInteger.valueOf(10000000000000000L));
|
||||
byte[] testData = Hex.decode("");
|
||||
|
@ -274,21 +274,21 @@ public class TransactionTest {
|
|||
System.out.println("tx1.hash: " + Hex.toHexString(tx1.getHash()));
|
||||
System.out.println("tx2.hash: " + Hex.toHexString(tx2.getHash()));
|
||||
System.out.println();
|
||||
System.out.println("plainTx1: " + plainTx1 );
|
||||
System.out.println("plainTx2: " + plainTx2 );
|
||||
System.out.println("plainTx1: " + plainTx1);
|
||||
System.out.println("plainTx2: " + plainTx2);
|
||||
|
||||
System.out.println( Hex.toHexString(tx2.getSender()));
|
||||
System.out.println(Hex.toHexString(tx2.getSender()));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void encodeReceiptTest(){
|
||||
public void encodeReceiptTest() {
|
||||
|
||||
String data = "f90244a0f5ff3fbd159773816a7c707a9b8cb6bb778b934a8f6466c7830ed970498f4b688301e848b902000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dbda94cd2a3d9f938e13cd947ec05abc7fe734df8dd826c083a1a1a1";
|
||||
|
||||
byte[] stateRoot = Hex.decode("f5ff3fbd159773816a7c707a9b8cb6bb778b934a8f6466c7830ed970498f4b68");
|
||||
byte[] gasUsed = Hex.decode("01E848");
|
||||
Bloom bloom = new Bloom(Hex.decode("0000000000000000800000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"));
|
||||
byte[] gasUsed = Hex.decode("01E848");
|
||||
Bloom bloom = new Bloom(Hex.decode("0000000000000000800000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"));
|
||||
|
||||
LogInfo logInfo1 = new LogInfo(
|
||||
Hex.decode("cd2a3d9f938e13cd947ec05abc7fe734df8dd826"),
|
||||
|
|
|
@ -16,7 +16,7 @@ public class RedisDataSourceTest {
|
|||
|
||||
|
||||
@Test
|
||||
public void testSet1(){
|
||||
public void testSet1() {
|
||||
|
||||
try {
|
||||
RedisDataSource redis = new RedisDataSource();
|
||||
|
@ -27,7 +27,7 @@ public class RedisDataSourceTest {
|
|||
byte[] val = Hex.decode("b1b2b3");
|
||||
|
||||
redis.put(key, val);
|
||||
byte[] val2 = redis.get(key);
|
||||
byte[] val2 = redis.get(key);
|
||||
|
||||
Assert.assertEquals(Hex.toHexString(val), Hex.toHexString(val2));
|
||||
} catch (JedisConnectionException e) {
|
||||
|
@ -36,7 +36,7 @@ public class RedisDataSourceTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSet2(){
|
||||
public void testSet2() {
|
||||
|
||||
try {
|
||||
RedisDataSource redis1 = new RedisDataSource();
|
||||
|
|
|
@ -119,7 +119,7 @@ public class GitHubStateTest {
|
|||
|
||||
Set<String> excluded = new HashSet<>();
|
||||
excluded.add("EmptyTransaction");
|
||||
//todo: it goes OOG, because no gasLimit is given. So it does not change the state.
|
||||
//todo: it goes OOG, because no gasLimit is given. So it does not change the state.
|
||||
|
||||
|
||||
String json = JSONReader.loadJSON("StateTests/stTransactionTest.json");
|
||||
|
|
|
@ -33,7 +33,7 @@ public class NewBlockMessageTest {
|
|||
|
||||
Block block = new Block(
|
||||
Hex.decode("f90277f8cfa0887ef3904d3c464cbb3ce2a7e2ce02c57b1a38caaa5013ad1202ead0fc1077baa0a962ba850109a5112e7bd3109db477014057b478772825173cc3da54cfc3264e94407d73d8a49eeb85d32cf465507dd71d507100c180a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b42180830200000380830f42408086014997893f1080a000000000000000000000000000000000000000000000000000000000000018e9c0f901a2f8cfa0955f36d073ccb026b78ab3424c15cf966a7563aa270413859f78702b9e8e22cba01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942bd26d8f796719923ff13d295644f9b45db1f73080a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b42180830200000180830f4240808601499789326680a00000000000000000000000000000000000000000000000000000000000010da5f8cfa0717e058643634a0f80b9cf33da423d304dabaa826c586f50a783ba6c70cfd60da01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794f92c0f3e4825f09490ca264dc0cdacffeb566f0680a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b42180830200000280830f424080860149978936fe80a0000000000000000000000000000000000000000000000000000000000001d01f"));
|
||||
byte[] diff = new byte[] {0};
|
||||
byte[] diff = new byte[]{0};
|
||||
|
||||
NewBlockMessage nbm = new NewBlockMessage(block, diff);
|
||||
|
||||
|
|
|
@ -75,24 +75,24 @@ public class TransactionsMessageTest {
|
|||
public void test_2() {
|
||||
|
||||
String txsPacketRaw = "f9025012f89d8080940000000000000000000000000000000000000000860918"
|
||||
+ "4e72a000822710b3606956330c0d630000003359366000530a0d630000003359"
|
||||
+ "602060005301356000533557604060005301600054630000000c588433606957"
|
||||
+ "1ca07f6eb94576346488c6253197bde6a7e59ddc36f2773672c849402aa9c402"
|
||||
+ "c3c4a06d254e662bf7450dd8d835160cbb053463fed0b53f2cdd7f3ea8731919"
|
||||
+ "c8e8ccf901050180940000000000000000000000000000000000000000860918"
|
||||
+ "4e72a000822710b85336630000002e59606956330c0d63000000155933ff3356"
|
||||
+ "0d63000000275960003356576000335700630000005358600035560d63000000"
|
||||
+ "3a590033560d63000000485960003356573360003557600035335700b84a7f4e"
|
||||
+ "616d655265670000000000000000000000000000000000000000000000000030"
|
||||
+ "57307f4e616d6552656700000000000000000000000000000000000000000000"
|
||||
+ "00000057336069571ba04af15a0ec494aeac5b243c8a2690833faa74c0f73db1"
|
||||
+ "f439d521c49c381513e9a05802e64939be5a1f9d4d614038fbd5479538c48795"
|
||||
+ "614ef9c551477ecbdb49d2f8a6028094ccdeac59d35627b7de09332e819d5159"
|
||||
+ "e7bb72508609184e72a000822710b84000000000000000000000000000000000"
|
||||
+ "000000000000000000000000000000000000000000000000000000002d0aceee"
|
||||
+ "7e5ab874e22ccf8d1a649f59106d74e81ba0d05887574456c6de8f7a0d172342"
|
||||
+ "c2cbdd4cf7afe15d9dbb8b75b748ba6791c9a01e87172a861f6c37b5a9e3a5d0"
|
||||
+ "d7393152a7fbe41530e5bb8ac8f35433e5931b";
|
||||
+ "4e72a000822710b3606956330c0d630000003359366000530a0d630000003359"
|
||||
+ "602060005301356000533557604060005301600054630000000c588433606957"
|
||||
+ "1ca07f6eb94576346488c6253197bde6a7e59ddc36f2773672c849402aa9c402"
|
||||
+ "c3c4a06d254e662bf7450dd8d835160cbb053463fed0b53f2cdd7f3ea8731919"
|
||||
+ "c8e8ccf901050180940000000000000000000000000000000000000000860918"
|
||||
+ "4e72a000822710b85336630000002e59606956330c0d63000000155933ff3356"
|
||||
+ "0d63000000275960003356576000335700630000005358600035560d63000000"
|
||||
+ "3a590033560d63000000485960003356573360003557600035335700b84a7f4e"
|
||||
+ "616d655265670000000000000000000000000000000000000000000000000030"
|
||||
+ "57307f4e616d6552656700000000000000000000000000000000000000000000"
|
||||
+ "00000057336069571ba04af15a0ec494aeac5b243c8a2690833faa74c0f73db1"
|
||||
+ "f439d521c49c381513e9a05802e64939be5a1f9d4d614038fbd5479538c48795"
|
||||
+ "614ef9c551477ecbdb49d2f8a6028094ccdeac59d35627b7de09332e819d5159"
|
||||
+ "e7bb72508609184e72a000822710b84000000000000000000000000000000000"
|
||||
+ "000000000000000000000000000000000000000000000000000000002d0aceee"
|
||||
+ "7e5ab874e22ccf8d1a649f59106d74e81ba0d05887574456c6de8f7a0d172342"
|
||||
+ "c2cbdd4cf7afe15d9dbb8b75b748ba6791c9a01e87172a861f6c37b5a9e3a5d0"
|
||||
+ "d7393152a7fbe41530e5bb8ac8f35433e5931b";
|
||||
|
||||
byte[] payload = Hex.decode(txsPacketRaw);
|
||||
|
||||
|
@ -158,7 +158,7 @@ public class TransactionsMessageTest {
|
|||
|
||||
assertEquals
|
||||
("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000002d0aceee7e5ab874e22ccf8d1a649f59106d74e8",
|
||||
Hex.toHexString(tx1.getData()));
|
||||
Hex.toHexString(tx1.getData()));
|
||||
|
||||
assertEquals("1b",
|
||||
Hex.toHexString(new byte[]{tx1.getSignature().v}));
|
||||
|
|
|
@ -45,10 +45,10 @@ public class MachineCompileTest {
|
|||
public void test3() {
|
||||
|
||||
String code = "a=2\n" +
|
||||
"if a>0:\n" +
|
||||
" b = 3\n" +
|
||||
"else: \n" +
|
||||
" c = 4";
|
||||
"if a>0:\n" +
|
||||
" b = 3\n" +
|
||||
"else: \n" +
|
||||
" c = 4";
|
||||
// String expected = "610100600e6000396101006000f260026000546002600054600260005460026000546002600054600260005460026000546002600054600260005460026000546002600054600260005460026000546002600054600260005460026000546002600054600260005460026000546002600054600260005460026000546002600054600260005460026000546002600054600260005460026000546002600054600260005460026000546002600054600260005460026000546002600054600260005460026000546002600054600260005460026000546002600054600260005460026000546002600054600260005460026000546002600054600260005460026000546002600054600260005469";
|
||||
String asm = SerpentCompiler.compile(code);
|
||||
byte[] machineCode = SerpentCompiler.compileAssemblyToMachine(asm);
|
||||
|
|
|
@ -590,11 +590,11 @@ public class SerpentCompileTest {
|
|||
public void test24() {
|
||||
|
||||
String code = "a = 20\n" +
|
||||
"b = 40\n" +
|
||||
"if a == 20: \n" +
|
||||
" a = 30\n" +
|
||||
"if b == 40: \n" +
|
||||
" b = 50\n";
|
||||
"b = 40\n" +
|
||||
"if a == 20: \n" +
|
||||
" a = 30\n" +
|
||||
"if b == 40: \n" +
|
||||
" b = 50\n";
|
||||
String expected = "20 0 MSTORE 40 32 MSTORE 20 0 MLOAD EQ NOT REF_1 JUMPI 30 0 MSTORE REF_0 JUMP LABEL_1 LABEL_0 40 32 MLOAD EQ NOT REF_3 JUMPI 50 32 MSTORE REF_2 JUMP LABEL_3 LABEL_2";
|
||||
|
||||
/**
|
||||
|
@ -626,13 +626,13 @@ public class SerpentCompileTest {
|
|||
@Test // if elif else test 10
|
||||
public void test25() {
|
||||
|
||||
String code = "a = 20\n" +
|
||||
"b = 40\n" +
|
||||
"if a == 20: \n" +
|
||||
" a = 30\n" +
|
||||
"a = 70\n" +
|
||||
"if b == 40: \n" +
|
||||
" b = 50\n";
|
||||
String code = "a = 20\n" +
|
||||
"b = 40\n" +
|
||||
"if a == 20: \n" +
|
||||
" a = 30\n" +
|
||||
"a = 70\n" +
|
||||
"if b == 40: \n" +
|
||||
" b = 50\n";
|
||||
String expected = "20 0 MSTORE 40 32 MSTORE 20 0 MLOAD EQ NOT REF_1 JUMPI 30 0 MSTORE REF_0 JUMP LABEL_1 LABEL_0 70 0 MSTORE 40 32 MLOAD EQ NOT REF_3 JUMPI 50 32 MSTORE REF_2 JUMP LABEL_3 LABEL_2";
|
||||
|
||||
/**
|
||||
|
@ -699,7 +699,7 @@ public class SerpentCompileTest {
|
|||
@Test // if elif else test 12
|
||||
public void test27() {
|
||||
|
||||
String code = "if 2>1: \n" +
|
||||
String code = "if 2>1: \n" +
|
||||
" if 3>2: \n" +
|
||||
" if 4>3:\n" +
|
||||
" if 5>4:\n" +
|
||||
|
@ -909,14 +909,14 @@ public class SerpentCompileTest {
|
|||
@Test // if elif else test 20
|
||||
public void test35() {
|
||||
|
||||
String code = "if 2>1: \n" +
|
||||
" a=20 \n" +
|
||||
"elif 5<1: \n" +
|
||||
" a=30 \n" +
|
||||
"elif 6>6: \n" +
|
||||
" a=40 \n" +
|
||||
"else: \n" +
|
||||
" a=50 \n" ;
|
||||
String code = "if 2>1: \n" +
|
||||
" a=20 \n" +
|
||||
"elif 5<1: \n" +
|
||||
" a=30 \n" +
|
||||
"elif 6>6: \n" +
|
||||
" a=40 \n" +
|
||||
"else: \n" +
|
||||
" a=50 \n";
|
||||
|
||||
String expected = "1 2 GT NOT REF_1 JUMPI 20 0 MSTORE REF_0 JUMP LABEL_1 1 5 LT NOT REF_2 JUMPI 30 0 MSTORE REF_0 JUMP LABEL_2 6 6 GT NOT REF_3 JUMPI 40 0 MSTORE REF_0 JUMP LABEL_3 50 0 MSTORE LABEL_0";
|
||||
|
||||
|
@ -984,12 +984,12 @@ public class SerpentCompileTest {
|
|||
@Test // while test 2
|
||||
public void test37() {
|
||||
|
||||
String code = "x = 248 \n" +
|
||||
"while x > 1: \n" +
|
||||
" if (x % 2) == 0: \n" +
|
||||
" x = x / 2 \n" +
|
||||
" else: \n " +
|
||||
" x = 3 * x + 1 \n" ;
|
||||
String code = "x = 248 \n" +
|
||||
"while x > 1: \n" +
|
||||
" if (x % 2) == 0: \n" +
|
||||
" x = x / 2 \n" +
|
||||
" else: \n " +
|
||||
" x = 3 * x + 1 \n";
|
||||
|
||||
String expected = "248 0 MSTORE LABEL_0 1 0 MLOAD GT NOT REF_1 JUMPI 0 2 0 MLOAD MOD EQ NOT REF_3 JUMPI 2 0 MLOAD DIV 0 MSTORE REF_2 JUMP LABEL_3 1 0 MLOAD 3 MUL ADD 0 MSTORE LABEL_2 REF_0 JUMP LABEL_1";
|
||||
|
||||
|
@ -1024,12 +1024,12 @@ public class SerpentCompileTest {
|
|||
@Test // while test 3
|
||||
public void test38() {
|
||||
|
||||
String code = "x = 0xFF \n" +
|
||||
"while x > 1: \n" +
|
||||
" if (x % 2) == 0: \n" +
|
||||
" x = x / 2 \n" +
|
||||
"x = x +2 \n" +
|
||||
"x = 3 * x + 1 \n" ;
|
||||
String code = "x = 0xFF \n" +
|
||||
"while x > 1: \n" +
|
||||
" if (x % 2) == 0: \n" +
|
||||
" x = x / 2 \n" +
|
||||
"x = x +2 \n" +
|
||||
"x = 3 * x + 1 \n";
|
||||
|
||||
String expected = "255 0 MSTORE LABEL_0 1 0 MLOAD GT NOT REF_1 JUMPI 0 2 0 MLOAD MOD EQ NOT REF_3 JUMPI 2 0 MLOAD DIV 0 MSTORE REF_2 JUMP LABEL_3 LABEL_2 REF_0 JUMP LABEL_1 2 0 MLOAD ADD 0 MSTORE 1 0 MLOAD 3 MUL ADD 0 MSTORE";
|
||||
|
||||
|
@ -1077,9 +1077,9 @@ public class SerpentCompileTest {
|
|||
@Test // while test 5
|
||||
public void test40() {
|
||||
|
||||
String code = "x = 0xFF\n" +
|
||||
"while (x > 1) && (x > 2) && (x > 3) && (2 <9):\n" +
|
||||
" x = x -2\n" ;
|
||||
String code = "x = 0xFF\n" +
|
||||
"while (x > 1) && (x > 2) && (x > 3) && (2 <9):\n" +
|
||||
" x = x -2\n";
|
||||
|
||||
String expected = "255 0 MSTORE LABEL_0 9 2 LT 3 0 MLOAD GT 2 0 MLOAD GT 1 0 MLOAD GT NOT NOT MUL NOT NOT MUL NOT NOT MUL NOT REF_1 JUMPI 2 0 MLOAD SUB 0 MSTORE REF_0 JUMP LABEL_1";
|
||||
|
||||
|
@ -1108,19 +1108,19 @@ public class SerpentCompileTest {
|
|||
@Test // special functions test 1
|
||||
public void test41() {
|
||||
|
||||
String code = "a = msg.datasize\n" +
|
||||
"b = msg.sender\n" +
|
||||
"c = msg.value\n" +
|
||||
"d = tx.gasprice\n" +
|
||||
"e = tx.origin\n" +
|
||||
"f = tx.gas\n" +
|
||||
"g = contract.balance\n" +
|
||||
"h = block.prevhash\n" +
|
||||
"i = block.coinbase\n" +
|
||||
"j = block.timestamp\n" +
|
||||
"k = block.number\n" +
|
||||
"l = block.difficulty\n" +
|
||||
"m = block.gaslimit\n" ;
|
||||
String code = "a = msg.datasize\n" +
|
||||
"b = msg.sender\n" +
|
||||
"c = msg.value\n" +
|
||||
"d = tx.gasprice\n" +
|
||||
"e = tx.origin\n" +
|
||||
"f = tx.gas\n" +
|
||||
"g = contract.balance\n" +
|
||||
"h = block.prevhash\n" +
|
||||
"i = block.coinbase\n" +
|
||||
"j = block.timestamp\n" +
|
||||
"k = block.number\n" +
|
||||
"l = block.difficulty\n" +
|
||||
"m = block.gaslimit\n";
|
||||
|
||||
String expected = "32 CALLDATASIZE DIV 0 MSTORE CALLER 32 MSTORE CALLVALUE 64 MSTORE GASPRICE 96 MSTORE ORIGIN 128 MSTORE GAS 160 MSTORE BALANCE 192 MSTORE PREVHASH 224 MSTORE COINBASE 256 MSTORE TIMESTAMP 288 MSTORE NUMBER 320 MSTORE DIFFICULTY 352 MSTORE GASLIMIT 384 MSTORE";
|
||||
|
||||
|
@ -1185,9 +1185,9 @@ public class SerpentCompileTest {
|
|||
|
||||
@Test // test arrays 1 simple create
|
||||
public void test45() {
|
||||
String code = "c = 2\n" +
|
||||
"d = 3\n" +
|
||||
"a = [11, 22, 33]" ;
|
||||
String code = "c = 2\n" +
|
||||
"d = 3\n" +
|
||||
"a = [11, 22, 33]";
|
||||
String expected = "0 63 MSTORE8 2 0 MSTORE 3 32 MSTORE MSIZE 32 ADD MSIZE DUP 32 ADD 11 SWAP MSTORE DUP 64 ADD 22 SWAP MSTORE DUP 96 ADD 33 SWAP MSTORE 128 SWAP MSTORE";
|
||||
|
||||
String asmResult = SerpentCompiler.compile(code);
|
||||
|
@ -1196,8 +1196,8 @@ public class SerpentCompileTest {
|
|||
|
||||
@Test // test arrays 2 simple set
|
||||
public void test46() {
|
||||
String code = "a = [11, 22, 33]\n" +
|
||||
"a[ 2 ] = 3" ;
|
||||
String code = "a = [11, 22, 33]\n" +
|
||||
"a[ 2 ] = 3";
|
||||
String expected = "MSIZE 32 ADD MSIZE DUP 32 ADD 11 SWAP MSTORE DUP 64 ADD 22 SWAP MSTORE DUP 96 ADD 33 SWAP MSTORE 128 SWAP MSTORE 3 32 2 MUL 32 ADD 0 ADD 0 ADD MSTORE";
|
||||
|
||||
String asmResult = SerpentCompiler.compile(code);
|
||||
|
@ -1206,7 +1206,7 @@ public class SerpentCompileTest {
|
|||
|
||||
@Test // test arrays 3 simple
|
||||
public void test46_1() {
|
||||
String code = "a = [11, 22, 33]\n" ;
|
||||
String code = "a = [11, 22, 33]\n";
|
||||
String expected = "MSIZE 32 ADD MSIZE DUP 32 ADD 11 SWAP MSTORE DUP 64 ADD 22 SWAP MSTORE DUP 96 ADD 33 SWAP MSTORE 128 SWAP MSTORE";
|
||||
|
||||
String asmResult = SerpentCompiler.compile(code);
|
||||
|
@ -1215,10 +1215,10 @@ public class SerpentCompileTest {
|
|||
|
||||
@Test // test arrays 3 complicated set after 2 arrays
|
||||
public void test47() {
|
||||
String code = "a = [2, 4, 6]\n" +
|
||||
"b = [12, 14]\n" +
|
||||
"c = [22, 24, 25]\n" +
|
||||
"c[ 0 ] = 3" ;
|
||||
String code = "a = [2, 4, 6]\n" +
|
||||
"b = [12, 14]\n" +
|
||||
"c = [22, 24, 25]\n" +
|
||||
"c[ 0 ] = 3";
|
||||
String expected = "MSIZE 32 ADD MSIZE DUP 32 ADD 2 SWAP MSTORE DUP 64 ADD 4 SWAP MSTORE DUP 96 ADD 6 SWAP MSTORE 128 SWAP MSTORE MSIZE 32 ADD MSIZE DUP 32 ADD 12 SWAP MSTORE DUP 64 ADD 14 SWAP MSTORE 96 SWAP MSTORE MSIZE 32 ADD MSIZE DUP 32 ADD 22 SWAP MSTORE DUP 64 ADD 24 SWAP MSTORE DUP 96 ADD 25 SWAP MSTORE 128 SWAP MSTORE 3 32 0 MUL 32 ADD 224 ADD 0 ADD MSTORE";
|
||||
|
||||
String asmResult = SerpentCompiler.compile(code);
|
||||
|
@ -1227,10 +1227,10 @@ public class SerpentCompileTest {
|
|||
|
||||
@Test // test arrays 4 simple set
|
||||
public void test48() {
|
||||
String code = "b = 1\n" +
|
||||
"c = 2\n" +
|
||||
"a = [11, 22, 33]\n" +
|
||||
"a[ 2 ] = 3" ;
|
||||
String code = "b = 1\n" +
|
||||
"c = 2\n" +
|
||||
"a = [11, 22, 33]\n" +
|
||||
"a[ 2 ] = 3";
|
||||
String expected = "0 63 MSTORE8 1 0 MSTORE 2 32 MSTORE MSIZE 32 ADD MSIZE DUP 32 ADD 11 SWAP MSTORE DUP 64 ADD 22 SWAP MSTORE DUP 96 ADD 33 SWAP MSTORE 128 SWAP MSTORE 3 32 2 MUL 32 ADD 0 ADD 64 ADD MSTORE";
|
||||
|
||||
String asmResult = SerpentCompiler.compile(code);
|
||||
|
@ -1239,9 +1239,9 @@ public class SerpentCompileTest {
|
|||
|
||||
@Test // test arrays 5 simple retrieve value
|
||||
public void test49() {
|
||||
String code = "c = [5]\n" +
|
||||
"a = [11, 22, 33]\n" +
|
||||
"b = a [0]" ;
|
||||
String code = "c = [5]\n" +
|
||||
"a = [11, 22, 33]\n" +
|
||||
"b = a [0]";
|
||||
String expected = "0 31 MSTORE8 MSIZE 32 ADD MSIZE DUP 32 ADD 5 SWAP MSTORE 64 SWAP MSTORE MSIZE 32 ADD MSIZE DUP 32 ADD 11 SWAP MSTORE DUP 64 ADD 22 SWAP MSTORE DUP 96 ADD 33 SWAP MSTORE 128 SWAP MSTORE 32 0 MUL 96 ADD 32 ADD MLOAD 0 MSTORE";
|
||||
|
||||
String asmResult = SerpentCompiler.compile(code);
|
||||
|
@ -1250,9 +1250,9 @@ public class SerpentCompileTest {
|
|||
|
||||
@Test // test msg(gas, to , val, [arr_in], in_len, out_len), and out access
|
||||
public void test50() {
|
||||
String code = "\n" +
|
||||
String code = "\n" +
|
||||
"a = msg(1, 2, 3, [11, 22, 33], 3, 6) \n" +
|
||||
"b = a[0]\n" ;
|
||||
"b = a[0]\n";
|
||||
String expected = "0 31 MSTORE8 224 MSIZE 224 MSIZE MSTORE 0 192 MSIZE ADD MSTORE8 96 MSIZE 32 ADD MSIZE DUP 32 ADD 11 SWAP MSTORE DUP 64 ADD 22 SWAP MSTORE DUP 96 ADD 33 SWAP MSTORE 128 SWAP MSTORE 3 2 1 CALL 32 0 MUL 160 ADD 32 ADD MLOAD 0 MSTORE";
|
||||
|
||||
String asmResult = SerpentCompiler.compile(code);
|
||||
|
|
|
@ -544,7 +544,7 @@ public class TrieTest {
|
|||
private final String randomDictionary = "spinneries, archipenko, prepotency, herniotomy, preexpress, relaxative, insolvably, debonnaire, apophysate, virtuality, cavalryman, utilizable, diagenesis, vitascopic, governessy, abranchial, cyanogenic, gratulated, signalment, predicable, subquality, crystalize, prosaicism, oenologist, repressive, impanelled, cockneyism, bordelaise, compigne, konstantin, predicated, unsublimed, hydrophane, phycomyces, capitalise, slippingly, untithable, unburnable, deoxidizer, misteacher, precorrect, disclaimer, solidified, neuraxitis, caravaning, betelgeuse, underprice, uninclosed, acrogynous, reirrigate, dazzlingly, chaffiness, corybantes, intumesced, intentness, superexert, abstrusely, astounding, pilgrimage, posttarsal, prayerless, nomologist, semibelted, frithstool, unstinging, ecalcarate, amputating, megascopic, graphalloy, platteland, adjacently, mingrelian, valentinus, appendical, unaccurate, coriaceous, waterworks, sympathize, doorkeeper, overguilty, flaggingly, admonitory, aeriferous, normocytic, parnellism, catafalque, odontiasis, apprentice, adulterous, mechanisma, wilderness, undivorced, reinterred, effleurage, pretrochal, phytogenic, swirlingly, herbarized, unresolved, classifier, diosmosing, microphage, consecrate, astarboard, predefying, predriving, lettergram, ungranular, overdozing, conferring, unfavorite, peacockish, coinciding, erythraeum, freeholder, zygophoric, imbitterer, centroidal, appendixes, grayfishes, enological, indiscreet, broadcloth, divulgated, anglophobe, stoopingly, bibliophil, laryngitis, separatist, estivating, bellarmine, greasiness, typhlology, xanthation, mortifying, endeavorer, aviatrices, unequalise, metastatic, leftwinger, apologizer, quatrefoil, nonfouling, bitartrate, outchiding, undeported, poussetted, haemolysis, asantehene, montgomery, unjoinable, cedarhurst, unfastener, nonvacuums, beauregard, animalized, polyphides, cannizzaro, gelatinoid, apologised, unscripted, tracheidal, subdiscoid, gravelling, variegated, interabang, inoperable, immortelle, laestrygon, duplicatus, proscience, deoxidised, manfulness, channelize, nondefense, ectomorphy, unimpelled, headwaiter, hexaemeric, derivation, prelexical, limitarian, nonionized, prorefugee, invariably, patronizer, paraplegia, redivision, occupative, unfaceable, hypomnesia, psalterium, doctorfish, gentlefolk, overrefine, heptastich, desirously, clarabelle, uneuphonic, autotelism, firewarden, timberjack, fumigation, drainpipes, spathulate, novelvelle, bicorporal, grisliness, unhesitant, supergiant, unpatented, womanpower, toastiness, multichord, paramnesia, undertrick, contrarily, neurogenic, gunmanship, settlement, brookville, gradualism, unossified, villanovan, ecospecies, organising, buckhannon, prefulfill, johnsonese, unforegone, unwrathful, dunderhead, erceldoune, unwadeable, refunction, understuff, swaggering, freckliest, telemachus, groundsill, outslidden, bolsheviks, recognizer, hemangioma, tarantella, muhammedan, talebearer, relocation, preemption, chachalaca, septuagint, ubiquitous, plexiglass, humoresque, biliverdin, tetraploid, capitoline, summerwood, undilating, undetested, meningitic, petrolatum, phytotoxic, adiphenine, flashlight, protectory, inwreathed, rawishness, tendrillar, hastefully, bananaquit, anarthrous, unbedimmed, herborized, decenniums, deprecated, karyotypic, squalidity, pomiferous, petroglyph, actinomere, peninsular, trigonally, androgenic, resistance, unassuming, frithstool, documental, eunuchised, interphone, thymbraeus, confirmand, expurgated, vegetation, myographic, plasmagene, spindrying, unlackeyed, foreknower, mythically, albescence, rebudgeted, implicitly, unmonastic, torricelli, mortarless, labialized, phenacaine, radiometry, sluggishly, understood, wiretapper, jacobitely, unbetrayed, stadholder, directress, emissaries, corelation, sensualize, uncurbable, permillage, tentacular, thriftless, demoralize, preimagine, iconoclast, acrobatism, firewarden, transpired, bluethroat, wanderjahr, groundable, pedestrian, unulcerous, preearthly, freelanced, sculleries, avengingly, visigothic, preharmony, bressummer, acceptable, unfoolable, predivider, overseeing, arcosolium, piriformis, needlecord, homebodies, sulphation, phantasmic, unsensible, unpackaged, isopiestic, cytophagic, butterlike, frizzliest, winklehawk, necrophile, mesothorax, cuchulainn, unrentable, untangible, unshifting, unfeasible, poetastric, extermined, gaillardia, nonpendent, harborside, pigsticker, infanthood, underrower, easterling, jockeyship, housebreak, horologium, undepicted, dysacousma, incurrable, editorship, unrelented, peritricha, interchaff, frothiness, underplant, proafrican, squareness, enigmatise, reconciled, nonnumeral, nonevident, hamantasch, victualing, watercolor, schrdinger, understand, butlerlike, hemiglobin, yankeeland";
|
||||
|
||||
@Test
|
||||
public void testMasiveUpdate(){
|
||||
public void testMasiveUpdate() {
|
||||
boolean massiveUpdateTestEnabled = false;
|
||||
|
||||
if (massiveUpdateTestEnabled) {
|
||||
|
@ -901,7 +901,7 @@ public class TrieTest {
|
|||
|
||||
|
||||
@Test // update the trie with blog key/val
|
||||
// each time dump the entire trie
|
||||
// each time dump the entire trie
|
||||
public void testSample_1() {
|
||||
|
||||
TrieImpl trie = new TrieImpl(mockDb);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -55,5 +55,5 @@ public class RlpTestData {
|
|||
|
||||
public static Object[] test16 = new Object[]{"zw", new Object[]{4}, "wz"};
|
||||
public static String result16 = "c8827a77c10482777a";
|
||||
public static Object[] expected16 = new Object[] { new byte[] { 122, 119 }, new Object[] { new byte[] { 4 } }, new byte[] { 119, 122 } };
|
||||
public static Object[] expected16 = new Object[]{new byte[]{122, 119}, new Object[]{new byte[]{4}}, new byte[]{119, 122}};
|
||||
}
|
||||
|
|
|
@ -254,7 +254,7 @@ public class DataWordTest {
|
|||
if (y.compareTo(BigInteger.ZERO) < 0)
|
||||
throw new IllegalArgumentException();
|
||||
BigInteger z = x; // z will successively become x^2, x^4, x^8, x^16,
|
||||
// x^32...
|
||||
// x^32...
|
||||
BigInteger result = BigInteger.ONE;
|
||||
byte[] bytes = y.toByteArray();
|
||||
for (int i = bytes.length - 1; i >= 0; i--) {
|
||||
|
|
|
@ -17,13 +17,12 @@ import static org.junit.Assert.*;
|
|||
public class PrecompiledContractTest {
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void identityTest1(){
|
||||
public void identityTest1() {
|
||||
|
||||
DataWord addr = new DataWord("0000000000000000000000000000000000000000000000000000000000000004");
|
||||
PrecompiledContract contract = PrecompiledContracts.getContractForAddress(addr);
|
||||
byte[] data = Hex.decode("112233445566");
|
||||
byte[] data = Hex.decode("112233445566");
|
||||
byte[] expected = Hex.decode("112233445566");
|
||||
|
||||
byte[] result = contract.execute(data);
|
||||
|
@ -33,11 +32,11 @@ public class PrecompiledContractTest {
|
|||
|
||||
|
||||
@Test
|
||||
public void sha256Test1(){
|
||||
public void sha256Test1() {
|
||||
|
||||
DataWord addr = new DataWord("0000000000000000000000000000000000000000000000000000000000000002");
|
||||
PrecompiledContract contract = PrecompiledContracts.getContractForAddress(addr);
|
||||
byte[] data = null;
|
||||
byte[] data = null;
|
||||
String expected = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
||||
|
||||
byte[] result = contract.execute(data);
|
||||
|
@ -46,11 +45,11 @@ public class PrecompiledContractTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sha256Test2(){
|
||||
public void sha256Test2() {
|
||||
|
||||
DataWord addr = new DataWord("0000000000000000000000000000000000000000000000000000000000000002");
|
||||
PrecompiledContract contract = PrecompiledContracts.getContractForAddress(addr);
|
||||
byte[] data = ByteUtil.EMPTY_BYTE_ARRAY;
|
||||
byte[] data = ByteUtil.EMPTY_BYTE_ARRAY;
|
||||
String expected = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
||||
|
||||
byte[] result = contract.execute(data);
|
||||
|
@ -59,11 +58,11 @@ public class PrecompiledContractTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sha256Test3(){
|
||||
public void sha256Test3() {
|
||||
|
||||
DataWord addr = new DataWord("0000000000000000000000000000000000000000000000000000000000000002");
|
||||
PrecompiledContract contract = PrecompiledContracts.getContractForAddress(addr);
|
||||
byte[] data = Hex.decode("112233");
|
||||
byte[] data = Hex.decode("112233");
|
||||
String expected = "49ee2bf93aac3b1fb4117e59095e07abe555c3383b38d608da37680a406096e8";
|
||||
|
||||
byte[] result = contract.execute(data);
|
||||
|
@ -73,11 +72,11 @@ public class PrecompiledContractTest {
|
|||
|
||||
|
||||
@Test
|
||||
public void Ripempd160Test1(){
|
||||
public void Ripempd160Test1() {
|
||||
|
||||
DataWord addr = new DataWord("0000000000000000000000000000000000000000000000000000000000000003");
|
||||
PrecompiledContract contract = PrecompiledContracts.getContractForAddress(addr);
|
||||
byte[] data = Hex.decode("0000000000000000000000000000000000000000000000000000000000000001");
|
||||
byte[] data = Hex.decode("0000000000000000000000000000000000000000000000000000000000000001");
|
||||
String expected = "000000000000000000000000ae387fcfeb723c3f5964509af111cf5a67f30661";
|
||||
|
||||
byte[] result = contract.execute(data);
|
||||
|
@ -86,7 +85,7 @@ public class PrecompiledContractTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void ecRecoverTest1(){
|
||||
public void ecRecoverTest1() {
|
||||
|
||||
byte[] data = Hex.decode("18c547e4f7b0f325ad1e56f57e26c745b09a3e503d86e00e5255ff7f715d3d1c000000000000000000000000000000000000000000000000000000000000001c73b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75feeb940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c4549");
|
||||
DataWord addr = new DataWord("0000000000000000000000000000000000000000000000000000000000000001");
|
||||
|
|
|
@ -54,7 +54,7 @@ public class AccountsListWindow extends JFrame {
|
|||
public void run() {
|
||||
Repository repository = UIEthereumManager.ethereum.getRepository();
|
||||
Set<byte[]> keys = repository.getAccountsKeys();
|
||||
for (byte[] key : keys){
|
||||
for (byte[] key : keys) {
|
||||
DataClass dc = new DataClass();
|
||||
dc.address = key;
|
||||
AccountState state = repository.getAccountState(dc.address);
|
||||
|
|
|
@ -644,7 +644,7 @@ public class ConsoleTokenMaker extends AbstractTokenMaker {
|
|||
}
|
||||
break;
|
||||
} else if (c == '.') { // Second decimal point; must catch now because it's a "separator"
|
||||
// below.
|
||||
// below.
|
||||
currentTokenType = Token.ERROR_NUMBER_FORMAT;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -442,7 +442,7 @@ public class SerpentTokenMaker extends AbstractTokenMaker {
|
|||
case Token.ERROR_STRING_DOUBLE:
|
||||
|
||||
if (c == '"') {
|
||||
addToken(text, currentTokenStart,i, Token.LITERAL_STRING_DOUBLE_QUOTE, newStartOffset+currentTokenStart);
|
||||
addToken(text, currentTokenStart, i, Token.LITERAL_STRING_DOUBLE_QUOTE, newStartOffset + currentTokenStart);
|
||||
currentTokenStart = i + 1;
|
||||
currentTokenType = Token.NULL;
|
||||
}
|
||||
|
@ -458,16 +458,14 @@ public class SerpentTokenMaker extends AbstractTokenMaker {
|
|||
bracketVariable = true;
|
||||
break;
|
||||
default:
|
||||
if (RSyntaxUtilities.isLetter(c) || c==' ') { // No tab, just space; spaces are okay in variable names.
|
||||
if (RSyntaxUtilities.isLetter(c) || c == ' ') { // No tab, just space; spaces are okay in variable names.
|
||||
break;
|
||||
}
|
||||
else if (RSyntaxUtilities.isDigit(c)) { // Single-digit command-line argument ("%1").
|
||||
addToken(text, currentTokenStart,i, Token.VARIABLE, newStartOffset+currentTokenStart);
|
||||
} else if (RSyntaxUtilities.isDigit(c)) { // Single-digit command-line argument ("%1").
|
||||
addToken(text, currentTokenStart, i, Token.VARIABLE, newStartOffset + currentTokenStart);
|
||||
currentTokenType = Token.NULL;
|
||||
break;
|
||||
}
|
||||
else { // Anything else, ???.
|
||||
addToken(text, currentTokenStart,i-1, Token.VARIABLE, newStartOffset+currentTokenStart); // ???
|
||||
} else { // Anything else, ???.
|
||||
addToken(text, currentTokenStart, i - 1, Token.VARIABLE, newStartOffset + currentTokenStart); // ???
|
||||
i--;
|
||||
currentTokenType = Token.NULL;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue