Skip to content
Open
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
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,21 @@ test-hive:
act -j test-hive -s GITHUB_TOKEN=$(GITHUB_TOKEN) ; \
fi

eest-bal:
@if [ ! -d "temp" ]; then mkdir temp; fi
docker build -t "test/erigon:$(SHORT_COMMIT)" .
rm -rf "temp/eest-hive-$(SHORT_COMMIT)" && mkdir "temp/eest-hive-$(SHORT_COMMIT)"
cd "temp/eest-hive-$(SHORT_COMMIT)" && git clone https://github.com/ethereum/hive
cd "temp/eest-hive-$(SHORT_COMMIT)/hive" && \
$(if $(filter Darwin,$(UNAME)), \
sed -i '' "s/^ARG baseimage=erigontech\/erigon$$/ARG baseimage=test\/erigon/" clients/erigon/Dockerfile && \
sed -i '' "s/^ARG tag=main-latest$$/ARG tag=$(SHORT_COMMIT)/" clients/erigon/Dockerfile, \
sed -i "s/^ARG baseimage=erigontech\/erigon$$/ARG baseimage=test\/erigon/" clients/erigon/Dockerfile && \
sed -i "s/^ARG tag=main-latest$$/ARG tag=$(SHORT_COMMIT)/" clients/erigon/Dockerfile \
)
cd "temp/eest-hive-$(SHORT_COMMIT)/hive" && go build . 2>&1 | tee buildlogs.log
cd "temp/eest-hive-$(SHORT_COMMIT)/hive" && go build ./cmd/hiveview && ./hiveview --serve --logdir ./workspace/logs &
cd "temp/eest-hive-$(SHORT_COMMIT)/hive" && $(call run_suite,eels/consume-engine,".*amsterdam.*",--sim.buildarg branch=hive --sim.buildarg branch=tests-bal@v1.7.0 --sim.buildarg fixtures=https://github.com/ethereum/execution-spec-tests/releases/download/bal%40v1.7.0/fixtures_bal.tar.gz)

# Define the run_suite function
define run_suite
Expand Down
5 changes: 5 additions & 0 deletions cl/clparams/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (
DenebVersion StateVersion = 4
ElectraVersion StateVersion = 5
FuluVersion StateVersion = 6
GloasVersion StateVersion = 7
)

func (v StateVersion) String() string {
Expand All @@ -46,6 +47,8 @@ func (v StateVersion) String() string {
return "electra"
case FuluVersion:
return "fulu"
case GloasVersion:
return "gloas"
default:
panic("unsupported fork version")
}
Expand Down Expand Up @@ -88,6 +91,8 @@ func StringToClVersion(s string) (StateVersion, error) {
return ElectraVersion, nil
case "fulu":
return FuluVersion, nil
case "gloas":
return GloasVersion, nil
default:
return 0, fmt.Errorf("unsupported fork version %s", s)
}
Expand Down
2 changes: 1 addition & 1 deletion cl/cltypes/eth1_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,6 @@ func (b *Eth1Block) Body() *types.RawBody {
})
return &types.RawBody{
Transactions: b.Transactions.UnderlyngReference(),
Withdrawals: types.Withdrawals(withdrawals),
Withdrawals: withdrawals,
}
}
27 changes: 16 additions & 11 deletions execution/chain/chain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ type Config struct {
MergeHeight *big.Int `json:"mergeBlock,omitempty"` // The Merge block number

// Mainnet fork scheduling switched from block numbers to timestamps after The Merge
ShanghaiTime *big.Int `json:"shanghaiTime,omitempty"`
CancunTime *big.Int `json:"cancunTime,omitempty"`
PragueTime *big.Int `json:"pragueTime,omitempty"`
OsakaTime *big.Int `json:"osakaTime,omitempty"`
GlamsterdamTime *big.Int `json:"glamsterdamTime,omitempty"`
ShanghaiTime *big.Int `json:"shanghaiTime,omitempty"`
CancunTime *big.Int `json:"cancunTime,omitempty"`
PragueTime *big.Int `json:"pragueTime,omitempty"`
OsakaTime *big.Int `json:"osakaTime,omitempty"`
AmsterdamTime *big.Int `json:"amsterdamTime,omitempty"`

// Optional EIP-4844 parameters (see also EIP-7691, EIP-7840, EIP-7892)
MinBlobGasPrice *uint64 `json:"minBlobGasPrice,omitempty"`
Expand Down Expand Up @@ -166,7 +166,7 @@ var (
ShanghaiTime: big.NewInt(0),
CancunTime: big.NewInt(0),
PragueTime: big.NewInt(0),
GlamsterdamTime: big.NewInt(0),
AmsterdamTime: big.NewInt(0),
DepositContract: common.HexToAddress("0x00000000219ab540356cBB839Cbe05303d7705Fa"),
Ethash: new(EthashConfig),
}
Expand Down Expand Up @@ -213,13 +213,14 @@ func (c *Config) String() string {
)
}

return fmt.Sprintf("{ChainID: %v, Terminal Total Difficulty: %v, Shapella: %v, Dencun: %v, Pectra: %v, Fusaka: %v, BPO1: %v, BPO2: %v, BPO3: %v, BPO4: %v, BPO5: %v, Engine: %v}",
return fmt.Sprintf("{ChainID: %v, Terminal Total Difficulty: %v, Shapella: %v, Dencun: %v, Pectra: %v, Fusaka: %v, BPO1: %v, BPO2: %v, BPO3: %v, BPO4: %v, BPO5: %v, Amsterdam: %v, Engine: %v}",
c.ChainID,
c.TerminalTotalDifficulty,
timestampToTime(c.ShanghaiTime),
timestampToTime(c.CancunTime),
timestampToTime(c.PragueTime),
timestampToTime(c.OsakaTime),
timestampToTime(c.AmsterdamTime),
timestampToTime(c.Bpo1Time),
timestampToTime(c.Bpo2Time),
timestampToTime(c.Bpo3Time),
Expand Down Expand Up @@ -339,9 +340,9 @@ func (c *Config) IsCancun(time uint64) bool {
return isForked(c.CancunTime, time)
}

// IsGlamsterdam returns whether time is either equal to the Glamsterdam fork time or greater.
func (c *Config) IsGlamsterdam(time uint64) bool {
return isForked(c.GlamsterdamTime, time)
// IsAmsterdam returns whether time is either equal to the Amsterdam fork time or greater.
func (c *Config) IsAmsterdam(time uint64) bool {
return isForked(c.AmsterdamTime, time)
}

// IsPrague returns whether time is either equal to the Prague fork time or greater.
Expand Down Expand Up @@ -395,6 +396,10 @@ func (c *Config) GetBlobConfig(time uint64) *params.BlobConfig {
if ok && c.OsakaTime != nil {
c.parsedBlobSchedule[c.OsakaTime.Uint64()] = val
}
val, ok = c.BlobSchedule["gloas"]
if ok && c.AmsterdamTime != nil {
c.parsedBlobSchedule[c.AmsterdamTime.Uint64()] = val
}
val, ok = c.BlobSchedule["bpo1"]
if ok && c.Bpo1Time != nil {
c.parsedBlobSchedule[c.Bpo1Time.Uint64()] = val
Expand Down Expand Up @@ -699,7 +704,7 @@ type Rules struct {
IsByzantium, IsConstantinople, IsPetersburg bool
IsIstanbul, IsBerlin, IsLondon, IsShanghai bool
IsCancun, IsNapoli, IsBhilai bool
IsPrague, IsOsaka, IsGlamsterdam bool
IsPrague, IsOsaka, IsAmsterdam bool
IsAura bool
}

Expand Down
17 changes: 17 additions & 0 deletions execution/engineapi/engine_api_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ var ourCapabilities = []string{
"engine_getClientVersionV1",
"engine_getBlobsV1",
"engine_getBlobsV2",
"engine_newPayloadV5",
"engine_getPayloadV6",
}

// Returns the most recent version of the payload(for the payloadID) at the time of receiving the call
Expand Down Expand Up @@ -99,6 +101,14 @@ func (e *EngineServer) GetPayloadV5(ctx context.Context, payloadID hexutil.Bytes
return e.getPayload(ctx, decodedPayloadId, clparams.FuluVersion)
}

// Same as [GetPayloadV5], but returning ExecutionPayloadV4
// See https://github.com/ethereum/execution-apis/blob/main/src/engine/amsterdam.md#engine_getpayloadv6
func (e *EngineServer) GetPayloadV6(ctx context.Context, payloadID hexutil.Bytes) (*engine_types.GetPayloadResponse, error) {
decodedPayloadId := binary.BigEndian.Uint64(payloadID)
e.logger.Info("Received GetPayloadV6", "payloadId", decodedPayloadId)
return e.getPayload(ctx, decodedPayloadId, clparams.GloasVersion)
}

// Updates the forkchoice state after validating the headBlockHash
// Additionally, builds and returns a unique identifier for an initial version of a payload
// (asynchronously updated with transactions), if payloadAttributes is not nil and passes validation
Expand Down Expand Up @@ -147,6 +157,13 @@ func (e *EngineServer) NewPayloadV4(ctx context.Context, payload *engine_types.E
return e.newPayload(ctx, payload, expectedBlobHashes, parentBeaconBlockRoot, executionRequests, clparams.ElectraVersion)
}

// NewPayloadV5 processes new payloads (blocks) from the beacon chain with withdrawals, blob gas, requests and block access list.
// See https://github.com/ethereum/execution-apis/blob/main/src/engine/amsterdam.md#engine_newpayloadv5
func (e *EngineServer) NewPayloadV5(ctx context.Context, payload *engine_types.ExecutionPayload,
expectedBlobHashes []common.Hash, parentBeaconBlockRoot *common.Hash, executionRequests []hexutil.Bytes) (*engine_types.PayloadStatus, error) {
return e.newPayload(ctx, payload, expectedBlobHashes, parentBeaconBlockRoot, executionRequests, clparams.GloasVersion)
}

// Returns an array of execution payload bodies referenced by their block hashes
// See https://github.com/ethereum/execution-apis/blob/main/src/engine/shanghai.md#engine_getpayloadbodiesbyhashv1
func (e *EngineServer) GetPayloadBodiesByHashV1(ctx context.Context, hashes []common.Hash) ([]*engine_types.ExecutionPayloadBody, error) {
Expand Down
46 changes: 43 additions & 3 deletions execution/engineapi/engine_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package engineapi

import (
"context"
"encoding/hex"
"errors"
"fmt"
"math/big"
Expand All @@ -31,6 +32,7 @@ import (
"github.com/erigontech/erigon/cmd/rpcdaemon/cli"
"github.com/erigontech/erigon/cmd/rpcdaemon/cli/httpcfg"
"github.com/erigontech/erigon/common"
"github.com/erigontech/erigon/common/crypto"
"github.com/erigontech/erigon/common/empty"
"github.com/erigontech/erigon/common/hexutil"
"github.com/erigontech/erigon/common/log/v3"
Expand Down Expand Up @@ -279,10 +281,40 @@ func (s *EngineServer) newPayload(ctx context.Context, req *engine_types.Executi
header.ParentBeaconBlockRoot = parentBeaconBlockRoot
}

var blockAccessList types.BlockAccessList
var err error
if version >= clparams.GloasVersion {
if req.BlockAccessList == nil {
return nil, &rpc.InvalidParamsError{Message: "blockAccessList missing"}
}
if len(*req.BlockAccessList) == 0 {
blockAccessList = nil
header.BlockAccessListHash = &empty.BlockAccessListHash
} else {
blockAccessList, err = types.DecodeBlockAccessListBytes(*req.BlockAccessList)
if err != nil {
s.logger.Debug("[NewPayload] failed to decode blockAccessList", "err", err, "raw", hex.EncodeToString(*req.BlockAccessList))
return nil, &rpc.InvalidParamsError{Message: fmt.Sprintf("invalid blockAccessList decode: %v", err)}
}
if err := blockAccessList.Validate(); err != nil {
return nil, &rpc.InvalidParamsError{Message: fmt.Sprintf("invalid blockAccessList validate: %v", err)}
}
hash := crypto.Keccak256Hash(*req.BlockAccessList)
header.BlockAccessListHash = &hash
}
} else if req.BlockAccessList != nil {
return nil, &rpc.InvalidParamsError{Message: "unexpected blockAccessList before Amsterdam"}
}
log.Debug(fmt.Sprintf("bal from header: %s", blockAccessList.DebugString()))

if (!s.config.IsCancun(header.Time) && version >= clparams.DenebVersion) ||
(s.config.IsCancun(header.Time) && version < clparams.DenebVersion) ||
(!s.config.IsPrague(header.Time) && version >= clparams.ElectraVersion) ||
(s.config.IsPrague(header.Time) && version < clparams.ElectraVersion) {
(s.config.IsPrague(header.Time) && version < clparams.ElectraVersion) ||
(!s.config.IsOsaka(header.Time) && version >= clparams.FuluVersion) ||
(s.config.IsOsaka(header.Time) && version < clparams.FuluVersion) ||
(!s.config.IsAmsterdam(header.Time) && version >= clparams.GloasVersion) ||
(s.config.IsAmsterdam(header.Time) && version < clparams.GloasVersion) {
return nil, &rpc.UnsupportedForkError{Message: "Unsupported fork"}
}

Expand Down Expand Up @@ -357,7 +389,7 @@ func (s *EngineServer) newPayload(ctx context.Context, req *engine_types.Executi
defer s.lock.Unlock()

s.logger.Debug("[NewPayload] sending block", "height", header.Number, "hash", blockHash)
block := types.NewBlockFromStorage(blockHash, &header, transactions, nil /* uncles */, withdrawals, nil)
block := types.NewBlockFromStorage(blockHash, &header, transactions, nil /* uncles */, withdrawals, blockAccessList)

payloadStatus, err := s.HandleNewPayload(ctx, "NewPayload", block, expectedBlobHashes)
if err != nil {
Expand Down Expand Up @@ -554,7 +586,9 @@ func (s *EngineServer) getPayload(ctx context.Context, payloadId uint64, version
(!s.config.IsPrague(ts) && version >= clparams.ElectraVersion) ||
(s.config.IsPrague(ts) && version < clparams.ElectraVersion) ||
(!s.config.IsOsaka(ts) && version >= clparams.FuluVersion) ||
(s.config.IsOsaka(ts) && version < clparams.FuluVersion) {
(s.config.IsOsaka(ts) && version < clparams.FuluVersion) ||
(!s.config.IsAmsterdam(ts) && version >= clparams.GloasVersion) ||
(s.config.IsAmsterdam(ts) && version < clparams.GloasVersion) {
return nil, &rpc.UnsupportedForkError{Message: "Unsupported fork"}
}

Expand Down Expand Up @@ -649,6 +683,12 @@ func (s *EngineServer) forkchoiceUpdated(ctx context.Context, forkchoiceState *e
if s.config.IsCancun(timestamp) && version < clparams.DenebVersion { // Not V3 after cancun
return nil, &rpc.UnsupportedForkError{Message: "Unsupported fork"}
}
if !s.config.IsAmsterdam(timestamp) && version >= clparams.GloasVersion {
return nil, &rpc.UnsupportedForkError{Message: "Unsupported fork"}
}
if s.config.IsAmsterdam(timestamp) && version < clparams.GloasVersion {
return nil, &rpc.UnsupportedForkError{Message: "Unsupported fork"}
}

if !s.proposing {
return nil, errors.New("execution layer not running as a proposer. enable proposer by taking out the --proposer.disable flag on startup")
Expand Down
41 changes: 24 additions & 17 deletions execution/engineapi/engine_types/jsonrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,24 @@ import (

// ExecutionPayload represents an execution payload (aka block)
type ExecutionPayload struct {
ParentHash common.Hash `json:"parentHash" gencodec:"required"`
FeeRecipient common.Address `json:"feeRecipient" gencodec:"required"`
StateRoot common.Hash `json:"stateRoot" gencodec:"required"`
ReceiptsRoot common.Hash `json:"receiptsRoot" gencodec:"required"`
LogsBloom hexutil.Bytes `json:"logsBloom" gencodec:"required"`
PrevRandao common.Hash `json:"prevRandao" gencodec:"required"`
BlockNumber hexutil.Uint64 `json:"blockNumber" gencodec:"required"`
GasLimit hexutil.Uint64 `json:"gasLimit" gencodec:"required"`
GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
Timestamp hexutil.Uint64 `json:"timestamp" gencodec:"required"`
ExtraData hexutil.Bytes `json:"extraData" gencodec:"required"`
BaseFeePerGas *hexutil.Big `json:"baseFeePerGas" gencodec:"required"`
BlockHash common.Hash `json:"blockHash" gencodec:"required"`
Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"`
Withdrawals []*types.Withdrawal `json:"withdrawals"`
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
ParentHash common.Hash `json:"parentHash" gencodec:"required"`
FeeRecipient common.Address `json:"feeRecipient" gencodec:"required"`
StateRoot common.Hash `json:"stateRoot" gencodec:"required"`
ReceiptsRoot common.Hash `json:"receiptsRoot" gencodec:"required"`
LogsBloom hexutil.Bytes `json:"logsBloom" gencodec:"required"`
PrevRandao common.Hash `json:"prevRandao" gencodec:"required"`
BlockNumber hexutil.Uint64 `json:"blockNumber" gencodec:"required"`
GasLimit hexutil.Uint64 `json:"gasLimit" gencodec:"required"`
GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
Timestamp hexutil.Uint64 `json:"timestamp" gencodec:"required"`
ExtraData hexutil.Bytes `json:"extraData" gencodec:"required"`
BaseFeePerGas *hexutil.Big `json:"baseFeePerGas" gencodec:"required"`
BlockHash common.Hash `json:"blockHash" gencodec:"required"`
Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"`
Withdrawals []*types.Withdrawal `json:"withdrawals"`
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
BlockAccessList *hexutil.Bytes `json:"blockAccessList"`
}

// PayloadAttributes represent the attributes required to start assembling a payload
Expand Down Expand Up @@ -202,6 +203,9 @@ func ConvertRpcBlockToExecutionPayload(payload *executionproto.Block) *Execution
excessBlobGas := *header.ExcessBlobGas
res.ExcessBlobGas = (*hexutil.Uint64)(&excessBlobGas)
}
if body.BlockAccessList != nil {
res.BlockAccessList = types.ConvertBlockAccessListFromExecutionProto(body.BlockAccessList)
}
return res
}

Expand Down Expand Up @@ -240,6 +244,9 @@ func ConvertPayloadFromRpc(payload *typesproto.ExecutionPayload) *ExecutionPaylo
excessBlobGas := *payload.ExcessBlobGas
res.ExcessBlobGas = (*hexutil.Uint64)(&excessBlobGas)
}
if payload.Version >= 4 {
res.BlockAccessList = types.ConvertBlockAccessListFromTypesProto(payload.BlockAccessList)
}
return res
}

Expand Down
22 changes: 14 additions & 8 deletions execution/execmodule/moduleutil/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,12 @@ func ConvertRawBlockBodyToRpc(in *types.RawBody, blockNumber uint64, blockHash c
}

return &executionproto.BlockBody{
BlockNumber: blockNumber,
BlockHash: gointerfaces.ConvertHashToH256(blockHash),
Transactions: in.Transactions,
Uncles: HeadersToHeadersRPC(in.Uncles),
Withdrawals: ConvertWithdrawalsToRpc(in.Withdrawals),
BlockNumber: blockNumber,
BlockHash: gointerfaces.ConvertHashToH256(blockHash),
Transactions: in.Transactions,
Uncles: HeadersToHeadersRPC(in.Uncles),
Withdrawals: ConvertWithdrawalsToRpc(in.Withdrawals),
BlockAccessList: types.ConvertBlockAccessListToExecutionProto(in.BlockAccessList),
}
}

Expand All @@ -250,10 +251,15 @@ func ConvertRawBlockBodyFromRpc(in *executionproto.BlockBody) (*types.RawBody, e
if err != nil {
return nil, err
}
blockAccessList, err := types.ConvertExecutionProtoToBlockAccessList(in.BlockAccessList)
if err != nil {
return nil, err
}
return &types.RawBody{
Transactions: in.Transactions,
Uncles: uncles,
Withdrawals: ConvertWithdrawalsFromRpc(in.Withdrawals),
Transactions: in.Transactions,
Uncles: uncles,
Withdrawals: ConvertWithdrawalsFromRpc(in.Withdrawals),
BlockAccessList: blockAccessList,
}, nil
}

Expand Down
Loading
Loading