Skip to content

Commit

Permalink
Merge branch 'main' into 7582-avoid-unnecessary-rlp-encoding-during-sync
Browse files Browse the repository at this point in the history
Signed-off-by: Matilda-Clerke <[email protected]>
  • Loading branch information
Matilda-Clerke authored Dec 11, 2024
2 parents 585ed8b + c8ad1d1 commit 007bc3c
Show file tree
Hide file tree
Showing 16 changed files with 346 additions and 224 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

### Breaking Changes
- `--host-whitelist` has been deprecated since 2020 and its related option will be removed in a future release.

### Upcoming Breaking Changes
- Plugin API will be deprecating the BesuContext interface to be replaced with the ServiceManager interface.
Expand All @@ -15,6 +16,8 @@
- Proof of Work consensus
- Fast Sync



### Additions and Improvements
- Retrieve all transaction receipts for a block in one request [#6646](https://github.com/hyperledger/besu/pull/6646)

Expand Down
4 changes: 2 additions & 2 deletions benchmark/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ services:
- --rpc-ws-enabled
- --rpc-ws-apis=admin,eth,miner,web3,net,priv,eea
- --rpc-ws-host=0.0.0.0
- --host-whitelist=*
- --host-allowlist=*
- --graphql-http-enabled
- --discovery-enabled=false
- --privacy-enabled=true
Expand All @@ -84,7 +84,7 @@ services:
- --rpc-ws-enabled
- --rpc-ws-apis=admin,eth,miner,web3,net,priv,eea
- --rpc-ws-host=0.0.0.0
- --host-whitelist=*
- --host-allowlist=*
- --graphql-http-enabled
- --discovery-enabled=false
- --privacy-enabled=true
Expand Down
17 changes: 0 additions & 17 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -610,14 +610,6 @@ static class PrivacyOptionGroup {
defaultValue = "localhost,127.0.0.1")
private final JsonRPCAllowlistHostsProperty hostsAllowlist = new JsonRPCAllowlistHostsProperty();

@Option(
names = {"--host-whitelist"},
hidden = true,
paramLabel = "<hostname>[,<hostname>...]... or * or all",
description =
"Deprecated in favor of --host-allowlist. Comma separated list of hostnames to allow for RPC access, or * to accept any host (default: ${DEFAULT-VALUE})")
private final JsonRPCAllowlistHostsProperty hostsWhitelist = new JsonRPCAllowlistHostsProperty();

@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"})
@Option(
names = {"--color-enabled"},
Expand Down Expand Up @@ -1701,15 +1693,6 @@ private void configure() throws Exception {
unstableIpcOptions.getRpcIpcApis());
inProcessRpcConfiguration = inProcessRpcOptions.toDomainObject();
dataStorageConfiguration = getDataStorageConfiguration();
// hostsWhitelist is a hidden option. If it is specified, add the list to hostAllowlist
if (!hostsWhitelist.isEmpty()) {
// if allowlist == default values, remove the default values
if (hostsAllowlist.size() == 2
&& hostsAllowlist.containsAll(List.of("localhost", "127.0.0.1"))) {
hostsAllowlist.removeAll(List.of("localhost", "127.0.0.1"));
}
hostsAllowlist.addAll(hostsWhitelist);
}

permissioningConfiguration = permissioningConfiguration();
staticNodes = loadStaticNodes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,6 @@

public class HostAllowlistOptionsTest extends CommandTestAbstract {

/** test deprecated CLI option * */
@Deprecated
@Test
public void rpcHttpHostWhitelistAcceptsSingleArgument() {
parseCommand("--host-whitelist", "a");

verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
verify(mockRunnerBuilder).build();

assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist().size()).isEqualTo(1);
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist()).contains("a");
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist())
.doesNotContain("localhost");

assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}

@Test
public void rpcHttpHostAllowlistAcceptsSingleArgument() {
parseCommand("--host-allowlist", "a");
Expand Down Expand Up @@ -89,23 +71,6 @@ public void rpcHttpHostAllowlistAcceptsDoubleComma() {
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}

@Deprecated
@Test
public void rpcHttpHostWhitelistAllowlistAcceptsMultipleFlags() {
parseCommand("--host-whitelist=a", "--host-allowlist=b");

verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
verify(mockRunnerBuilder).build();

assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist().size()).isEqualTo(2);
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist()).contains("a", "b");
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist())
.doesNotContain("*", "localhost");

assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}

@Test
public void rpcHttpHostAllowlistAcceptsMultipleFlags() {
parseCommand("--host-allowlist=a", "--host-allowlist=b");
Expand Down
1 change: 0 additions & 1 deletion besu/src/test/resources/everything_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ max-peers=42
remote-connections-limit-enabled=true
remote-connections-max-percentage=60
random-peer-priority-enabled=false
host-whitelist=["all"]
host-allowlist=["all"]
engine-host-allowlist=["all"]
engine-rpc-enabled=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.hyperledger.besu.ethereum.rlp.RLPException;
import org.hyperledger.besu.ethereum.rlp.RLPInput;

import java.util.Arrays;
import java.util.concurrent.ExecutionException;

import com.fasterxml.jackson.annotation.JsonCreator;
Expand Down Expand Up @@ -291,4 +292,16 @@ public Hash addressHash() {
return Hash.hash(this);
}
}

@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Address)) {
return false;
}
Address other = (Address) obj;
return Arrays.equals(this.toArrayUnsafe(), other.toArrayUnsafe());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,10 @@ public Transaction detachedCopy() {
blobsWithCommitments.map(
withCommitments ->
blobsWithCommitmentsDetachedCopy(withCommitments, detachedVersionedHashes.get()));
final Optional<List<CodeDelegation>> detachedCodeDelegationList =
maybeCodeDelegationList.map(
codeDelegations ->
codeDelegations.stream().map(this::codeDelegationDetachedCopy).toList());

final var copiedTx =
new Transaction(
Expand All @@ -1124,7 +1128,7 @@ public Transaction detachedCopy() {
chainId,
detachedVersionedHashes,
detachedBlobsWithCommitments,
maybeCodeDelegationList,
detachedCodeDelegationList,
Optional.empty());

// copy also the computed fields, to avoid to recompute them
Expand All @@ -1142,6 +1146,15 @@ private AccessListEntry accessListDetachedCopy(final AccessListEntry accessListE
return new AccessListEntry(detachedAddress, detachedStorage);
}

private CodeDelegation codeDelegationDetachedCopy(final CodeDelegation codeDelegation) {
final Address detachedAddress = Address.wrap(codeDelegation.address().copy());
return new org.hyperledger.besu.ethereum.core.CodeDelegation(
codeDelegation.chainId(),
detachedAddress,
codeDelegation.nonce(),
codeDelegation.signature());
}

private BlobsWithCommitments blobsWithCommitmentsDetachedCopy(
final BlobsWithCommitments blobsWithCommitments, final List<VersionedHash> versionedHashes) {
final var detachedCommitments =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class RequestContractAddresses {
private final Address consolidationRequestContractAddress;

public static final Address DEFAULT_WITHDRAWAL_REQUEST_CONTRACT_ADDRESS =
Address.fromHexString("0x09FC772D0857550724B07B850A4323F39112AAAA");
Address.fromHexString("0x0c15F14308530b7CDB8460094BbB9cC28b9AaaAA");
public static final Address DEFAULT_CONSOLIDATION_REQUEST_CONTRACT_ADDRESS =
Address.fromHexString("0x01ABEA29659E5E97C95107F20BB753CD3E09BBBB");
public static final Address DEFAULT_DEPOSIT_CONTRACT_ADDRESS =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.hyperledger.besu.ethereum.core;

import org.hyperledger.besu.crypto.KeyPair;
import org.hyperledger.besu.crypto.SECPSignature;
import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.BlobsWithCommitments;
Expand All @@ -29,7 +30,8 @@
import org.apache.tuweni.bytes.Bytes;

public class TransactionTestFixture {

private final SECPSignature signature =
new SECPSignature(BigInteger.ONE, BigInteger.ONE, (byte) 0);
private TransactionType transactionType = TransactionType.FRONTIER;

private long nonce = 0;
Expand All @@ -56,6 +58,8 @@ public class TransactionTestFixture {

private Optional<BlobsWithCommitments> blobs = Optional.empty();
private Optional<BigInteger> v = Optional.empty();
private Optional<List<org.hyperledger.besu.datatypes.CodeDelegation>> codeDelegations =
Optional.empty();

public Transaction createTransaction(final KeyPair keys) {
final Transaction.Builder builder = Transaction.builder();
Expand Down Expand Up @@ -93,6 +97,12 @@ public Transaction createTransaction(final KeyPair keys) {
}
break;
case DELEGATE_CODE:
builder.maxPriorityFeePerGas(maxPriorityFeePerGas.orElse(Wei.of(500)));
builder.maxFeePerGas(maxFeePerGas.orElse(Wei.of(5000)));
builder.accessList(accessListEntries.orElse(List.of()));
builder.codeDelegations(
codeDelegations.orElse(
List.of(new CodeDelegation(chainId.get(), sender, 0, signature))));
break;
}

Expand Down Expand Up @@ -183,4 +193,10 @@ public TransactionTestFixture blobsWithCommitments(final Optional<BlobsWithCommi
this.blobs = blobs;
return this;
}

public TransactionTestFixture codeDelegations(
final List<org.hyperledger.besu.datatypes.CodeDelegation> codeDelegations) {
this.codeDelegations = Optional.of(codeDelegations);
return this;
}
}
Loading

0 comments on commit 007bc3c

Please sign in to comment.