Skip to content

Commit

Permalink
Merge pull request #30 from HorizenOfficial/development
Browse files Browse the repository at this point in the history
1.1.0 to master
  • Loading branch information
paolocappelletti authored Mar 5, 2024
2 parents 78dc436 + 55a5c84 commit 4995c71
Show file tree
Hide file tree
Showing 32 changed files with 1,462 additions and 212 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ pom.xml.versionsBackup
*.iml
.project
.classpath
*.*bkp*
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# Changelog

## 1.1.0
- Based on [HorizenOfficial/go-ethereum](https://github.com/HorizenOfficial/go-ethereum) `v1.1.0`
(Shangai update)

## 1.0.0

- Updated Go version to 1.21
- Based on [HorizenOfficial/go-ethereum](https://github.com/HorizenOfficial/go-ethereum) `v1.0.0`
- Support for interoperability between EVM and native smart contracts



## 0.1.0

Provides standalone access to go-ethereum features:
Expand Down
2 changes: 1 addition & 1 deletion libevm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.horizen</groupId>
<artifactId>libevm</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
<name>${project.groupId}:${project.artifactId}</name>
<description>This library provides access to a standalone version of the go-ethereum EVM and its state storage layer StateDB and underlying LevelDB.</description>
<url>https://github.com/${project.github.organization}/${project.artifactId}</url>
Expand Down
8 changes: 6 additions & 2 deletions libevm/src/main/java/io/horizen/evm/EvmContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class EvmContext {
public final BigInteger time;
public final BigInteger baseFee;
public final Hash random;
public final ForkRules rules;
private BlockHashCallback blockHashCallback;
private Address[] externalContracts;
private InvocationCallback externalCallback;
Expand All @@ -25,7 +26,8 @@ public EvmContext(BigInteger chainID,
BigInteger blockNumber,
BigInteger time,
BigInteger baseFee,
Hash random) {
Hash random,
ForkRules rules) {
this.chainID = chainID;
this.coinbase = coinbase;
this.gasLimit = gasLimit;
Expand All @@ -34,6 +36,7 @@ public EvmContext(BigInteger chainID,
this.time = time;
this.baseFee = baseFee;
this.random = random;
this.rules = rules;
}

//This constructor is just for testing purposes
Expand All @@ -46,7 +49,8 @@ public EvmContext(BigInteger chainID,
time = BigInteger.ZERO;
baseFee = BigInteger.ZERO;
random = Hash.ZERO;
};
rules = new ForkRules(false);
}

public BlockHashCallback getBlockHashCallback() {
return blockHashCallback;
Expand Down
20 changes: 20 additions & 0 deletions libevm/src/main/java/io/horizen/evm/ForkRules.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.horizen.evm;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.math.BigInteger;

/*
This class contains which go-ethereum fork points should be activated.
The mapping between SDK fork points and go-ethereum fork points must be done inside the SDK.
Objects of this class must be passed to all EVM invocations that require checking a go-ethereum fork point.
*/
public class ForkRules {
public final boolean isShanghai;

public ForkRules(
@JsonProperty("isShanghai") boolean isShanghai
) {
this.isShanghai = isShanghai;
}
}
12 changes: 6 additions & 6 deletions libevm/src/main/java/io/horizen/evm/StateDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class StateDB extends ResourceHandle {
* @param root root hash
*/
public StateDB(Database db, Hash root) {
super(LibEvm.invoke("StateOpen", new OpenStateParams(db.handle, root), int.class));
super(LibEvm.invoke("StateOpen", new OpenStateParams(db.handle, root.equals(Hash.ZERO) ? EMPTY_ROOT_HASH : root), int.class));
}

/**
Expand Down Expand Up @@ -227,7 +227,7 @@ public Hash getStorage(Address address, Hash key) {
}

/**
* Read comitted storage trie of given account.
* Read committed storage trie of given account.
*
* @param address account address
* @param key storage key
Expand Down Expand Up @@ -257,8 +257,8 @@ public void setStorage(Address address, Hash key, Hash value) {
* @param storageKeys storage keys
* @return proofs
*/
public ProofAccountResult getProof(Address address, Hash[] storageKeys) {
return LibEvm.invoke("StateGetProof", new ProofParams(handle, address, storageKeys), ProofAccountResult.class);
public ProofAccountResult getProof(Address address, Hash root, Hash[] storageKeys) {
return LibEvm.invoke("StateGetProof", new ProofParams(handle, address, root, storageKeys), ProofAccountResult.class);
}

/**
Expand Down Expand Up @@ -314,8 +314,8 @@ public void setTxContext(Hash txHash, int txIndex) {
* @param sender sender account
* @param destination destination account
*/
public void accessSetup(Address sender, Address destination) {
LibEvm.invoke("AccessSetup", new AccessParams(handle, sender, destination));
public void accessSetup(Address sender, Address destination, Address coinbase, ForkRules rules) {
LibEvm.invoke("AccessSetup", new AccessParams(handle, sender, destination, coinbase, rules));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions libevm/src/main/java/io/horizen/evm/Tracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public void CaptureStart(
}

// Top call frame
public void CaptureEnd(byte[] output, BigInteger gasUsed, long duration, String err) {
LibEvm.invoke("TracerCaptureEnd", new TracerEndParams(handle, output, gasUsed, duration, err));
public void CaptureEnd(byte[] output, BigInteger gasUsed, String err) {
LibEvm.invoke("TracerCaptureEnd", new TracerEndParams(handle, output, gasUsed, err));
}

// Rest of call frames
Expand Down
7 changes: 6 additions & 1 deletion libevm/src/main/java/io/horizen/evm/params/AccessParams.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package io.horizen.evm.params;

import io.horizen.evm.Address;
import io.horizen.evm.ForkRules;

public class AccessParams extends AccountParams {
public final Address destination;
public final Address coinbase;
public final ForkRules rules;

public AccessParams(int handle, Address sender, Address destination) {
public AccessParams(int handle, Address sender, Address destination, Address coinbase, ForkRules rules) {
super(handle, sender);
this.destination = destination;
this.coinbase = coinbase;
this.rules = rules;
}
}
4 changes: 3 additions & 1 deletion libevm/src/main/java/io/horizen/evm/params/ProofParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

public class ProofParams extends AccountParams {
public final Hash[] storageKeys;
public final Hash root;

public ProofParams(int handle, Address address, Hash[] storageKeys) {
public ProofParams(int handle, Address address, Hash root, Hash[] storageKeys) {
super(handle, address);
this.storageKeys = storageKeys;
this.root = root;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
public class TracerEndParams extends TracerParams {
public final byte[] output;
public final BigInteger gasUsed;
public final long duration;
public final String err;

public TracerEndParams(int tracerHandle, byte[] output, BigInteger gasUsed, long duration, String err) {
public TracerEndParams(int tracerHandle, byte[] output, BigInteger gasUsed, String err) {
super(tracerHandle);
this.output = output;
this.gasUsed = gasUsed;
this.duration = duration;
this.err = err;
}
}
Loading

0 comments on commit 4995c71

Please sign in to comment.