Added missed fields to NewHeadMessage
- fixed all mappings - BlockJson structure moved from 3rd party library to dshackle codebase
This commit is contained in:
@@ -0,0 +1,373 @@
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.json;
|
||||
|
||||
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.BlockHash;
|
||||
import io.emeraldpay.etherjar.domain.Bloom;
|
||||
import io.emeraldpay.etherjar.domain.Wei;
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson;
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@JsonDeserialize(using = BlockJsonDeserializer.class)
|
||||
@JsonSerialize(using = BlockJsonSerializer.class)
|
||||
public class BlockJson<T extends TransactionRefJson> implements Serializable {
|
||||
|
||||
//TODO nonce or sealFields
|
||||
|
||||
/**
|
||||
* the block number. null when its pending block.
|
||||
*/
|
||||
private Long number;
|
||||
|
||||
/**
|
||||
* hash of the block. null when its pending block.
|
||||
*/
|
||||
private BlockHash hash;
|
||||
|
||||
/**
|
||||
* hash of the parent block.
|
||||
*/
|
||||
private BlockHash parentHash;
|
||||
|
||||
/**
|
||||
* SHA3 of the uncles data in the block.
|
||||
*/
|
||||
private HexData sha3Uncles;
|
||||
|
||||
/**
|
||||
* the bloom filter for the logs of the block. null when its pending block.
|
||||
*/
|
||||
private Bloom logsBloom;
|
||||
|
||||
/**
|
||||
* the root of the transaction trie of the block.
|
||||
*/
|
||||
private HexData transactionsRoot;
|
||||
|
||||
/**
|
||||
* the root of the final state trie of the block.
|
||||
*/
|
||||
private HexData stateRoot;
|
||||
|
||||
/**
|
||||
* the root of the receipts trie of the block.
|
||||
*/
|
||||
private HexData receiptsRoot;
|
||||
|
||||
/**
|
||||
* the address of the beneficiary to whom the mining rewards were given.
|
||||
*/
|
||||
private Address miner;
|
||||
|
||||
/**
|
||||
* the difficulty for this block.
|
||||
*/
|
||||
private BigInteger difficulty;
|
||||
|
||||
/**
|
||||
* total difficulty of the chain until this block.
|
||||
*/
|
||||
private BigInteger totalDifficulty;
|
||||
|
||||
/**
|
||||
* the "extra data" field of this block.
|
||||
*/
|
||||
private HexData extraData;
|
||||
|
||||
/**
|
||||
* the size of this block in bytes.
|
||||
*/
|
||||
private Long size;
|
||||
|
||||
/**
|
||||
* the maximum gas allowed in this block.
|
||||
*/
|
||||
private Long gasLimit;
|
||||
|
||||
/**
|
||||
* the total used gas by all transactions in this block.
|
||||
*/
|
||||
private Long gasUsed;
|
||||
|
||||
/**
|
||||
* when the block was collated
|
||||
*/
|
||||
private Instant timestamp;
|
||||
|
||||
/**
|
||||
* List of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter.
|
||||
*
|
||||
* HexData or TransactionJson
|
||||
*/
|
||||
private List<T> transactions;
|
||||
|
||||
/**
|
||||
* list of uncle hashes.
|
||||
*/
|
||||
private List<BlockHash> uncles;
|
||||
|
||||
/**
|
||||
* basefee value for that block, as per EIP-1559
|
||||
*/
|
||||
private Wei baseFeePerGas;
|
||||
|
||||
|
||||
private HexData mixHash;
|
||||
|
||||
private HexData nonce;
|
||||
|
||||
private HexData withdrawalsRoot;
|
||||
|
||||
public HexData getMixHash() {
|
||||
return mixHash;
|
||||
}
|
||||
|
||||
public void setMixHash(HexData mixHash) {
|
||||
this.mixHash = mixHash;
|
||||
}
|
||||
|
||||
public HexData getNonce() {
|
||||
return nonce;
|
||||
}
|
||||
|
||||
public void setNonce(HexData nonce) {
|
||||
this.nonce = nonce;
|
||||
}
|
||||
|
||||
public HexData getWithdrawalsRoot() {
|
||||
return withdrawalsRoot;
|
||||
}
|
||||
|
||||
public void setWithdrawalsRoot(HexData withdrawalsRoot) {
|
||||
this.withdrawalsRoot = withdrawalsRoot;
|
||||
}
|
||||
|
||||
public Long getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(Long number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public BlockHash getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public void setHash(BlockHash hash) {
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
public BlockHash getParentHash() {
|
||||
return parentHash;
|
||||
}
|
||||
|
||||
public void setParentHash(BlockHash parentHash) {
|
||||
this.parentHash = parentHash;
|
||||
}
|
||||
|
||||
public HexData getSha3Uncles() {
|
||||
return sha3Uncles;
|
||||
}
|
||||
|
||||
public void setSha3Uncles(HexData sha3Uncles) {
|
||||
this.sha3Uncles = sha3Uncles;
|
||||
}
|
||||
|
||||
public Bloom getLogsBloom() {
|
||||
return logsBloom;
|
||||
}
|
||||
|
||||
public void setLogsBloom(Bloom logsBloom) {
|
||||
this.logsBloom = logsBloom;
|
||||
}
|
||||
|
||||
public HexData getTransactionsRoot() {
|
||||
return transactionsRoot;
|
||||
}
|
||||
|
||||
public void setTransactionsRoot(HexData transactionsRoot) {
|
||||
this.transactionsRoot = transactionsRoot;
|
||||
}
|
||||
|
||||
public HexData getStateRoot() {
|
||||
return stateRoot;
|
||||
}
|
||||
|
||||
public void setStateRoot(HexData stateRoot) {
|
||||
this.stateRoot = stateRoot;
|
||||
}
|
||||
|
||||
public HexData getReceiptsRoot() {
|
||||
return receiptsRoot;
|
||||
}
|
||||
|
||||
public void setReceiptsRoot(HexData receiptsRoot) {
|
||||
this.receiptsRoot = receiptsRoot;
|
||||
}
|
||||
|
||||
public Address getMiner() {
|
||||
return miner;
|
||||
}
|
||||
|
||||
public void setMiner(Address miner) {
|
||||
this.miner = miner;
|
||||
}
|
||||
|
||||
public BigInteger getDifficulty() {
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
public void setDifficulty(BigInteger difficulty) {
|
||||
this.difficulty = difficulty;
|
||||
}
|
||||
|
||||
public BigInteger getTotalDifficulty() {
|
||||
return totalDifficulty;
|
||||
}
|
||||
|
||||
public void setTotalDifficulty(BigInteger totalDifficulty) {
|
||||
this.totalDifficulty = totalDifficulty;
|
||||
}
|
||||
|
||||
public HexData getExtraData() {
|
||||
return extraData;
|
||||
}
|
||||
|
||||
public void setExtraData(HexData extraData) {
|
||||
this.extraData = extraData;
|
||||
}
|
||||
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public Long getGasLimit() {
|
||||
return gasLimit;
|
||||
}
|
||||
|
||||
public void setGasLimit(Long gasLimit) {
|
||||
this.gasLimit = gasLimit;
|
||||
}
|
||||
|
||||
public Long getGasUsed() {
|
||||
return gasUsed;
|
||||
}
|
||||
|
||||
public void setGasUsed(Long gasUsed) {
|
||||
this.gasUsed = gasUsed;
|
||||
}
|
||||
|
||||
public Instant getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(Instant timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public List<T> getTransactions() {
|
||||
return transactions;
|
||||
}
|
||||
|
||||
public void setTransactions(List<T> transactions) {
|
||||
this.transactions = transactions;
|
||||
}
|
||||
|
||||
public List<BlockHash> getUncles() {
|
||||
return uncles;
|
||||
}
|
||||
|
||||
public void setUncles(List<BlockHash> uncles) {
|
||||
this.uncles = uncles;
|
||||
}
|
||||
|
||||
public Wei getBaseFeePerGas() {
|
||||
return baseFeePerGas;
|
||||
}
|
||||
|
||||
public void setBaseFeePerGas(Wei baseFeePerGas) {
|
||||
this.baseFeePerGas = baseFeePerGas;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this instance is empty or contains only references, then return as is. Otherwise
|
||||
* returns a copy of the BlockJson with transactions fields replaced with id references
|
||||
*
|
||||
* @return BlockJson instance with transactions ids only.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public BlockJson<TransactionRefJson> withoutTransactionDetails() {
|
||||
// if empty then type doesn't matter
|
||||
if (this.transactions == null || this.transactions.isEmpty()) {
|
||||
return (BlockJson<TransactionRefJson>) this;
|
||||
}
|
||||
// if it's already just a reference
|
||||
if (this.transactions.stream().noneMatch((tx) -> tx instanceof TransactionJson)) {
|
||||
return (BlockJson<TransactionRefJson>) this;
|
||||
}
|
||||
BlockJson<TransactionRefJson> copy = (BlockJson<TransactionRefJson>) copy();
|
||||
copy.transactions = new ArrayList<>(this.transactions.size());
|
||||
for (T tx: this.transactions) {
|
||||
copy.transactions.add(new TransactionRefJson(tx.getHash()));
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return copy of the current instance
|
||||
*/
|
||||
public BlockJson<T> copy() {
|
||||
BlockJson<T> copy = new BlockJson<>();
|
||||
copy.number = this.number;
|
||||
copy.hash = this.hash;
|
||||
copy.parentHash = this.parentHash;
|
||||
copy.sha3Uncles = this.sha3Uncles;
|
||||
copy.logsBloom = this.logsBloom;
|
||||
copy.transactionsRoot = this.transactionsRoot;
|
||||
copy.stateRoot = this.stateRoot;
|
||||
copy.receiptsRoot = this.receiptsRoot;
|
||||
copy.miner = this.miner;
|
||||
copy.difficulty = this.difficulty;
|
||||
copy.totalDifficulty = this.totalDifficulty;
|
||||
copy.extraData = this.extraData;
|
||||
copy.size = this.size;
|
||||
copy.gasLimit = this.gasLimit;
|
||||
copy.gasUsed = this.gasUsed;
|
||||
copy.timestamp = this.timestamp;
|
||||
copy.transactions = this.transactions;
|
||||
copy.uncles = this.uncles;
|
||||
copy.baseFeePerGas = this.baseFeePerGas;
|
||||
copy.withdrawalsRoot = this.withdrawalsRoot;
|
||||
copy.mixHash = this.mixHash;
|
||||
copy.nonce = this.nonce;
|
||||
return copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
BlockJson<?> blockJson = (BlockJson<?>) o;
|
||||
return Objects.equals(number, blockJson.number) && Objects.equals(hash, blockJson.hash) && Objects.equals(parentHash, blockJson.parentHash) && Objects.equals(sha3Uncles, blockJson.sha3Uncles) && Objects.equals(logsBloom, blockJson.logsBloom) && Objects.equals(transactionsRoot, blockJson.transactionsRoot) && Objects.equals(stateRoot, blockJson.stateRoot) && Objects.equals(receiptsRoot, blockJson.receiptsRoot) && Objects.equals(miner, blockJson.miner) && Objects.equals(difficulty, blockJson.difficulty) && Objects.equals(totalDifficulty, blockJson.totalDifficulty) && Objects.equals(extraData, blockJson.extraData) && Objects.equals(size, blockJson.size) && Objects.equals(gasLimit, blockJson.gasLimit) && Objects.equals(gasUsed, blockJson.gasUsed) && Objects.equals(timestamp, blockJson.timestamp) && Objects.equals(transactions, blockJson.transactions) && Objects.equals(uncles, blockJson.uncles) && Objects.equals(baseFeePerGas, blockJson.baseFeePerGas) && Objects.equals(mixHash, blockJson.mixHash) && Objects.equals(nonce, blockJson.nonce) && Objects.equals(withdrawalsRoot, blockJson.withdrawalsRoot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(number, hash, parentHash, sha3Uncles, logsBloom, transactionsRoot, stateRoot, receiptsRoot, miner, difficulty, totalDifficulty, extraData, size, gasLimit, gasUsed, timestamp, transactions, uncles, baseFeePerGas, mixHash, nonce, withdrawalsRoot);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2020 EmeraldPay Inc, All Rights Reserved.
|
||||
* Copyright (c) 2016-2017 Infinitape Inc, All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.json;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.emeraldpay.etherjar.domain.BlockHash;
|
||||
import io.emeraldpay.etherjar.domain.Bloom;
|
||||
import io.emeraldpay.etherjar.domain.TransactionId;
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.etherjar.rpc.json.EtherJsonDeserializer;
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJsonDeserializer;
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockJsonDeserializer extends EtherJsonDeserializer<BlockJson<?>> {
|
||||
|
||||
private TransactionJsonDeserializer transactionJsonDeserializer = new TransactionJsonDeserializer();
|
||||
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
public BlockJson deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
|
||||
JsonNode node = jp.readValueAsTree();
|
||||
return deserialize(node);
|
||||
}
|
||||
|
||||
public BlockJson<? extends TransactionRefJson> deserialize(JsonNode node) {
|
||||
BlockJson<TransactionRefJson> blockJson = new BlockJson<>();
|
||||
Long number = getLong(node, "number");
|
||||
if (number != null) {
|
||||
blockJson.setNumber(number);
|
||||
}
|
||||
blockJson.setHash(getBlockHash(node, "hash"));
|
||||
Long timestamp = getLong(node, "timestamp");
|
||||
if (timestamp != null) {
|
||||
blockJson.setTimestamp(Instant.ofEpochSecond(timestamp));
|
||||
} else {
|
||||
System.err.println("Null timestamp for block " + number);
|
||||
}
|
||||
|
||||
if (node.has("transactions")) {
|
||||
List<TransactionRefJson> txes = new ArrayList<>();
|
||||
for (JsonNode tx: node.get("transactions")) {
|
||||
if (tx.isObject()) {
|
||||
txes.add(transactionJsonDeserializer.deserialize(tx));
|
||||
} else {
|
||||
txes.add(new TransactionRefJson(TransactionId.from(tx.textValue())));
|
||||
}
|
||||
}
|
||||
blockJson.setTransactions(txes);
|
||||
}
|
||||
|
||||
blockJson.setParentHash(getBlockHash(node, "parentHash"));
|
||||
blockJson.setSha3Uncles(getData(node, "sha3Uncles"));
|
||||
blockJson.setMiner(getAddress(node, "miner"));
|
||||
blockJson.setDifficulty(getQuantity(node, "difficulty"));
|
||||
blockJson.setTotalDifficulty(getQuantity(node, "totalDifficulty"));
|
||||
Long size = getLong(node, "size");
|
||||
if (size != null) {
|
||||
blockJson.setSize(size);
|
||||
}
|
||||
blockJson.setGasLimit(getLong(node, "gasLimit"));
|
||||
blockJson.setGasUsed(getLong(node, "gasUsed"));
|
||||
blockJson.setExtraData(getData(node, "extraData"));
|
||||
HexData logsBloom = getData(node, "logsBloom");
|
||||
if (logsBloom != null) {
|
||||
blockJson.setLogsBloom(Bloom.from(logsBloom));
|
||||
}
|
||||
|
||||
List<BlockHash> uncles = new ArrayList<>();
|
||||
JsonNode unclesNode = node.get("uncles");
|
||||
if (unclesNode != null && unclesNode.isArray()) {
|
||||
for (JsonNode tx: unclesNode) {
|
||||
uncles.add(BlockHash.from(tx.textValue()));
|
||||
}
|
||||
}
|
||||
blockJson.setUncles(uncles);
|
||||
|
||||
blockJson.setBaseFeePerGas(getWei(node, "baseFeePerGas"));
|
||||
|
||||
blockJson.setReceiptsRoot(getData(node, "receiptsRoot"));
|
||||
blockJson.setStateRoot(getData(node, "stateRoot"));
|
||||
blockJson.setTransactionsRoot(getData(node, "transactionsRoot"));
|
||||
blockJson.setNonce(getData(node, "nonce"));
|
||||
blockJson.setMixHash(getData(node, "mixHash"));
|
||||
blockJson.setWithdrawalsRoot(getData(node, "withdrawalsRoot"));
|
||||
|
||||
return blockJson;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2019 Igor Artamonov, All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.json;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import io.emeraldpay.etherjar.domain.BlockHash;
|
||||
import io.emeraldpay.etherjar.domain.Wei;
|
||||
import io.emeraldpay.etherjar.rpc.json.EtherJsonSerializer;
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson;
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJsonSerializer;
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class BlockJsonSerializer extends EtherJsonSerializer<BlockJson<?>> {
|
||||
|
||||
private TransactionJsonSerializer transactionJsonSerializer = new TransactionJsonSerializer();
|
||||
|
||||
@Override
|
||||
public void serialize(BlockJson<?> value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
gen.writeStartObject();
|
||||
writeField(gen, "number", value.getNumber());
|
||||
writeField(gen, "hash", value.getHash());
|
||||
writeField(gen, "timestamp", value.getTimestamp());
|
||||
|
||||
Wei baseFeePerGas = value.getBaseFeePerGas();
|
||||
if (baseFeePerGas != null) {
|
||||
writeField(gen, "baseFeePerGas", baseFeePerGas);
|
||||
}
|
||||
|
||||
gen.writeFieldName("transactions");
|
||||
gen.writeStartArray();
|
||||
if (value.getTransactions() != null) {
|
||||
for (Object tx: value.getTransactions()) {
|
||||
if (tx == null) {
|
||||
gen.writeNull();
|
||||
} else if (tx instanceof TransactionJson) {
|
||||
transactionJsonSerializer.serialize((TransactionJson) tx, gen, serializers);
|
||||
} else if (tx instanceof TransactionRefJson) {
|
||||
gen.writeString(((TransactionRefJson) tx).getHash().toHex());
|
||||
}
|
||||
}
|
||||
}
|
||||
gen.writeEndArray();
|
||||
|
||||
writeField(gen, "parentHash", value.getParentHash());
|
||||
writeField(gen, "sha3Uncles", value.getSha3Uncles());
|
||||
writeField(gen, "miner", value.getMiner());
|
||||
writeField(gen, "difficulty", value.getDifficulty());
|
||||
writeField(gen, "totalDifficulty", value.getTotalDifficulty());
|
||||
if (value.getSize() != null) {
|
||||
writeFieldNumber(gen, "size", value.getSize().intValue());
|
||||
}
|
||||
writeField(gen, "gasLimit", value.getGasLimit());
|
||||
writeField(gen, "gasUsed", value.getGasUsed());
|
||||
writeField(gen, "extraData", value.getExtraData());
|
||||
writeField(gen, "stateRoot", value.getStateRoot());
|
||||
writeField(gen, "receiptsRoot", value.getReceiptsRoot());
|
||||
writeField(gen, "transactionsRoot", value.getTransactionsRoot());
|
||||
writeField(gen, "logsBloom", value.getLogsBloom());
|
||||
writeField(gen, "mixHash", value.getMixHash());
|
||||
writeField(gen, "nonce", value.getNonce());
|
||||
writeField(gen, "withdrawalsRoot", value.getWithdrawalsRoot());
|
||||
|
||||
gen.writeFieldName("uncles");
|
||||
gen.writeStartArray();
|
||||
if (value.getUncles() != null) {
|
||||
for (BlockHash uncle: value.getUncles()) {
|
||||
gen.writeString(uncle.toHex());
|
||||
}
|
||||
}
|
||||
gen.writeEndArray();
|
||||
|
||||
gen.writeEndObject();
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import io.emeraldpay.dshackle.data.TxId
|
||||
import io.emeraldpay.dshackle.reader.CompoundReader
|
||||
import io.emeraldpay.dshackle.reader.Reader
|
||||
import io.emeraldpay.dshackle.upstream.Head
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionReceiptJson
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
package io.emeraldpay.dshackle.data
|
||||
|
||||
import io.emeraldpay.dshackle.Global
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.domain.Address
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.domain.Bloom
|
||||
import io.emeraldpay.etherjar.domain.Wei
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import java.math.BigInteger
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package io.emeraldpay.dshackle.data
|
||||
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import org.bouncycastle.util.encoders.Hex
|
||||
|
||||
class BlockId(
|
||||
|
||||
@@ -25,10 +25,10 @@ import io.emeraldpay.dshackle.data.BlockContainer
|
||||
import io.emeraldpay.dshackle.data.TxId
|
||||
import io.emeraldpay.dshackle.upstream.MultistreamHolder
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
@@ -10,7 +10,7 @@ import io.emeraldpay.dshackle.upstream.ethereum.RLP.Companion.encodeBigInt
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.RLP.Companion.encodeList
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.RLP.Companion.fromHexString
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.RLP.Companion.fromHexStringI
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import org.bouncycastle.jcajce.provider.digest.Keccak
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.math.BigDecimal
|
||||
|
||||
@@ -39,11 +39,11 @@ import io.emeraldpay.dshackle.reader.TransformingReader
|
||||
import io.emeraldpay.dshackle.upstream.Lifecycle
|
||||
import io.emeraldpay.dshackle.upstream.Multistream
|
||||
import io.emeraldpay.dshackle.upstream.calls.CallMethods
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.domain.Address
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.domain.Wei
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import org.apache.commons.collections4.Factory
|
||||
|
||||
@@ -15,6 +15,7 @@ import io.emeraldpay.dshackle.reader.Reader
|
||||
import io.emeraldpay.dshackle.upstream.Multistream
|
||||
import io.emeraldpay.dshackle.upstream.Selector
|
||||
import io.emeraldpay.dshackle.upstream.calls.CallMethods
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.etherjar.domain.Address
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
@@ -23,7 +24,6 @@ import io.emeraldpay.etherjar.domain.Wei
|
||||
import io.emeraldpay.etherjar.hex.HexQuantity
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionReceiptJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
|
||||
@@ -18,8 +18,8 @@ package io.emeraldpay.dshackle.upstream.ethereum
|
||||
import io.emeraldpay.dshackle.upstream.AbstractChainFees
|
||||
import io.emeraldpay.dshackle.upstream.ChainFees
|
||||
import io.emeraldpay.dshackle.upstream.Multistream
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.domain.Wei
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
package io.emeraldpay.dshackle.upstream.ethereum
|
||||
|
||||
import io.emeraldpay.api.proto.BlockchainOuterClass
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.domain.Wei
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
@@ -17,8 +17,8 @@ package io.emeraldpay.dshackle.upstream.ethereum
|
||||
|
||||
import io.emeraldpay.api.proto.BlockchainOuterClass
|
||||
import io.emeraldpay.dshackle.upstream.Multistream
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.domain.Wei
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
@@ -23,10 +23,10 @@ import io.emeraldpay.dshackle.data.BlockContainer
|
||||
import io.emeraldpay.dshackle.reader.JsonRpcReader
|
||||
import io.emeraldpay.dshackle.upstream.BlockValidator
|
||||
import io.emeraldpay.dshackle.upstream.Lifecycle
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import reactor.core.Disposable
|
||||
import reactor.core.publisher.Flux
|
||||
|
||||
@@ -43,6 +43,14 @@ class ProduceNewHeads(
|
||||
block.logsBloom,
|
||||
block.miner,
|
||||
block.baseFeePerGas?.amount,
|
||||
block.extraData,
|
||||
block.mixHash,
|
||||
block.nonce,
|
||||
block.receiptsRoot,
|
||||
block.sha3Uncles,
|
||||
block.stateRoot,
|
||||
block.transactionsRoot,
|
||||
block.withdrawalsRoot,
|
||||
it.upstreamId
|
||||
)
|
||||
}
|
||||
|
||||
@@ -21,14 +21,15 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize
|
||||
import io.emeraldpay.etherjar.domain.Address
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.domain.Bloom
|
||||
import io.emeraldpay.etherjar.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.hex.HexData
|
||||
import io.emeraldpay.etherjar.rpc.json.HexDataSerializer
|
||||
import java.math.BigInteger
|
||||
import java.time.Instant
|
||||
|
||||
/**
|
||||
* Common fields for newHeads event. IT's different from Block JSON and doesn't include many fields, most notable is
|
||||
* list of transactions. Also, our JSON doesn't include rarely used fields such as extraData, sha3uncles, stateRoot,
|
||||
* transactionRoot and some others.
|
||||
* list of transactions.
|
||||
*/
|
||||
data class NewHeadMessage(
|
||||
@get:JsonSerialize(using = NumberAsHexSerializer::class)
|
||||
@@ -52,6 +53,30 @@ data class NewHeadMessage(
|
||||
@get:JsonSerialize(using = NumberAsHexSerializer::class)
|
||||
@get:JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
val baseFeePerGas: BigInteger?,
|
||||
|
||||
@get:JsonSerialize(using = HexDataSerializer::class)
|
||||
val extraData: HexData,
|
||||
@get:JsonSerialize(using = HexDataSerializer::class)
|
||||
val mixHash: HexData?,
|
||||
@get:JsonSerialize(using = HexDataSerializer::class)
|
||||
val nonce: HexData,
|
||||
@get:JsonSerialize(using = HexDataSerializer::class)
|
||||
val receiptsRoot: HexData,
|
||||
@get:JsonSerialize(using = HexDataSerializer::class)
|
||||
val sha3Uncles: HexData,
|
||||
@get:JsonSerialize(using = HexDataSerializer::class)
|
||||
val stateRoot: HexData,
|
||||
@get:JsonSerialize(using = HexDataSerializer::class)
|
||||
val transactionsRoot: HexData,
|
||||
@get:JsonSerialize(using = HexDataSerializer::class)
|
||||
@get:JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
val withdrawalsRoot: HexData?,
|
||||
|
||||
@get:JsonIgnore
|
||||
override val upstreamId: String
|
||||
override val upstreamId: String,
|
||||
|
||||
// lists always empty
|
||||
val transactions: List<TransactionId> = emptyList(),
|
||||
val uncles: List<BlockHash> = emptyList(),
|
||||
val sealFields: List<BlockHash> = emptyList(),
|
||||
) : HasUpstream
|
||||
|
||||
@@ -20,7 +20,7 @@ import io.emeraldpay.dshackle.Global
|
||||
import io.emeraldpay.dshackle.data.BlockContainer
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import spock.lang.Specification
|
||||
|
||||
@@ -22,7 +22,7 @@ import io.emeraldpay.dshackle.data.BlockContainer
|
||||
import io.emeraldpay.dshackle.data.BlockId
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import spock.lang.Specification
|
||||
|
||||
@@ -23,7 +23,7 @@ import io.emeraldpay.dshackle.data.BlockId
|
||||
import io.emeraldpay.dshackle.data.TxId
|
||||
import io.emeraldpay.dshackle.test.IntegrationTestingCommons
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import io.lettuce.core.api.StatefulRedisConnection
|
||||
import spock.lang.IgnoreIf
|
||||
|
||||
@@ -26,7 +26,7 @@ import io.emeraldpay.dshackle.upstream.Head
|
||||
import io.emeraldpay.etherjar.domain.Address
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionReceiptJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
|
||||
@@ -17,7 +17,7 @@ package io.emeraldpay.dshackle.cache
|
||||
|
||||
import io.emeraldpay.dshackle.data.BlockContainer
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import spock.lang.Specification
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import io.emeraldpay.dshackle.data.TxContainer
|
||||
import io.emeraldpay.dshackle.data.TxId
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import spock.lang.Specification
|
||||
|
||||
@@ -26,7 +26,7 @@ import io.emeraldpay.dshackle.test.IntegrationTestingCommons
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.domain.Wei
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import io.lettuce.core.api.StatefulRedisConnection
|
||||
|
||||
@@ -28,7 +28,7 @@ import io.emeraldpay.dshackle.test.MultistreamHolderMock
|
||||
import io.emeraldpay.dshackle.test.TestingCommons
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosRpcUpstream
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.test.StepVerifier
|
||||
|
||||
@@ -24,7 +24,7 @@ import io.emeraldpay.dshackle.test.MultistreamHolderMock
|
||||
import io.emeraldpay.dshackle.test.TestingCommons
|
||||
import io.emeraldpay.dshackle.upstream.MultistreamHolder
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import reactor.test.StepVerifier
|
||||
import spock.lang.Specification
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import io.emeraldpay.dshackle.upstream.MultistreamHolder
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import reactor.core.publisher.Flux
|
||||
|
||||
@@ -33,7 +33,7 @@ import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.micrometer.core.instrument.MeterRegistry
|
||||
import io.micrometer.core.instrument.logging.LoggingMeterRegistry
|
||||
import org.apache.commons.lang3.StringUtils
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.emeraldpay.dshackle.upstream
|
||||
|
||||
import io.emeraldpay.dshackle.data.BlockContainer
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import spock.lang.Specification
|
||||
|
||||
import java.time.Instant
|
||||
|
||||
@@ -18,7 +18,7 @@ package io.emeraldpay.dshackle.upstream
|
||||
|
||||
import io.emeraldpay.dshackle.data.BlockContainer
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.publisher.Sinks
|
||||
|
||||
@@ -32,7 +32,7 @@ import io.emeraldpay.dshackle.upstream.grpc.EthereumPosGrpcUpstream
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import reactor.core.publisher.Flux
|
||||
|
||||
@@ -22,7 +22,7 @@ import io.emeraldpay.dshackle.data.BlockContainer
|
||||
import io.emeraldpay.dshackle.upstream.BlockValidator
|
||||
import io.emeraldpay.dshackle.upstream.forkchoice.MostWorkForkChoice
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.scheduler.Schedulers
|
||||
import reactor.test.StepVerifier
|
||||
|
||||
@@ -4,7 +4,7 @@ package io.emeraldpay.dshackle.upstream.ethereum
|
||||
import io.emeraldpay.dshackle.Global
|
||||
import io.emeraldpay.dshackle.data.BlockContainer
|
||||
import io.emeraldpay.dshackle.data.BlockId
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import org.apache.commons.io.FileUtils
|
||||
import spock.lang.Specification
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import io.emeraldpay.etherjar.domain.Address
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.domain.Wei
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionReceiptJson
|
||||
import org.apache.commons.collections4.Factory
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package io.emeraldpay.dshackle.upstream.ethereum
|
||||
|
||||
import io.emeraldpay.etherjar.domain.Wei
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import spock.lang.Specification
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import io.emeraldpay.dshackle.upstream.EmptyHead
|
||||
import io.emeraldpay.dshackle.upstream.Head
|
||||
import io.emeraldpay.dshackle.upstream.calls.DefaultEthereumMethods
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import org.apache.commons.collections4.functors.ConstantFactory
|
||||
import reactor.core.publisher.Mono
|
||||
import spock.lang.Specification
|
||||
|
||||
@@ -20,7 +20,7 @@ import io.emeraldpay.dshackle.upstream.ChainFees
|
||||
import io.emeraldpay.dshackle.upstream.Head
|
||||
import io.emeraldpay.etherjar.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.domain.Wei
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import reactor.core.publisher.Flux
|
||||
|
||||
@@ -22,7 +22,7 @@ import io.emeraldpay.dshackle.upstream.BlockValidator
|
||||
import io.emeraldpay.dshackle.upstream.forkchoice.AlwaysForkChoice
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
@@ -23,7 +23,7 @@ import io.emeraldpay.dshackle.upstream.Selector
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.etherjar.rpc.json.TransactionRefJson
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.scheduler.Schedulers
|
||||
|
||||
@@ -5,6 +5,7 @@ import io.emeraldpay.dshackle.Global
|
||||
import io.emeraldpay.etherjar.domain.Address
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.domain.Bloom
|
||||
import io.emeraldpay.etherjar.hex.HexData
|
||||
import spock.lang.Specification
|
||||
|
||||
import java.time.Instant
|
||||
@@ -24,19 +25,41 @@ class NewHeadMessageSpec extends Specification {
|
||||
Bloom.from("0x012040020880820356a20b8e980a2004c19f1291800501040001180bb029d0002d8c49440e002048ca00d48581000d900a458100c90139056140880582f22a0a8050224c020c233be8c3080c0a016aa4226a2001446c800822080445a2454118139804001202068401841900840c484222420c4b2022046052c0011e81a9e450085883708545810592e40040010411442300080b0130711f602880600a30c90702cb420a0102a644820650908802840810948142541404884300acc69d000840702020224c000020200880c10858418408098a61445b0ab0480234862655a5000434311b91044849c165040411aa0400b00008222642d24313020d9022219120"),
|
||||
Address.from("0x829bd824b016326a401d083b33d092293333a830"),
|
||||
null,
|
||||
"NewHeadMessageSpec"
|
||||
HexData.from("0x0000000000000001"), // extra data
|
||||
HexData.from("0x0000000000000002"), // mixHash
|
||||
HexData.from("0x0000000000000003"), // nonce
|
||||
HexData.from("0x0000000000000004"), // receiptsRoot
|
||||
HexData.from("0x0000000000000005"), // sha3Uncles
|
||||
HexData.from("0x0000000000000006"), // stateRoot
|
||||
HexData.from("0x0000000000000007"), // transactionsRoot
|
||||
HexData.from("0x0000000000000008"), // withdrawalsRoot
|
||||
"NewHeadMessageSpec",
|
||||
[],
|
||||
[],
|
||||
[]
|
||||
)
|
||||
ObjectMapper objectMapper = Global.getObjectMapper()
|
||||
def exp = '{' +
|
||||
def exp = '{'+
|
||||
'"number":"0xc7f3b4",' +
|
||||
'"hash":"0xd3b7ae1a79f5418debae9b8e9318094298c087183be0f7a0151b0e76ba38d6bc",' +
|
||||
'"parentHash":"0xcda7fd1d6ee2d5da7505a0634e27f41d5ae87a344cd75bb64c1dc0863fbe9c0a",' +
|
||||
'"timestamp":"0x6128264d",' +
|
||||
'"difficulty":"0x1de7f7a458cc08",' +
|
||||
'"gasLimit":"0x1ca35ef",' +
|
||||
'"gasUsed":"0x7bb33e",' +
|
||||
'"logsBloom":"0x012040020880820356a20b8e980a2004c19f1291800501040001180bb029d0002d8c49440e002048ca00d48581000d900a458100c90139056140880582f22a0a8050224c020c233be8c3080c0a016aa4226a2001446c800822080445a2454118139804001202068401841900840c484222420c4b2022046052c0011e81a9e450085883708545810592e40040010411442300080b0130711f602880600a30c90702cb420a0102a644820650908802840810948142541404884300acc69d000840702020224c000020200880c10858418408098a61445b0ab0480234862655a5000434311b91044849c165040411aa0400b00008222642d24313020d9022219120",' +
|
||||
'"miner":"0x829bd824b016326a401d083b33d092293333a830"' +
|
||||
'"hash":"0xd3b7ae1a79f5418debae9b8e9318094298c087183be0f7a0151b0e76ba38d6bc",'+
|
||||
'"parentHash":"0xcda7fd1d6ee2d5da7505a0634e27f41d5ae87a344cd75bb64c1dc0863fbe9c0a",'+
|
||||
'"timestamp":"0x6128264d",'+
|
||||
'"difficulty":"0x1de7f7a458cc08",'+
|
||||
'"gasLimit":"0x1ca35ef",'+
|
||||
'"gasUsed":"0x7bb33e",'+
|
||||
'"logsBloom":"0x012040020880820356a20b8e980a2004c19f1291800501040001180bb029d0002d8c49440e002048ca00d48581000d900a458100c90139056140880582f22a0a8050224c020c233be8c3080c0a016aa4226a2001446c800822080445a2454118139804001202068401841900840c484222420c4b2022046052c0011e81a9e450085883708545810592e40040010411442300080b0130711f602880600a30c90702cb420a0102a644820650908802840810948142541404884300acc69d000840702020224c000020200880c10858418408098a61445b0ab0480234862655a5000434311b91044849c165040411aa0400b00008222642d24313020d9022219120",'+
|
||||
'"miner":"0x829bd824b016326a401d083b33d092293333a830",'+
|
||||
'"extraData":"0x0000000000000001",'+
|
||||
'"mixHash":"0x0000000000000002",'+
|
||||
'"nonce":"0x0000000000000003",'+
|
||||
'"receiptsRoot":"0x0000000000000004",'+
|
||||
'"sha3Uncles":"0x0000000000000005",'+
|
||||
'"stateRoot":"0x0000000000000006",'+
|
||||
'"transactionsRoot":"0x0000000000000007",'+
|
||||
'"withdrawalsRoot":"0x0000000000000008",'+
|
||||
'"transactions":[],'+
|
||||
'"uncles":[],'+
|
||||
'"sealFields":[]'+
|
||||
'}'
|
||||
when:
|
||||
def json = objectMapper.writeValueAsString(obj)
|
||||
|
||||
@@ -33,7 +33,7 @@ import io.emeraldpay.dshackle.upstream.UpstreamAvailability
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcGrpcClient
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.RpcMetrics
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
import io.emeraldpay.etherjar.rpc.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.grpc.stub.StreamObserver
|
||||
import io.micrometer.core.instrument.Counter
|
||||
import io.micrometer.core.instrument.Timer
|
||||
|
||||
Reference in New Issue
Block a user