Skip to content

Commit

Permalink
Merge branch 'zkbesu' into clique-simulate-block-production
Browse files Browse the repository at this point in the history
  • Loading branch information
fab-10 committed Sep 11, 2024
2 parents 4d4176c + 7b249a6 commit 12716f7
Show file tree
Hide file tree
Showing 42 changed files with 531 additions and 294 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Release

on:
release:
types: [released]

jobs:
build:

runs-on: ubuntu-latest-128

steps:
- name: Pre-process Release Name
id: pre_process_release_name
run: |
RELEASE_NAME="${{ github.event.release.name }}"
# strip all whitespace
RELEASE_NAME="${RELEASE_NAME//[[:space:]]/}"
if [[ ! "$RELEASE_NAME" =~ ^[0-9]+\.[0-9]+(\.[0-9]+)?(-.*)?$ ]]; then
echo "Release name does not conform to a valid besu release format YY.M.v[-suffix], e.g. 24.8.0-RC1."
exit 1
fi
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV # Store in environment variable
- name: checkout
uses: actions/checkout@v3

- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 21
distribution: temurin

- name: Publish Java artifacts
run: ./gradlew -Prelease.releaseVersion=${{env.RELEASE_NAME}} -Pversion=${{env.RELEASE_NAME}} publish
env:
CLOUDSMITH_USER: ${{ secrets.CLOUDSMITH_USER }}
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}

- name: Publish distribution artifacts
run: |
sudo apt update
sudo apt install -y python3 python3-pip python3-venv
./gradlew -Prelease.releaseVersion=${{env.RELEASE_NAME}} -Pversion=${{env.RELEASE_NAME}} cloudsmithUpload
env:
CLOUDSMITH_USER: ${{ secrets.CLOUDSMITH_USER }}
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}

- name: Set up QEMU for Docker
uses: docker/setup-qemu-action@v3
with:
platforms: arm64

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64

- name: Check Dockerfile syntax
run: |
docker run --rm -i hadolint/hadolint < docker/Dockerfile
- name: Login to Docker Hub for self hosted
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER_RW }}
password: ${{ secrets.DOCKER_PAT_RW }}

- name: Build and Publish Docker Image
run: |
./gradlew -Prelease.releaseVersion=${{env.RELEASE_NAME}} -Pversion=${{env.RELEASE_NAME}} -Pdocker-platform=linux/amd64,linux/arm64 distDocker
19 changes: 4 additions & 15 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,8 @@ jobs:
java-version: 21
distribution: temurin

- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/gradle/versions.gradle') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-gradle-${{ hashFiles('**/gradle/versions.gradle') }}
${{ runner.os }}-gradle-
- name: Spotless
run: ./gradlew clean spotlessCheck
run: ./gradlew spotlessCheck

- name: Test & Build
run: ./gradlew build
Expand Down Expand Up @@ -71,7 +60,7 @@ jobs:
distribution: temurin

- name: Publish Java artifacts
run: ./gradlew publish -x checkLicense
run: ./gradlew publish
env:
CLOUDSMITH_USER: ${{ secrets.CLOUDSMITH_USER }}
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
Expand All @@ -80,7 +69,7 @@ jobs:
run: |
sudo apt update
sudo apt install -y python3 python3-pip python3-venv
./gradlew cloudsmithUpload -x checkLicense
./gradlew cloudsmithUpload
env:
CLOUDSMITH_USER: ${{ secrets.CLOUDSMITH_USER }}
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
Expand All @@ -107,4 +96,4 @@ jobs:

- name: Build and Publish Docker Image
run: |
./gradlew -Pdocker-platform=linux/amd64,linux/arm64 distDocker -x checkLicense
./gradlew -Pdocker-platform=linux/amd64,linux/arm64 distDocker
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
- Correctly drops messages that exceeds local message size limit [#5455](https://github.com/hyperledger/besu/pull/7507)
- **DebugMetrics**: Fixed a `ClassCastException` occurring in `DebugMetrics` when handling nested metric structures. Previously, `Double` values within these structures were incorrectly cast to `Map` objects, leading to errors. This update allows for proper handling of both direct values and nested structures at the same level. Issue# [#7383](https://github.com/hyperledger/besu/pull/7383)
- `evmtool` was not respecting the `--genesis` setting, resulting in unexpected trace results. [#7433](https://github.com/hyperledger/besu/pull/7433)
- The genesis config override `contractSizeLimit`q was not wired into code size limits [#7557](https://github.com/hyperledger/besu/pull/7557)
- The genesis config override `contractSizeLimit` was not wired into code size limits [#7557](https://github.com/hyperledger/besu/pull/7557)
- Fix incorrect key filtering in LayeredKeyValueStorage stream [#7535](https://github.com/hyperledger/besu/pull/7557)

## 24.8.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,29 +175,61 @@ public void shouldCheckNonceAfterNonceIncreaseOfSender() throws IOException {
besuNode.execute(ethTransactions.sendRawTransaction(tx.encoded().toHexString()));
testHelper.buildNewBlock();

Optional<TransactionReceipt> maybeTransactionReceipt =
final Optional<TransactionReceipt> maybeFirstTransactionReceipt =
besuNode.execute(ethTransactions.getTransactionReceipt(txHash));
assertThat(maybeTransactionReceipt).isPresent();
assertThat(maybeFirstTransactionReceipt).isPresent();

final String gasPriceWithout0x =
maybeTransactionReceipt.get().getEffectiveGasPrice().substring(2);
maybeFirstTransactionReceipt.get().getEffectiveGasPrice().substring(2);
final BigInteger gasPrice = new BigInteger(gasPriceWithout0x, 16);
final BigInteger txCost = maybeTransactionReceipt.get().getGasUsed().multiply(gasPrice);
final BigInteger txCost = maybeFirstTransactionReceipt.get().getGasUsed().multiply(gasPrice);

final BigInteger authorizerBalance = besuNode.execute(ethTransactions.getBalance(authorizer));
final BigInteger authorizerBalanceAfterFirstTx =
besuNode.execute(ethTransactions.getBalance(authorizer));

// The remaining balance of the authorizer should the gas limit multiplied by the gas price
// minus the transaction cost.
// The following executes this calculation in reverse.
assertThat(GAS_LIMIT).isEqualTo(authorizerBalance.add(txCost).divide(gasPrice).longValue());
assertThat(GAS_LIMIT)
.isEqualTo(authorizerBalanceAfterFirstTx.add(txCost).divide(gasPrice).longValue());

// The other accounts balance should be the initial 9000 ETH balance from the authorizer minus
// the remaining balance of the authorizer and minus the transaction cost
cluster.verify(
otherAccount.balanceEquals(
Amount.wei(
new BigInteger("90000000000000000000000")
.subtract(authorizerBalance)
.subtract(txCost))));
final BigInteger otherAccountBalanceAfterFirstTx =
new BigInteger("90000000000000000000000")
.subtract(authorizerBalanceAfterFirstTx)
.subtract(txCost);

cluster.verify(otherAccount.balanceEquals(Amount.wei(otherAccountBalanceAfterFirstTx)));

final Transaction txSendEthToOtherAccount =
Transaction.builder()
.type(TransactionType.EIP1559)
.chainId(BigInteger.valueOf(20211))
.nonce(2)
.maxPriorityFeePerGas(Wei.of(10))
.maxFeePerGas(Wei.of(100))
.gasLimit(21000)
.to(Address.fromHexStringStrict(otherAccount.getAddress()))
.value(Wei.ONE)
.payload(Bytes.EMPTY)
.signAndBuild(
secp256k1.createKeyPair(
secp256k1.createPrivateKey(AUTHORIZER_PRIVATE_KEY.toUnsignedBigInteger())));

final String txSendEthToOtherAccountHash =
besuNode.execute(
ethTransactions.sendRawTransaction(txSendEthToOtherAccount.encoded().toHexString()));
testHelper.buildNewBlock();

final Optional<TransactionReceipt> maybeSecondTransactionReceipt =
besuNode.execute(ethTransactions.getTransactionReceipt(txSendEthToOtherAccountHash));
assertThat(maybeSecondTransactionReceipt).isPresent();

// the balance of the other account should be the previous balance plus the value of the 1 Wei
final BigInteger otherAccountBalanceAfterSecondTx =
besuNode.execute(ethTransactions.getBalance(otherAccount));
assertThat(otherAccountBalanceAfterFirstTx.add(BigInteger.ONE))
.isEqualTo(otherAccountBalanceAfterSecondTx);
}
}
2 changes: 1 addition & 1 deletion besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ public Runner build() {
if (miningParameters.isStratumMiningEnabled()) {
if (!(miningCoordinator instanceof PoWMiningCoordinator powMiningCoordinator)) {
throw new IllegalArgumentException(
"Stratum server requires an PoWMiningCoordinator not "
"Stratum mining requires the network option(--network) to be set to CLASSIC. Stratum server requires a PoWMiningCoordinator not "
+ ((miningCoordinator == null) ? "null" : miningCoordinator.getClass().getName()));
}
stratumServer =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ public class MiningOptions implements CLIOptions<MiningParameters> {

@Option(
names = {"--miner-stratum-enabled"},
description = "Set if node will perform Stratum mining (default: ${DEFAULT-VALUE})")
description =
"Set if node will perform Stratum mining (default: ${DEFAULT-VALUE})."
+ " Compatible with Proof of Work (PoW) only."
+ " Requires the network option (--network) to be set to CLASSIC.")
private Boolean iStratumMiningEnabled = false;

@Option(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.nio.file.Files;
import java.nio.file.Path;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

public class TxPoolOptionsTest extends CommandTestAbstract {
Expand Down Expand Up @@ -98,7 +97,6 @@ public void txpoolSaveFileAbsolutePathOutsideDataPath() throws IOException {
}

@Test
@Disabled // Failing in CI, but not locally
public void txpoolForcePriceBumpToZeroWhenZeroBaseFeeMarket() throws IOException {
final Path genesisFile = createFakeGenesisFile(GENESIS_WITH_ZERO_BASE_FEE_MARKET);
parseCommand("--genesis-file", genesisFile.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public class CliqueBlockCreator extends AbstractBlockCreator {
* @param protocolContext the protocol context
* @param protocolSchedule the protocol schedule
* @param nodeKey the node key
* @param parentHeader the parent header
* @param epochManager the epoch manager
* @param ethScheduler the scheduler for asynchronous block creation tasks
*/
Expand All @@ -65,7 +64,6 @@ public CliqueBlockCreator(
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
final NodeKey nodeKey,
final BlockHeader parentHeader,
final EpochManager epochManager,
final EthScheduler ethScheduler) {
super(
Expand All @@ -75,7 +73,6 @@ public CliqueBlockCreator(
transactionPool,
protocolContext,
protocolSchedule,
parentHeader,
ethScheduler);
this.nodeKey = nodeKey;
this.epochManager = epochManager;
Expand Down Expand Up @@ -112,6 +109,8 @@ protected BlockHeader createFinalBlockHeader(final SealableBlockHeader sealableB

private Optional<ValidatorVote> determineCliqueVote(
final SealableBlockHeader sealableBlockHeader) {
BlockHeader parentHeader =
protocolContext.getBlockchain().getBlockHeader(sealableBlockHeader.getParentHash()).get();
if (epochManager.isEpochBlock(sealableBlockHeader.getNumber())) {
return Optional.empty();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public CliqueBlockMiner createMiner(
protocolContext,
protocolSchedule,
nodeKey,
header,
epochManager,
ethScheduler);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ public void proposerAddressCanBeExtractFromAConstructedBlock() {
protocolContext,
protocolSchedule,
proposerNodeKey,
blockchain.getChainHeadHeader(),
epochManager,
ethScheduler);

final Block createdBlock = blockCreator.createBlock(5L).getBlock();
final Block createdBlock =
blockCreator.createBlock(5L, blockchain.getChainHeadHeader()).getBlock();

assertThat(CliqueHelpers.getProposerOfBlock(createdBlock.getHeader()))
.isEqualTo(proposerAddress);
Expand All @@ -185,11 +185,11 @@ public void insertsValidVoteIntoConstructedBlock() {
protocolContext,
protocolSchedule,
proposerNodeKey,
blockchain.getChainHeadHeader(),
epochManager,
ethScheduler);

final Block createdBlock = blockCreator.createBlock(0L).getBlock();
final Block createdBlock =
blockCreator.createBlock(0L, blockchain.getChainHeadHeader()).getBlock();
assertThat(createdBlock.getHeader().getNonce()).isEqualTo(CliqueBlockInterface.ADD_NONCE);
assertThat(createdBlock.getHeader().getCoinbase()).isEqualTo(a1);
}
Expand Down Expand Up @@ -219,11 +219,11 @@ public void insertsNoVoteWhenAtEpoch() {
protocolContext,
protocolSchedule,
proposerNodeKey,
blockchain.getChainHeadHeader(),
epochManager,
ethScheduler);

final Block createdBlock = blockCreator.createBlock(0L).getBlock();
final Block createdBlock =
blockCreator.createBlock(0L, blockchain.getChainHeadHeader()).getBlock();
assertThat(createdBlock.getHeader().getNonce()).isEqualTo(CliqueBlockInterface.DROP_NONCE);
assertThat(createdBlock.getHeader().getCoinbase()).isEqualTo(Address.fromHexString("0"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void doesNotMineBlockIfNoTransactionsWhenEmptyBlocksNotAllowed() throws Interrup
final CliqueBlockCreator blockCreator = mock(CliqueBlockCreator.class);
final Function<BlockHeader, CliqueBlockCreator> blockCreatorSupplier =
(parentHeader) -> blockCreator;
when(blockCreator.createBlock(anyLong()))
when(blockCreator.createBlock(anyLong(), any()))
.thenReturn(
new BlockCreator.BlockCreationResult(
blockToCreate, new TransactionSelectionResults(), new BlockCreationTiming()));
Expand Down Expand Up @@ -147,7 +147,7 @@ void minesBlockIfHasTransactionsWhenEmptyBlocksNotAllowed() throws InterruptedEx
final CliqueBlockCreator blockCreator = mock(CliqueBlockCreator.class);
final Function<BlockHeader, CliqueBlockCreator> blockCreatorSupplier =
(parentHeader) -> blockCreator;
when(blockCreator.createBlock(anyLong()))
when(blockCreator.createBlock(anyLong(), any()))
.thenReturn(
new BlockCreator.BlockCreationResult(
blockToCreate, new TransactionSelectionResults(), new BlockCreationTiming()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public class BftBlockCreator extends AbstractBlockCreator {
* @param transactionPool the pending transactions
* @param protocolContext the protocol context
* @param protocolSchedule the protocol schedule
* @param parentHeader the parent header
* @param bftExtraDataCodec the bft extra data codec
* @param ethScheduler the scheduler for asynchronous block creation tasks
*/
Expand All @@ -65,7 +64,6 @@ public BftBlockCreator(
final TransactionPool transactionPool,
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
final BlockHeader parentHeader,
final BftExtraDataCodec bftExtraDataCodec,
final EthScheduler ethScheduler) {
super(
Expand All @@ -75,21 +73,20 @@ public BftBlockCreator(
transactionPool,
protocolContext,
protocolSchedule,
parentHeader,
ethScheduler);
this.bftExtraDataCodec = bftExtraDataCodec;
}

@Override
public BlockCreationResult createBlock(final long timestamp) {
public BlockCreationResult createBlock(final long timestamp, final BlockHeader parentHeader) {
ProtocolSpec protocolSpec =
((BftProtocolSchedule) protocolSchedule)
.getByBlockNumberOrTimestamp(parentHeader.getNumber() + 1, timestamp);

if (protocolSpec.getWithdrawalsValidator() instanceof WithdrawalsValidator.AllowedWithdrawals) {
return createEmptyWithdrawalsBlock(timestamp);
return createEmptyWithdrawalsBlock(timestamp, parentHeader);
} else {
return createBlock(Optional.empty(), Optional.empty(), timestamp);
return createBlock(Optional.empty(), Optional.empty(), timestamp, parentHeader);
}
}

Expand All @@ -100,9 +97,14 @@ private static MiningBeneficiaryCalculator miningBeneficiaryCalculator(
}

@Override
public BlockCreationResult createEmptyWithdrawalsBlock(final long timestamp) {
public BlockCreationResult createEmptyWithdrawalsBlock(
final long timestamp, final BlockHeader parentHeader) {
return createBlock(
Optional.empty(), Optional.empty(), Optional.of(Collections.emptyList()), timestamp);
Optional.empty(),
Optional.empty(),
Optional.of(Collections.emptyList()),
timestamp,
parentHeader);
}

@Override
Expand Down
Loading

0 comments on commit 12716f7

Please sign in to comment.