Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 0 additions & 94 deletions scripts/build/testing.mk
Original file line number Diff line number Diff line change
Expand Up @@ -73,34 +73,6 @@ start-reth:
--engine.persistence-threshold 0 \
--engine.memory-block-buffer-target 0

## Start an ephemeral `geth` node with docker
start-geth:
$(call ask_reset_dir_func, $(ETH_DATA_DIR))
docker run \
--rm -v $(PWD)/${TESTAPP_FILES_DIR}:/${TESTAPP_FILES_DIR} \
-v $(PWD)/.tmp:/.tmp \
ghcr.io/berachain/bera-geth:latest init \
--datadir ${ETH_DATA_DIR} \
${ETH_GENESIS_PATH}

docker run \
-p 30303:30303 \
-p 8545:8545 \
-p 8551:8551 \
--rm -v $(PWD)/${TESTAPP_FILES_DIR}:/${TESTAPP_FILES_DIR} \
-v $(PWD)/.tmp:/.tmp \
ghcr.io/berachain/bera-geth:latest \
--syncmode=full \
--http \
--http.addr 0.0.0.0 \
--http.api eth,net \
--authrpc.addr 0.0.0.0 \
--authrpc.jwtsecret $(JWT_PATH) \
--authrpc.vhosts "*" \
--datadir ${ETH_DATA_DIR} \
--ipcpath ${IPC_PATH}


#################
# Bepolia #
#################
Expand All @@ -112,38 +84,6 @@ start-bepolia:
@JWT_SECRET_PATH=$(JWT_PATH) \
${TESTAPP_FILES_DIR}/entrypoint.sh testnet

start-geth-bepolia:
$(call ask_reset_dir_func, $(ETH_DATA_DIR))
docker run \
--rm -v $(PWD)/${TESTAPP_FILES_DIR}:/${TESTAPP_FILES_DIR} \
--rm -v $(PWD)/${BEPOLIA_NETWORK_FILES_DIR}:/${BEPOLIA_NETWORK_FILES_DIR} \
-v $(PWD)/.tmp:/.tmp \
ghcr.io/berachain/bera-geth:latest init \
--datadir ${ETH_DATA_DIR} \
${BEPOLIA_ETH_GENESIS_PATH}

@# Read bootnodes from the file; the file is mounted into the container.
@bootnodes=`cat $(PWD)/$(BEPOLIA_NETWORK_FILES_DIR)/el-bootnodes.txt`; \
echo "Using bootnodes: $$bootnodes"; \
docker run \
-p 30303:30303 \
-p 8545:8545 \
-p 8551:8551 \
--rm -v $(PWD)/${TESTAPP_FILES_DIR}:/${TESTAPP_FILES_DIR} \
--rm -v $(PWD)/${BEPOLIA_NETWORK_FILES_DIR}:/${BEPOLIA_NETWORK_FILES_DIR} \
-v $(PWD)/.tmp:/.tmp \
ghcr.io/berachain/bera-geth:latest \
--http \
--http.addr 0.0.0.0 \
--http.api eth,net \
--authrpc.addr 0.0.0.0 \
--authrpc.jwtsecret $(JWT_PATH) \
--authrpc.vhosts "*" \
--datadir ${ETH_DATA_DIR} \
--ipcpath ${IPC_PATH} \
--syncmode=full \
--bootnodes $$bootnodes

start-reth-bepolia:
$(call ask_reset_dir_func, $(ETH_DATA_DIR))
@trustedpeers=`cat $(PWD)/$(BEPOLIA_NETWORK_FILES_DIR)/el-peers.txt`; \
Expand Down Expand Up @@ -177,40 +117,6 @@ start-mainnet:
@JWT_SECRET_PATH=$(JWT_PATH) \
${TESTAPP_FILES_DIR}/entrypoint.sh mainnet

# NOTE: By default this will use the EL peers as your bootnodes. If you want specific
# discovery bootnodes by region, refer to testing/networks/80094/el-bootnodes.txt
start-geth-mainnet:
$(call ask_reset_dir_func, $(ETH_DATA_DIR))
docker run \
--rm -v $(PWD)/${TESTAPP_FILES_DIR}:/${TESTAPP_FILES_DIR} \
--rm -v $(PWD)/${MAINNET_NETWORK_FILES_DIR}:/${MAINNET_NETWORK_FILES_DIR} \
-v $(PWD)/.tmp:/.tmp \
ghcr.io/berachain/bera-geth:latest init \
--datadir ${ETH_DATA_DIR} \
${MAINNET_ETH_GENESIS_PATH}

@# Read bootnodes from the file; the file is mounted into the container.
@bootnodes=`cat $(PWD)/$(MAINNET_NETWORK_FILES_DIR)/el-peers.txt`; \
echo "Using bootnodes: $$bootnodes"; \
docker run \
-p 30303:30303 \
-p 8545:8545 \
-p 8551:8551 \
--rm -v $(PWD)/${TESTAPP_FILES_DIR}:/${TESTAPP_FILES_DIR} \
--rm -v $(PWD)/${MAINNET_NETWORK_FILES_DIR}:/${MAINNET_NETWORK_FILES_DIR} \
-v $(PWD)/.tmp:/.tmp \
ghcr.io/berachain/bera-geth:latest \
--http \
--http.addr 0.0.0.0 \
--http.api eth,net \
--authrpc.addr 0.0.0.0 \
--authrpc.jwtsecret $(JWT_PATH) \
--authrpc.vhosts "*" \
--datadir ${ETH_DATA_DIR} \
--ipcpath ${IPC_PATH} \
--syncmode=full \
--bootnodes $$bootnodes

start-reth-mainnet:
$(call ask_reset_dir_func, $(ETH_DATA_DIR))
@trustedpeers=`cat $(PWD)/$(MAINNET_NETWORK_FILES_DIR)/el-peers.txt`; \
Expand Down
8 changes: 7 additions & 1 deletion testing/simulated/el-genesis-files/eth-genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"mergeNetsplitBlock": 0,
"shanghaiTime": 0,
"cancunTime": 0,
"pragueTime": 9999999999999999,
"terminalTotalDifficulty": 0,
"terminalTotalDifficultyPassed": true,
"ethash": {},
Expand All @@ -27,6 +28,11 @@
"target": 3,
"max": 6,
"baseFeeUpdateFraction": 3338477
},
"prague": {
"target": 3,
"max": 6,
"baseFeeUpdateFraction": 3338477
}
},
"berachain": {
Expand Down Expand Up @@ -384,4 +390,4 @@
"balance": "0x0"
}
}
}
}
12 changes: 9 additions & 3 deletions testing/simulated/execution/execnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,15 @@ func (e *ExecNode) Start(t *testing.T, genesisFile string) (*Resource, *url.Conn
err = pool.Client.Ping()
require.NoErrorf(t, err, "could not connect to Docker: %s", err)

// Pull the image if it is not already present.
err = pool.Client.PullImage(e.image, docker.AuthConfiguration{})
require.NoError(t, err, "failed to pull image")
// Refresh the image from the registry, but tolerate an unreachable registry when the
// image is already present locally.
if pullErr := pool.Client.PullImage(e.image, docker.AuthConfiguration{}); pullErr != nil {
_, inspectErr := pool.Client.InspectImage(e.image.Repository + ":" + e.image.Tag)
require.NoErrorf(t, inspectErr,
"failed to pull image %s:%s and it is not present locally (pull error: %v)",
e.image.Repository, e.image.Tag, pullErr,
)
}

// Resolve the absolute path to the local test files.
absPath, err := filepath.Abs("../files")
Expand Down
58 changes: 0 additions & 58 deletions testing/simulated/execution/geth.go

This file was deleted.

6 changes: 6 additions & 0 deletions testing/simulated/execution/reth.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func defaultRethCmdStrBuilder(genesisFile string) string {
--full \
--engine.persistence-threshold=0 \
--engine.memory-block-buffer-target=0 \
--txpool.pending-max-count=4096 \
--txpool.queued-max-count=4096 \
--txpool.max-account-slots=256 \
-vvvv \
`, genesisFile)
}
Expand All @@ -75,6 +78,9 @@ func rethWithEngineOverrideFlagCmdStrBuilder(genesisFile string) string {
--engine.persistence-threshold=0 \
--engine.memory-block-buffer-target=0 \
--engine.always-process-payload-attributes-on-canonical-head \
--txpool.pending-max-count=4096 \
--txpool.queued-max-count=4096 \
--txpool.max-account-slots=256 \
-vvvv \
`, genesisFile)
}
22 changes: 9 additions & 13 deletions testing/simulated/execution/simulation_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ import (
"context"
"math/big"

"github.com/berachain/beacon-kit/execution/client"
"github.com/berachain/beacon-kit/primitives/encoding/json"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto/kzg4844"
"github.com/ethereum/go-ethereum/ethclient"
)

// SimulationClient calls `eth_simulateV1` on a Geth node.
// SimulationClient calls `eth_simulateV1` on an execution client's eth JSON-RPC
// endpoint. Reth only serves eth_simulateV1 on the eth namespace, not on the auth RPC.
type SimulationClient struct {
engineClient *client.EngineClient
ethClient *ethclient.Client
}

// TransactionArgs represents the fields needed to construct a dynamic-fee transaction.
Expand Down Expand Up @@ -129,7 +130,7 @@ type SimulatedBlock struct {
}

// NewSimulationClient returns a client for eth_simulateV1 calls.
func NewSimulationClient(cli *client.EngineClient) *SimulationClient {
func NewSimulationClient(cli *ethclient.Client) *SimulationClient {
return &SimulationClient{cli}
}

Expand All @@ -143,7 +144,7 @@ func (c *SimulationClient) Simulate(
var result []*SimulatedBlock
blockNumberInput := hexutil.Uint64(blockNumber)

if err := c.engineClient.Call(ctx, &result, "eth_simulateV1", opts, blockNumberInput); err != nil {
if err := c.ethClient.Client().CallContext(ctx, &result, "eth_simulateV1", opts, blockNumberInput); err != nil {
return nil, err
}
return result, nil
Expand Down Expand Up @@ -183,14 +184,9 @@ func TxsToTransactionArgs(chainID uint64, txs []*types.Transaction) ([]Transacti
ChainID: &chainIDHex,
}

if sidecar := tx.BlobTxSidecar(); sidecar != nil {
blobCap := hexutil.Big(*tx.BlobGasFeeCap())
call.BlobHashes = tx.BlobHashes()
call.BlobFeeCap = &blobCap
call.Blobs = sidecar.Blobs
call.Commitments = sidecar.Commitments
call.Proofs = sidecar.Proofs
}
// NOTE: blob fields are intentionally NOT set for simulation.
// reth's eth_simulateV1 cannot build an EIP-4844 transaction from
// blobVersionedHashes / maxFeePerBlobGas alone.

args[i] = call
}
Expand Down
2 changes: 1 addition & 1 deletion testing/simulated/fulu_deposit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (s *FuluDepositSuite) SetupTest() {
_ = s.TestNode.Start(s.CtxApp)
}()

s.SimulationClient = execution.NewSimulationClient(s.TestNode.EngineClient)
s.SimulationClient = execution.NewSimulationClient(s.TestNode.ContractBackend)
timeOut := 10 * time.Second
interval := 50 * time.Millisecond
err = simulated.WaitTillServicesStarted(s.LogBuffer, timeOut, interval)
Expand Down
2 changes: 1 addition & 1 deletion testing/simulated/malicious_consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,5 @@ func (s *SimulatedSuite) TestFinalizeBlock_BadBlock_Errors() {
})
s.Require().ErrorIs(err, errors.ErrInvalidPayloadStatus)
s.Require().Nil(finalizeResp)
s.Require().Contains(s.LogBuffer.String(), "max fee per gas less than block base fee: address 0x20f33CE90A13a4b5E7697E3544c3083B8F8A51D4, maxFeePerGas: 10000000, baseFee: 765625000")
s.Require().Contains(s.LogBuffer.String(), "gas price is less than basefee")
}
17 changes: 6 additions & 11 deletions testing/simulated/malicious_proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (s *SimulatedSuite) TestProcessProposal_BadBlock_IsRejected() {
// Verify that the log contains the expected error message.
s.Require().Contains(s.LogBuffer.String(), errors.ErrInvalidPayloadStatus.Error())
// Note this error message may change across execution clients. Base fee changes with number of core loop iterations.
s.Require().Contains(s.LogBuffer.String(), "max fee per gas less than block base fee: address 0x20f33CE90A13a4b5E7697E3544c3083B8F8A51D4, maxFeePerGas: 10000000, baseFee: 765625000")
s.Require().Contains(s.LogBuffer.String(), "gas price is less than basefee")
}

// TestProcessProposal_InvalidTimestamps_Errors effectively serves as a test for how a valid node would react to
Expand Down Expand Up @@ -305,22 +305,17 @@ func (s *SimulatedSuite) TestProcessProposal_InvalidBlobCommitment_Errors() {
blobTxs[i] = blobTx
}

proposedBlockMessage := simulated.ComputeAndSetValidExecutionBlock(
// Build the block carrying the malformed blob tx directly via MakeEthBlock (no eth_simulateV1,
// which reth cannot use to build blob txs).
proposedBlockMessage := simulated.ComputeAndSetInvalidExecutionBlock(
s.T(),
proposedBlock.GetBeaconBlock(),
s.SimulationClient,
s.TestNode.ChainSpec,
blobTxs,
nil,
)
proposedBlockMessage.GetBody().SetBlobKzgCommitments(commitments)

// Finalize the block by applying the state transition to update its state root.
queryCtx, err := s.SimComet.CreateQueryContext(currentHeight-1, false)
s.Require().NoError(err)

proposedBlockMessage, err = simulated.ComputeAndSetStateRoot(queryCtx, consensusTime, nodeAddress, s.TestNode.StateProcessor, s.TestNode.StorageBackend, proposedBlockMessage)
s.Require().NoError(err)

newSignedBlock, err := ctypes.NewSignedBeaconBlock(
proposedBlockMessage,
&ctypes.ForkData{
Expand Down Expand Up @@ -377,7 +372,7 @@ func (s *SimulatedSuite) TestProcessProposal_InvalidBlobCommitment_Errors() {
})
s.Require().NoError(err)
s.Require().Equal(types.PROCESS_PROPOSAL_STATUS_REJECT, processResp.Status)
s.Require().Contains(s.LogBuffer.String(), "could not apply tx 1 [0xdbbf691e9271a8bc3de5e64405337972fb4a5185cc3df160bac310c515f7d768]: blob transaction missing blob hashes")
s.Require().Contains(s.LogBuffer.String(), "unexpected list")
}

// TestProcessProposal_InvalidBlobInclusionProof_Errors effectively serves as a test for a malicious blobs.
Expand Down
Loading
Loading