-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from HorizenOfficial/development
version 1.0.0 to master
- Loading branch information
Showing
77 changed files
with
1,917 additions
and
836 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,13 @@ | ||
package io.horizen.evm; | ||
|
||
import io.horizen.evm.params.EvmParams; | ||
import io.horizen.evm.results.EvmResult; | ||
|
||
import java.math.BigInteger; | ||
import io.horizen.evm.results.InvocationResult; | ||
|
||
public final class Evm { | ||
private Evm() { } | ||
|
||
public static EvmResult Apply( | ||
ResourceHandle stateDBHandle, | ||
Address from, | ||
Address to, | ||
BigInteger value, | ||
byte[] input, | ||
BigInteger gasLimit, | ||
BigInteger gasPrice, | ||
EvmContext context, | ||
TraceOptions traceOptions | ||
) { | ||
var params = new EvmParams( | ||
stateDBHandle.handle, from, to, value, input, gasLimit, gasPrice, context, traceOptions); | ||
return LibEvm.invoke("EvmApply", params, EvmResult.class); | ||
public static InvocationResult Apply(ResourceHandle stateDBHandle, Invocation invocation, EvmContext context) { | ||
var params = new EvmParams(stateDBHandle.handle, invocation, context); | ||
return LibEvm.invoke("EvmApply", params, InvocationResult.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
libevm/src/main/java/io/horizen/evm/ExternalInvocation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.horizen.evm; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.math.BigInteger; | ||
|
||
public class ExternalInvocation extends Invocation { | ||
public final int depth; | ||
|
||
public ExternalInvocation( | ||
@JsonProperty("caller") Address caller, | ||
@JsonProperty("callee") Address callee, | ||
@JsonProperty("value") BigInteger value, | ||
@JsonProperty("input") byte[] input, | ||
@JsonProperty("gas") BigInteger gas, | ||
@JsonProperty("readOnly") boolean readOnly, | ||
@JsonProperty("depth") int depth | ||
) { | ||
super(caller, callee, value, input, gas, readOnly); | ||
this.depth = depth; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.horizen.evm; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.math.BigInteger; | ||
|
||
public class Invocation { | ||
public final Address caller; | ||
public final Address callee; | ||
public final BigInteger value; | ||
public final byte[] input; | ||
public final BigInteger gas; | ||
public final boolean readOnly; | ||
|
||
public Invocation( | ||
@JsonProperty("caller") Address caller, | ||
@JsonProperty("callee") Address callee, | ||
@JsonProperty("value") BigInteger value, | ||
@JsonProperty("input") byte[] input, | ||
@JsonProperty("gas") BigInteger gas, | ||
@JsonProperty("readOnly") boolean readOnly | ||
) { | ||
this.caller = caller; | ||
this.callee = callee; | ||
this.value = value; | ||
this.input = input; | ||
this.gas = gas; | ||
this.readOnly = readOnly; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
libevm/src/main/java/io/horizen/evm/InvocationCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.horizen.evm; | ||
|
||
import io.horizen.evm.results.InvocationResult; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
public abstract class InvocationCallback extends LibEvmCallback { | ||
private static final Logger logger = LogManager.getLogger(); | ||
|
||
protected abstract InvocationResult execute(ExternalInvocation args); | ||
|
||
@Override | ||
public String invoke(String args) { | ||
logger.debug("received external contract callback"); | ||
try { | ||
var invocation = Converter.fromJson(args, ExternalInvocation.class); | ||
return Converter.toJson(execute(invocation)); | ||
} catch (Exception e) { | ||
// note: make sure we do not throw any exception here because this callback is called by native code | ||
// for diagnostics we log the exception here | ||
logger.warn("received invalid external contract callback", e); | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.