Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Prototype of EVMC Java interface #171

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bindings/java/evmc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.class
22 changes: 22 additions & 0 deletions bindings/java/evmc/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.ethereum.evmc</groupId>
<artifactId>evmc</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>evmc</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
27 changes: 27 additions & 0 deletions bindings/java/evmc/src/main/java/org/ethereum/evmc/Host.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.ethereum.evmc;

enum StorageStatus {
unchanged, modified, modifiedAgain, added, deleted
}

class TxContext {
public Hash txGasPrice;
public Address txOrigin;
public Address blockCoinbase;
public long blockNumber;
public long blockTimestamp;
public long blockGasLimit;
public Hash blockDifficulty;
}

interface Host {
Result call(Message msg);

Hash getStorage(Address addr, Hash key);

StorageStatus setStorage(Address addr, Hash key);

Hash getBalance(Address addr);

TxContext getTxContext();
}
30 changes: 30 additions & 0 deletions bindings/java/evmc/src/main/java/org/ethereum/evmc/Message.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.ethereum.evmc;

/**
* A class representing 256-bit hashes and big-endian integers.
*/
class Hash {
}

/**
* A class representing 160-bit address.
*/
class Address {

}

enum CallKind {
call, delegatecall, callcode, create, create2
}

public class Message {
CallKind kind;
int flags;
int depth;
long gas;
Address destination;
Address sender;
byte[] input;
Hash value;
Hash create2Salt;
}
10 changes: 10 additions & 0 deletions bindings/java/evmc/src/main/java/org/ethereum/evmc/Result.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.ethereum.evmc;

public class Result {
long gasLeft;
byte[] output;
Address createAddress;

public void dispose() {
}
}
9 changes: 9 additions & 0 deletions bindings/java/evmc/src/main/java/org/ethereum/evmc/VM.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.ethereum.evmc;

enum Revision {
frontier, homestead, tangerineWhistle, spuriousDragon, constantinople
}

interface VM {
public Result execute(Host host, Revision rev, Message msg, byte[] code);
}