Skip to content

Commit

Permalink
Merge branch 'master' into container-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-terry authored Apr 8, 2021
2 parents ebe8586 + 11060f0 commit 59193e0
Show file tree
Hide file tree
Showing 32 changed files with 310 additions and 167 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

### Additions and Improvements

- Adds `--discovery-dns-url` CLI command [\#2088](https://github.com/hyperledger/besu/pull/2088)

### Bug Fixes

- Fixed issue in discv5 where nonce was incorrectly reused.
- Fixed issue in discv5 where nonce was incorrectly reused. [\#2075](https://github.com/hyperledger/besu/pull/2075)
- Fixed issues in debug_standardTraceBadBlockToFile and debug_standardTraceBlockToFile. [\#2120](https://github.com/hyperledger/besu/pull/2120)

### Early Access Features

Expand All @@ -15,6 +18,10 @@
- [Fast sync when running Besu on cloud providers](KNOWN_ISSUES.md#fast-sync-when-running-besu-on-cloud-providers)
- [Privacy users with private transactions created using v1.3.4 or earlier](KNOWN_ISSUES.md#privacy-users-with-private-transactions-created-using-v134-or-earlier)

## Download Link
https://hyperledger.jfrog.io/artifactory/besu-binaries/besu/21.1.4/besu-21.1.4.zip
58ae55b492680d92aeccfbed477e8b9c25ccc1a97cca71895e27448d754a7d8b

## 21.1.3

### Additions and Improvements
Expand Down
6 changes: 3 additions & 3 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
| Adrian Sutton | ajsutton | ajsutton |
| Antoine Toulme | atoulme | atoulme |
| Byron Gravenorst | bgravenorst | bgravenorst |
| Chris Hare | CjHare | cjhare |
| David Mechler | davemec | davemec |
| Edward Mack | edwardmack | mackcom |
| Ivaylo Kirilov | iikirilov | iikirilov |
| Jason Frame | jframe | jframe |
| Joshua Fernandes | joshuafernandes | joshuafernandes |
| Lucas Saldanha | lucassaldanha | lucassaldanha |
Expand All @@ -26,15 +24,17 @@
| Stefan Pingel | pinges | pinges |
| Trent Mohay | rain-on | trent.mohay |
| Rai Sur | RatanRSur | ratanraisur |
| Rob Dawson | rojotek | RobDawson |
| Danno Ferrin | shemnon | shemnon |
| Usman Saleem | usmansaleem | usmansaleem |

## Emeritus Maintainers

| Name | Github | LFID |
|------------------|------------------|------------------|
| Chris Hare | CjHare | cjhare |
| Edward Evans | EdJoJob | EdJoJob |
| Ivaylo Kirilov | iikirilov | iikirilov |
| Rob Dawson | rojotek | RobDawson |
| Tim Beiko | timbeiko | timbeiko |

## Becoming a Maintainer
Expand Down
10 changes: 10 additions & 0 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,12 @@ void setBannedNodeIds(final List<String> values) {
"Specifies the static node file containing the static nodes for this node to connect to")
private final Path staticNodesFile = null;

@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings.
@CommandLine.Option(
names = {"--discovery-dns-url"},
description = "Specifies the URL to use for DNS discovery")
private String discoveryDnsUrl = null;

private EthNetworkConfig ethNetworkConfig;
private JsonRpcConfiguration jsonRpcConfiguration;
private GraphQLConfiguration graphQLConfiguration;
Expand Down Expand Up @@ -2404,6 +2410,10 @@ private EthNetworkConfig updateNetworkConfig(final NetworkName network) {
builder.setDnsDiscoveryUrl(null);
}

if (discoveryDnsUrl != null) {
builder.setDnsDiscoveryUrl(discoveryDnsUrl);
}

if (networkId != null) {
builder.setNetworkId(networkId);
}
Expand Down
38 changes: 38 additions & 0 deletions besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,44 @@ public void genesisAndNetworkMustNotBeUsedTogether() throws Exception {
.startsWith("--network option and --genesis-file option can't be used at the same time.");
}

@Test
public void testDnsDiscoveryUrlEthConfig() throws Exception {
final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);

parseCommand(
"--discovery-dns-url",
"enrtree://AM5FCQLWIZX2QFPNJAP7VUERCCRNGRHWZG3YYHIUV7BVDQ5FDPRT2@nodes.example.org");

verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any());
verify(mockControllerBuilder).build();

final EthNetworkConfig config = networkArg.getValue();
assertThat(config.getDnsDiscoveryUrl())
.isEqualTo(
"enrtree://AM5FCQLWIZX2QFPNJAP7VUERCCRNGRHWZG3YYHIUV7BVDQ5FDPRT2@nodes.example.org");
}

@Test
public void testDnsDiscoveryUrlOverridesNetworkEthConfig() throws Exception {
final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);

parseCommand(
"--network",
"dev",
"--discovery-dns-url",
"enrtree://AM5FCQLWIZX2QFPNJAP7VUERCCRNGRHWZG3YYHIUV7BVDQ5FDPRT2@nodes.example.org");

verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any());
verify(mockControllerBuilder).build();

final EthNetworkConfig config = networkArg.getValue();
assertThat(config.getDnsDiscoveryUrl())
.isEqualTo(
"enrtree://AM5FCQLWIZX2QFPNJAP7VUERCCRNGRHWZG3YYHIUV7BVDQ5FDPRT2@nodes.example.org");
}

@Test
public void defaultNetworkIdAndBootnodesForCustomNetworkOptions() throws Exception {
final Path genesisFile = createFakeGenesisFile(GENESIS_VALID_JSON);
Expand Down
1 change: 1 addition & 0 deletions besu/src/test/resources/everything_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ random-peer-priority-enabled=false
host-whitelist=["all"]
host-allowlist=["all"]
required-blocks=["8675309=123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"]
discovery-dns-url="enrtree://AM5FCQLWIZX2QFPNJAP7VUERCCRNGRHWZG3YYHIUV7BVDQ5FDPRT2@nodes.example.org"

# chain
network="MAINNET"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,27 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcErrorConverter;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcRequestException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.util.DomainObjectDecodeUtils;
import org.hyperledger.besu.ethereum.core.Hash;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPException;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;

import java.util.function.Supplier;

import com.google.common.base.Suppliers;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.tuweni.bytes.Bytes;

public class EthSendRawTransaction implements JsonRpcMethod {
private static final Logger LOG = LogManager.getLogger();

private final boolean sendEmptyHashOnInvalidBlock;

Expand Down Expand Up @@ -64,12 +68,14 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {

final Transaction transaction;
try {
transaction = DomainObjectDecodeUtils.decodeRawTransaction(rawTransaction);
} catch (final InvalidJsonRpcRequestException e) {
transaction = Transaction.readFrom(RLP.input(Bytes.fromHexString(rawTransaction)));
} catch (final RLPException | IllegalArgumentException e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
}

LOG.trace("Received local transaction {}", transaction);

final ValidationResult<TransactionInvalidReason> validationResult =
transactionPool.get().addLocalTransaction(transaction);
return validationResult.either(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.AbstractWorldUpdater;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Hash;
import org.hyperledger.besu.ethereum.core.Transaction;
Expand Down Expand Up @@ -97,9 +98,10 @@ public List<String> traceTransactionToFile(
.performActionWithBlock(
blockHash,
(body, header, blockchain, worldState, transactionProcessor) -> {
final WorldUpdater worldUpdater = worldState.updater();
WorldUpdater stackedUpdater = worldState.updater().updater();
final List<String> traces = new ArrayList<>();
for (int i = 0; i < body.getTransactions().size(); i++) {
((AbstractWorldUpdater.StackedUpdater) stackedUpdater).markTransactionBoundary();
final Transaction transaction = body.getTransactions().get(i);
if (selectedHash.isEmpty()
|| selectedHash.filter(isEqual(transaction.getHash())).isPresent()) {
Expand All @@ -110,7 +112,7 @@ public List<String> traceTransactionToFile(
processTransaction(
header,
blockchain,
worldUpdater,
stackedUpdater,
transaction,
transactionProcessor,
new StandardJsonTracer(out, showMemory));
Expand All @@ -126,7 +128,7 @@ public List<String> traceTransactionToFile(
processTransaction(
header,
blockchain,
worldUpdater,
stackedUpdater,
transaction,
transactionProcessor,
OperationTracer.NO_TRACING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.ImmutableTransactionTraceParams;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.AbstractWorldUpdater;
import org.hyperledger.besu.ethereum.core.Address;
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
Expand Down Expand Up @@ -226,6 +227,8 @@ public void traceTransactionToFileShouldReturnEmptyListWhenNoTransaction() {
when(blockBody.getTransactions()).thenReturn(transactions);
when(blockchain.getBlockBody(blockHash)).thenReturn(Optional.of(blockBody));

final WorldUpdater updater = mock(WorldUpdater.class);
when(mutableWorldState.updater()).thenReturn(updater);
final List<String> transactionTraces =
transactionTracer.traceTransactionToFile(
blockHash,
Expand All @@ -251,11 +254,14 @@ public void traceTransactionToFileShouldReturnResultFromProcessTransaction() thr
when(blockBody.getTransactions()).thenReturn(Collections.singletonList(transaction));
when(blockchain.getBlockBody(blockHash)).thenReturn(Optional.of(blockBody));

final WorldUpdater updater = mutableWorldState.updater();
final WorldUpdater updater = mock(WorldUpdater.class);
when(mutableWorldState.updater()).thenReturn(updater);
final WorldUpdater stackedUpdater = mock(AbstractWorldUpdater.StackedUpdater.class);
when(updater.updater()).thenReturn(stackedUpdater);
final Address coinbase = blockHeader.getCoinbase();
when(transactionProcessor.processTransaction(
eq(blockchain),
eq(updater),
eq(stackedUpdater),
eq(blockHeader),
eq(transaction),
eq(coinbase),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"jsonrpc": "2.0",
"method": "eth_sendRawTransaction",
"params": [
"0x0"
"0x0123"
]
},
"response": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,18 @@ public Transaction(
throw new IllegalStateException(
String.format("chainId '%s' and v '%s' cannot both be provided", chainId.get(), v.get()));
}

if (maybeAccessList.isPresent()) {
checkState(
transactionType.supportAccessList(),
"Must not specify access list for transaction not supporting it");
}

if (Objects.equals(transactionType, TransactionType.ACCESS_LIST)) {
checkState(
maybeAccessList.isPresent(), "Must specify access list for access list transaction");
} else {
checkState(
maybeAccessList.isEmpty(),
"Must not specify access list for non-access list transaction");
}

this.transactionType = transactionType;
this.nonce = nonce;
this.gasPrice = gasPrice;
Expand Down Expand Up @@ -526,6 +530,9 @@ public Wei getUpfrontGasCost() {
* @return the up-front cost for the gas the transaction can use.
*/
public Wei getUpfrontGasCost(final Wei gasPrice) {
if (gasPrice == null || gasPrice.isZero()) {
return Wei.ZERO;
}
return Wei.of(getGasLimit()).multiply(gasPrice);
}

Expand Down Expand Up @@ -582,7 +589,7 @@ private static Bytes32 computeSenderRecoveryHash(
case EIP1559:
preimage =
eip1559Preimage(
nonce, gasPrice, gasPremium, feeCap, gasLimit, to, value, payload, chainId);
nonce, gasPremium, feeCap, gasLimit, to, value, payload, chainId, accessList);
break;
case ACCESS_LIST:
preimage =
Expand Down Expand Up @@ -634,32 +641,30 @@ private static Bytes frontierPreimage(

private static Bytes eip1559Preimage(
final long nonce,
final Wei gasPrice,
final Wei gasPremium,
final Wei feeCap,
final long gasLimit,
final Optional<Address> to,
final Wei value,
final Bytes payload,
final Optional<BigInteger> chainId) {
return RLP.encode(
rlpOutput -> {
rlpOutput.startList();
rlpOutput.writeLongScalar(nonce);
rlpOutput.writeUInt256Scalar(gasPrice);
rlpOutput.writeLongScalar(gasLimit);
rlpOutput.writeBytes(to.map(Bytes::copy).orElse(Bytes.EMPTY));
rlpOutput.writeUInt256Scalar(value);
rlpOutput.writeBytes(payload);
rlpOutput.writeUInt256Scalar(gasPremium);
rlpOutput.writeUInt256Scalar(feeCap);
if (chainId.isPresent()) {
rlpOutput.writeBigIntegerScalar(chainId.get());
rlpOutput.writeUInt256Scalar(UInt256.ZERO);
rlpOutput.writeUInt256Scalar(UInt256.ZERO);
}
rlpOutput.endList();
});
final Optional<BigInteger> chainId,
final Optional<List<AccessListEntry>> accessList) {
final Bytes encoded =
RLP.encode(
rlpOutput -> {
rlpOutput.startList();
rlpOutput.writeBigIntegerScalar(chainId.orElseThrow());
rlpOutput.writeLongScalar(nonce);
rlpOutput.writeUInt256Scalar(gasPremium);
rlpOutput.writeUInt256Scalar(feeCap);
rlpOutput.writeLongScalar(gasLimit);
rlpOutput.writeBytes(to.map(Bytes::copy).orElse(Bytes.EMPTY));
rlpOutput.writeUInt256Scalar(value);
rlpOutput.writeBytes(payload);
TransactionEncoder.writeAccessList(rlpOutput, accessList);
rlpOutput.endList();
});
return Bytes.concatenate(Bytes.of(TransactionType.EIP1559.getSerializedType()), encoded);
}

private static Bytes accessListPreimage(
Expand Down Expand Up @@ -839,10 +844,10 @@ public Builder signature(final SECPSignature signature) {
}

public Builder guessType() {
if (accessList.isPresent()) {
transactionType = TransactionType.ACCESS_LIST;
} else if (gasPremium != null || feeCap != null) {
if (gasPremium != null || feeCap != null) {
transactionType = TransactionType.EIP1559;
} else if (accessList.isPresent()) {
transactionType = TransactionType.ACCESS_LIST;
} else {
transactionType = TransactionType.FRONTIER;
}
Expand Down
Loading

0 comments on commit 59193e0

Please sign in to comment.