-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
solution: implement RPC mapping for eth_simulateV1
- Loading branch information
Showing
19 changed files
with
1,112 additions
and
64 deletions.
There are no files selected for viewing
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
152 changes: 152 additions & 0 deletions
152
etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/BlockOverridesJson.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,152 @@ | ||
package io.emeraldpay.etherjar.rpc.json; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import io.emeraldpay.etherjar.domain.Address; | ||
import io.emeraldpay.etherjar.domain.Wei; | ||
import io.emeraldpay.etherjar.hex.Hex32; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* The fields of this object customize the block as part of which a call is simulated. This object can be passed to <code>eth_call</code>, <code>eth_simulateV1</code> as well as <code>debug_traceCall</code> methods. | ||
* | ||
* @see <a href="https://geth.ethereum.org/docs/interacting-with-geth/rpc/objects#block-overrides">eth_simulateV1</a> | ||
*/ | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class BlockOverridesJson { | ||
|
||
/** | ||
* Block number | ||
*/ | ||
@JsonDeserialize(using = HexLongDeserializer.class) | ||
@JsonSerialize(using = HexLongSerializer.class) | ||
private Long number; | ||
|
||
/** | ||
* The previous value of randomness beacon | ||
*/ | ||
private Hex32 prevRandao; | ||
|
||
/** | ||
* Block timestamp | ||
*/ | ||
@JsonDeserialize(using = HexLongDeserializer.class) | ||
@JsonSerialize(using = HexLongSerializer.class) | ||
private Long time; | ||
|
||
/** | ||
* Gas limit. | ||
*/ | ||
@JsonDeserialize(using = HexLongDeserializer.class) | ||
@JsonSerialize(using = HexLongSerializer.class) | ||
private Long gasLimit; | ||
|
||
/** | ||
* Fee recipient (also known as coinbase). | ||
*/ | ||
private Address feeRecipient; | ||
|
||
/** | ||
* Withdrawals made by validators. | ||
*/ | ||
private List<WithdrawalJson> withdrawals; | ||
|
||
/** | ||
* Base fee per unit of gas (see EIP-1559). | ||
*/ | ||
private Wei baseFeePerGas; | ||
|
||
/** | ||
* Base fee per unit of blob gas (see EIP-4844). | ||
*/ | ||
private Wei blobBaseFee; | ||
|
||
public Long getNumber() { | ||
return number; | ||
} | ||
|
||
public void setNumber(Long number) { | ||
this.number = number; | ||
} | ||
|
||
public Hex32 getPrevRandao() { | ||
return prevRandao; | ||
} | ||
|
||
public void setPrevRandao(Hex32 prevRandao) { | ||
this.prevRandao = prevRandao; | ||
} | ||
|
||
public Long getTime() { | ||
return time; | ||
} | ||
|
||
public void setTime(Long time) { | ||
this.time = time; | ||
} | ||
|
||
public Long getGasLimit() { | ||
return gasLimit; | ||
} | ||
|
||
public void setGasLimit(Long gasLimit) { | ||
this.gasLimit = gasLimit; | ||
} | ||
|
||
public Address getFeeRecipient() { | ||
return feeRecipient; | ||
} | ||
|
||
public void setFeeRecipient(Address feeRecipient) { | ||
this.feeRecipient = feeRecipient; | ||
} | ||
|
||
public List<WithdrawalJson> getWithdrawals() { | ||
return withdrawals; | ||
} | ||
|
||
public void setWithdrawals(List<WithdrawalJson> withdrawals) { | ||
this.withdrawals = withdrawals; | ||
} | ||
|
||
public BlockOverridesJson appendWithdrawal(WithdrawalJson withdrawal) { | ||
if (withdrawals == null) { | ||
withdrawals = new ArrayList<>(); | ||
} | ||
withdrawals.add(withdrawal); | ||
return this; | ||
} | ||
|
||
public Wei getBaseFeePerGas() { | ||
return baseFeePerGas; | ||
} | ||
|
||
public void setBaseFeePerGas(Wei baseFeePerGas) { | ||
this.baseFeePerGas = baseFeePerGas; | ||
} | ||
|
||
public Wei getBlobBaseFee() { | ||
return blobBaseFee; | ||
} | ||
|
||
public void setBlobBaseFee(Wei blobBaseFee) { | ||
this.blobBaseFee = blobBaseFee; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (!(o instanceof BlockOverridesJson that)) return false; | ||
return Objects.equals(number, that.number) && Objects.equals(prevRandao, that.prevRandao) && Objects.equals(time, that.time) && Objects.equals(gasLimit, that.gasLimit) && Objects.equals(feeRecipient, that.feeRecipient) && Objects.equals(withdrawals, that.withdrawals) && Objects.equals(baseFeePerGas, that.baseFeePerGas) && Objects.equals(blobBaseFee, that.blobBaseFee); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(number, prevRandao, time, gasLimit, feeRecipient, withdrawals, baseFeePerGas, blobBaseFee); | ||
} | ||
} |
123 changes: 123 additions & 0 deletions
123
etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/BlockSimulatedJson.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,123 @@ | ||
package io.emeraldpay.etherjar.rpc.json; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import io.emeraldpay.etherjar.domain.Wei; | ||
import io.emeraldpay.etherjar.hex.HexData; | ||
import io.emeraldpay.etherjar.hex.HexQuantity; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class BlockSimulatedJson extends BlockJson<TransactionRefJson> { | ||
|
||
/** | ||
* Log events emitted during call. This includes ETH logs, if <code>traceTransfers</code> is enabled | ||
*/ | ||
private List<CallResultLog> calls; | ||
|
||
public List<CallResultLog> getCalls() { | ||
return calls; | ||
} | ||
|
||
public void setCalls(List<CallResultLog> calls) { | ||
this.calls = calls; | ||
} | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public static class CallResultLog { | ||
|
||
/** | ||
* Transactions return data | ||
*/ | ||
private HexData returnData; | ||
|
||
/** | ||
* Log events emitted during call. This includes ETH logs, if traceTransfers is enabled | ||
*/ | ||
private List<TransactionLogJson> logs; | ||
|
||
/** | ||
* Gas used by the transaction | ||
*/ | ||
private HexQuantity gasUsed; | ||
|
||
/** | ||
* Status indicating that the transaction succeeded | ||
* 1 is success | ||
*/ | ||
@JsonDeserialize(using = HexLongDeserializer.class) | ||
@JsonSerialize(using = HexLongSerializer.class) | ||
private Long status; | ||
|
||
public HexData getReturnData() { | ||
return returnData; | ||
} | ||
|
||
public void setReturnData(HexData returnData) { | ||
this.returnData = returnData; | ||
} | ||
|
||
public List<TransactionLogJson> getLogs() { | ||
return logs; | ||
} | ||
|
||
public void setLogs(List<TransactionLogJson> logs) { | ||
this.logs = logs; | ||
} | ||
|
||
public HexQuantity getGasUsed() { | ||
return gasUsed; | ||
} | ||
|
||
public void setGasUsed(HexQuantity gasUsed) { | ||
this.gasUsed = gasUsed; | ||
} | ||
|
||
public Long getStatus() { | ||
return status; | ||
} | ||
|
||
public void setStatus(Long status) { | ||
this.status = status; | ||
} | ||
|
||
@JsonIgnore | ||
public boolean isSuccessful() { | ||
return status == 1; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (!(o instanceof CallResultLog that)) return false; | ||
return Objects.equals(returnData, that.returnData) | ||
&& Objects.equals(logs, that.logs) | ||
&& Objects.equals(gasUsed, that.gasUsed) | ||
&& Objects.equals(status, that.status); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(returnData, logs, gasUsed, status); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (!(o instanceof BlockSimulatedJson that)) return false; | ||
if (!super.equals(o)) return false; | ||
return Objects.equals(calls, that.calls); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(super.hashCode(), calls); | ||
} | ||
} | ||
|
Oops, something went wrong.