mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
Merge pull request #31 from berachain/update-main
Update main with latest upstream/master changes
This commit is contained in:
commit
91117be440
111 changed files with 7962 additions and 488 deletions
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
|
|
@ -13,6 +13,8 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
# Cache build tools to avoid downloading them each time
|
||||
- uses: actions/cache@v4
|
||||
|
|
@ -23,7 +25,7 @@ jobs:
|
|||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: 1.23.0
|
||||
go-version: 1.24
|
||||
cache: false
|
||||
|
||||
- name: Run linters
|
||||
|
|
@ -37,13 +39,14 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: 1.24.0
|
||||
cache: false
|
||||
|
||||
- name: Run tests
|
||||
run: go test -short ./...
|
||||
env:
|
||||
GOOS: linux
|
||||
GOARCH: 386
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ package bind
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
|
|
@ -241,3 +242,27 @@ func DefaultDeployer(opts *TransactOpts, backend ContractBackend) DeployFn {
|
|||
return addr, tx, nil
|
||||
}
|
||||
}
|
||||
|
||||
// DeployerWithNonceAssignment is basically identical to DefaultDeployer,
|
||||
// but it additionally tracks the nonce to enable automatic assignment.
|
||||
//
|
||||
// This is especially useful when deploying multiple contracts
|
||||
// from the same address — whether they are independent contracts
|
||||
// or part of a dependency chain that must be deployed in order.
|
||||
func DeployerWithNonceAssignment(opts *TransactOpts, backend ContractBackend) DeployFn {
|
||||
var pendingNonce int64
|
||||
if opts.Nonce != nil {
|
||||
pendingNonce = opts.Nonce.Int64()
|
||||
}
|
||||
return func(input []byte, deployer []byte) (common.Address, *types.Transaction, error) {
|
||||
if pendingNonce != 0 {
|
||||
opts.Nonce = big.NewInt(pendingNonce)
|
||||
}
|
||||
addr, tx, err := DeployContract(opts, deployer, backend, input)
|
||||
if err != nil {
|
||||
return common.Address{}, nil, err
|
||||
}
|
||||
pendingNonce = int64(tx.Nonce() + 1)
|
||||
return addr, tx, nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,14 @@ func makeTestDeployer(backend simulated.Client) func(input, deployer []byte) (co
|
|||
return bind.DefaultDeployer(bind.NewKeyedTransactor(testKey, chainId), backend)
|
||||
}
|
||||
|
||||
// makeTestDeployerWithNonceAssignment is similar to makeTestDeployer,
|
||||
// but it returns a deployer that automatically tracks nonce,
|
||||
// enabling the deployment of multiple contracts from the same account.
|
||||
func makeTestDeployerWithNonceAssignment(backend simulated.Client) func(input, deployer []byte) (common.Address, *types.Transaction, error) {
|
||||
chainId, _ := backend.ChainID(context.Background())
|
||||
return bind.DeployerWithNonceAssignment(bind.NewKeyedTransactor(testKey, chainId), backend)
|
||||
}
|
||||
|
||||
// test that deploying a contract with library dependencies works,
|
||||
// verifying by calling method on the deployed contract.
|
||||
func TestDeploymentLibraries(t *testing.T) {
|
||||
|
|
@ -80,7 +88,7 @@ func TestDeploymentLibraries(t *testing.T) {
|
|||
Contracts: []*bind.MetaData{&nested_libraries.C1MetaData},
|
||||
Inputs: map[string][]byte{nested_libraries.C1MetaData.ID: constructorInput},
|
||||
}
|
||||
res, err := bind.LinkAndDeploy(deploymentParams, makeTestDeployer(bindBackend.Client))
|
||||
res, err := bind.LinkAndDeploy(deploymentParams, makeTestDeployerWithNonceAssignment(bindBackend.Client))
|
||||
if err != nil {
|
||||
t.Fatalf("err: %+v\n", err)
|
||||
}
|
||||
|
|
@ -122,7 +130,7 @@ func TestDeploymentWithOverrides(t *testing.T) {
|
|||
deploymentParams := &bind.DeploymentParams{
|
||||
Contracts: nested_libraries.C1MetaData.Deps,
|
||||
}
|
||||
res, err := bind.LinkAndDeploy(deploymentParams, makeTestDeployer(bindBackend))
|
||||
res, err := bind.LinkAndDeploy(deploymentParams, makeTestDeployerWithNonceAssignment(bindBackend))
|
||||
if err != nil {
|
||||
t.Fatalf("err: %+v\n", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
// Package keystore implements encrypted storage of secp256k1 private keys.
|
||||
//
|
||||
// Keys are stored as encrypted JSON files according to the Web3 Secret Storage specification.
|
||||
// See https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition for more information.
|
||||
// See https://ethereum.org/en/developers/docs/data-structures-and-encoding/web3-secret-storage/ for more information.
|
||||
package keystore
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
This key store behaves as KeyStorePlain with the difference that
|
||||
the private key is encrypted and on disk uses another JSON encoding.
|
||||
|
||||
The crypto is documented at https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition
|
||||
The crypto is documented at https://ethereum.org/en/developers/docs/data-structures-and-encoding/web3-secret-storage/
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -34,21 +34,13 @@ func TestBlobs(t *testing.T) {
|
|||
header := types.Header{}
|
||||
block := types.NewBlock(&header, &types.Body{}, nil, nil)
|
||||
|
||||
sidecarWithoutCellProofs := &types.BlobTxSidecar{
|
||||
Blobs: []kzg4844.Blob{*emptyBlob},
|
||||
Commitments: []kzg4844.Commitment{emptyBlobCommit},
|
||||
Proofs: []kzg4844.Proof{emptyBlobProof},
|
||||
}
|
||||
sidecarWithoutCellProofs := types.NewBlobTxSidecar(types.BlobSidecarVersion0, []kzg4844.Blob{*emptyBlob}, []kzg4844.Commitment{emptyBlobCommit}, []kzg4844.Proof{emptyBlobProof})
|
||||
env := BlockToExecutableData(block, common.Big0, []*types.BlobTxSidecar{sidecarWithoutCellProofs}, nil)
|
||||
if len(env.BlobsBundle.Proofs) != 1 {
|
||||
t.Fatalf("Expect 1 proof in blobs bundle, got %v", len(env.BlobsBundle.Proofs))
|
||||
}
|
||||
|
||||
sidecarWithCellProofs := &types.BlobTxSidecar{
|
||||
Blobs: []kzg4844.Blob{*emptyBlob},
|
||||
Commitments: []kzg4844.Commitment{emptyBlobCommit},
|
||||
Proofs: emptyCellProof,
|
||||
}
|
||||
sidecarWithCellProofs := types.NewBlobTxSidecar(types.BlobSidecarVersion0, []kzg4844.Blob{*emptyBlob}, []kzg4844.Commitment{emptyBlobCommit}, emptyCellProof)
|
||||
env = BlockToExecutableData(block, common.Big0, []*types.BlobTxSidecar{sidecarWithCellProofs}, nil)
|
||||
if len(env.BlobsBundle.Proofs) != 128 {
|
||||
t.Fatalf("Expect 128 proofs in blobs bundle, got %v", len(env.BlobsBundle.Proofs))
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
# This file contains sha256 checksums of optional build dependencies.
|
||||
|
||||
# version:spec-tests v4.5.0
|
||||
# version:spec-tests fusaka-devnet-3%40v1.0.0
|
||||
# https://github.com/ethereum/execution-spec-tests/releases
|
||||
# https://github.com/ethereum/execution-spec-tests/releases/download/v4.5.0/
|
||||
58afb92a0075a2cb7c4dec1281f7cb88b21b02afbedad096b580f3f8cc14c54c fixtures_develop.tar.gz
|
||||
# https://github.com/ethereum/execution-spec-tests/releases/download/fusaka-devnet-3%40v1.0.0
|
||||
576261e1280e5300c458aa9b05eccb2fec5ff80a0005940dc52fa03fdd907249 fixtures_fusaka-devnet-3.tar.gz
|
||||
|
||||
# version:golang 1.24.4
|
||||
# https://go.dev/dl/
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ func doTest(cmdline []string) {
|
|||
// downloadSpecTestFixtures downloads and extracts the execution-spec-tests fixtures.
|
||||
func downloadSpecTestFixtures(csdb *download.ChecksumDB, cachedir string) string {
|
||||
ext := ".tar.gz"
|
||||
base := "fixtures_develop"
|
||||
base := "fixtures_fusaka-devnet-3"
|
||||
archivePath := filepath.Join(cachedir, base+ext)
|
||||
if err := csdb.DownloadFileFromKnownURL(archivePath); err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ The API-method `account_signGnosisSafeTx` was added. This method takes two param
|
|||
```
|
||||
|
||||
Not all fields are required, though. This method is really just a UX helper, which massages the
|
||||
input to conform to the `EIP-712` [specification](https://docs.gnosis.io/safe/docs/contracts_tx_execution/#transaction-hash)
|
||||
input to conform to the `EIP-712` [specification](https://docs.safe.global/core-api/transaction-service-reference/gnosis)
|
||||
for the Gnosis Safe, and making the output be directly importable to by a relay service.
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -879,11 +879,7 @@ func makeSidecar(data ...byte) *types.BlobTxSidecar {
|
|||
commitments = append(commitments, c)
|
||||
proofs = append(proofs, p)
|
||||
}
|
||||
return &types.BlobTxSidecar{
|
||||
Blobs: blobs,
|
||||
Commitments: commitments,
|
||||
Proofs: proofs,
|
||||
}
|
||||
return types.NewBlobTxSidecar(types.BlobSidecarVersion0, blobs, commitments, proofs)
|
||||
}
|
||||
|
||||
func (s *Suite) makeBlobTxs(count, blobs int, discriminator byte) (txs types.Transactions) {
|
||||
|
|
@ -988,14 +984,10 @@ func (s *Suite) TestBlobViolations(t *utesting.T) {
|
|||
// data has been modified to produce a different commitment hash.
|
||||
func mangleSidecar(tx *types.Transaction) *types.Transaction {
|
||||
sidecar := tx.BlobTxSidecar()
|
||||
copy := types.BlobTxSidecar{
|
||||
Blobs: append([]kzg4844.Blob{}, sidecar.Blobs...),
|
||||
Commitments: append([]kzg4844.Commitment{}, sidecar.Commitments...),
|
||||
Proofs: append([]kzg4844.Proof{}, sidecar.Proofs...),
|
||||
}
|
||||
cpy := sidecar.Copy()
|
||||
// zero the first commitment to alter the sidecar hash
|
||||
copy.Commitments[0] = kzg4844.Commitment{}
|
||||
return tx.WithBlobTxSidecar(©)
|
||||
cpy.Commitments[0] = kzg4844.Commitment{}
|
||||
return tx.WithBlobTxSidecar(cpy)
|
||||
}
|
||||
|
||||
func (s *Suite) TestBlobTxWithoutSidecar(t *utesting.T) {
|
||||
|
|
|
|||
|
|
@ -183,6 +183,9 @@ func Transaction(ctx *cli.Context) error {
|
|||
if chainConfig.IsShanghai(new(big.Int), 0) && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize {
|
||||
r.Error = errors.New("max initcode size exceeded")
|
||||
}
|
||||
if chainConfig.IsOsaka(new(big.Int), 0) && tx.Gas() > params.MaxTxGas {
|
||||
r.Error = errors.New("gas limit exceeds maximum")
|
||||
}
|
||||
results = append(results, r)
|
||||
}
|
||||
out, err := json.MarshalIndent(results, "", " ")
|
||||
|
|
|
|||
|
|
@ -580,8 +580,8 @@ func parseDumpConfig(ctx *cli.Context, db ethdb.Database) (*state.DumpConfig, co
|
|||
arg := ctx.Args().First()
|
||||
if hashish(arg) {
|
||||
hash := common.HexToHash(arg)
|
||||
if number := rawdb.ReadHeaderNumber(db, hash); number != nil {
|
||||
header = rawdb.ReadHeader(db, hash, *number)
|
||||
if number, ok := rawdb.ReadHeaderNumber(db, hash); ok {
|
||||
header = rawdb.ReadHeader(db, hash, number)
|
||||
} else {
|
||||
return nil, common.Hash{}, fmt.Errorf("block %x not found", hash)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ func makeFullNode(ctx *cli.Context) *node.Node {
|
|||
if len(hex) != common.HashLength {
|
||||
utils.Fatalf("invalid sync target length: have %d, want %d", len(hex), common.HashLength)
|
||||
}
|
||||
utils.RegisterFullSyncTester(stack, eth, common.BytesToHash(hex))
|
||||
utils.RegisterFullSyncTester(stack, eth, common.BytesToHash(hex), ctx.Bool(utils.ExitWhenSyncedFlag.Name))
|
||||
}
|
||||
|
||||
if ctx.IsSet(utils.DeveloperFlag.Name) {
|
||||
|
|
|
|||
161
cmd/geth/testdata/vcheck/data.json
vendored
161
cmd/geth/testdata/vcheck/data.json
vendored
|
|
@ -6,28 +6,33 @@
|
|||
"description": "A mining flaw could cause miners to erroneously calculate PoW, due to an index overflow, if DAG size is exceeding the maximum 32 bit unsigned value.\n\nThis occurred on the ETC chain on 2020-11-06. This is likely to trigger for ETH mainnet around block `11550000`/epoch `385`, slated to occur early January 2021.\n\nThis issue is relevant only for miners, non-mining nodes are unaffected, since non-mining nodes use a smaller verification cache instead of a full DAG.",
|
||||
"links": [
|
||||
"https://github.com/ethereum/go-ethereum/pull/21793",
|
||||
"https://blog.ethereum.org/2020/11/12/geth_security_release/",
|
||||
"https://github.com/ethereum/go-ethereum/commit/567d41d9363706b4b13ce0903804e8acf214af49"
|
||||
"https://blog.ethereum.org/2020/11/12/geth-security-release",
|
||||
"https://github.com/ethereum/go-ethereum/commit/567d41d9363706b4b13ce0903804e8acf214af49",
|
||||
"https://github.com/ethereum/go-ethereum/security/advisories/GHSA-v592-xf75-856p"
|
||||
],
|
||||
"introduced": "v1.6.0",
|
||||
"fixed": "v1.9.24",
|
||||
"published": "2020-11-12",
|
||||
"severity": "Medium",
|
||||
"check": "Geth\\/v1\\.(6|7|8)\\..*|Geth\\/v1\\.9\\.2(1|2|3)-.*"
|
||||
"CVE": "CVE-2020-26240",
|
||||
"check": "Geth\\/v1\\.(6|7|8)\\..*|Geth\\/v1\\.9\\.\\d-.*|Geth\\/v1\\.9\\.1.*|Geth\\/v1\\.9\\.2(0|1|2|3)-.*"
|
||||
},
|
||||
{
|
||||
"name": "GoCrash",
|
||||
"name": "Denial of service due to Go CVE-2020-28362",
|
||||
"uid": "GETH-2020-02",
|
||||
"summary": "A denial-of-service issue can be used to crash Geth nodes during block processing, due to an underlying bug in Go (CVE-2020-28362) versions < `1.15.5`, or `<1.14.12`",
|
||||
"description": "The DoS issue can be used to crash all Geth nodes during block processing, the effects of which would be that a major part of the Ethereum network went offline.\n\nOutside of Go-Ethereum, the issue is most likely relevant for all forks of Geth (such as TurboGeth or ETC’s core-geth) which is built with versions of Go which contains the vulnerability.",
|
||||
"links": [
|
||||
"https://blog.ethereum.org/2020/11/12/geth_security_release/",
|
||||
"https://blog.ethereum.org/2020/11/12/geth-security-release",
|
||||
"https://groups.google.com/g/golang-announce/c/NpBGTTmKzpM",
|
||||
"https://github.com/golang/go/issues/42552"
|
||||
"https://github.com/golang/go/issues/42552",
|
||||
"https://github.com/ethereum/go-ethereum/security/advisories/GHSA-m6gx-rhvj-fh52"
|
||||
],
|
||||
"introduced": "v0.0.0",
|
||||
"fixed": "v1.9.24",
|
||||
"published": "2020-11-12",
|
||||
"severity": "Critical",
|
||||
"CVE": "CVE-2020-28362",
|
||||
"check": "Geth.*\\/go1\\.(11(.*)|12(.*)|13(.*)|14|14\\.(\\d|10|11|)|15|15\\.[0-4])$"
|
||||
},
|
||||
{
|
||||
|
|
@ -36,26 +41,162 @@
|
|||
"summary": "A consensus flaw in Geth, related to `datacopy` precompile",
|
||||
"description": "Geth erroneously performed a 'shallow' copy when the precompiled `datacopy` (at `0x00...04`) was invoked. An attacker could deploy a contract that uses the shallow copy to corrupt the contents of the `RETURNDATA`, thus causing a consensus failure.",
|
||||
"links": [
|
||||
"https://blog.ethereum.org/2020/11/12/geth_security_release/"
|
||||
"https://blog.ethereum.org/2020/11/12/geth-security-release",
|
||||
"https://github.com/ethereum/go-ethereum/security/advisories/GHSA-69v6-xc2j-r2jf"
|
||||
],
|
||||
"introduced": "v1.9.7",
|
||||
"fixed": "v1.9.17",
|
||||
"published": "2020-11-12",
|
||||
"severity": "Critical",
|
||||
"CVE": "CVE-2020-26241",
|
||||
"check": "Geth\\/v1\\.9\\.(7|8|9|10|11|12|13|14|15|16).*$"
|
||||
},
|
||||
{
|
||||
"name": "GethCrash",
|
||||
"name": "Geth DoS via MULMOD",
|
||||
"uid": "GETH-2020-04",
|
||||
"summary": "A denial-of-service issue can be used to crash Geth nodes during block processing",
|
||||
"description": "Full details to be disclosed at a later date",
|
||||
"description": "Affected versions suffer from a vulnerability which can be exploited through the `MULMOD` operation, by specifying a modulo of `0`: `mulmod(a,b,0)`, causing a `panic` in the underlying library. \nThe crash was in the `uint256` library, where a buffer [underflowed](https://github.com/holiman/uint256/blob/4ce82e695c10ddad57215bdbeafb68b8c5df2c30/uint256.go#L442).\n\n\tif `d == 0`, `dLen` remains `0`\n\nand https://github.com/holiman/uint256/blob/4ce82e695c10ddad57215bdbeafb68b8c5df2c30/uint256.go#L451 will try to access index `[-1]`.\n\nThe `uint256` library was first merged in this [commit](https://github.com/ethereum/go-ethereum/commit/cf6674539c589f80031f3371a71c6a80addbe454), on 2020-06-08. \nExploiting this vulnerabilty would cause all vulnerable nodes to drop off the network. \n\nThe issue was brought to our attention through a [bug report](https://github.com/ethereum/go-ethereum/issues/21367), showing a `panic` occurring on sync from genesis on the Ropsten network.\n \nIt was estimated that the least obvious way to fix this would be to merge the fix into `uint256`, make a new release of that library and then update the geth-dependency.\n",
|
||||
"links": [
|
||||
"https://blog.ethereum.org/2020/11/12/geth_security_release/"
|
||||
"https://blog.ethereum.org/2020/11/12/geth-security-release",
|
||||
"https://github.com/ethereum/go-ethereum/security/advisories/GHSA-jm5c-rv3w-w83m",
|
||||
"https://github.com/holiman/uint256/releases/tag/v1.1.1",
|
||||
"https://github.com/holiman/uint256/pull/80",
|
||||
"https://github.com/ethereum/go-ethereum/pull/21368"
|
||||
],
|
||||
"introduced": "v1.9.16",
|
||||
"fixed": "v1.9.18",
|
||||
"published": "2020-11-12",
|
||||
"severity": "Critical",
|
||||
"CVE": "CVE-2020-26242",
|
||||
"check": "Geth\\/v1\\.9.(16|17).*$"
|
||||
},
|
||||
{
|
||||
"name": "LES Server DoS via GetProofsV2",
|
||||
"uid": "GETH-2020-05",
|
||||
"summary": "A DoS vulnerability can make a LES server crash.",
|
||||
"description": "A DoS vulnerability can make a LES server crash via malicious GetProofsV2 request from a connected LES client.\n\nThe vulnerability was patched in #21896.\n\nThis vulnerability only concern users explicitly running geth as a light server",
|
||||
"links": [
|
||||
"https://github.com/ethereum/go-ethereum/security/advisories/GHSA-r33q-22hv-j29q",
|
||||
"https://github.com/ethereum/go-ethereum/pull/21896"
|
||||
],
|
||||
"introduced": "v1.8.0",
|
||||
"fixed": "v1.9.25",
|
||||
"published": "2020-12-10",
|
||||
"severity": "Medium",
|
||||
"CVE": "CVE-2020-26264",
|
||||
"check": "(Geth\\/v1\\.8\\.*)|(Geth\\/v1\\.9\\.\\d-.*)|(Geth\\/v1\\.9\\.1\\d-.*)|(Geth\\/v1\\.9\\.(20|21|22|23|24)-.*)$"
|
||||
},
|
||||
{
|
||||
"name": "SELFDESTRUCT-recreate consensus flaw",
|
||||
"uid": "GETH-2020-06",
|
||||
"introduced": "v1.9.4",
|
||||
"fixed": "v1.9.20",
|
||||
"summary": "A consensus-vulnerability in Geth could cause a chain split, where vulnerable versions refuse to accept the canonical chain.",
|
||||
"description": "A flaw was repoted at 2020-08-11 by John Youngseok Yang (Software Platform Lab), where a particular sequence of transactions could cause a consensus failure.\n\n- Tx 1:\n - `sender` invokes `caller`.\n - `caller` invokes `0xaa`. `0xaa` has 3 wei, does a self-destruct-to-self\n - `caller` does a `1 wei` -call to `0xaa`, who thereby has 1 wei (the code in `0xaa` still executed, since the tx is still ongoing, but doesn't redo the selfdestruct, it takes a different path if callvalue is non-zero)\n\n-Tx 2:\n - `sender` does a 5-wei call to 0xaa. No exec (since no code). \n\nIn geth, the result would be that `0xaa` had `6 wei`, whereas OE reported (correctly) `5` wei. Furthermore, in geth, if the second tx was not executed, the `0xaa` would be destructed, resulting in `0 wei`. Thus obviously wrong. \n\nIt was determined that the root cause was this [commit](https://github.com/ethereum/go-ethereum/commit/223b950944f494a5b4e0957fd9f92c48b09037ad) from [this PR](https://github.com/ethereum/go-ethereum/pull/19953). The semantics of `createObject` was subtly changd, into returning a non-nil object (with `deleted=true`) where it previously did not if the account had been destructed. This return value caused the new object to inherit the old `balance`.\n",
|
||||
"links": [
|
||||
"https://github.com/ethereum/go-ethereum/security/advisories/GHSA-xw37-57qp-9mm4"
|
||||
],
|
||||
"published": "2020-12-10",
|
||||
"severity": "High",
|
||||
"CVE": "CVE-2020-26265",
|
||||
"check": "(Geth\\/v1\\.9\\.(4|5|6|7|8|9)-.*)|(Geth\\/v1\\.9\\.1\\d-.*)$"
|
||||
},
|
||||
{
|
||||
"name": "Not ready for London upgrade",
|
||||
"uid": "GETH-2021-01",
|
||||
"summary": "The client is not ready for the 'London' technical upgrade, and will deviate from the canonical chain when the London upgrade occurs (at block '12965000' around August 4, 2021.",
|
||||
"description": "At (or around) August 4, Ethereum will undergo a technical upgrade called 'London'. Clients not upgraded will fail to progress on the canonical chain.",
|
||||
"links": [
|
||||
"https://github.com/ethereum/eth1.0-specs/blob/master/network-upgrades/mainnet-upgrades/london.md",
|
||||
"https://notes.ethereum.org/@timbeiko/ropsten-postmortem"
|
||||
],
|
||||
"introduced": "v1.10.1",
|
||||
"fixed": "v1.10.6",
|
||||
"published": "2021-07-22",
|
||||
"severity": "High",
|
||||
"check": "(Geth\\/v1\\.10\\.(1|2|3|4|5)-.*)$"
|
||||
},
|
||||
{
|
||||
"name": "RETURNDATA corruption via datacopy",
|
||||
"uid": "GETH-2021-02",
|
||||
"summary": "A consensus-flaw in the Geth EVM could cause a node to deviate from the canonical chain.",
|
||||
"description": "A memory-corruption bug within the EVM can cause a consensus error, where vulnerable nodes obtain a different `stateRoot` when processing a maliciously crafted transaction. This, in turn, would lead to the chain being split: mainnet splitting in two forks.\n\nAll Geth versions supporting the London hard fork are vulnerable (the bug is older than London), so all users should update.\n\nThis bug was exploited on Mainnet at block 13107518.\n\nCredits for the discovery go to @guidovranken (working for Sentnl during an audit of the Telos EVM) and reported via bounty@ethereum.org.",
|
||||
"links": [
|
||||
"https://github.com/ethereum/go-ethereum/blob/master/docs/postmortems/2021-08-22-split-postmortem.md",
|
||||
"https://github.com/ethereum/go-ethereum/security/advisories/GHSA-9856-9gg9-qcmq",
|
||||
"https://github.com/ethereum/go-ethereum/releases/tag/v1.10.8"
|
||||
],
|
||||
"introduced": "v1.10.0",
|
||||
"fixed": "v1.10.8",
|
||||
"published": "2021-08-24",
|
||||
"severity": "High",
|
||||
"CVE": "CVE-2021-39137",
|
||||
"check": "(Geth\\/v1\\.10\\.(0|1|2|3|4|5|6|7)-.*)$"
|
||||
},
|
||||
{
|
||||
"name": "DoS via malicious `snap/1` request",
|
||||
"uid": "GETH-2021-03",
|
||||
"summary": "A vulnerable node is susceptible to crash when processing a maliciously crafted message from a peer, via the snap/1 protocol. The crash can be triggered by sending a malicious snap/1 GetTrieNodes package.",
|
||||
"description": "The `snap/1` protocol handler contains two vulnerabilities related to the `GetTrieNodes` packet, which can be exploited to crash the node. Full details are available at the Github security [advisory](https://github.com/ethereum/go-ethereum/security/advisories/GHSA-59hh-656j-3p7v)",
|
||||
"links": [
|
||||
"https://github.com/ethereum/go-ethereum/security/advisories/GHSA-59hh-656j-3p7v",
|
||||
"https://geth.ethereum.org/docs/vulnerabilities/vulnerabilities",
|
||||
"https://github.com/ethereum/go-ethereum/pull/23657"
|
||||
],
|
||||
"introduced": "v1.10.0",
|
||||
"fixed": "v1.10.9",
|
||||
"published": "2021-10-24",
|
||||
"severity": "Medium",
|
||||
"CVE": "CVE-2021-41173",
|
||||
"check": "(Geth\\/v1\\.10\\.(0|1|2|3|4|5|6|7|8)-.*)$"
|
||||
},
|
||||
{
|
||||
"name": "DoS via malicious p2p message",
|
||||
"uid": "GETH-2022-01",
|
||||
"summary": "A vulnerable node can crash via p2p messages sent from an attacker node, if running with non-default log options.",
|
||||
"description": "A vulnerable node, if configured to use high verbosity logging, can be made to crash when handling specially crafted p2p messages sent from an attacker node. Full details are available at the Github security [advisory](https://github.com/ethereum/go-ethereum/security/advisories/GHSA-wjxw-gh3m-7pm5)",
|
||||
"links": [
|
||||
"https://github.com/ethereum/go-ethereum/security/advisories/GHSA-wjxw-gh3m-7pm5",
|
||||
"https://geth.ethereum.org/docs/vulnerabilities/vulnerabilities",
|
||||
"https://github.com/ethereum/go-ethereum/pull/24507"
|
||||
],
|
||||
"introduced": "v1.10.0",
|
||||
"fixed": "v1.10.17",
|
||||
"published": "2022-05-11",
|
||||
"severity": "Low",
|
||||
"CVE": "CVE-2022-29177",
|
||||
"check": "(Geth\\/v1\\.10\\.(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16)-.*)$"
|
||||
},
|
||||
{
|
||||
"name": "DoS via malicious p2p message",
|
||||
"uid": "GETH-2023-01",
|
||||
"summary": "A vulnerable node can be made to consume unbounded amounts of memory when handling specially crafted p2p messages sent from an attacker node.",
|
||||
"description": "The p2p handler spawned a new goroutine to respond to ping requests. By flooding a node with ping requests, an unbounded number of goroutines can be created, leading to resource exhaustion and potentially crash due to OOM.",
|
||||
"links": [
|
||||
"https://github.com/ethereum/go-ethereum/security/advisories/GHSA-ppjg-v974-84cm",
|
||||
"https://geth.ethereum.org/docs/vulnerabilities/vulnerabilities"
|
||||
],
|
||||
"introduced": "v1.10.0",
|
||||
"fixed": "v1.12.1",
|
||||
"published": "2023-09-06",
|
||||
"severity": "High",
|
||||
"CVE": "CVE-2023-40591",
|
||||
"check": "(Geth\\/v1\\.(10|11)\\..*)|(Geth\\/v1\\.12\\.0-.*)$"
|
||||
},
|
||||
{
|
||||
"name": "DoS via malicious p2p message",
|
||||
"uid": "GETH-2024-01",
|
||||
"summary": "A vulnerable node can be made to consume very large amounts of memory when handling specially crafted p2p messages sent from an attacker node.",
|
||||
"description": "A vulnerable node can be made to consume very large amounts of memory when handling specially crafted p2p messages sent from an attacker node. Full details will be available at the Github security [advisory](https://github.com/ethereum/go-ethereum/security/advisories/GHSA-4xc9-8hmq-j652)",
|
||||
"links": [
|
||||
"https://github.com/ethereum/go-ethereum/security/advisories/GHSA-4xc9-8hmq-j652",
|
||||
"https://geth.ethereum.org/docs/vulnerabilities/vulnerabilities"
|
||||
],
|
||||
"introduced": "v1.10.0",
|
||||
"fixed": "v1.13.15",
|
||||
"published": "2024-05-06",
|
||||
"severity": "High",
|
||||
"CVE": "CVE-2024-32972",
|
||||
"check": "(Geth\\/v1\\.(10|11|12)\\..*)|(Geth\\/v1\\.13\\.\\d-.*)|(Geth\\/v1\\.13\\.1(0|1|2|3|4)-.*)$"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
untrusted comment: signature from minisign secret key
|
||||
RUQkliYstQBOKLK05Sy5f3bVRMBqJT26ABo6Vbp3BNJAVjejoqYCu4GWE/+7qcDfHBqYIniDCbFIUvYEnOHxV6vZ93wO1xJWDQw=
|
||||
trusted comment: timestamp:1693986492 file:data.json hashed
|
||||
6Fdw2H+W1ZXK7QXSF77Z5AWC7+AEFAfDmTSxNGylU5HLT1AuSJQmxslj+VjtUBamYCvOuET7plbXza942AlWDw==
|
||||
RUQkliYstQBOKHklFEYCUjepz81dyUuDmIAxjAvXa+icjGuKcjtVfV06G7qfOMSpplS5EcntU12n+AnGNyuOM8zIctaIWcfG2w0=
|
||||
trusted comment: timestamp:1752094689 file:data.json hashed
|
||||
u2e4wo4HBTU6viQTSY/NVBHoWoPFJnnTvLZS0FYl3JdvSOYi6+qpbEsDhAIFqq/n8VmlS/fPqqf7vKCNiAgjAA==
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
untrusted comment: signature from minisign secret key
|
||||
RWQkliYstQBOKFQFQTjmCd6TPw07VZyWFSB3v4+1BM1kv8eHLE5FDy2OkPEqtdaL53xftlrHoJQie0uCcovdlSV8kpyxiLrxEQ0=
|
||||
trusted comment: timestamp:1605618622 file:vulnerabilities.json
|
||||
osAPs4QPdDkmiWQxqeMIzYv/b+ZGxJ+19Sbrk1Cpq4t2gHBT+lqFtwL3OCzKWWyjGRTmHfsVGBYpzEdPRQ0/BQ==
|
||||
RWQkliYstQBOKNoyq2O98hPmeVJQ6ShQLM58+4n0gkY0y0trFMDAsHuN/l4IyHfh8dDQ1ry0+IuZVrf/i8M/P3YFzFfAymDYCQ0=
|
||||
trusted comment: timestamp:1752094703 file:data.json
|
||||
cNyq3ZGlqo785HtWODb9ejWqF0HhSeXuLGXzC7z1IhnDrBObWBJngYd3qBG1dQcYlHQ+bgB/On5mSyMFn4UoCQ==
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
untrusted comment: Here's a comment
|
||||
RWQkliYstQBOKFQFQTjmCd6TPw07VZyWFSB3v4+1BM1kv8eHLE5FDy2OkPEqtdaL53xftlrHoJQie0uCcovdlSV8kpyxiLrxEQ0=
|
||||
RWQkliYstQBOKNoyq2O98hPmeVJQ6ShQLM58+4n0gkY0y0trFMDAsHuN/l4IyHfh8dDQ1ry0+IuZVrf/i8M/P3YFzFfAymDYCQ0=
|
||||
trusted comment: Here's a trusted comment
|
||||
3CnkIuz9MEDa7uNyGZAbKZhuirwfiqm7E1uQHrd2SiO4Y8+Akw9vs052AyKw0s5nhbYHCZE2IMQdHNjKwxEGAQ==
|
||||
dL7lO8sqFFCOXJO/u8SgoDk2nlXGWPRDbOTJkChMbmtUp9PB7sG831basXkZ/0CQ/l/vG7AbPyMNEVZyJn5NCg==
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
untrusted comment: One more (untrusted) comment
|
||||
RWQkliYstQBOKFQFQTjmCd6TPw07VZyWFSB3v4+1BM1kv8eHLE5FDy2OkPEqtdaL53xftlrHoJQie0uCcovdlSV8kpyxiLrxEQ0=
|
||||
untrusted comment: One more (untrusted™) comment
|
||||
RWQkliYstQBOKNoyq2O98hPmeVJQ6ShQLM58+4n0gkY0y0trFMDAsHuN/l4IyHfh8dDQ1ry0+IuZVrf/i8M/P3YFzFfAymDYCQ0=
|
||||
trusted comment: Here's a trusted comment
|
||||
3CnkIuz9MEDa7uNyGZAbKZhuirwfiqm7E1uQHrd2SiO4Y8+Akw9vs052AyKw0s5nhbYHCZE2IMQdHNjKwxEGAQ==
|
||||
dL7lO8sqFFCOXJO/u8SgoDk2nlXGWPRDbOTJkChMbmtUp9PB7sG831basXkZ/0CQ/l/vG7AbPyMNEVZyJn5NCg==
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
untrusted comment: verify with ./signifykey.pub
|
||||
RWSKLNhZb0KdAbhRUhW2LQZXdnwttu2SYhM9EuC4mMgOJB85h7/YIPupf8/ldTs4N8e9Y/fhgdY40q5LQpt5IFC62fq0v8U1/w8=
|
||||
untrusted comment: verify with signifykey.pub
|
||||
RWSKLNhZb0KdARbMcGN40hbHzKQYZDgDOFhEUT1YpzMnqre/mbKJ8td/HVlG03Am1YCszATiI0DbnljjTy4iNHYwqBfzrFUqUg0=
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
untrusted comment: signature from minisign secret key
|
||||
RWQkliYstQBOKFQFQTjmCd6TPw07VZyWFSB3v4+1BM1kv8eHLE5FDy2OkPEqtdaL53xftlrHoJQie0uCcovdlSV8kpyxiLrxEQ0=
|
||||
trusted comment: timestamp:1605618622 file:vulnerabilities.json
|
||||
osAPs4QPdDkmiWQxqeMIzYv/b+ZGxJ+19Sbrk1Cpq4t2gHBT+lqFtwL3OCzKWWyjGRTmHfsVGBYpzEdPRQ0/BQ==
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
untrusted comment: Here's a comment
|
||||
RWQkliYstQBOKFQFQTjmCd6TPw07VZyWFSB3v4+1BM1kv8eHLE5FDy2OkPEqtdaL53xftlrHoJQie0uCcovdlSV8kpyxiLrxEQ0=
|
||||
trusted comment: Here's a trusted comment
|
||||
3CnkIuz9MEDa7uNyGZAbKZhuirwfiqm7E1uQHrd2SiO4Y8+Akw9vs052AyKw0s5nhbYHCZE2IMQdHNjKwxEGAQ==
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
untrusted comment: One more (untrusted) comment
|
||||
RWQkliYstQBOKFQFQTjmCd6TPw07VZyWFSB3v4+1BM1kv8eHLE5FDy2OkPEqtdaL53xftlrHoJQie0uCcovdlSV8kpyxiLrxEQ0=
|
||||
trusted comment: Here's a trusted comment
|
||||
3CnkIuz9MEDa7uNyGZAbKZhuirwfiqm7E1uQHrd2SiO4Y8+Akw9vs052AyKw0s5nhbYHCZE2IMQdHNjKwxEGAQ==
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
"description": "A mining flaw could cause miners to erroneously calculate PoW, due to an index overflow, if DAG size is exceeding the maximum 32 bit unsigned value.\n\nThis occurred on the ETC chain on 2020-11-06. This is likely to trigger for ETH mainnet around block `11550000`/epoch `385`, slated to occur early January 2021.\n\nThis issue is relevant only for miners, non-mining nodes are unaffected, since non-mining nodes use a smaller verification cache instead of a full DAG.",
|
||||
"links": [
|
||||
"https://github.com/ethereum/go-ethereum/pull/21793",
|
||||
"https://blog.ethereum.org/2020/11/12/geth_security_release/",
|
||||
"https://blog.ethereum.org/2020/11/12/geth-security-release",
|
||||
"https://github.com/ethereum/go-ethereum/commit/567d41d9363706b4b13ce0903804e8acf214af49",
|
||||
"https://github.com/ethereum/go-ethereum/security/advisories/GHSA-v592-xf75-856p"
|
||||
],
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
"summary": "A denial-of-service issue can be used to crash Geth nodes during block processing, due to an underlying bug in Go (CVE-2020-28362) versions < `1.15.5`, or `<1.14.12`",
|
||||
"description": "The DoS issue can be used to crash all Geth nodes during block processing, the effects of which would be that a major part of the Ethereum network went offline.\n\nOutside of Go-Ethereum, the issue is most likely relevant for all forks of Geth (such as TurboGeth or ETC’s core-geth) which is built with versions of Go which contains the vulnerability.",
|
||||
"links": [
|
||||
"https://blog.ethereum.org/2020/11/12/geth_security_release/",
|
||||
"https://blog.ethereum.org/2020/11/12/geth-security-release",
|
||||
"https://groups.google.com/g/golang-announce/c/NpBGTTmKzpM",
|
||||
"https://github.com/golang/go/issues/42552",
|
||||
"https://github.com/ethereum/go-ethereum/security/advisories/GHSA-m6gx-rhvj-fh52"
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
"summary": "A consensus flaw in Geth, related to `datacopy` precompile",
|
||||
"description": "Geth erroneously performed a 'shallow' copy when the precompiled `datacopy` (at `0x00...04`) was invoked. An attacker could deploy a contract that uses the shallow copy to corrupt the contents of the `RETURNDATA`, thus causing a consensus failure.",
|
||||
"links": [
|
||||
"https://blog.ethereum.org/2020/11/12/geth_security_release/",
|
||||
"https://blog.ethereum.org/2020/11/12/geth-security-release",
|
||||
"https://github.com/ethereum/go-ethereum/security/advisories/GHSA-69v6-xc2j-r2jf"
|
||||
],
|
||||
"introduced": "v1.9.7",
|
||||
|
|
@ -57,7 +57,7 @@
|
|||
"summary": "A denial-of-service issue can be used to crash Geth nodes during block processing",
|
||||
"description": "Affected versions suffer from a vulnerability which can be exploited through the `MULMOD` operation, by specifying a modulo of `0`: `mulmod(a,b,0)`, causing a `panic` in the underlying library. \nThe crash was in the `uint256` library, where a buffer [underflowed](https://github.com/holiman/uint256/blob/4ce82e695c10ddad57215bdbeafb68b8c5df2c30/uint256.go#L442).\n\n\tif `d == 0`, `dLen` remains `0`\n\nand https://github.com/holiman/uint256/blob/4ce82e695c10ddad57215bdbeafb68b8c5df2c30/uint256.go#L451 will try to access index `[-1]`.\n\nThe `uint256` library was first merged in this [commit](https://github.com/ethereum/go-ethereum/commit/cf6674539c589f80031f3371a71c6a80addbe454), on 2020-06-08. \nExploiting this vulnerabilty would cause all vulnerable nodes to drop off the network. \n\nThe issue was brought to our attention through a [bug report](https://github.com/ethereum/go-ethereum/issues/21367), showing a `panic` occurring on sync from genesis on the Ropsten network.\n \nIt was estimated that the least obvious way to fix this would be to merge the fix into `uint256`, make a new release of that library and then update the geth-dependency.\n",
|
||||
"links": [
|
||||
"https://blog.ethereum.org/2020/11/12/geth_security_release/",
|
||||
"https://blog.ethereum.org/2020/11/12/geth-security-release",
|
||||
"https://github.com/ethereum/go-ethereum/security/advisories/GHSA-jm5c-rv3w-w83m",
|
||||
"https://github.com/holiman/uint256/releases/tag/v1.1.1",
|
||||
"https://github.com/holiman/uint256/pull/80",
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@ func TestVerification(t *testing.T) {
|
|||
t.Parallel()
|
||||
// For this test, the pubkey is in testdata/vcheck/minisign.pub
|
||||
// (the privkey is `minisign.sec`, if we want to expand this test. Password 'test' )
|
||||
// 1. `minisign -S -l -s ./minisign.sec -m data.json -x ./minisig-sigs/vulnerabilities.json.minisig.1 -c "signature from minisign secret key"`
|
||||
// 2. `minisign -S -l -s ./minisign.sec -m vulnerabilities.json -x ./minisig-sigs/vulnerabilities.json.minisig.2 -c "Here's a comment" -t "Here's a trusted comment"`
|
||||
// 3. minisign -S -l -s ./minisign.sec -m vulnerabilities.json -x ./minisig-sigs/vulnerabilities.json.minisig.3 -c "One more (untrusted™) comment" -t "Here's a trusted comment"
|
||||
pub := "RWQkliYstQBOKOdtClfgC3IypIPX6TAmoEi7beZ4gyR3wsaezvqOMWsp"
|
||||
testVerification(t, pub, "./testdata/vcheck/minisig-sigs/")
|
||||
})
|
||||
|
|
@ -53,6 +56,7 @@ func TestVerification(t *testing.T) {
|
|||
t.Skip("This currently fails, minisign expects 4 lines of data, signify provides only 2")
|
||||
// For this test, the pubkey is in testdata/vcheck/signifykey.pub
|
||||
// (the privkey is `signifykey.sec`, if we want to expand this test. Password 'test' )
|
||||
// `signify -S -s signifykey.sec -m data.json -x ./signify-sigs/data.json.sig`
|
||||
pub := "RWSKLNhZb0KdATtRT7mZC/bybI3t3+Hv/O2i3ye04Dq9fnT9slpZ1a2/"
|
||||
testVerification(t, pub, "./testdata/vcheck/signify-sigs/")
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1870,7 +1870,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
|||
func MakeBeaconLightConfig(ctx *cli.Context) bparams.ClientConfig {
|
||||
var config bparams.ClientConfig
|
||||
customConfig := ctx.IsSet(BeaconConfigFlag.Name)
|
||||
flags.CheckExclusive(ctx, MainnetFlag, SepoliaFlag, HoleskyFlag, BeaconConfigFlag)
|
||||
flags.CheckExclusive(ctx, MainnetFlag, SepoliaFlag, HoleskyFlag, HoodiFlag, BeaconConfigFlag)
|
||||
switch {
|
||||
case ctx.Bool(MainnetFlag.Name):
|
||||
config.ChainConfig = *bparams.MainnetLightConfig
|
||||
|
|
@ -2009,9 +2009,9 @@ func RegisterFilterAPI(stack *node.Node, backend ethapi.Backend, ethcfg *ethconf
|
|||
}
|
||||
|
||||
// RegisterFullSyncTester adds the full-sync tester service into node.
|
||||
func RegisterFullSyncTester(stack *node.Node, eth *eth.Ethereum, target common.Hash) {
|
||||
catalyst.RegisterFullSyncTester(stack, eth, target)
|
||||
log.Info("Registered full-sync tester", "hash", target)
|
||||
func RegisterFullSyncTester(stack *node.Node, eth *eth.Ethereum, target common.Hash, exitWhenSynced bool) {
|
||||
catalyst.RegisterFullSyncTester(stack, eth, target, exitWhenSynced)
|
||||
log.Info("Registered full-sync tester", "hash", target, "exitWhenSynced", exitWhenSynced)
|
||||
}
|
||||
|
||||
// SetupMetrics configures the metrics system.
|
||||
|
|
@ -2209,6 +2209,12 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
|
|||
StateHistory: ctx.Uint64(StateHistoryFlag.Name),
|
||||
// Disable transaction indexing/unindexing.
|
||||
TxLookupLimit: -1,
|
||||
|
||||
// Enables file journaling for the trie database. The journal files will be stored
|
||||
// within the data directory. The corresponding paths will be either:
|
||||
// - DATADIR/triedb/merkle.journal
|
||||
// - DATADIR/triedb/verkle.journal
|
||||
TrieJournalDirectory: stack.ResolvePath("triedb"),
|
||||
}
|
||||
if options.ArchiveMode && !options.Preimages {
|
||||
options.Preimages = true
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import (
|
|||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/params/forks"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -71,52 +70,82 @@ func CalcExcessBlobGas(config *params.ChainConfig, parent *types.Header, headTim
|
|||
parentExcessBlobGas = *parent.ExcessBlobGas
|
||||
parentBlobGasUsed = *parent.BlobGasUsed
|
||||
}
|
||||
excessBlobGas := parentExcessBlobGas + parentBlobGasUsed
|
||||
targetGas := uint64(targetBlobsPerBlock(config, headTimestamp)) * params.BlobTxBlobGasPerBlob
|
||||
var (
|
||||
excessBlobGas = parentExcessBlobGas + parentBlobGasUsed
|
||||
target = targetBlobsPerBlock(config, headTimestamp)
|
||||
targetGas = uint64(target) * params.BlobTxBlobGasPerBlob
|
||||
)
|
||||
if excessBlobGas < targetGas {
|
||||
return 0
|
||||
}
|
||||
if !config.IsOsaka(config.LondonBlock, headTimestamp) {
|
||||
// Pre-Osaka, we use the formula defined by EIP-4844.
|
||||
return excessBlobGas - targetGas
|
||||
}
|
||||
|
||||
// EIP-7918 (post-Osaka) introduces a different formula for computing excess.
|
||||
var (
|
||||
baseCost = big.NewInt(params.BlobBaseCost)
|
||||
reservePrice = baseCost.Mul(baseCost, parent.BaseFee)
|
||||
blobPrice = calcBlobPrice(config, parent)
|
||||
)
|
||||
if reservePrice.Cmp(blobPrice) > 0 {
|
||||
max := MaxBlobsPerBlock(config, headTimestamp)
|
||||
scaledExcess := parentBlobGasUsed * uint64(max-target) / uint64(max)
|
||||
return parentExcessBlobGas + scaledExcess
|
||||
}
|
||||
return excessBlobGas - targetGas
|
||||
}
|
||||
|
||||
// CalcBlobFee calculates the blobfee from the header's excess blob gas field.
|
||||
func CalcBlobFee(config *params.ChainConfig, header *types.Header) *big.Int {
|
||||
var frac uint64
|
||||
switch config.LatestFork(header.Time) {
|
||||
case forks.Osaka:
|
||||
frac = config.BlobScheduleConfig.Osaka.UpdateFraction
|
||||
case forks.Prague, forks.Prague1:
|
||||
frac = config.BlobScheduleConfig.Prague.UpdateFraction
|
||||
case forks.Cancun:
|
||||
frac = config.BlobScheduleConfig.Cancun.UpdateFraction
|
||||
default:
|
||||
blobConfig := latestBlobConfig(config, header.Time)
|
||||
if blobConfig == nil {
|
||||
panic("calculating blob fee on unsupported fork")
|
||||
}
|
||||
return fakeExponential(minBlobGasPrice, new(big.Int).SetUint64(*header.ExcessBlobGas), new(big.Int).SetUint64(frac))
|
||||
return fakeExponential(minBlobGasPrice, new(big.Int).SetUint64(*header.ExcessBlobGas), new(big.Int).SetUint64(blobConfig.UpdateFraction))
|
||||
}
|
||||
|
||||
// MaxBlobsPerBlock returns the max blobs per block for a block at the given timestamp.
|
||||
func MaxBlobsPerBlock(cfg *params.ChainConfig, time uint64) int {
|
||||
if cfg.BlobScheduleConfig == nil {
|
||||
blobConfig := latestBlobConfig(cfg, time)
|
||||
if blobConfig == nil {
|
||||
return 0
|
||||
}
|
||||
return blobConfig.Max
|
||||
}
|
||||
|
||||
func latestBlobConfig(cfg *params.ChainConfig, time uint64) *params.BlobConfig {
|
||||
if cfg.BlobScheduleConfig == nil {
|
||||
return nil
|
||||
}
|
||||
var (
|
||||
london = cfg.LondonBlock
|
||||
s = cfg.BlobScheduleConfig
|
||||
)
|
||||
switch {
|
||||
case cfg.IsBPO5(london, time) && s.BPO5 != nil:
|
||||
return s.BPO5
|
||||
case cfg.IsBPO4(london, time) && s.BPO4 != nil:
|
||||
return s.BPO4
|
||||
case cfg.IsBPO3(london, time) && s.BPO3 != nil:
|
||||
return s.BPO3
|
||||
case cfg.IsBPO2(london, time) && s.BPO2 != nil:
|
||||
return s.BPO2
|
||||
case cfg.IsBPO1(london, time) && s.BPO1 != nil:
|
||||
return s.BPO1
|
||||
case cfg.IsOsaka(london, time) && s.Osaka != nil:
|
||||
return s.Osaka.Max
|
||||
return s.Osaka
|
||||
case cfg.IsPrague(london, time) && s.Prague != nil:
|
||||
return s.Prague.Max
|
||||
return s.Prague
|
||||
case cfg.IsCancun(london, time) && s.Cancun != nil:
|
||||
return s.Cancun.Max
|
||||
return s.Cancun
|
||||
default:
|
||||
return 0
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// MaxBlobsPerBlock returns the maximum blob gas that can be spent in a block at the given timestamp.
|
||||
// MaxBlobGasPerBlock returns the maximum blob gas that can be spent in a block at the given timestamp.
|
||||
func MaxBlobGasPerBlock(cfg *params.ChainConfig, time uint64) uint64 {
|
||||
return uint64(MaxBlobsPerBlock(cfg, time)) * params.BlobTxBlobGasPerBlob
|
||||
}
|
||||
|
|
@ -129,6 +158,16 @@ func LatestMaxBlobsPerBlock(cfg *params.ChainConfig) int {
|
|||
return 0
|
||||
}
|
||||
switch {
|
||||
case s.BPO5 != nil:
|
||||
return s.BPO5.Max
|
||||
case s.BPO4 != nil:
|
||||
return s.BPO4.Max
|
||||
case s.BPO3 != nil:
|
||||
return s.BPO3.Max
|
||||
case s.BPO2 != nil:
|
||||
return s.BPO2.Max
|
||||
case s.BPO1 != nil:
|
||||
return s.BPO1.Max
|
||||
case s.Osaka != nil:
|
||||
return s.Osaka.Max
|
||||
case s.Prague != nil:
|
||||
|
|
@ -142,23 +181,11 @@ func LatestMaxBlobsPerBlock(cfg *params.ChainConfig) int {
|
|||
|
||||
// targetBlobsPerBlock returns the target number of blobs in a block at the given timestamp.
|
||||
func targetBlobsPerBlock(cfg *params.ChainConfig, time uint64) int {
|
||||
if cfg.BlobScheduleConfig == nil {
|
||||
return 0
|
||||
}
|
||||
var (
|
||||
london = cfg.LondonBlock
|
||||
s = cfg.BlobScheduleConfig
|
||||
)
|
||||
switch {
|
||||
case cfg.IsOsaka(london, time) && s.Osaka != nil:
|
||||
return s.Osaka.Target
|
||||
case cfg.IsPrague(london, time) && s.Prague != nil:
|
||||
return s.Prague.Target
|
||||
case cfg.IsCancun(london, time) && s.Cancun != nil:
|
||||
return s.Cancun.Target
|
||||
default:
|
||||
blobConfig := latestBlobConfig(cfg, time)
|
||||
if blobConfig == nil {
|
||||
return 0
|
||||
}
|
||||
return blobConfig.Target
|
||||
}
|
||||
|
||||
// fakeExponential approximates factor * e ** (numerator / denominator) using
|
||||
|
|
@ -177,3 +204,9 @@ func fakeExponential(factor, numerator, denominator *big.Int) *big.Int {
|
|||
}
|
||||
return output.Div(output, denominator)
|
||||
}
|
||||
|
||||
// calcBlobPrice calculates the blob price for a block.
|
||||
func calcBlobPrice(config *params.ChainConfig, header *types.Header) *big.Int {
|
||||
blobBaseFee := CalcBlobFee(config, header)
|
||||
return new(big.Int).Mul(blobBaseFee, big.NewInt(params.BlobTxBlobGasPerBlob))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,3 +127,43 @@ func TestFakeExponential(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCalcExcessBlobGasEIP7918(t *testing.T) {
|
||||
var (
|
||||
cfg = params.MergedTestChainConfig
|
||||
targetBlobs = targetBlobsPerBlock(cfg, *cfg.CancunTime)
|
||||
blobGasTarget = uint64(targetBlobs) * params.BlobTxBlobGasPerBlob
|
||||
)
|
||||
makeHeader := func(parentExcess, parentBaseFee uint64, blobsUsed int) *types.Header {
|
||||
blobGasUsed := uint64(blobsUsed) * params.BlobTxBlobGasPerBlob
|
||||
return &types.Header{
|
||||
BaseFee: big.NewInt(int64(parentBaseFee)),
|
||||
ExcessBlobGas: &parentExcess,
|
||||
BlobGasUsed: &blobGasUsed,
|
||||
}
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
header *types.Header
|
||||
wantExcessGas uint64
|
||||
}{
|
||||
{
|
||||
name: "BelowReservePrice",
|
||||
header: makeHeader(0, 1_000_000_000, targetBlobs),
|
||||
wantExcessGas: blobGasTarget * 3 / 9,
|
||||
},
|
||||
{
|
||||
name: "AboveReservePrice",
|
||||
header: makeHeader(0, 1, targetBlobs),
|
||||
wantExcessGas: 0,
|
||||
},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
got := CalcExcessBlobGas(cfg, tc.header, *cfg.CancunTime)
|
||||
if got != tc.wantExcessGas {
|
||||
t.Fatalf("%s: excess-blob-gas mismatch – have %d, want %d",
|
||||
tc.name, got, tc.wantExcessGas)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,10 @@ func NewBlockValidator(config *params.ChainConfig, blockchain *BlockChain) *Bloc
|
|||
// header's transaction and uncle roots. The headers are assumed to be already
|
||||
// validated at this point. Also it the Prague1 block according to BRIP-0004.
|
||||
func (v *BlockValidator) ValidateBody(block *types.Block) error {
|
||||
// check EIP 7934 RLP-encoded block size cap
|
||||
if v.config.IsOsaka(block.Number(), block.Time()) && block.Size() > params.MaxBlockSize {
|
||||
return ErrBlockOversized
|
||||
}
|
||||
// Check whether the block is already imported.
|
||||
if v.bc.HasBlockAndState(block.Hash(), block.NumberU64()) {
|
||||
return ErrKnownBlock
|
||||
|
|
|
|||
|
|
@ -166,6 +166,7 @@ type BlockChainConfig struct {
|
|||
TrieDirtyLimit int // Memory limit (MB) at which to start flushing dirty trie nodes to disk
|
||||
TrieTimeLimit time.Duration // Time limit after which to flush the current in-memory trie to disk
|
||||
TrieNoAsyncFlush bool // Whether the asynchronous buffer flushing is disallowed
|
||||
TrieJournalDirectory string // Directory path to the journal used for persisting trie data across node restarts
|
||||
|
||||
Preimages bool // Whether to store preimage of trie key to the disk
|
||||
StateHistory uint64 // Number of blocks from head whose state histories are reserved.
|
||||
|
|
@ -246,6 +247,7 @@ func (cfg *BlockChainConfig) triedbConfig(isVerkle bool) *triedb.Config {
|
|||
EnableStateIndexing: cfg.ArchiveMode,
|
||||
TrieCleanSize: cfg.TrieCleanLimit * 1024 * 1024,
|
||||
StateCleanSize: cfg.SnapshotLimit * 1024 * 1024,
|
||||
JournalDirectory: cfg.TrieJournalDirectory,
|
||||
|
||||
// TODO(rjl493456442): The write buffer represents the memory limit used
|
||||
// for flushing both trie data and state data to disk. The config name
|
||||
|
|
|
|||
|
|
@ -91,7 +91,10 @@ func (bc *BlockChain) GetHeaderByNumber(number uint64) *types.Header {
|
|||
|
||||
// GetBlockNumber retrieves the block number associated with a block hash.
|
||||
func (bc *BlockChain) GetBlockNumber(hash common.Hash) *uint64 {
|
||||
return bc.hc.GetBlockNumber(hash)
|
||||
if num, ok := bc.hc.GetBlockNumber(hash); ok {
|
||||
return &num
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetHeadersFrom returns a contiguous segment of headers, in rlp-form, going
|
||||
|
|
@ -107,11 +110,11 @@ func (bc *BlockChain) GetBody(hash common.Hash) *types.Body {
|
|||
if cached, ok := bc.bodyCache.Get(hash); ok {
|
||||
return cached
|
||||
}
|
||||
number := bc.hc.GetBlockNumber(hash)
|
||||
if number == nil {
|
||||
number, ok := bc.hc.GetBlockNumber(hash)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
body := rawdb.ReadBody(bc.db, hash, *number)
|
||||
body := rawdb.ReadBody(bc.db, hash, number)
|
||||
if body == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -127,11 +130,11 @@ func (bc *BlockChain) GetBodyRLP(hash common.Hash) rlp.RawValue {
|
|||
if cached, ok := bc.bodyRLPCache.Get(hash); ok {
|
||||
return cached
|
||||
}
|
||||
number := bc.hc.GetBlockNumber(hash)
|
||||
if number == nil {
|
||||
number, ok := bc.hc.GetBlockNumber(hash)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
body := rawdb.ReadBodyRLP(bc.db, hash, *number)
|
||||
body := rawdb.ReadBodyRLP(bc.db, hash, number)
|
||||
if len(body) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -180,11 +183,11 @@ func (bc *BlockChain) GetBlock(hash common.Hash, number uint64) *types.Block {
|
|||
|
||||
// GetBlockByHash retrieves a block from the database by hash, caching it if found.
|
||||
func (bc *BlockChain) GetBlockByHash(hash common.Hash) *types.Block {
|
||||
number := bc.hc.GetBlockNumber(hash)
|
||||
if number == nil {
|
||||
number, ok := bc.hc.GetBlockNumber(hash)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return bc.GetBlock(hash, *number)
|
||||
return bc.GetBlock(hash, number)
|
||||
}
|
||||
|
||||
// GetBlockByNumber retrieves a block from the database by number, caching it
|
||||
|
|
@ -200,18 +203,18 @@ func (bc *BlockChain) GetBlockByNumber(number uint64) *types.Block {
|
|||
// GetBlocksFromHash returns the block corresponding to hash and up to n-1 ancestors.
|
||||
// [deprecated by eth/62]
|
||||
func (bc *BlockChain) GetBlocksFromHash(hash common.Hash, n int) (blocks []*types.Block) {
|
||||
number := bc.hc.GetBlockNumber(hash)
|
||||
if number == nil {
|
||||
number, ok := bc.hc.GetBlockNumber(hash)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
for i := 0; i < n; i++ {
|
||||
block := bc.GetBlock(hash, *number)
|
||||
block := bc.GetBlock(hash, number)
|
||||
if block == nil {
|
||||
break
|
||||
}
|
||||
blocks = append(blocks, block)
|
||||
hash = block.ParentHash()
|
||||
*number--
|
||||
number--
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -259,15 +262,15 @@ func (bc *BlockChain) GetReceiptsByHash(hash common.Hash) types.Receipts {
|
|||
if receipts, ok := bc.receiptsCache.Get(hash); ok {
|
||||
return receipts
|
||||
}
|
||||
number := rawdb.ReadHeaderNumber(bc.db, hash)
|
||||
if number == nil {
|
||||
number, ok := rawdb.ReadHeaderNumber(bc.db, hash)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
header := bc.GetHeader(hash, *number)
|
||||
header := bc.GetHeader(hash, number)
|
||||
if header == nil {
|
||||
return nil
|
||||
}
|
||||
receipts := rawdb.ReadReceipts(bc.db, hash, *number, header.Time, bc.chainConfig)
|
||||
receipts := rawdb.ReadReceipts(bc.db, hash, number, header.Time, bc.chainConfig)
|
||||
if receipts == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -286,11 +289,11 @@ func (bc *BlockChain) GetRawReceipts(hash common.Hash, number uint64) types.Rece
|
|||
|
||||
// GetReceiptsRLP retrieves the receipts of a block.
|
||||
func (bc *BlockChain) GetReceiptsRLP(hash common.Hash) rlp.RawValue {
|
||||
number := rawdb.ReadHeaderNumber(bc.db, hash)
|
||||
if number == nil {
|
||||
number, ok := rawdb.ReadHeaderNumber(bc.db, hash)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return rawdb.ReadReceiptsRLP(bc.db, hash, *number)
|
||||
return rawdb.ReadReceiptsRLP(bc.db, hash, number)
|
||||
}
|
||||
|
||||
// GetUnclesInChain retrieves all the uncles from a given block backwards until
|
||||
|
|
|
|||
|
|
@ -782,13 +782,13 @@ func testFastVsFullChains(t *testing.T, scheme string) {
|
|||
}
|
||||
|
||||
// Check that hash-to-number mappings are present in all databases.
|
||||
if m := rawdb.ReadHeaderNumber(fastDb, hash); m == nil || *m != num {
|
||||
if m, ok := rawdb.ReadHeaderNumber(fastDb, hash); !ok || m != num {
|
||||
t.Errorf("block #%d [%x]: wrong hash-to-number mapping in fastdb: %v", num, hash, m)
|
||||
}
|
||||
if m := rawdb.ReadHeaderNumber(ancientDb, hash); m == nil || *m != num {
|
||||
if m, ok := rawdb.ReadHeaderNumber(ancientDb, hash); !ok || m != num {
|
||||
t.Errorf("block #%d [%x]: wrong hash-to-number mapping in ancientdb: %v", num, hash, m)
|
||||
}
|
||||
if m := rawdb.ReadHeaderNumber(archiveDb, hash); m == nil || *m != num {
|
||||
if m, ok := rawdb.ReadHeaderNumber(archiveDb, hash); !ok || m != num {
|
||||
t.Errorf("block #%d [%x]: wrong hash-to-number mapping in archivedb: %v", num, hash, m)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ var (
|
|||
|
||||
// ErrNoGenesis is returned when there is no Genesis Block.
|
||||
ErrNoGenesis = errors.New("genesis not found in chain")
|
||||
|
||||
// ErrBlockOversized is returned if the size of the RLP-encoded block
|
||||
// exceeds the cap established by EIP 7934
|
||||
ErrBlockOversized = errors.New("block RLP-encoded size exceeds maximum")
|
||||
)
|
||||
|
||||
// List of evm-call-message pre-checking errors. All state transition messages will
|
||||
|
|
@ -114,6 +118,9 @@ var (
|
|||
// ErrMissingBlobHashes is returned if a blob transaction has no blob hashes.
|
||||
ErrMissingBlobHashes = errors.New("blob transaction missing blob hashes")
|
||||
|
||||
// ErrTooManyBlobs is returned if a blob transaction exceeds the maximum number of blobs.
|
||||
ErrTooManyBlobs = errors.New("blob transaction has too many blobs")
|
||||
|
||||
// ErrBlobTxCreate is returned if a blob transaction has no explicit to field.
|
||||
ErrBlobTxCreate = errors.New("blob transaction of type create")
|
||||
|
||||
|
|
@ -122,6 +129,9 @@ var (
|
|||
// Message validation errors:
|
||||
ErrEmptyAuthList = errors.New("EIP-7702 transaction with empty auth list")
|
||||
ErrSetCodeTxCreate = errors.New("EIP-7702 transaction cannot be used to create contract")
|
||||
|
||||
// -- EIP-7825 errors --
|
||||
ErrGasLimitTooHigh = errors.New("transaction gas limit too high")
|
||||
)
|
||||
|
||||
// EIP-7702 state transition errors.
|
||||
|
|
|
|||
|
|
@ -97,15 +97,15 @@ func NewHeaderChain(chainDb ethdb.Database, config *params.ChainConfig, engine c
|
|||
|
||||
// GetBlockNumber retrieves the block number belonging to the given hash
|
||||
// from the cache or database
|
||||
func (hc *HeaderChain) GetBlockNumber(hash common.Hash) *uint64 {
|
||||
func (hc *HeaderChain) GetBlockNumber(hash common.Hash) (uint64, bool) {
|
||||
if cached, ok := hc.numberCache.Get(hash); ok {
|
||||
return &cached
|
||||
return cached, true
|
||||
}
|
||||
number := rawdb.ReadHeaderNumber(hc.chainDb, hash)
|
||||
if number != nil {
|
||||
hc.numberCache.Add(hash, *number)
|
||||
number, ok := rawdb.ReadHeaderNumber(hc.chainDb, hash)
|
||||
if ok {
|
||||
hc.numberCache.Add(hash, number)
|
||||
}
|
||||
return number
|
||||
return number, ok
|
||||
}
|
||||
|
||||
type headerWriteResult struct {
|
||||
|
|
@ -402,11 +402,11 @@ func (hc *HeaderChain) GetHeader(hash common.Hash, number uint64) *types.Header
|
|||
// GetHeaderByHash retrieves a block header from the database by hash, caching it if
|
||||
// found.
|
||||
func (hc *HeaderChain) GetHeaderByHash(hash common.Hash) *types.Header {
|
||||
number := hc.GetBlockNumber(hash)
|
||||
if number == nil {
|
||||
number, ok := hc.GetBlockNumber(hash)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return hc.GetHeader(hash, *number)
|
||||
return hc.GetHeader(hash, number)
|
||||
}
|
||||
|
||||
// HasHeader checks if a block header is present in the database or not.
|
||||
|
|
|
|||
|
|
@ -143,13 +143,13 @@ func ReadAllCanonicalHashes(db ethdb.Iteratee, from uint64, to uint64, limit int
|
|||
}
|
||||
|
||||
// ReadHeaderNumber returns the header number assigned to a hash.
|
||||
func ReadHeaderNumber(db ethdb.KeyValueReader, hash common.Hash) *uint64 {
|
||||
func ReadHeaderNumber(db ethdb.KeyValueReader, hash common.Hash) (uint64, bool) {
|
||||
data, _ := db.Get(headerNumberKey(hash))
|
||||
if len(data) != 8 {
|
||||
return nil
|
||||
return 0, false
|
||||
}
|
||||
number := binary.BigEndian.Uint64(data)
|
||||
return &number
|
||||
return number, true
|
||||
}
|
||||
|
||||
// WriteHeaderNumber stores the hash->number mapping.
|
||||
|
|
@ -935,11 +935,11 @@ func ReadHeadHeader(db ethdb.Reader) *types.Header {
|
|||
if headHeaderHash == (common.Hash{}) {
|
||||
return nil
|
||||
}
|
||||
headHeaderNumber := ReadHeaderNumber(db, headHeaderHash)
|
||||
if headHeaderNumber == nil {
|
||||
headHeaderNumber, ok := ReadHeaderNumber(db, headHeaderHash)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return ReadHeader(db, headHeaderHash, *headHeaderNumber)
|
||||
return ReadHeader(db, headHeaderHash, headHeaderNumber)
|
||||
}
|
||||
|
||||
// ReadHeadBlock returns the current canonical head block.
|
||||
|
|
@ -948,9 +948,9 @@ func ReadHeadBlock(db ethdb.Reader) *types.Block {
|
|||
if headBlockHash == (common.Hash{}) {
|
||||
return nil
|
||||
}
|
||||
headBlockNumber := ReadHeaderNumber(db, headBlockHash)
|
||||
if headBlockNumber == nil {
|
||||
headBlockNumber, ok := ReadHeaderNumber(db, headBlockHash)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return ReadBlock(db, headBlockHash, *headBlockNumber)
|
||||
return ReadBlock(db, headBlockHash, headBlockNumber)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,11 @@ func DecodeTxLookupEntry(data []byte, db ethdb.Reader) *uint64 {
|
|||
}
|
||||
// Database v4-v5 tx lookup format just stores the hash
|
||||
if len(data) == common.HashLength {
|
||||
return ReadHeaderNumber(db, common.BytesToHash(data))
|
||||
number, ok := ReadHeaderNumber(db, common.BytesToHash(data))
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return &number
|
||||
}
|
||||
// Finally try database v3 tx lookup format
|
||||
var entry LegacyTxLookupEntry
|
||||
|
|
|
|||
|
|
@ -157,14 +157,6 @@ func WriteTrieJournal(db ethdb.KeyValueWriter, journal []byte) {
|
|||
}
|
||||
}
|
||||
|
||||
// DeleteTrieJournal deletes the serialized in-memory trie nodes of layers saved at
|
||||
// the last shutdown.
|
||||
func DeleteTrieJournal(db ethdb.KeyValueWriter) {
|
||||
if err := db.Delete(trieJournalKey); err != nil {
|
||||
log.Crit("Failed to remove tries journal", "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
// ReadStateHistoryMeta retrieves the metadata corresponding to the specified
|
||||
// state history. Compute the position of state history in freezer by minus
|
||||
// one since the id of first state history starts from one(zero for initial
|
||||
|
|
|
|||
|
|
@ -107,12 +107,12 @@ func (f *chainFreezer) readHeadNumber(db ethdb.KeyValueReader) uint64 {
|
|||
log.Error("Head block is not reachable")
|
||||
return 0
|
||||
}
|
||||
number := ReadHeaderNumber(db, hash)
|
||||
if number == nil {
|
||||
number, ok := ReadHeaderNumber(db, hash)
|
||||
if !ok {
|
||||
log.Error("Number of head block is missing")
|
||||
return 0
|
||||
}
|
||||
return *number
|
||||
return number
|
||||
}
|
||||
|
||||
// readFinalizedNumber returns the number of finalized block. 0 is returned
|
||||
|
|
@ -122,12 +122,12 @@ func (f *chainFreezer) readFinalizedNumber(db ethdb.KeyValueReader) uint64 {
|
|||
if hash == (common.Hash{}) {
|
||||
return 0
|
||||
}
|
||||
number := ReadHeaderNumber(db, hash)
|
||||
if number == nil {
|
||||
number, ok := ReadHeaderNumber(db, hash)
|
||||
if !ok {
|
||||
log.Error("Number of finalized block is missing")
|
||||
return 0
|
||||
}
|
||||
return *number
|
||||
return number
|
||||
}
|
||||
|
||||
// freezeThreshold returns the threshold for chain freezing. It's determined
|
||||
|
|
|
|||
|
|
@ -268,7 +268,12 @@ func Open(db ethdb.KeyValueStore, opts OpenOptions) (ethdb.Database, error) {
|
|||
if kvhash, _ := db.Get(headerHashKey(frozen)); len(kvhash) == 0 {
|
||||
// Subsequent header after the freezer limit is missing from the database.
|
||||
// Reject startup if the database has a more recent head.
|
||||
if head := *ReadHeaderNumber(db, ReadHeadHeaderHash(db)); head > frozen-1 {
|
||||
head, ok := ReadHeaderNumber(db, ReadHeadHeaderHash(db))
|
||||
if !ok {
|
||||
printChainMetadata(db)
|
||||
return nil, fmt.Errorf("could not read header number, hash %v", ReadHeadHeaderHash(db))
|
||||
}
|
||||
if head > frozen-1 {
|
||||
// Find the smallest block stored in the key-value store
|
||||
// in range of [frozen, head]
|
||||
var number uint64
|
||||
|
|
|
|||
|
|
@ -25,9 +25,16 @@ import (
|
|||
"github.com/golang/snappy"
|
||||
)
|
||||
|
||||
const (
|
||||
// This is the maximum amount of data that will be buffered in memory
|
||||
// for a single freezer table batch.
|
||||
const freezerBatchBufferLimit = 2 * 1024 * 1024
|
||||
freezerBatchBufferLimit = 2 * 1024 * 1024
|
||||
|
||||
// freezerTableFlushThreshold defines the threshold for triggering a freezer
|
||||
// table sync operation. If the number of accumulated uncommitted items exceeds
|
||||
// this value, a sync will be scheduled.
|
||||
freezerTableFlushThreshold = 512
|
||||
)
|
||||
|
||||
// freezerBatch is a write operation of multiple items on a freezer.
|
||||
type freezerBatch struct {
|
||||
|
|
@ -201,6 +208,7 @@ func (batch *freezerTableBatch) commit() error {
|
|||
|
||||
// Update headBytes of table.
|
||||
batch.t.headBytes += dataSize
|
||||
items := batch.curItem - batch.t.items.Load()
|
||||
batch.t.items.Store(batch.curItem)
|
||||
|
||||
// Update metrics.
|
||||
|
|
@ -208,7 +216,9 @@ func (batch *freezerTableBatch) commit() error {
|
|||
batch.t.writeMeter.Mark(dataSize + indexSize)
|
||||
|
||||
// Periodically sync the table, todo (rjl493456442) make it configurable?
|
||||
if time.Since(batch.t.lastSync) > 30*time.Second {
|
||||
batch.t.uncommitted += items
|
||||
if batch.t.uncommitted > freezerTableFlushThreshold && time.Since(batch.t.lastSync) > 30*time.Second {
|
||||
batch.t.uncommitted = 0
|
||||
batch.t.lastSync = time.Now()
|
||||
return batch.t.Sync()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ type freezerTable struct {
|
|||
tailId uint32 // number of the earliest file
|
||||
|
||||
metadata *freezerTableMeta // metadata of the table
|
||||
uncommitted uint64 // Count of items written without flushing to file
|
||||
lastSync time.Time // Timestamp when the last sync was performed
|
||||
|
||||
headBytes int64 // Number of bytes written to the head file
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ func TestStateProcessorErrors(t *testing.T) {
|
|||
bigNumber := new(big.Int).SetBytes(common.MaxHash.Bytes())
|
||||
tooBigNumber := new(big.Int).Set(bigNumber)
|
||||
tooBigNumber.Add(tooBigNumber, common.Big1)
|
||||
gasLimit := blockchain.CurrentHeader().GasLimit
|
||||
for i, tt := range []struct {
|
||||
txs []*types.Transaction
|
||||
want string
|
||||
|
|
@ -157,9 +158,9 @@ func TestStateProcessorErrors(t *testing.T) {
|
|||
},
|
||||
{ // ErrGasLimitReached
|
||||
txs: []*types.Transaction{
|
||||
makeTx(key1, 0, common.Address{}, big.NewInt(0), 21000000, big.NewInt(875000000), nil),
|
||||
makeTx(key1, 0, common.Address{}, big.NewInt(0), gasLimit+1, big.NewInt(875000000), nil),
|
||||
},
|
||||
want: "could not apply tx 0 [0xbd49d8dadfd47fb846986695f7d4da3f7b2c48c8da82dbc211a26eb124883de9]: gas limit reached",
|
||||
want: "could not apply tx 0 [0xd0fb3ea181e800cd55c4637c55c1f2f78137efb6bb9723e50bda3cad97208db2]: gas limit reached",
|
||||
},
|
||||
{ // ErrInsufficientFundsForTransfer
|
||||
txs: []*types.Transaction{
|
||||
|
|
@ -185,9 +186,9 @@ func TestStateProcessorErrors(t *testing.T) {
|
|||
},
|
||||
{ // ErrGasLimitReached
|
||||
txs: []*types.Transaction{
|
||||
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.TxGas*1000, big.NewInt(875000000), nil),
|
||||
makeTx(key1, 0, common.Address{}, big.NewInt(0), gasLimit+1, big.NewInt(875000000), nil),
|
||||
},
|
||||
want: "could not apply tx 0 [0xbd49d8dadfd47fb846986695f7d4da3f7b2c48c8da82dbc211a26eb124883de9]: gas limit reached",
|
||||
want: "could not apply tx 0 [0xd0fb3ea181e800cd55c4637c55c1f2f78137efb6bb9723e50bda3cad97208db2]: gas limit reached",
|
||||
},
|
||||
{ // ErrFeeCapTooLow
|
||||
txs: []*types.Transaction{
|
||||
|
|
@ -256,6 +257,12 @@ func TestStateProcessorErrors(t *testing.T) {
|
|||
},
|
||||
// ErrSetCodeTxCreate cannot be tested here: it is impossible to create a SetCode-tx with nil `to`.
|
||||
// The EstimateGas API tests test this case.
|
||||
{ // ErrGasLimitTooHigh
|
||||
txs: []*types.Transaction{
|
||||
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.MaxTxGas+1, big.NewInt(875000000), nil),
|
||||
},
|
||||
want: "could not apply tx 0 [0x16505812a6da0b0150593e4d4eb90190ba64816a04b27d19ca926ebd6aff8aa0]: transaction gas limit too high (cap: 16777216, tx: 16777217)",
|
||||
},
|
||||
} {
|
||||
block := GenerateBadBlock(gspec.ToBlock(), beacon.New(ethash.NewFaker()), tt.txs, gspec.Config, false)
|
||||
_, err := blockchain.InsertChain(types.Blocks{block})
|
||||
|
|
|
|||
|
|
@ -379,6 +379,7 @@ func (st *stateTransition) preCheck() error {
|
|||
}
|
||||
}
|
||||
// Check the blob version validity
|
||||
isOsaka := st.evm.ChainConfig().IsOsaka(st.evm.Context.BlockNumber, st.evm.Context.Time)
|
||||
if msg.BlobHashes != nil {
|
||||
// The to field of a blob tx type is mandatory, and a `BlobTx` transaction internally
|
||||
// has it as a non-nillable value, so any msg derived from blob transaction has it non-nil.
|
||||
|
|
@ -389,6 +390,9 @@ func (st *stateTransition) preCheck() error {
|
|||
if len(msg.BlobHashes) == 0 {
|
||||
return ErrMissingBlobHashes
|
||||
}
|
||||
if isOsaka && len(msg.BlobHashes) > params.BlobTxMaxBlobs {
|
||||
return ErrTooManyBlobs
|
||||
}
|
||||
for i, hash := range msg.BlobHashes {
|
||||
if !kzg4844.IsValidVersionedHash(hash[:]) {
|
||||
return fmt.Errorf("blob %d has invalid hash version", i)
|
||||
|
|
@ -419,6 +423,10 @@ func (st *stateTransition) preCheck() error {
|
|||
return fmt.Errorf("%w (sender %v)", ErrEmptyAuthList, msg.From)
|
||||
}
|
||||
}
|
||||
// Verify tx gas limit does not exceed EIP-7825 cap.
|
||||
if isOsaka && msg.GasLimit > params.MaxTxGas {
|
||||
return fmt.Errorf("%w (cap: %d, tx: %d)", ErrGasLimitTooHigh, params.MaxTxGas, msg.GasLimit)
|
||||
}
|
||||
return st.buyGas()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -217,11 +217,11 @@ func (indexer *txIndexer) resolveHead() uint64 {
|
|||
if headBlockHash == (common.Hash{}) {
|
||||
return 0
|
||||
}
|
||||
headBlockNumber := rawdb.ReadHeaderNumber(indexer.db, headBlockHash)
|
||||
if headBlockNumber == nil {
|
||||
headBlockNumber, ok := rawdb.ReadHeaderNumber(indexer.db, headBlockHash)
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
return *headBlockNumber
|
||||
return headBlockNumber
|
||||
}
|
||||
|
||||
// loop is the scheduler of the indexer, assigning indexing/unindexing tasks depending
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ const (
|
|||
// carry. We choose a smaller limit than the protocol-permitted MaxBlobsPerBlock
|
||||
// in order to ensure network and txpool stability.
|
||||
// Note: if you increase this, validation will fail on txMaxSize.
|
||||
maxBlobsPerTx = 7
|
||||
maxBlobsPerTx = params.BlobTxMaxBlobs
|
||||
|
||||
// maxTxsPerAccount is the maximum number of blob transactions admitted from
|
||||
// a single account. The limit is enforced to minimize the DoS potential of
|
||||
|
|
@ -326,10 +326,6 @@ type BlobPool struct {
|
|||
discoverFeed event.Feed // Event feed to send out new tx events on pool discovery (reorg excluded)
|
||||
insertFeed event.Feed // Event feed to send out new tx events on pool inclusion (reorg included)
|
||||
|
||||
// txValidationFn defaults to txpool.ValidateTransaction, but can be
|
||||
// overridden for testing purposes.
|
||||
txValidationFn txpool.ValidationFunction
|
||||
|
||||
lock sync.RWMutex // Mutex protecting the pool during reorg handling
|
||||
}
|
||||
|
||||
|
|
@ -348,7 +344,6 @@ func New(config Config, chain BlockChain, hasPendingAuth func(common.Address) bo
|
|||
lookup: newLookup(),
|
||||
index: make(map[common.Address][]*blobTxMeta),
|
||||
spent: make(map[common.Address]*uint256.Int),
|
||||
txValidationFn: txpool.ValidateTransaction,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1638,6 +1633,11 @@ func (p *BlobPool) Pending(filter txpool.PendingFilter) map[common.Address][]*tx
|
|||
break // blobfee too low, cannot be included, discard rest of txs from the account
|
||||
}
|
||||
}
|
||||
if filter.GasLimitCap != 0 {
|
||||
if tx.execGas > filter.GasLimitCap {
|
||||
break // execution gas limit is too high
|
||||
}
|
||||
}
|
||||
// Transaction was accepted according to the filter, append to the pending list
|
||||
lazies = append(lazies, &txpool.LazyTransaction{
|
||||
Pool: p,
|
||||
|
|
|
|||
|
|
@ -238,11 +238,7 @@ func makeMultiBlobTx(nonce uint64, gasTipCap uint64, gasFeeCap uint64, blobFeeCa
|
|||
BlobFeeCap: uint256.NewInt(blobFeeCap),
|
||||
BlobHashes: blobHashes,
|
||||
Value: uint256.NewInt(100),
|
||||
Sidecar: &types.BlobTxSidecar{
|
||||
Blobs: blobs,
|
||||
Commitments: commitments,
|
||||
Proofs: proofs,
|
||||
},
|
||||
Sidecar: types.NewBlobTxSidecar(types.BlobSidecarVersion0, blobs, commitments, proofs),
|
||||
}
|
||||
return types.MustSignNewTx(key, types.LatestSigner(params.MainnetChainConfig), blobtx)
|
||||
}
|
||||
|
|
@ -265,11 +261,7 @@ func makeUnsignedTxWithTestBlob(nonce uint64, gasTipCap uint64, gasFeeCap uint64
|
|||
BlobFeeCap: uint256.NewInt(blobFeeCap),
|
||||
BlobHashes: []common.Hash{testBlobVHashes[blobIdx]},
|
||||
Value: uint256.NewInt(100),
|
||||
Sidecar: &types.BlobTxSidecar{
|
||||
Blobs: []kzg4844.Blob{*testBlobs[blobIdx]},
|
||||
Commitments: []kzg4844.Commitment{testBlobCommits[blobIdx]},
|
||||
Proofs: []kzg4844.Proof{testBlobProofs[blobIdx]},
|
||||
},
|
||||
Sidecar: types.NewBlobTxSidecar(types.BlobSidecarVersion0, []kzg4844.Blob{*testBlobs[blobIdx]}, []kzg4844.Commitment{testBlobCommits[blobIdx]}, []kzg4844.Proof{testBlobProofs[blobIdx]}),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1199,8 +1191,8 @@ func TestBlobCountLimit(t *testing.T) {
|
|||
|
||||
// Attempt to add transactions.
|
||||
var (
|
||||
tx1 = makeMultiBlobTx(0, 1, 1000, 100, 7, key1)
|
||||
tx2 = makeMultiBlobTx(0, 1, 800, 70, 8, key2)
|
||||
tx1 = makeMultiBlobTx(0, 1, 1000, 100, 6, key1)
|
||||
tx2 = makeMultiBlobTx(0, 1, 800, 70, 7, key2)
|
||||
)
|
||||
errs := pool.Add([]*types.Transaction{tx1, tx2}, true)
|
||||
|
||||
|
|
@ -1732,12 +1724,6 @@ func benchmarkPoolPending(b *testing.B, datacap uint64) {
|
|||
// Make the pool not use disk (just drop everything). This test never reads
|
||||
// back the data, it just iterates over the pool in-memory items
|
||||
pool.store = &fakeBilly{pool.store, 0}
|
||||
// Avoid validation - verifying all blob proofs take significant time
|
||||
// when the capacity is large. The purpose of this bench is to measure assembling
|
||||
// the lazies, not the kzg verifications.
|
||||
pool.txValidationFn = func(tx *types.Transaction, head *types.Header, signer types.Signer, opts *txpool.ValidationOptions) error {
|
||||
return nil // accept all
|
||||
}
|
||||
// Fill the pool up with one random transaction from each account with the
|
||||
// same price and everything to maximize the worst case scenario
|
||||
for i := 0; i < int(capacity); i++ {
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ func (l *limbo) finalize(final *types.Header) {
|
|||
// Just in case there's no final block yet (network not yet merged, weird
|
||||
// restart, sethead, etc), fail gracefully.
|
||||
if final == nil {
|
||||
log.Error("Nil finalized block cannot evict old blobs")
|
||||
log.Warn("Nil finalized block cannot evict old blobs")
|
||||
return
|
||||
}
|
||||
for block, ids := range l.groups {
|
||||
|
|
@ -139,11 +139,11 @@ func (l *limbo) push(tx *types.Transaction, block uint64) error {
|
|||
// If the blobs are already tracked by the limbo, consider it a programming
|
||||
// error. There's not much to do against it, but be loud.
|
||||
if _, ok := l.index[tx.Hash()]; ok {
|
||||
log.Error("Limbo cannot push already tracked blobs", "tx", tx)
|
||||
log.Error("Limbo cannot push already tracked blobs", "tx", tx.Hash())
|
||||
return errors.New("already tracked blob transaction")
|
||||
}
|
||||
if err := l.setAndIndex(tx, block); err != nil {
|
||||
log.Error("Failed to set and index limboed blobs", "tx", tx, "err", err)
|
||||
log.Error("Failed to set and index limboed blobs", "tx", tx.Hash(), "err", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -530,13 +530,21 @@ func (pool *LegacyPool) Pending(filter txpool.PendingFilter) map[common.Address]
|
|||
txs := list.Flatten()
|
||||
|
||||
// If the miner requests tip enforcement, cap the lists now
|
||||
if minTipBig != nil {
|
||||
if minTipBig != nil || filter.GasLimitCap != 0 {
|
||||
for i, tx := range txs {
|
||||
if minTipBig != nil {
|
||||
if tx.EffectiveGasTipIntCmp(minTipBig, baseFeeBig) < 0 {
|
||||
txs = txs[:i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if filter.GasLimitCap != 0 {
|
||||
if tx.Gas() > filter.GasLimitCap {
|
||||
txs = txs[:i]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(txs) > 0 {
|
||||
lazies := make([]*txpool.LazyTransaction, len(txs))
|
||||
|
|
@ -1255,6 +1263,21 @@ func (pool *LegacyPool) runReorg(done chan struct{}, reset *txpoolResetRequest,
|
|||
}
|
||||
pool.mu.Lock()
|
||||
if reset != nil {
|
||||
if reset.newHead != nil && reset.oldHead != nil {
|
||||
// Discard the transactions with the gas limit higher than the cap.
|
||||
if pool.chainconfig.IsOsaka(reset.newHead.Number, reset.newHead.Time) && !pool.chainconfig.IsOsaka(reset.oldHead.Number, reset.oldHead.Time) {
|
||||
var hashes []common.Hash
|
||||
pool.all.Range(func(hash common.Hash, tx *types.Transaction) bool {
|
||||
if tx.Gas() > params.MaxTxGas {
|
||||
hashes = append(hashes, hash)
|
||||
}
|
||||
return true
|
||||
})
|
||||
for _, hash := range hashes {
|
||||
pool.removeTx(hash, true, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Reset from the old head to the new, rescheduling any reorged transactions
|
||||
pool.reset(reset.oldHead, reset.newHead)
|
||||
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ type PendingFilter struct {
|
|||
MinTip *uint256.Int // Minimum miner tip required to include a transaction
|
||||
BaseFee *uint256.Int // Minimum 1559 basefee needed to include a transaction
|
||||
BlobFee *uint256.Int // Minimum 4844 blobfee needed to include a blob transaction
|
||||
GasLimitCap uint64 // Maximum gas can be used for a single transaction execution (0 means no limit)
|
||||
|
||||
OnlyPlainTxs bool // Return only plain EVM transactions (peer-join announces, block space filling)
|
||||
OnlyBlobTxs bool // Return only blob transactions (block blob-space filling)
|
||||
|
|
|
|||
|
|
@ -90,6 +90,9 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
|
|||
if rules.IsShanghai && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize {
|
||||
return fmt.Errorf("%w: code size %v, limit %v", core.ErrMaxInitCodeSizeExceeded, len(tx.Data()), params.MaxInitCodeSize)
|
||||
}
|
||||
if rules.IsOsaka && tx.Gas() > params.MaxTxGas {
|
||||
return fmt.Errorf("%w (cap: %d, tx: %d)", core.ErrGasLimitTooHigh, params.MaxTxGas, tx.Gas())
|
||||
}
|
||||
// Transactions can't be negative. This may never happen using RLP decoded
|
||||
// transactions but may occur for transactions created using the RPC.
|
||||
if tx.Value().Sign() < 0 {
|
||||
|
|
@ -182,7 +185,7 @@ func validateBlobTx(tx *types.Transaction, head *types.Header, opts *ValidationO
|
|||
}
|
||||
|
||||
func validateBlobSidecarLegacy(sidecar *types.BlobTxSidecar, hashes []common.Hash) error {
|
||||
if sidecar.Version != 0 {
|
||||
if sidecar.Version != types.BlobSidecarVersion0 {
|
||||
return fmt.Errorf("invalid sidecar version pre-osaka: %v", sidecar.Version)
|
||||
}
|
||||
if len(sidecar.Proofs) != len(hashes) {
|
||||
|
|
@ -197,7 +200,7 @@ func validateBlobSidecarLegacy(sidecar *types.BlobTxSidecar, hashes []common.Has
|
|||
}
|
||||
|
||||
func validateBlobSidecarOsaka(sidecar *types.BlobTxSidecar, hashes []common.Hash) error {
|
||||
if sidecar.Version != 1 {
|
||||
if sidecar.Version != types.BlobSidecarVersion1 {
|
||||
return fmt.Errorf("invalid sidecar version post-osaka: %v", sidecar.Version)
|
||||
}
|
||||
if len(sidecar.Proofs) != len(hashes)*kzg4844.CellProofsPerBlob {
|
||||
|
|
|
|||
182
core/types/bal/bal.go
Normal file
182
core/types/bal/bal.go
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
// Copyright 2025 The go-ethereum Authors
|
||||
// This file is part of the go-ethereum library.
|
||||
//
|
||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package bal
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"maps"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/holiman/uint256"
|
||||
)
|
||||
|
||||
// CodeChange contains the runtime bytecode deployed at an address and the
|
||||
// transaction index where the deployment took place.
|
||||
type CodeChange struct {
|
||||
TxIndex uint16
|
||||
Code []byte `json:"code,omitempty"`
|
||||
}
|
||||
|
||||
// ConstructionAccountAccess contains post-block account state for mutations as well as
|
||||
// all storage keys that were read during execution. It is used when building block
|
||||
// access list during execution.
|
||||
type ConstructionAccountAccess struct {
|
||||
// StorageWrites is the post-state values of an account's storage slots
|
||||
// that were modified in a block, keyed by the slot key and the tx index
|
||||
// where the modification occurred.
|
||||
StorageWrites map[common.Hash]map[uint16]common.Hash `json:"storageWrites,omitempty"`
|
||||
|
||||
// StorageReads is the set of slot keys that were accessed during block
|
||||
// execution.
|
||||
//
|
||||
// Storage slots which are both read and written (with changed values)
|
||||
// appear only in StorageWrites.
|
||||
StorageReads map[common.Hash]struct{} `json:"storageReads,omitempty"`
|
||||
|
||||
// BalanceChanges contains the post-transaction balances of an account,
|
||||
// keyed by transaction indices where it was changed.
|
||||
BalanceChanges map[uint16]*uint256.Int `json:"balanceChanges,omitempty"`
|
||||
|
||||
// NonceChanges contains the post-state nonce values of an account keyed
|
||||
// by tx index.
|
||||
NonceChanges map[uint16]uint64 `json:"nonceChanges,omitempty"`
|
||||
|
||||
// CodeChange is only set for contract accounts which were deployed in
|
||||
// the block.
|
||||
CodeChange *CodeChange `json:"codeChange,omitempty"`
|
||||
}
|
||||
|
||||
// NewConstructionAccountAccess initializes the account access object.
|
||||
func NewConstructionAccountAccess() *ConstructionAccountAccess {
|
||||
return &ConstructionAccountAccess{
|
||||
StorageWrites: make(map[common.Hash]map[uint16]common.Hash),
|
||||
StorageReads: make(map[common.Hash]struct{}),
|
||||
BalanceChanges: make(map[uint16]*uint256.Int),
|
||||
NonceChanges: make(map[uint16]uint64),
|
||||
}
|
||||
}
|
||||
|
||||
// ConstructionBlockAccessList contains post-block modified state and some state accessed
|
||||
// in execution (account addresses and storage keys).
|
||||
type ConstructionBlockAccessList struct {
|
||||
Accounts map[common.Address]*ConstructionAccountAccess
|
||||
}
|
||||
|
||||
// NewConstructionBlockAccessList instantiates an empty access list.
|
||||
func NewConstructionBlockAccessList() ConstructionBlockAccessList {
|
||||
return ConstructionBlockAccessList{
|
||||
Accounts: make(map[common.Address]*ConstructionAccountAccess),
|
||||
}
|
||||
}
|
||||
|
||||
// AccountRead records the address of an account that has been read during execution.
|
||||
func (b *ConstructionBlockAccessList) AccountRead(addr common.Address) {
|
||||
if _, ok := b.Accounts[addr]; !ok {
|
||||
b.Accounts[addr] = NewConstructionAccountAccess()
|
||||
}
|
||||
}
|
||||
|
||||
// StorageRead records a storage key read during execution.
|
||||
func (b *ConstructionBlockAccessList) StorageRead(address common.Address, key common.Hash) {
|
||||
if _, ok := b.Accounts[address]; !ok {
|
||||
b.Accounts[address] = NewConstructionAccountAccess()
|
||||
}
|
||||
if _, ok := b.Accounts[address].StorageWrites[key]; ok {
|
||||
return
|
||||
}
|
||||
b.Accounts[address].StorageReads[key] = struct{}{}
|
||||
}
|
||||
|
||||
// StorageWrite records the post-transaction value of a mutated storage slot.
|
||||
// The storage slot is removed from the list of read slots.
|
||||
func (b *ConstructionBlockAccessList) StorageWrite(txIdx uint16, address common.Address, key, value common.Hash) {
|
||||
if _, ok := b.Accounts[address]; !ok {
|
||||
b.Accounts[address] = NewConstructionAccountAccess()
|
||||
}
|
||||
if _, ok := b.Accounts[address].StorageWrites[key]; !ok {
|
||||
b.Accounts[address].StorageWrites[key] = make(map[uint16]common.Hash)
|
||||
}
|
||||
b.Accounts[address].StorageWrites[key][txIdx] = value
|
||||
|
||||
delete(b.Accounts[address].StorageReads, key)
|
||||
}
|
||||
|
||||
// CodeChange records the code of a newly-created contract.
|
||||
func (b *ConstructionBlockAccessList) CodeChange(address common.Address, txIndex uint16, code []byte) {
|
||||
if _, ok := b.Accounts[address]; !ok {
|
||||
b.Accounts[address] = NewConstructionAccountAccess()
|
||||
}
|
||||
b.Accounts[address].CodeChange = &CodeChange{
|
||||
TxIndex: txIndex,
|
||||
Code: bytes.Clone(code),
|
||||
}
|
||||
}
|
||||
|
||||
// NonceChange records tx post-state nonce of any contract-like accounts whose
|
||||
// nonce was incremented.
|
||||
func (b *ConstructionBlockAccessList) NonceChange(address common.Address, txIdx uint16, postNonce uint64) {
|
||||
if _, ok := b.Accounts[address]; !ok {
|
||||
b.Accounts[address] = NewConstructionAccountAccess()
|
||||
}
|
||||
b.Accounts[address].NonceChanges[txIdx] = postNonce
|
||||
}
|
||||
|
||||
// BalanceChange records the post-transaction balance of an account whose
|
||||
// balance changed.
|
||||
func (b *ConstructionBlockAccessList) BalanceChange(txIdx uint16, address common.Address, balance *uint256.Int) {
|
||||
if _, ok := b.Accounts[address]; !ok {
|
||||
b.Accounts[address] = NewConstructionAccountAccess()
|
||||
}
|
||||
b.Accounts[address].BalanceChanges[txIdx] = balance.Clone()
|
||||
}
|
||||
|
||||
// PrettyPrint returns a human-readable representation of the access list
|
||||
func (b *ConstructionBlockAccessList) PrettyPrint() string {
|
||||
enc := b.toEncodingObj()
|
||||
return enc.PrettyPrint()
|
||||
}
|
||||
|
||||
// Copy returns a deep copy of the access list.
|
||||
func (b *ConstructionBlockAccessList) Copy() *ConstructionBlockAccessList {
|
||||
res := NewConstructionBlockAccessList()
|
||||
for addr, aa := range b.Accounts {
|
||||
var aaCopy ConstructionAccountAccess
|
||||
|
||||
slotWrites := make(map[common.Hash]map[uint16]common.Hash, len(aa.StorageWrites))
|
||||
for key, m := range aa.StorageWrites {
|
||||
slotWrites[key] = maps.Clone(m)
|
||||
}
|
||||
aaCopy.StorageWrites = slotWrites
|
||||
aaCopy.StorageReads = maps.Clone(aa.StorageReads)
|
||||
|
||||
balances := make(map[uint16]*uint256.Int, len(aa.BalanceChanges))
|
||||
for index, balance := range aa.BalanceChanges {
|
||||
balances[index] = balance.Clone()
|
||||
}
|
||||
aaCopy.BalanceChanges = balances
|
||||
aaCopy.NonceChanges = maps.Clone(aa.NonceChanges)
|
||||
|
||||
if aa.CodeChange != nil {
|
||||
aaCopy.CodeChange = &CodeChange{
|
||||
TxIndex: aa.CodeChange.TxIndex,
|
||||
Code: bytes.Clone(aa.CodeChange.Code),
|
||||
}
|
||||
}
|
||||
res.Accounts[addr] = &aaCopy
|
||||
}
|
||||
return &res
|
||||
}
|
||||
344
core/types/bal/bal_encoding.go
Normal file
344
core/types/bal/bal_encoding.go
Normal file
|
|
@ -0,0 +1,344 @@
|
|||
// Copyright 2025 The go-ethereum Authors
|
||||
// This file is part of the go-ethereum library.
|
||||
//
|
||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package bal
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"cmp"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"maps"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/holiman/uint256"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/ethereum/go-ethereum/rlp/rlpgen -out bal_encoding_rlp_generated.go -type BlockAccessList -decoder
|
||||
|
||||
// These are objects used as input for the access list encoding. They mirror
|
||||
// the spec format.
|
||||
|
||||
// BlockAccessList is the encoding format of ConstructionBlockAccessList.
|
||||
type BlockAccessList struct {
|
||||
Accesses []AccountAccess `ssz-max:"300000"`
|
||||
}
|
||||
|
||||
// Validate returns an error if the contents of the access list are not ordered
|
||||
// according to the spec or any code changes are contained which exceed protocol
|
||||
// max code size.
|
||||
func (e *BlockAccessList) Validate() error {
|
||||
if !slices.IsSortedFunc(e.Accesses, func(a, b AccountAccess) int {
|
||||
return bytes.Compare(a.Address[:], b.Address[:])
|
||||
}) {
|
||||
return errors.New("block access list accounts not in lexicographic order")
|
||||
}
|
||||
for _, entry := range e.Accesses {
|
||||
if err := entry.validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Hash computes the keccak256 hash of the access list
|
||||
func (e *BlockAccessList) Hash() common.Hash {
|
||||
var enc bytes.Buffer
|
||||
err := e.EncodeRLP(&enc)
|
||||
if err != nil {
|
||||
// errors here are related to BAL values exceeding maximum size defined
|
||||
// by the spec. Hard-fail because these cases are not expected to be hit
|
||||
// under reasonable conditions.
|
||||
panic(err)
|
||||
}
|
||||
return crypto.Keccak256Hash(enc.Bytes())
|
||||
}
|
||||
|
||||
// encodeBalance encodes the provided balance into 16-bytes.
|
||||
func encodeBalance(val *uint256.Int) [16]byte {
|
||||
valBytes := val.Bytes()
|
||||
if len(valBytes) > 16 {
|
||||
panic("can't encode value that is greater than 16 bytes in size")
|
||||
}
|
||||
var enc [16]byte
|
||||
copy(enc[16-len(valBytes):], valBytes[:])
|
||||
return enc
|
||||
}
|
||||
|
||||
// encodingBalanceChange is the encoding format of BalanceChange.
|
||||
type encodingBalanceChange struct {
|
||||
TxIdx uint16 `ssz-size:"2"`
|
||||
Balance [16]byte `ssz-size:"16"`
|
||||
}
|
||||
|
||||
// encodingAccountNonce is the encoding format of NonceChange.
|
||||
type encodingAccountNonce struct {
|
||||
TxIdx uint16 `ssz-size:"2"`
|
||||
Nonce uint64 `ssz-size:"8"`
|
||||
}
|
||||
|
||||
// encodingStorageWrite is the encoding format of StorageWrites.
|
||||
type encodingStorageWrite struct {
|
||||
TxIdx uint16
|
||||
ValueAfter [32]byte `ssz-size:"32"`
|
||||
}
|
||||
|
||||
// encodingStorageWrite is the encoding format of SlotWrites.
|
||||
type encodingSlotWrites struct {
|
||||
Slot [32]byte `ssz-size:"32"`
|
||||
Accesses []encodingStorageWrite `ssz-max:"300000"`
|
||||
}
|
||||
|
||||
// validate returns an instance of the encoding-representation slot writes in
|
||||
// working representation.
|
||||
func (e *encodingSlotWrites) validate() error {
|
||||
if slices.IsSortedFunc(e.Accesses, func(a, b encodingStorageWrite) int {
|
||||
return cmp.Compare[uint16](a.TxIdx, b.TxIdx)
|
||||
}) {
|
||||
return nil
|
||||
}
|
||||
return errors.New("storage write tx indices not in order")
|
||||
}
|
||||
|
||||
// AccountAccess is the encoding format of ConstructionAccountAccess.
|
||||
type AccountAccess struct {
|
||||
Address [20]byte `ssz-size:"20"` // 20-byte Ethereum address
|
||||
StorageWrites []encodingSlotWrites `ssz-max:"300000"` // Storage changes (slot -> [tx_index -> new_value])
|
||||
StorageReads [][32]byte `ssz-max:"300000"` // Read-only storage keys
|
||||
BalanceChanges []encodingBalanceChange `ssz-max:"300000"` // Balance changes ([tx_index -> post_balance])
|
||||
NonceChanges []encodingAccountNonce `ssz-max:"300000"` // Nonce changes ([tx_index -> new_nonce])
|
||||
Code []CodeChange `ssz-max:"1"` // Code changes ([tx_index -> new_code])
|
||||
}
|
||||
|
||||
// validate converts the account accesses out of encoding format.
|
||||
// If any of the keys in the encoding object are not ordered according to the
|
||||
// spec, an error is returned.
|
||||
func (e *AccountAccess) validate() error {
|
||||
// Check the storage write slots are sorted in order
|
||||
if !slices.IsSortedFunc(e.StorageWrites, func(a, b encodingSlotWrites) int {
|
||||
return bytes.Compare(a.Slot[:], b.Slot[:])
|
||||
}) {
|
||||
return errors.New("storage writes slots not in lexicographic order")
|
||||
}
|
||||
for _, write := range e.StorageWrites {
|
||||
if err := write.validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Check the storage read slots are sorted in order
|
||||
if !slices.IsSortedFunc(e.StorageReads, func(a, b [32]byte) int {
|
||||
return bytes.Compare(a[:], b[:])
|
||||
}) {
|
||||
return errors.New("storage read slots not in lexicographic order")
|
||||
}
|
||||
|
||||
// Check the balance changes are sorted in order
|
||||
if !slices.IsSortedFunc(e.BalanceChanges, func(a, b encodingBalanceChange) int {
|
||||
return cmp.Compare[uint16](a.TxIdx, b.TxIdx)
|
||||
}) {
|
||||
return errors.New("balance changes not in ascending order by tx index")
|
||||
}
|
||||
|
||||
// Check the nonce changes are sorted in order
|
||||
if !slices.IsSortedFunc(e.NonceChanges, func(a, b encodingAccountNonce) int {
|
||||
return cmp.Compare[uint16](a.TxIdx, b.TxIdx)
|
||||
}) {
|
||||
return errors.New("nonce changes not in ascending order by tx index")
|
||||
}
|
||||
|
||||
// Convert code change
|
||||
if len(e.Code) == 1 {
|
||||
if len(e.Code[0].Code) > params.MaxCodeSize {
|
||||
return fmt.Errorf("code change contained oversized code")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Copy returns a deep copy of the account access
|
||||
func (e *AccountAccess) Copy() AccountAccess {
|
||||
res := AccountAccess{
|
||||
Address: e.Address,
|
||||
StorageReads: slices.Clone(e.StorageReads),
|
||||
BalanceChanges: slices.Clone(e.BalanceChanges),
|
||||
NonceChanges: slices.Clone(e.NonceChanges),
|
||||
}
|
||||
for _, storageWrite := range e.StorageWrites {
|
||||
res.StorageWrites = append(res.StorageWrites, encodingSlotWrites{
|
||||
Slot: storageWrite.Slot,
|
||||
Accesses: slices.Clone(storageWrite.Accesses),
|
||||
})
|
||||
}
|
||||
if len(e.Code) == 1 {
|
||||
res.Code = []CodeChange{
|
||||
{
|
||||
e.Code[0].TxIndex,
|
||||
bytes.Clone(e.Code[0].Code),
|
||||
},
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// EncodeRLP returns the RLP-encoded access list
|
||||
func (b *ConstructionBlockAccessList) EncodeRLP(wr io.Writer) error {
|
||||
return b.toEncodingObj().EncodeRLP(wr)
|
||||
}
|
||||
|
||||
var _ rlp.Encoder = &ConstructionBlockAccessList{}
|
||||
|
||||
// toEncodingObj creates an instance of the ConstructionAccountAccess of the type that is
|
||||
// used as input for the encoding.
|
||||
func (a *ConstructionAccountAccess) toEncodingObj(addr common.Address) AccountAccess {
|
||||
res := AccountAccess{
|
||||
Address: addr,
|
||||
StorageWrites: make([]encodingSlotWrites, 0),
|
||||
StorageReads: make([][32]byte, 0),
|
||||
BalanceChanges: make([]encodingBalanceChange, 0),
|
||||
NonceChanges: make([]encodingAccountNonce, 0),
|
||||
Code: nil,
|
||||
}
|
||||
|
||||
// Convert write slots
|
||||
writeSlots := slices.Collect(maps.Keys(a.StorageWrites))
|
||||
slices.SortFunc(writeSlots, common.Hash.Cmp)
|
||||
for _, slot := range writeSlots {
|
||||
var obj encodingSlotWrites
|
||||
obj.Slot = slot
|
||||
|
||||
slotWrites := a.StorageWrites[slot]
|
||||
obj.Accesses = make([]encodingStorageWrite, 0, len(slotWrites))
|
||||
|
||||
indices := slices.Collect(maps.Keys(slotWrites))
|
||||
slices.SortFunc(indices, cmp.Compare[uint16])
|
||||
for _, index := range indices {
|
||||
obj.Accesses = append(obj.Accesses, encodingStorageWrite{
|
||||
TxIdx: index,
|
||||
ValueAfter: slotWrites[index],
|
||||
})
|
||||
}
|
||||
res.StorageWrites = append(res.StorageWrites, obj)
|
||||
}
|
||||
|
||||
// Convert read slots
|
||||
readSlots := slices.Collect(maps.Keys(a.StorageReads))
|
||||
slices.SortFunc(readSlots, common.Hash.Cmp)
|
||||
for _, slot := range readSlots {
|
||||
res.StorageReads = append(res.StorageReads, slot)
|
||||
}
|
||||
|
||||
// Convert balance changes
|
||||
balanceIndices := slices.Collect(maps.Keys(a.BalanceChanges))
|
||||
slices.SortFunc(balanceIndices, cmp.Compare[uint16])
|
||||
for _, idx := range balanceIndices {
|
||||
res.BalanceChanges = append(res.BalanceChanges, encodingBalanceChange{
|
||||
TxIdx: idx,
|
||||
Balance: encodeBalance(a.BalanceChanges[idx]),
|
||||
})
|
||||
}
|
||||
|
||||
// Convert nonce changes
|
||||
nonceIndices := slices.Collect(maps.Keys(a.NonceChanges))
|
||||
slices.SortFunc(nonceIndices, cmp.Compare[uint16])
|
||||
for _, idx := range nonceIndices {
|
||||
res.NonceChanges = append(res.NonceChanges, encodingAccountNonce{
|
||||
TxIdx: idx,
|
||||
Nonce: a.NonceChanges[idx],
|
||||
})
|
||||
}
|
||||
|
||||
// Convert code change
|
||||
if a.CodeChange != nil {
|
||||
res.Code = []CodeChange{
|
||||
{
|
||||
a.CodeChange.TxIndex,
|
||||
bytes.Clone(a.CodeChange.Code),
|
||||
},
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// toEncodingObj returns an instance of the access list expressed as the type
|
||||
// which is used as input for the encoding/decoding.
|
||||
func (b *ConstructionBlockAccessList) toEncodingObj() *BlockAccessList {
|
||||
var addresses []common.Address
|
||||
for addr := range b.Accounts {
|
||||
addresses = append(addresses, addr)
|
||||
}
|
||||
slices.SortFunc(addresses, common.Address.Cmp)
|
||||
|
||||
var res BlockAccessList
|
||||
for _, addr := range addresses {
|
||||
res.Accesses = append(res.Accesses, b.Accounts[addr].toEncodingObj(addr))
|
||||
}
|
||||
return &res
|
||||
}
|
||||
|
||||
func (e *BlockAccessList) PrettyPrint() string {
|
||||
var res bytes.Buffer
|
||||
printWithIndent := func(indent int, text string) {
|
||||
fmt.Fprintf(&res, "%s%s\n", strings.Repeat(" ", indent), text)
|
||||
}
|
||||
for _, accountDiff := range e.Accesses {
|
||||
printWithIndent(0, fmt.Sprintf("%x:", accountDiff.Address))
|
||||
|
||||
printWithIndent(1, "storage writes:")
|
||||
for _, sWrite := range accountDiff.StorageWrites {
|
||||
printWithIndent(2, fmt.Sprintf("%x:", sWrite.Slot))
|
||||
for _, access := range sWrite.Accesses {
|
||||
printWithIndent(3, fmt.Sprintf("%d: %x", access.TxIdx, access.ValueAfter))
|
||||
}
|
||||
}
|
||||
|
||||
printWithIndent(1, "storage reads:")
|
||||
for _, slot := range accountDiff.StorageReads {
|
||||
printWithIndent(2, fmt.Sprintf("%x", slot))
|
||||
}
|
||||
|
||||
printWithIndent(1, "balance changes:")
|
||||
for _, change := range accountDiff.BalanceChanges {
|
||||
balance := new(uint256.Int).SetBytes(change.Balance[:]).String()
|
||||
printWithIndent(2, fmt.Sprintf("%d: %s", change.TxIdx, balance))
|
||||
}
|
||||
|
||||
printWithIndent(1, "nonce changes:")
|
||||
for _, change := range accountDiff.NonceChanges {
|
||||
printWithIndent(2, fmt.Sprintf("%d: %d", change.TxIdx, change.Nonce))
|
||||
}
|
||||
|
||||
if len(accountDiff.Code) > 0 {
|
||||
printWithIndent(1, "code:")
|
||||
printWithIndent(2, fmt.Sprintf("%d: %x", accountDiff.Code[0].TxIndex, accountDiff.Code[0].Code))
|
||||
}
|
||||
}
|
||||
return res.String()
|
||||
}
|
||||
|
||||
// Copy returns a deep copy of the access list
|
||||
func (e *BlockAccessList) Copy() (res BlockAccessList) {
|
||||
for _, accountAccess := range e.Accesses {
|
||||
res.Accesses = append(res.Accesses, accountAccess.Copy())
|
||||
}
|
||||
return
|
||||
}
|
||||
280
core/types/bal/bal_encoding_rlp_generated.go
Normal file
280
core/types/bal/bal_encoding_rlp_generated.go
Normal file
|
|
@ -0,0 +1,280 @@
|
|||
// Code generated by rlpgen. DO NOT EDIT.
|
||||
|
||||
package bal
|
||||
|
||||
import "github.com/ethereum/go-ethereum/rlp"
|
||||
import "io"
|
||||
|
||||
func (obj *BlockAccessList) EncodeRLP(_w io.Writer) error {
|
||||
w := rlp.NewEncoderBuffer(_w)
|
||||
_tmp0 := w.List()
|
||||
_tmp1 := w.List()
|
||||
for _, _tmp2 := range obj.Accesses {
|
||||
_tmp3 := w.List()
|
||||
w.WriteBytes(_tmp2.Address[:])
|
||||
_tmp4 := w.List()
|
||||
for _, _tmp5 := range _tmp2.StorageWrites {
|
||||
_tmp6 := w.List()
|
||||
w.WriteBytes(_tmp5.Slot[:])
|
||||
_tmp7 := w.List()
|
||||
for _, _tmp8 := range _tmp5.Accesses {
|
||||
_tmp9 := w.List()
|
||||
w.WriteUint64(uint64(_tmp8.TxIdx))
|
||||
w.WriteBytes(_tmp8.ValueAfter[:])
|
||||
w.ListEnd(_tmp9)
|
||||
}
|
||||
w.ListEnd(_tmp7)
|
||||
w.ListEnd(_tmp6)
|
||||
}
|
||||
w.ListEnd(_tmp4)
|
||||
_tmp10 := w.List()
|
||||
for _, _tmp11 := range _tmp2.StorageReads {
|
||||
w.WriteBytes(_tmp11[:])
|
||||
}
|
||||
w.ListEnd(_tmp10)
|
||||
_tmp12 := w.List()
|
||||
for _, _tmp13 := range _tmp2.BalanceChanges {
|
||||
_tmp14 := w.List()
|
||||
w.WriteUint64(uint64(_tmp13.TxIdx))
|
||||
w.WriteBytes(_tmp13.Balance[:])
|
||||
w.ListEnd(_tmp14)
|
||||
}
|
||||
w.ListEnd(_tmp12)
|
||||
_tmp15 := w.List()
|
||||
for _, _tmp16 := range _tmp2.NonceChanges {
|
||||
_tmp17 := w.List()
|
||||
w.WriteUint64(uint64(_tmp16.TxIdx))
|
||||
w.WriteUint64(_tmp16.Nonce)
|
||||
w.ListEnd(_tmp17)
|
||||
}
|
||||
w.ListEnd(_tmp15)
|
||||
_tmp18 := w.List()
|
||||
for _, _tmp19 := range _tmp2.Code {
|
||||
_tmp20 := w.List()
|
||||
w.WriteUint64(uint64(_tmp19.TxIndex))
|
||||
w.WriteBytes(_tmp19.Code)
|
||||
w.ListEnd(_tmp20)
|
||||
}
|
||||
w.ListEnd(_tmp18)
|
||||
w.ListEnd(_tmp3)
|
||||
}
|
||||
w.ListEnd(_tmp1)
|
||||
w.ListEnd(_tmp0)
|
||||
return w.Flush()
|
||||
}
|
||||
|
||||
func (obj *BlockAccessList) DecodeRLP(dec *rlp.Stream) error {
|
||||
var _tmp0 BlockAccessList
|
||||
{
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
// Accesses:
|
||||
var _tmp1 []AccountAccess
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
for dec.MoreDataInList() {
|
||||
var _tmp2 AccountAccess
|
||||
{
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
// Address:
|
||||
var _tmp3 [20]byte
|
||||
if err := dec.ReadBytes(_tmp3[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp2.Address = _tmp3
|
||||
// StorageWrites:
|
||||
var _tmp4 []encodingSlotWrites
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
for dec.MoreDataInList() {
|
||||
var _tmp5 encodingSlotWrites
|
||||
{
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
// Slot:
|
||||
var _tmp6 [32]byte
|
||||
if err := dec.ReadBytes(_tmp6[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp5.Slot = _tmp6
|
||||
// Accesses:
|
||||
var _tmp7 []encodingStorageWrite
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
for dec.MoreDataInList() {
|
||||
var _tmp8 encodingStorageWrite
|
||||
{
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
// TxIdx:
|
||||
_tmp9, err := dec.Uint16()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp8.TxIdx = _tmp9
|
||||
// ValueAfter:
|
||||
var _tmp10 [32]byte
|
||||
if err := dec.ReadBytes(_tmp10[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp8.ValueAfter = _tmp10
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_tmp7 = append(_tmp7, _tmp8)
|
||||
}
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp5.Accesses = _tmp7
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_tmp4 = append(_tmp4, _tmp5)
|
||||
}
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp2.StorageWrites = _tmp4
|
||||
// StorageReads:
|
||||
var _tmp11 [][32]byte
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
for dec.MoreDataInList() {
|
||||
var _tmp12 [32]byte
|
||||
if err := dec.ReadBytes(_tmp12[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp11 = append(_tmp11, _tmp12)
|
||||
}
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp2.StorageReads = _tmp11
|
||||
// BalanceChanges:
|
||||
var _tmp13 []encodingBalanceChange
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
for dec.MoreDataInList() {
|
||||
var _tmp14 encodingBalanceChange
|
||||
{
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
// TxIdx:
|
||||
_tmp15, err := dec.Uint16()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp14.TxIdx = _tmp15
|
||||
// Balance:
|
||||
var _tmp16 [16]byte
|
||||
if err := dec.ReadBytes(_tmp16[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp14.Balance = _tmp16
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_tmp13 = append(_tmp13, _tmp14)
|
||||
}
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp2.BalanceChanges = _tmp13
|
||||
// NonceChanges:
|
||||
var _tmp17 []encodingAccountNonce
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
for dec.MoreDataInList() {
|
||||
var _tmp18 encodingAccountNonce
|
||||
{
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
// TxIdx:
|
||||
_tmp19, err := dec.Uint16()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp18.TxIdx = _tmp19
|
||||
// Nonce:
|
||||
_tmp20, err := dec.Uint64()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp18.Nonce = _tmp20
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_tmp17 = append(_tmp17, _tmp18)
|
||||
}
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp2.NonceChanges = _tmp17
|
||||
// Code:
|
||||
var _tmp21 []CodeChange
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
for dec.MoreDataInList() {
|
||||
var _tmp22 CodeChange
|
||||
{
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
// TxIndex:
|
||||
_tmp23, err := dec.Uint16()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp22.TxIndex = _tmp23
|
||||
// Code:
|
||||
_tmp24, err := dec.Bytes()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp22.Code = _tmp24
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_tmp21 = append(_tmp21, _tmp22)
|
||||
}
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp2.Code = _tmp21
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_tmp1 = append(_tmp1, _tmp2)
|
||||
}
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp0.Accesses = _tmp1
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
*obj = _tmp0
|
||||
return nil
|
||||
}
|
||||
252
core/types/bal/bal_test.go
Normal file
252
core/types/bal/bal_test.go
Normal file
|
|
@ -0,0 +1,252 @@
|
|||
// Copyright 2025 The go-ethereum Authors
|
||||
// This file is part of the go-ethereum library.
|
||||
//
|
||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package bal
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"cmp"
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/internal/testrand"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/holiman/uint256"
|
||||
)
|
||||
|
||||
func equalBALs(a *BlockAccessList, b *BlockAccessList) bool {
|
||||
if !reflect.DeepEqual(a, b) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func makeTestConstructionBAL() *ConstructionBlockAccessList {
|
||||
return &ConstructionBlockAccessList{
|
||||
map[common.Address]*ConstructionAccountAccess{
|
||||
common.BytesToAddress([]byte{0xff, 0xff}): {
|
||||
StorageWrites: map[common.Hash]map[uint16]common.Hash{
|
||||
common.BytesToHash([]byte{0x01}): {
|
||||
1: common.BytesToHash([]byte{1, 2, 3, 4}),
|
||||
2: common.BytesToHash([]byte{1, 2, 3, 4, 5, 6}),
|
||||
},
|
||||
common.BytesToHash([]byte{0x10}): {
|
||||
20: common.BytesToHash([]byte{1, 2, 3, 4}),
|
||||
},
|
||||
},
|
||||
StorageReads: map[common.Hash]struct{}{
|
||||
common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7}): {},
|
||||
},
|
||||
BalanceChanges: map[uint16]*uint256.Int{
|
||||
1: uint256.NewInt(100),
|
||||
2: uint256.NewInt(500),
|
||||
},
|
||||
NonceChanges: map[uint16]uint64{
|
||||
1: 2,
|
||||
2: 6,
|
||||
},
|
||||
CodeChange: &CodeChange{
|
||||
TxIndex: 0,
|
||||
Code: common.Hex2Bytes("deadbeef"),
|
||||
},
|
||||
},
|
||||
common.BytesToAddress([]byte{0xff, 0xff, 0xff}): {
|
||||
StorageWrites: map[common.Hash]map[uint16]common.Hash{
|
||||
common.BytesToHash([]byte{0x01}): {
|
||||
2: common.BytesToHash([]byte{1, 2, 3, 4, 5, 6}),
|
||||
3: common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7, 8}),
|
||||
},
|
||||
common.BytesToHash([]byte{0x10}): {
|
||||
21: common.BytesToHash([]byte{1, 2, 3, 4, 5}),
|
||||
},
|
||||
},
|
||||
StorageReads: map[common.Hash]struct{}{
|
||||
common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7, 8}): {},
|
||||
},
|
||||
BalanceChanges: map[uint16]*uint256.Int{
|
||||
2: uint256.NewInt(100),
|
||||
3: uint256.NewInt(500),
|
||||
},
|
||||
NonceChanges: map[uint16]uint64{
|
||||
1: 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// TestBALEncoding tests that a populated access list can be encoded/decoded correctly.
|
||||
func TestBALEncoding(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
bal := makeTestConstructionBAL()
|
||||
err := bal.EncodeRLP(&buf)
|
||||
if err != nil {
|
||||
t.Fatalf("encoding failed: %v\n", err)
|
||||
}
|
||||
var dec BlockAccessList
|
||||
if err := dec.DecodeRLP(rlp.NewStream(bytes.NewReader(buf.Bytes()), 10000000)); err != nil {
|
||||
t.Fatalf("decoding failed: %v\n", err)
|
||||
}
|
||||
if dec.Hash() != bal.toEncodingObj().Hash() {
|
||||
t.Fatalf("encoded block hash doesn't match decoded")
|
||||
}
|
||||
if !equalBALs(bal.toEncodingObj(), &dec) {
|
||||
t.Fatal("decoded BAL doesn't match")
|
||||
}
|
||||
}
|
||||
|
||||
func makeTestAccountAccess(sort bool) AccountAccess {
|
||||
var (
|
||||
storageWrites []encodingSlotWrites
|
||||
storageReads [][32]byte
|
||||
balances []encodingBalanceChange
|
||||
nonces []encodingAccountNonce
|
||||
)
|
||||
for i := 0; i < 5; i++ {
|
||||
slot := encodingSlotWrites{
|
||||
Slot: testrand.Hash(),
|
||||
}
|
||||
for j := 0; j < 3; j++ {
|
||||
slot.Accesses = append(slot.Accesses, encodingStorageWrite{
|
||||
TxIdx: uint16(2 * j),
|
||||
ValueAfter: testrand.Hash(),
|
||||
})
|
||||
}
|
||||
if sort {
|
||||
slices.SortFunc(slot.Accesses, func(a, b encodingStorageWrite) int {
|
||||
return cmp.Compare[uint16](a.TxIdx, b.TxIdx)
|
||||
})
|
||||
}
|
||||
storageWrites = append(storageWrites, slot)
|
||||
}
|
||||
if sort {
|
||||
slices.SortFunc(storageWrites, func(a, b encodingSlotWrites) int {
|
||||
return bytes.Compare(a.Slot[:], b.Slot[:])
|
||||
})
|
||||
}
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
storageReads = append(storageReads, testrand.Hash())
|
||||
}
|
||||
if sort {
|
||||
slices.SortFunc(storageReads, func(a, b [32]byte) int {
|
||||
return bytes.Compare(a[:], b[:])
|
||||
})
|
||||
}
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
balances = append(balances, encodingBalanceChange{
|
||||
TxIdx: uint16(2 * i),
|
||||
Balance: [16]byte(testrand.Bytes(16)),
|
||||
})
|
||||
}
|
||||
if sort {
|
||||
slices.SortFunc(balances, func(a, b encodingBalanceChange) int {
|
||||
return cmp.Compare[uint16](a.TxIdx, b.TxIdx)
|
||||
})
|
||||
}
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
nonces = append(nonces, encodingAccountNonce{
|
||||
TxIdx: uint16(2 * i),
|
||||
Nonce: uint64(i + 100),
|
||||
})
|
||||
}
|
||||
if sort {
|
||||
slices.SortFunc(nonces, func(a, b encodingAccountNonce) int {
|
||||
return cmp.Compare[uint16](a.TxIdx, b.TxIdx)
|
||||
})
|
||||
}
|
||||
|
||||
return AccountAccess{
|
||||
Address: [20]byte(testrand.Bytes(20)),
|
||||
StorageWrites: storageWrites,
|
||||
StorageReads: storageReads,
|
||||
BalanceChanges: balances,
|
||||
NonceChanges: nonces,
|
||||
Code: []CodeChange{
|
||||
{
|
||||
TxIndex: 100,
|
||||
Code: testrand.Bytes(256),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func makeTestBAL(sort bool) BlockAccessList {
|
||||
list := BlockAccessList{}
|
||||
for i := 0; i < 5; i++ {
|
||||
list.Accesses = append(list.Accesses, makeTestAccountAccess(sort))
|
||||
}
|
||||
if sort {
|
||||
slices.SortFunc(list.Accesses, func(a, b AccountAccess) int {
|
||||
return bytes.Compare(a.Address[:], b.Address[:])
|
||||
})
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
func TestBlockAccessListCopy(t *testing.T) {
|
||||
list := makeTestBAL(true)
|
||||
cpy := list.Copy()
|
||||
cpyCpy := cpy.Copy()
|
||||
|
||||
if !reflect.DeepEqual(list, cpy) {
|
||||
t.Fatal("block access mismatch")
|
||||
}
|
||||
if !reflect.DeepEqual(cpy, cpyCpy) {
|
||||
t.Fatal("block access mismatch")
|
||||
}
|
||||
|
||||
// Make sure the mutations on copy won't affect the origin
|
||||
for _, aa := range cpyCpy.Accesses {
|
||||
for i := 0; i < len(aa.StorageReads); i++ {
|
||||
aa.StorageReads[i] = [32]byte(testrand.Bytes(32))
|
||||
}
|
||||
}
|
||||
if !reflect.DeepEqual(list, cpy) {
|
||||
t.Fatal("block access mismatch")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBlockAccessListValidation(t *testing.T) {
|
||||
// Validate the block access list after RLP decoding
|
||||
enc := makeTestBAL(true)
|
||||
if err := enc.Validate(); err != nil {
|
||||
t.Fatalf("Unexpected validation error: %v", err)
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
if err := enc.EncodeRLP(&buf); err != nil {
|
||||
t.Fatalf("Unexpected encoding error: %v", err)
|
||||
}
|
||||
|
||||
var dec BlockAccessList
|
||||
if err := dec.DecodeRLP(rlp.NewStream(bytes.NewReader(buf.Bytes()), 0)); err != nil {
|
||||
t.Fatalf("Unexpected RLP-decode error: %v", err)
|
||||
}
|
||||
if err := dec.Validate(); err != nil {
|
||||
t.Fatalf("Unexpected validation error: %v", err)
|
||||
}
|
||||
|
||||
// Validate the derived block access list
|
||||
cBAL := makeTestConstructionBAL()
|
||||
listB := cBAL.toEncodingObj()
|
||||
if err := listB.Validate(); err != nil {
|
||||
t.Fatalf("Unexpected validation error: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
@ -24,11 +24,13 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/common/math"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/internal/blocktest"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/holiman/uint256"
|
||||
)
|
||||
|
||||
// from bcValidBlockTest.json, "SimpleTx"
|
||||
|
|
@ -194,6 +196,60 @@ func TestEIP2718BlockEncoding(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestEIP4844BlockEncoding(t *testing.T) {
|
||||
// https://github.com/ethereum/tests/blob/develop/BlockchainTests/ValidBlocks/bcEIP4844-blobtransactions/blockWithAllTransactionTypes.json
|
||||
blockEnc := common.FromHex("0xf90417f90244a05eb7f6da0f3e237c62bcae48b7fb5f4506d392616b62890429c8b76b4a1d4104a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794ba5e000000000000000000000000000000000000a011639dcca0b44f2acb5b630a82c8a69cb82742b3711383ec4e111a554d27aea5a05cb644f722e31f9792a8ef6e2a762334e1a862e8b40c1612e1e9507fd7121ef9a00c82719448356ba6807d6edfcd8e5aea575a5e97f36038ffb3e395749b26d41cb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800188016345785d8a00008301482082079e42a00000000000000000000000000000000000000000000000000000000000020000880000000000000000820314a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b4218302000080a00000000000000000000000000000000000000000000000000000000000000000f901cbf864808203e885e8d4a5100094100000000000000000000000000000000000000a01801ca09de4adda6288582a6700dbcd8eb70c0a4a7fc9487d965f7bf22424e0bd121095a01cdb078764cc3770d5db847e99e10333aa7c356247baaf09b03eae04d64e7926b86901f86601018203e885e8d4a5100094100000000000000000000000000000000000000a0380c080a025090740da12684493e4fb466a3979e365b194e8cf462edf3c2c3be2f130bb2ea034fa18fb4c1bff4d957d72e28535d27f1352517a942aeaca0ed944085f0cd8bbb86a02f8670102018203e885e8d4a5100094100000000000000000000000000000000000000a0580c080a0352a7be5002ce111bc5167f3addf97a75e2e0b810d826af71d2caae18aed284ea065d38f8a5c8948ce706842e8861fb21020b93a4d5e489162a0e6d419a457b735b88c03f8890103018203e885e8d4a5100094100000000000000000000000000000000000000a0780c00ae1a001a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8809f638144c46d5de7a9e630c0e7c5c63ae829ecfd8cc94715d9c29fe17c464de0a06c5fc54c3aa868ba35ef31a4e12431611631ab7bcdceb4214dd273d83f73b5e1c0c0")
|
||||
var block Block
|
||||
if err := rlp.DecodeBytes(blockEnc, &block); err != nil {
|
||||
t.Fatal("decode error: ", err)
|
||||
}
|
||||
|
||||
check := func(f string, got, want interface{}) {
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("%s mismatch: got %v, want %v", f, got, want)
|
||||
}
|
||||
}
|
||||
check("Difficulty", block.Difficulty(), big.NewInt(0))
|
||||
check("GasLimit", block.GasLimit(), hexutil.MustDecodeUint64("0x16345785d8a0000"))
|
||||
check("GasUsed", block.GasUsed(), hexutil.MustDecodeUint64("0x14820"))
|
||||
check("Coinbase", block.Coinbase(), common.HexToAddress("0xba5e000000000000000000000000000000000000"))
|
||||
check("MixDigest", block.MixDigest(), common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000020000"))
|
||||
check("Root", block.Root(), common.HexToHash("0x11639dcca0b44f2acb5b630a82c8a69cb82742b3711383ec4e111a554d27aea5"))
|
||||
check("WithdrawalRoot", *block.Header().WithdrawalsHash, common.HexToHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"))
|
||||
check("Nonce", block.Nonce(), uint64(0))
|
||||
check("Time", block.Time(), hexutil.MustDecodeUint64("0x79e"))
|
||||
check("Size", block.Size(), uint64(len(blockEnc)))
|
||||
|
||||
// Create blob tx.
|
||||
tx := NewTx(&BlobTx{
|
||||
ChainID: uint256.NewInt(1),
|
||||
Nonce: 3,
|
||||
To: common.HexToAddress("0x100000000000000000000000000000000000000a"),
|
||||
Gas: hexutil.MustDecodeUint64("0xe8d4a51000"),
|
||||
GasTipCap: uint256.MustFromHex("0x1"),
|
||||
GasFeeCap: uint256.MustFromHex("0x3e8"),
|
||||
BlobFeeCap: uint256.MustFromHex("0xa"),
|
||||
BlobHashes: []common.Hash{
|
||||
common.BytesToHash(hexutil.MustDecode("0x01a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8")),
|
||||
},
|
||||
Value: uint256.MustFromHex("0x7"),
|
||||
})
|
||||
sig := common.Hex2Bytes("00638144c46d5de7a9e630c0e7c5c63ae829ecfd8cc94715d9c29fe17c464de06c5fc54c3aa868ba35ef31a4e12431611631ab7bcdceb4214dd273d83f73b5e100")
|
||||
tx, _ = tx.WithSignature(LatestSignerForChainID(big.NewInt(1)), sig)
|
||||
|
||||
check("len(Transactions)", len(block.Transactions()), 4)
|
||||
check("Transactions[3].Hash", block.Transactions()[3].Hash(), tx.Hash())
|
||||
check("Transactions[3].Type()", block.Transactions()[3].Type(), uint8(BlobTxType))
|
||||
|
||||
ourBlockEnc, err := rlp.EncodeToBytes(&block)
|
||||
if err != nil {
|
||||
t.Fatal("encode error: ", err)
|
||||
}
|
||||
if !bytes.Equal(ourBlockEnc, blockEnc) {
|
||||
t.Errorf("encoded block mismatch:\ngot: %x\nwant: %x", ourBlockEnc, blockEnc)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUncleHash(t *testing.T) {
|
||||
uncles := make([]*Header, 0)
|
||||
h := CalcUncleHash(uncles)
|
||||
|
|
|
|||
|
|
@ -454,14 +454,18 @@ func (tx *Transaction) BlobGasFeeCapIntCmp(other *big.Int) int {
|
|||
// WithoutBlobTxSidecar returns a copy of tx with the blob sidecar removed.
|
||||
func (tx *Transaction) WithoutBlobTxSidecar() *Transaction {
|
||||
blobtx, ok := tx.inner.(*BlobTx)
|
||||
if !ok {
|
||||
if !ok || blobtx.Sidecar == nil {
|
||||
return tx
|
||||
}
|
||||
cpy := &Transaction{
|
||||
inner: blobtx.withoutSidecar(),
|
||||
time: tx.time,
|
||||
}
|
||||
// Note: tx.size cache not carried over because the sidecar is included in size!
|
||||
if size := tx.size.Load(); size != 0 {
|
||||
// The tx had a sidecar before, so we need to subtract it from the size.
|
||||
scSize := rlp.ListSize(blobtx.Sidecar.encodedSize())
|
||||
cpy.size.Store(size - scSize)
|
||||
}
|
||||
if h := tx.hash.Load(); h != nil {
|
||||
cpy.hash.Store(h)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"slices"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
|
@ -32,6 +31,18 @@ import (
|
|||
"github.com/holiman/uint256"
|
||||
)
|
||||
|
||||
const (
|
||||
// BlobSidecarVersion0 includes a single proof for verifying the entire blob
|
||||
// against its commitment. Used when the full blob is available and needs to
|
||||
// be checked as a whole.
|
||||
BlobSidecarVersion0 = byte(0)
|
||||
|
||||
// BlobSidecarVersion1 includes multiple cell proofs for verifying specific
|
||||
// blob elements (cells). Used in scenarios like data availability sampling,
|
||||
// where only portions of the blob are verified individually.
|
||||
BlobSidecarVersion1 = byte(1)
|
||||
)
|
||||
|
||||
// BlobTx represents an EIP-4844 transaction.
|
||||
type BlobTx struct {
|
||||
ChainID *uint256.Int
|
||||
|
|
@ -64,6 +75,16 @@ type BlobTxSidecar struct {
|
|||
Proofs []kzg4844.Proof // Proofs needed by the blob pool
|
||||
}
|
||||
|
||||
// NewBlobTxSidecar initialises the BlobTxSidecar object with the provided parameters.
|
||||
func NewBlobTxSidecar(version byte, blobs []kzg4844.Blob, commitments []kzg4844.Commitment, proofs []kzg4844.Proof) *BlobTxSidecar {
|
||||
return &BlobTxSidecar{
|
||||
Version: version,
|
||||
Blobs: blobs,
|
||||
Commitments: commitments,
|
||||
Proofs: proofs,
|
||||
}
|
||||
}
|
||||
|
||||
// BlobHashes computes the blob hashes of the given blobs.
|
||||
func (sc *BlobTxSidecar) BlobHashes() []common.Hash {
|
||||
hasher := sha256.New()
|
||||
|
|
@ -75,17 +96,38 @@ func (sc *BlobTxSidecar) BlobHashes() []common.Hash {
|
|||
}
|
||||
|
||||
// CellProofsAt returns the cell proofs for blob with index idx.
|
||||
func (sc *BlobTxSidecar) CellProofsAt(idx int) []kzg4844.Proof {
|
||||
var cellProofs []kzg4844.Proof
|
||||
for i := range kzg4844.CellProofsPerBlob {
|
||||
index := idx*kzg4844.CellProofsPerBlob + i
|
||||
if index > len(sc.Proofs) {
|
||||
// This method is only valid for sidecars with version 1.
|
||||
func (sc *BlobTxSidecar) CellProofsAt(idx int) ([]kzg4844.Proof, error) {
|
||||
if sc.Version != BlobSidecarVersion1 {
|
||||
return nil, fmt.Errorf("cell proof unsupported, version: %d", sc.Version)
|
||||
}
|
||||
if idx < 0 || idx >= len(sc.Blobs) {
|
||||
return nil, fmt.Errorf("cell proof out of bounds, index: %d, blobs: %d", idx, len(sc.Blobs))
|
||||
}
|
||||
index := idx * kzg4844.CellProofsPerBlob
|
||||
if len(sc.Proofs) < index+kzg4844.CellProofsPerBlob {
|
||||
return nil, fmt.Errorf("cell proof is corrupted, index: %d, proofs: %d", idx, len(sc.Proofs))
|
||||
}
|
||||
return sc.Proofs[index : index+kzg4844.CellProofsPerBlob], nil
|
||||
}
|
||||
|
||||
// ToV1 converts the BlobSidecar to version 1, attaching the cell proofs.
|
||||
func (sc *BlobTxSidecar) ToV1() error {
|
||||
if sc.Version == BlobSidecarVersion1 {
|
||||
return nil
|
||||
}
|
||||
proof := sc.Proofs[index]
|
||||
cellProofs = append(cellProofs, proof)
|
||||
if sc.Version == BlobSidecarVersion0 {
|
||||
sc.Proofs = make([]kzg4844.Proof, 0, len(sc.Blobs)*kzg4844.CellProofsPerBlob)
|
||||
for _, blob := range sc.Blobs {
|
||||
cellProofs, err := kzg4844.ComputeCellProofs(&blob)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cellProofs
|
||||
sc.Proofs = append(sc.Proofs, cellProofs...)
|
||||
}
|
||||
sc.Version = BlobSidecarVersion1
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// encodedSize computes the RLP size of the sidecar elements. This does NOT return the
|
||||
|
|
@ -120,6 +162,19 @@ func (sc *BlobTxSidecar) ValidateBlobCommitmentHashes(hashes []common.Hash) erro
|
|||
return nil
|
||||
}
|
||||
|
||||
// Copy returns a deep-copied BlobTxSidecar object.
|
||||
func (sc *BlobTxSidecar) Copy() *BlobTxSidecar {
|
||||
return &BlobTxSidecar{
|
||||
Version: sc.Version,
|
||||
|
||||
// The element of these slice is fix-size byte array,
|
||||
// therefore slices.Clone will actually deep copy by value.
|
||||
Blobs: slices.Clone(sc.Blobs),
|
||||
Commitments: slices.Clone(sc.Commitments),
|
||||
Proofs: slices.Clone(sc.Proofs),
|
||||
}
|
||||
}
|
||||
|
||||
// blobTxWithBlobs represents blob tx with its corresponding sidecar.
|
||||
// This is an interface because sidecars are versioned.
|
||||
type blobTxWithBlobs interface {
|
||||
|
|
@ -147,7 +202,7 @@ func (btx *blobTxWithBlobsV0) tx() *BlobTx {
|
|||
}
|
||||
|
||||
func (btx *blobTxWithBlobsV0) assign(sc *BlobTxSidecar) error {
|
||||
sc.Version = 0
|
||||
sc.Version = BlobSidecarVersion0
|
||||
sc.Blobs = btx.Blobs
|
||||
sc.Commitments = btx.Commitments
|
||||
sc.Proofs = btx.Proofs
|
||||
|
|
@ -159,10 +214,10 @@ func (btx *blobTxWithBlobsV1) tx() *BlobTx {
|
|||
}
|
||||
|
||||
func (btx *blobTxWithBlobsV1) assign(sc *BlobTxSidecar) error {
|
||||
if btx.Version != 1 {
|
||||
if btx.Version != BlobSidecarVersion1 {
|
||||
return fmt.Errorf("unsupported blob tx version %d", btx.Version)
|
||||
}
|
||||
sc.Version = 1
|
||||
sc.Version = BlobSidecarVersion1
|
||||
sc.Blobs = btx.Blobs
|
||||
sc.Commitments = btx.Commitments
|
||||
sc.Proofs = btx.Proofs
|
||||
|
|
@ -216,11 +271,7 @@ func (tx *BlobTx) copy() TxData {
|
|||
cpy.S.Set(tx.S)
|
||||
}
|
||||
if tx.Sidecar != nil {
|
||||
cpy.Sidecar = &BlobTxSidecar{
|
||||
Blobs: slices.Clone(tx.Sidecar.Blobs),
|
||||
Commitments: slices.Clone(tx.Sidecar.Commitments),
|
||||
Proofs: slices.Clone(tx.Sidecar.Proofs),
|
||||
}
|
||||
cpy.Sidecar = tx.Sidecar.Copy()
|
||||
}
|
||||
return cpy
|
||||
}
|
||||
|
|
@ -278,7 +329,7 @@ func (tx *BlobTx) encode(b *bytes.Buffer) error {
|
|||
case tx.Sidecar == nil:
|
||||
return rlp.Encode(b, tx)
|
||||
|
||||
case tx.Sidecar.Version == 0:
|
||||
case tx.Sidecar.Version == BlobSidecarVersion0:
|
||||
return rlp.Encode(b, &blobTxWithBlobsV0{
|
||||
BlobTx: tx,
|
||||
Blobs: tx.Sidecar.Blobs,
|
||||
|
|
@ -286,7 +337,7 @@ func (tx *BlobTx) encode(b *bytes.Buffer) error {
|
|||
Proofs: tx.Sidecar.Proofs,
|
||||
})
|
||||
|
||||
case tx.Sidecar.Version == 1:
|
||||
case tx.Sidecar.Version == BlobSidecarVersion1:
|
||||
return rlp.Encode(b, &blobTxWithBlobsV1{
|
||||
BlobTx: tx,
|
||||
Version: tx.Sidecar.Version,
|
||||
|
|
|
|||
|
|
@ -87,11 +87,7 @@ func createEmptyBlobTx(key *ecdsa.PrivateKey, withSidecar bool) *Transaction {
|
|||
}
|
||||
|
||||
func createEmptyBlobTxInner(withSidecar bool) *BlobTx {
|
||||
sidecar := &BlobTxSidecar{
|
||||
Blobs: []kzg4844.Blob{*emptyBlob},
|
||||
Commitments: []kzg4844.Commitment{emptyBlobCommit},
|
||||
Proofs: []kzg4844.Proof{emptyBlobProof},
|
||||
}
|
||||
sidecar := NewBlobTxSidecar(BlobSidecarVersion0, []kzg4844.Blob{*emptyBlob}, []kzg4844.Commitment{emptyBlobCommit}, []kzg4844.Proof{emptyBlobProof})
|
||||
blobtx := &BlobTx{
|
||||
ChainID: uint256.NewInt(1),
|
||||
Nonce: 5,
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/crypto/blake2b"
|
||||
"github.com/ethereum/go-ethereum/crypto/bn256"
|
||||
"github.com/ethereum/go-ethereum/crypto/kzg4844"
|
||||
"github.com/ethereum/go-ethereum/crypto/secp256r1"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"golang.org/x/crypto/ripemd160"
|
||||
)
|
||||
|
|
@ -161,6 +162,14 @@ var PrecompiledContractsOsaka = PrecompiledContracts{
|
|||
common.BytesToAddress([]byte{0x0f}): &bls12381Pairing{},
|
||||
common.BytesToAddress([]byte{0x10}): &bls12381MapG1{},
|
||||
common.BytesToAddress([]byte{0x11}): &bls12381MapG2{},
|
||||
|
||||
common.BytesToAddress([]byte{0x1, 0x00}): &p256Verify{},
|
||||
}
|
||||
|
||||
// PrecompiledContractsP256Verify contains the precompiled Ethereum
|
||||
// contract specified in EIP-7212. This is exported for testing purposes.
|
||||
var PrecompiledContractsP256Verify = PrecompiledContracts{
|
||||
common.BytesToAddress([]byte{0x1, 0x00}): &p256Verify{},
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
@ -468,7 +477,9 @@ func (c *bigModExp) RequiredGas(input []byte) uint64 {
|
|||
gas.Mul(gas, adjExpLen)
|
||||
}
|
||||
// 2. Different divisor (`GQUADDIVISOR`) (3)
|
||||
if !c.eip7883 {
|
||||
gas.Div(gas, big3)
|
||||
}
|
||||
if gas.BitLen() > 64 {
|
||||
return math.MaxUint64
|
||||
}
|
||||
|
|
@ -1232,3 +1243,31 @@ func kZGToVersionedHash(kzg kzg4844.Commitment) common.Hash {
|
|||
|
||||
return h
|
||||
}
|
||||
|
||||
// P256VERIFY (secp256r1 signature verification)
|
||||
// implemented as a native contract
|
||||
type p256Verify struct{}
|
||||
|
||||
// RequiredGas returns the gas required to execute the precompiled contract
|
||||
func (c *p256Verify) RequiredGas(input []byte) uint64 {
|
||||
return params.P256VerifyGas
|
||||
}
|
||||
|
||||
// Run executes the precompiled contract with given 160 bytes of param, returning the output and the used gas
|
||||
func (c *p256Verify) Run(input []byte) ([]byte, error) {
|
||||
const p256VerifyInputLength = 160
|
||||
if len(input) != p256VerifyInputLength {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Extract hash, r, s, x, y from the input.
|
||||
hash := input[0:32]
|
||||
r, s := new(big.Int).SetBytes(input[32:64]), new(big.Int).SetBytes(input[64:96])
|
||||
x, y := new(big.Int).SetBytes(input[96:128]), new(big.Int).SetBytes(input[128:160])
|
||||
|
||||
// Verify the signature.
|
||||
if secp256r1.Verify(hash, r, s, x, y) {
|
||||
return true32Byte, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ var allPrecompiles = map[common.Address]PrecompiledContract{
|
|||
common.BytesToAddress([]byte{0x0f, 0x0e}): &bls12381Pairing{},
|
||||
common.BytesToAddress([]byte{0x0f, 0x0f}): &bls12381MapG1{},
|
||||
common.BytesToAddress([]byte{0x0f, 0x10}): &bls12381MapG2{},
|
||||
|
||||
common.BytesToAddress([]byte{0x0b}): &p256Verify{},
|
||||
}
|
||||
|
||||
// EIP-152 test vectors
|
||||
|
|
@ -397,3 +399,15 @@ func BenchmarkPrecompiledBLS12381G2MultiExpWorstCase(b *testing.B) {
|
|||
}
|
||||
benchmarkPrecompiled("f0d", testcase, b)
|
||||
}
|
||||
|
||||
// Benchmarks the sample inputs from the P256VERIFY precompile.
|
||||
func BenchmarkPrecompiledP256Verify(bench *testing.B) {
|
||||
t := precompiledTest{
|
||||
Input: "4cee90eb86eaa050036147a12d49004b6b9c72bd725d39d4785011fe190f0b4da73bd4903f0ce3b639bbbf6e8e80d16931ff4bcf5993d58468e8fb19086e8cac36dbcd03009df8c59286b162af3bd7fcc0450c9aa81be5d10d312af6c66b1d604aebd3099c618202fcfe16ae7770b0c49ab5eadf74b754204a3bb6060e44eff37618b065f9832de4ca6ca971a7a1adc826d0f7c00181a5fb2ddf79ae00b4e10e",
|
||||
Expected: "0000000000000000000000000000000000000000000000000000000000000001",
|
||||
Name: "p256Verify",
|
||||
}
|
||||
benchmarkPrecompiled("0b", t, bench)
|
||||
}
|
||||
|
||||
func TestPrecompiledP256Verify(t *testing.T) { testJson("p256Verify", "0b", t) }
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ var activators = map[int]func(*JumpTable){
|
|||
1153: enable1153,
|
||||
4762: enable4762,
|
||||
7702: enable7702,
|
||||
7939: enable7939,
|
||||
}
|
||||
|
||||
// EnableEIP enables the given EIP on the config.
|
||||
|
|
@ -293,6 +294,13 @@ func opBlobBaseFee(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
// opCLZ implements the CLZ opcode (count leading zero bytes)
|
||||
func opCLZ(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
||||
x := scope.Stack.peek()
|
||||
x.SetUint64(256 - uint64(x.BitLen()))
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// enable4844 applies EIP-4844 (BLOBHASH opcode)
|
||||
func enable4844(jt *JumpTable) {
|
||||
jt[BLOBHASH] = &operation{
|
||||
|
|
@ -303,6 +311,16 @@ func enable4844(jt *JumpTable) {
|
|||
}
|
||||
}
|
||||
|
||||
// enable7939 enables EIP-7939 (CLZ opcode)
|
||||
func enable7939(jt *JumpTable) {
|
||||
jt[CLZ] = &operation{
|
||||
execute: opCLZ,
|
||||
constantGas: GasFastStep,
|
||||
minStack: minStack(1, 1),
|
||||
maxStack: maxStack(1, 1),
|
||||
}
|
||||
}
|
||||
|
||||
// enable7516 applies EIP-7516 (BLOBBASEFEE opcode)
|
||||
func enable7516(jt *JumpTable) {
|
||||
jt[BLOBBASEFEE] = &operation{
|
||||
|
|
|
|||
|
|
@ -972,3 +972,43 @@ func TestPush(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpCLZ(t *testing.T) {
|
||||
evm := NewEVM(BlockContext{}, nil, params.TestChainConfig, Config{})
|
||||
|
||||
tests := []struct {
|
||||
inputHex string
|
||||
want uint64 // expected CLZ result
|
||||
}{
|
||||
{"0x0", 256},
|
||||
{"0x1", 255},
|
||||
{"0x6ff", 245}, // 0x6ff = 0b11011111111 (11 bits), so 256-11 = 245
|
||||
{"0xffffffffff", 216}, // 40 bits, so 256-40 = 216
|
||||
{"0x4000000000000000000000000000000000000000000000000000000000000000", 1},
|
||||
{"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1},
|
||||
{"0x8000000000000000000000000000000000000000000000000000000000000000", 0},
|
||||
{"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 0},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
// prepare a fresh stack and PC
|
||||
stack := newstack()
|
||||
pc := uint64(0)
|
||||
|
||||
// parse input
|
||||
val := new(uint256.Int)
|
||||
if err := val.SetFromHex(tc.inputHex); err != nil {
|
||||
t.Fatal("invalid hex uint256:", tc.inputHex)
|
||||
}
|
||||
|
||||
stack.push(val)
|
||||
opCLZ(&pc, evm.interpreter, &ScopeContext{Stack: stack})
|
||||
|
||||
if gotLen := stack.len(); gotLen != 1 {
|
||||
t.Fatalf("stack length = %d; want 1", gotLen)
|
||||
}
|
||||
result := stack.pop()
|
||||
if got := result.Uint64(); got != tc.want {
|
||||
t.Fatalf("clz(%q) = %d; want %d", tc.inputHex, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,6 +106,8 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter {
|
|||
// If jump table was not initialised we set the default one.
|
||||
var table *JumpTable
|
||||
switch {
|
||||
case evm.chainRules.IsOsaka:
|
||||
table = &osakaInstructionSet
|
||||
case evm.chainRules.IsVerkle:
|
||||
// TODO replace with proper instruction set when fork is specified
|
||||
table = &verkleInstructionSet
|
||||
|
|
@ -182,6 +184,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
|||
|
||||
var (
|
||||
op OpCode // current opcode
|
||||
jumpTable *JumpTable = in.table
|
||||
mem = NewMemory() // bound memory
|
||||
stack = newstack() // local stack
|
||||
callContext = &ScopeContext{
|
||||
|
|
@ -227,6 +230,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
|||
// explicit STOP, RETURN or SELFDESTRUCT is executed, an error occurred during
|
||||
// the execution of one of the operations or until the done flag is set by the
|
||||
// parent context.
|
||||
_ = jumpTable[0] // nil-check the jumpTable out of the loop
|
||||
for {
|
||||
if debug {
|
||||
// Capture pre-execution values for tracing.
|
||||
|
|
@ -247,7 +251,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
|||
// Get the operation from the jump table and validate the stack to ensure there are
|
||||
// enough stack items available to perform the operation.
|
||||
op = contract.GetOp(pc)
|
||||
operation := in.table[op]
|
||||
operation := jumpTable[op]
|
||||
cost = operation.constantGas // For tracing
|
||||
// Validate stack
|
||||
if sLen := stack.len(); sLen < operation.minStack {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ var (
|
|||
cancunInstructionSet = newCancunInstructionSet()
|
||||
verkleInstructionSet = newVerkleInstructionSet()
|
||||
pragueInstructionSet = newPragueInstructionSet()
|
||||
osakaInstructionSet = newOsakaInstructionSet()
|
||||
)
|
||||
|
||||
// JumpTable contains the EVM opcodes supported at a given fork.
|
||||
|
|
@ -91,6 +92,12 @@ func newVerkleInstructionSet() JumpTable {
|
|||
return validate(instructionSet)
|
||||
}
|
||||
|
||||
func newOsakaInstructionSet() JumpTable {
|
||||
instructionSet := newPragueInstructionSet()
|
||||
enable7939(&instructionSet) // EIP-7939 (CLZ opcode)
|
||||
return validate(instructionSet)
|
||||
}
|
||||
|
||||
func newPragueInstructionSet() JumpTable {
|
||||
instructionSet := newCancunInstructionSet()
|
||||
enable7702(&instructionSet) // EIP-7702 Setcode transaction type
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ func LookupInstructionSet(rules params.Rules) (JumpTable, error) {
|
|||
case rules.IsVerkle:
|
||||
return newCancunInstructionSet(), errors.New("verkle-fork not defined yet")
|
||||
case rules.IsOsaka:
|
||||
return newPragueInstructionSet(), errors.New("osaka-fork not defined yet")
|
||||
return newOsakaInstructionSet(), nil
|
||||
case rules.IsPrague:
|
||||
return newPragueInstructionSet(), nil
|
||||
case rules.IsCancun:
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ const (
|
|||
SHL OpCode = 0x1b
|
||||
SHR OpCode = 0x1c
|
||||
SAR OpCode = 0x1d
|
||||
CLZ OpCode = 0x1e
|
||||
)
|
||||
|
||||
// 0x20 range - crypto.
|
||||
|
|
@ -282,6 +283,7 @@ var opCodeToString = [256]string{
|
|||
SHL: "SHL",
|
||||
SHR: "SHR",
|
||||
SAR: "SAR",
|
||||
CLZ: "CLZ",
|
||||
ADDMOD: "ADDMOD",
|
||||
MULMOD: "MULMOD",
|
||||
|
||||
|
|
@ -484,6 +486,7 @@ var stringToOp = map[string]OpCode{
|
|||
"SHL": SHL,
|
||||
"SHR": SHR,
|
||||
"SAR": SAR,
|
||||
"CLZ": CLZ,
|
||||
"ADDMOD": ADDMOD,
|
||||
"MULMOD": MULMOD,
|
||||
"KECCAK256": KECCAK256,
|
||||
|
|
|
|||
26
core/vm/testdata/precompiles/modexp_eip7883.json
vendored
26
core/vm/testdata/precompiles/modexp_eip7883.json
vendored
|
|
@ -17,91 +17,91 @@
|
|||
"Input": "000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000040e09ad9675465c53a109fac66a445c91b292d2bb2c5268addb30cd82f80fcb0033ff97c80a5fc6f39193ae969c6ede6710a6b7ac27078a06d90ef1c72e5c85fb5010001fc9e1f6beb81516545975218075ec2af118cd8798df6e08a147c60fd6095ac2bb02c2908cf4dd7c81f11c289e4bce98f3553768f392a80ce22bf5c4f4a248c6b",
|
||||
"Expected": "c36d804180c35d4426b57b50c5bfcca5c01856d104564cd513b461d3c8b8409128a5573e416d0ebe38f5f736766d9dc27143e4da981dfa4d67f7dc474cbee6d2",
|
||||
"Name": "nagydani-1-pow0x10001",
|
||||
"Gas": 682,
|
||||
"Gas": 2048,
|
||||
"NoBenchmark": false
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080cad7d991a00047dd54d3399b6b0b937c718abddef7917c75b6681f40cc15e2be0003657d8d4c34167b2f0bbbca0ccaa407c2a6a07d50f1517a8f22979ce12a81dcaf707cc0cebfc0ce2ee84ee7f77c38b9281b9822a8d3de62784c089c9b18dcb9a2a5eecbede90ea788a862a9ddd9d609c2c52972d63e289e28f6a590ffbf5102e6d893b80aeed5e6e9ce9afa8a5d5675c93a32ac05554cb20e9951b2c140e3ef4e433068cf0fb73bc9f33af1853f64aa27a0028cbf570d7ac9048eae5dc7b28c87c31e5810f1e7fa2cda6adf9f1076dbc1ec1238560071e7efc4e9565c49be9e7656951985860a558a754594115830bcdb421f741408346dd5997bb01c287087",
|
||||
"Expected": "981dd99c3b113fae3e3eaa9435c0dc96779a23c12a53d1084b4f67b0b053a27560f627b873e3f16ad78f28c94f14b6392def26e4d8896c5e3c984e50fa0b3aa44f1da78b913187c6128baa9340b1e9c9a0fd02cb78885e72576da4a8f7e5a113e173a7a2889fde9d407bd9f06eb05bc8fc7b4229377a32941a02bf4edcc06d70",
|
||||
"Name": "nagydani-2-square",
|
||||
"Gas": 500,
|
||||
"Gas": 512,
|
||||
"NoBenchmark": false
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080cad7d991a00047dd54d3399b6b0b937c718abddef7917c75b6681f40cc15e2be0003657d8d4c34167b2f0bbbca0ccaa407c2a6a07d50f1517a8f22979ce12a81dcaf707cc0cebfc0ce2ee84ee7f77c38b9281b9822a8d3de62784c089c9b18dcb9a2a5eecbede90ea788a862a9ddd9d609c2c52972d63e289e28f6a590ffbf5103e6d893b80aeed5e6e9ce9afa8a5d5675c93a32ac05554cb20e9951b2c140e3ef4e433068cf0fb73bc9f33af1853f64aa27a0028cbf570d7ac9048eae5dc7b28c87c31e5810f1e7fa2cda6adf9f1076dbc1ec1238560071e7efc4e9565c49be9e7656951985860a558a754594115830bcdb421f741408346dd5997bb01c287087",
|
||||
"Expected": "d89ceb68c32da4f6364978d62aaa40d7b09b59ec61eb3c0159c87ec3a91037f7dc6967594e530a69d049b64adfa39c8fa208ea970cfe4b7bcd359d345744405afe1cbf761647e32b3184c7fbe87cee8c6c7ff3b378faba6c68b83b6889cb40f1603ee68c56b4c03d48c595c826c041112dc941878f8c5be828154afd4a16311f",
|
||||
"Name": "nagydani-2-qube",
|
||||
"Gas": 500,
|
||||
"Gas": 512,
|
||||
"NoBenchmark": false
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000080cad7d991a00047dd54d3399b6b0b937c718abddef7917c75b6681f40cc15e2be0003657d8d4c34167b2f0bbbca0ccaa407c2a6a07d50f1517a8f22979ce12a81dcaf707cc0cebfc0ce2ee84ee7f77c38b9281b9822a8d3de62784c089c9b18dcb9a2a5eecbede90ea788a862a9ddd9d609c2c52972d63e289e28f6a590ffbf51010001e6d893b80aeed5e6e9ce9afa8a5d5675c93a32ac05554cb20e9951b2c140e3ef4e433068cf0fb73bc9f33af1853f64aa27a0028cbf570d7ac9048eae5dc7b28c87c31e5810f1e7fa2cda6adf9f1076dbc1ec1238560071e7efc4e9565c49be9e7656951985860a558a754594115830bcdb421f741408346dd5997bb01c287087",
|
||||
"Expected": "ad85e8ef13fd1dd46eae44af8b91ad1ccae5b7a1c92944f92a19f21b0b658139e0cabe9c1f679507c2de354bf2c91ebd965d1e633978a830d517d2f6f8dd5fd58065d58559de7e2334a878f8ec6992d9b9e77430d4764e863d77c0f87beede8f2f7f2ab2e7222f85cc9d98b8467f4bb72e87ef2882423ebdb6daf02dddac6db2",
|
||||
"Name": "nagydani-2-pow0x10001",
|
||||
"Gas": 2730,
|
||||
"Gas": 8192,
|
||||
"NoBenchmark": false
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000100c9130579f243e12451760976261416413742bd7c91d39ae087f46794062b8c239f2a74abf3918605a0e046a7890e049475ba7fbb78f5de6490bd22a710cc04d30088179a919d86c2da62cf37f59d8f258d2310d94c24891be2d7eeafaa32a8cb4b0cfe5f475ed778f45907dc8916a73f03635f233f7a77a00a3ec9ca6761a5bbd558a2318ecd0caa1c5016691523e7e1fa267dd35e70c66e84380bdcf7c0582f540174e572c41f81e93da0b757dff0b0fe23eb03aa19af0bdec3afb474216febaacb8d0381e631802683182b0fe72c28392539850650b70509f54980241dc175191a35d967288b532a7a8223ce2440d010615f70df269501944d4ec16fe4a3cb02d7a85909174757835187cb52e71934e6c07ef43b4c46fc30bbcd0bc72913068267c54a4aabebb493922492820babdeb7dc9b1558fcf7bd82c37c82d3147e455b623ab0efa752fe0b3a67ca6e4d126639e645a0bf417568adbb2a6a4eef62fa1fa29b2a5a43bebea1f82193a7dd98eb483d09bb595af1fa9c97c7f41f5649d976aee3e5e59e2329b43b13bea228d4a93f16ba139ccb511de521ffe747aa2eca664f7c9e33da59075cc335afcd2bf3ae09765f01ab5a7c3e3938ec168b74724b5074247d200d9970382f683d6059b94dbc336603d1dfee714e4b447ac2fa1d99ecb4961da2854e03795ed758220312d101e1e3d87d5313a6d052aebde75110363d",
|
||||
"Expected": "affc7507ea6d84751ec6b3f0d7b99dbcc263f33330e450d1b3ff0bc3d0874320bf4edd57debd587306988157958cb3cfd369cc0c9c198706f635c9e0f15d047df5cb44d03e2727f26b083c4ad8485080e1293f171c1ed52aef5993a5815c35108e848c951cf1e334490b4a539a139e57b68f44fee583306f5b85ffa57206b3ee5660458858534e5386b9584af3c7f67806e84c189d695e5eb96e1272d06ec2df5dc5fabc6e94b793718c60c36be0a4d031fc84cd658aa72294b2e16fc240aef70cb9e591248e38bd49c5a554d1afa01f38dab72733092f7555334bbef6c8c430119840492380aa95fa025dcf699f0a39669d812b0c6946b6091e6e235337b6f8",
|
||||
"Name": "nagydani-3-square",
|
||||
"Gas": 682,
|
||||
"Gas": 2048,
|
||||
"NoBenchmark": false
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000100c9130579f243e12451760976261416413742bd7c91d39ae087f46794062b8c239f2a74abf3918605a0e046a7890e049475ba7fbb78f5de6490bd22a710cc04d30088179a919d86c2da62cf37f59d8f258d2310d94c24891be2d7eeafaa32a8cb4b0cfe5f475ed778f45907dc8916a73f03635f233f7a77a00a3ec9ca6761a5bbd558a2318ecd0caa1c5016691523e7e1fa267dd35e70c66e84380bdcf7c0582f540174e572c41f81e93da0b757dff0b0fe23eb03aa19af0bdec3afb474216febaacb8d0381e631802683182b0fe72c28392539850650b70509f54980241dc175191a35d967288b532a7a8223ce2440d010615f70df269501944d4ec16fe4a3cb03d7a85909174757835187cb52e71934e6c07ef43b4c46fc30bbcd0bc72913068267c54a4aabebb493922492820babdeb7dc9b1558fcf7bd82c37c82d3147e455b623ab0efa752fe0b3a67ca6e4d126639e645a0bf417568adbb2a6a4eef62fa1fa29b2a5a43bebea1f82193a7dd98eb483d09bb595af1fa9c97c7f41f5649d976aee3e5e59e2329b43b13bea228d4a93f16ba139ccb511de521ffe747aa2eca664f7c9e33da59075cc335afcd2bf3ae09765f01ab5a7c3e3938ec168b74724b5074247d200d9970382f683d6059b94dbc336603d1dfee714e4b447ac2fa1d99ecb4961da2854e03795ed758220312d101e1e3d87d5313a6d052aebde75110363d",
|
||||
"Expected": "1b280ecd6a6bf906b806d527c2a831e23b238f89da48449003a88ac3ac7150d6a5e9e6b3be4054c7da11dd1e470ec29a606f5115801b5bf53bc1900271d7c3ff3cd5ed790d1c219a9800437a689f2388ba1a11d68f6a8e5b74e9a3b1fac6ee85fc6afbac599f93c391f5dc82a759e3c6c0ab45ce3f5d25d9b0c1bf94cf701ea6466fc9a478dacc5754e593172b5111eeba88557048bceae401337cd4c1182ad9f700852bc8c99933a193f0b94cf1aedbefc48be3bc93ef5cb276d7c2d5462ac8bb0c8fe8923a1db2afe1c6b90d59c534994a6a633f0ead1d638fdc293486bb634ff2c8ec9e7297c04241a61c37e3ae95b11d53343d4ba2b4cc33d2cfa7eb705e",
|
||||
"Name": "nagydani-3-qube",
|
||||
"Gas": 682,
|
||||
"Gas": 2048,
|
||||
"NoBenchmark": false
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000100c9130579f243e12451760976261416413742bd7c91d39ae087f46794062b8c239f2a74abf3918605a0e046a7890e049475ba7fbb78f5de6490bd22a710cc04d30088179a919d86c2da62cf37f59d8f258d2310d94c24891be2d7eeafaa32a8cb4b0cfe5f475ed778f45907dc8916a73f03635f233f7a77a00a3ec9ca6761a5bbd558a2318ecd0caa1c5016691523e7e1fa267dd35e70c66e84380bdcf7c0582f540174e572c41f81e93da0b757dff0b0fe23eb03aa19af0bdec3afb474216febaacb8d0381e631802683182b0fe72c28392539850650b70509f54980241dc175191a35d967288b532a7a8223ce2440d010615f70df269501944d4ec16fe4a3cb010001d7a85909174757835187cb52e71934e6c07ef43b4c46fc30bbcd0bc72913068267c54a4aabebb493922492820babdeb7dc9b1558fcf7bd82c37c82d3147e455b623ab0efa752fe0b3a67ca6e4d126639e645a0bf417568adbb2a6a4eef62fa1fa29b2a5a43bebea1f82193a7dd98eb483d09bb595af1fa9c97c7f41f5649d976aee3e5e59e2329b43b13bea228d4a93f16ba139ccb511de521ffe747aa2eca664f7c9e33da59075cc335afcd2bf3ae09765f01ab5a7c3e3938ec168b74724b5074247d200d9970382f683d6059b94dbc336603d1dfee714e4b447ac2fa1d99ecb4961da2854e03795ed758220312d101e1e3d87d5313a6d052aebde75110363d",
|
||||
"Expected": "37843d7c67920b5f177372fa56e2a09117df585f81df8b300fba245b1175f488c99476019857198ed459ed8d9799c377330e49f4180c4bf8e8f66240c64f65ede93d601f957b95b83efdee1e1bfde74169ff77002eaf078c71815a9220c80b2e3b3ff22c2f358111d816ebf83c2999026b6de50bfc711ff68705d2f40b753424aefc9f70f08d908b5a20276ad613b4ab4309a3ea72f0c17ea9df6b3367d44fb3acab11c333909e02e81ea2ed404a712d3ea96bba87461720e2d98723e7acd0520ac1a5212dbedcd8dc0c1abf61d4719e319ff4758a774790b8d463cdfe131d1b2dcfee52d002694e98e720cb6ae7ccea353bc503269ba35f0f63bf8d7b672a76",
|
||||
"Name": "nagydani-3-pow0x10001",
|
||||
"Gas": 10922,
|
||||
"Gas": 32768,
|
||||
"NoBenchmark": false
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000200db34d0e438249c0ed685c949cc28776a05094e1c48691dc3f2dca5fc3356d2a0663bd376e4712839917eb9a19c670407e2c377a2de385a3ff3b52104f7f1f4e0c7bf7717fb913896693dc5edbb65b760ef1b00e42e9d8f9af17352385e1cd742c9b006c0f669995cb0bb21d28c0aced2892267637b6470d8cee0ab27fc5d42658f6e88240c31d6774aa60a7ebd25cd48b56d0da11209f1928e61005c6eb709f3e8e0aaf8d9b10f7d7e296d772264dc76897ccdddadc91efa91c1903b7232a9e4c3b941917b99a3bc0c26497dedc897c25750af60237aa67934a26a2bc491db3dcc677491944bc1f51d3e5d76b8d846a62db03dedd61ff508f91a56d71028125035c3a44cbb041497c83bf3e4ae2a9613a401cc721c547a2afa3b16a2969933d3626ed6d8a7428648f74122fd3f2a02a20758f7f693892c8fd798b39abac01d18506c45e71432639e9f9505719ee822f62ccbf47f6850f096ff77b5afaf4be7d772025791717dbe5abf9b3f40cff7d7aab6f67e38f62faf510747276e20a42127e7500c444f9ed92baf65ade9e836845e39c4316d9dce5f8e2c8083e2c0acbb95296e05e51aab13b6b8f53f06c9c4276e12b0671133218cc3ea907da3bd9a367096d9202128d14846cc2e20d56fc8473ecb07cecbfb8086919f3971926e7045b853d85a69d026195c70f9f7a823536e2a8f4b3e12e94d9b53a934353451094b8102df3143a0057457d75e8c708b6337a6f5a4fd1a06727acf9fb93e2993c62f3378b37d56c85e7b1e00f0145ebf8e4095bd723166293c60b6ac1252291ef65823c9e040ddad14969b3b340a4ef714db093a587c37766d68b8d6b5016e741587e7e6bf7e763b44f0247e64bae30f994d248bfd20541a333e5b225ef6a61199e301738b1e688f70ec1d7fb892c183c95dc543c3e12adf8a5e8b9ca9d04f9445cced3ab256f29e998e69efaa633a7b60e1db5a867924ccab0a171d9d6e1098dfa15acde9553de599eaa56490c8f411e4985111f3d40bddfc5e301edb01547b01a886550a61158f7e2033c59707789bf7c854181d0c2e2a42a93cf09209747d7082e147eb8544de25c3eb14f2e35559ea0c0f5877f2f3fc92132c0ae9da4e45b2f6c866a224ea6d1f28c05320e287750fbc647368d41116e528014cc1852e5531d53e4af938374daba6cee4baa821ed07117253bb3601ddd00d59a3d7fb2ef1f5a2fbba7c429f0cf9a5b3462410fd833a69118f8be9c559b1000cc608fd877fb43f8e65c2d1302622b944462579056874b387208d90623fcdaf93920ca7a9e4ba64ea208758222ad868501cc2c345e2d3a5ea2a17e5069248138c8a79c0251185d29ee73e5afab5354769142d2bf0cb6712727aa6bf84a6245fcdae66e4938d84d1b9dd09a884818622080ff5f98942fb20acd7e0c916c2d5ea7ce6f7e173315384518f",
|
||||
"Expected": "8a5aea5f50dcc03dc7a7a272b5aeebc040554dbc1ffe36753c4fc75f7ed5f6c2cc0de3a922bf96c78bf0643a73025ad21f45a4a5cadd717612c511ab2bff1190fe5f1ae05ba9f8fe3624de1de2a817da6072ddcdb933b50216811dbe6a9ca79d3a3c6b3a476b079fd0d05f04fb154e2dd3e5cb83b148a006f2bcbf0042efb2ae7b916ea81b27aac25c3bf9a8b6d35440062ad8eae34a83f3ffa2cc7b40346b62174a4422584f72f95316f6b2bee9ff232ba9739301c97c99a9ded26c45d72676eb856ad6ecc81d36a6de36d7f9dafafee11baa43a4b0d5e4ecffa7b9b7dcefd58c397dd373e6db4acd2b2c02717712e6289bed7c813b670c4a0c6735aa7f3b0f1ce556eae9fcc94b501b2c8781ba50a8c6220e8246371c3c7359fe4ef9da786ca7d98256754ca4e496be0a9174bedbecb384bdf470779186d6a833f068d2838a88d90ef3ad48ff963b67c39cc5a3ee123baf7bf3125f64e77af7f30e105d72c4b9b5b237ed251e4c122c6d8c1405e736299c3afd6db16a28c6a9cfa68241e53de4cd388271fe534a6a9b0dbea6171d170db1b89858468885d08fecbd54c8e471c3e25d48e97ba450b96d0d87e00ac732aaa0d3ce4309c1064bd8a4c0808a97e0143e43a24cfa847635125cd41c13e0574487963e9d725c01375db99c31da67b4cf65eff555f0c0ac416c727ff8d438ad7c42030551d68c2e7adda0abb1ca7c10",
|
||||
"Name": "nagydani-4-square",
|
||||
"Gas": 2730,
|
||||
"Gas": 8192,
|
||||
"NoBenchmark": false
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000200db34d0e438249c0ed685c949cc28776a05094e1c48691dc3f2dca5fc3356d2a0663bd376e4712839917eb9a19c670407e2c377a2de385a3ff3b52104f7f1f4e0c7bf7717fb913896693dc5edbb65b760ef1b00e42e9d8f9af17352385e1cd742c9b006c0f669995cb0bb21d28c0aced2892267637b6470d8cee0ab27fc5d42658f6e88240c31d6774aa60a7ebd25cd48b56d0da11209f1928e61005c6eb709f3e8e0aaf8d9b10f7d7e296d772264dc76897ccdddadc91efa91c1903b7232a9e4c3b941917b99a3bc0c26497dedc897c25750af60237aa67934a26a2bc491db3dcc677491944bc1f51d3e5d76b8d846a62db03dedd61ff508f91a56d71028125035c3a44cbb041497c83bf3e4ae2a9613a401cc721c547a2afa3b16a2969933d3626ed6d8a7428648f74122fd3f2a02a20758f7f693892c8fd798b39abac01d18506c45e71432639e9f9505719ee822f62ccbf47f6850f096ff77b5afaf4be7d772025791717dbe5abf9b3f40cff7d7aab6f67e38f62faf510747276e20a42127e7500c444f9ed92baf65ade9e836845e39c4316d9dce5f8e2c8083e2c0acbb95296e05e51aab13b6b8f53f06c9c4276e12b0671133218cc3ea907da3bd9a367096d9202128d14846cc2e20d56fc8473ecb07cecbfb8086919f3971926e7045b853d85a69d026195c70f9f7a823536e2a8f4b3e12e94d9b53a934353451094b8103df3143a0057457d75e8c708b6337a6f5a4fd1a06727acf9fb93e2993c62f3378b37d56c85e7b1e00f0145ebf8e4095bd723166293c60b6ac1252291ef65823c9e040ddad14969b3b340a4ef714db093a587c37766d68b8d6b5016e741587e7e6bf7e763b44f0247e64bae30f994d248bfd20541a333e5b225ef6a61199e301738b1e688f70ec1d7fb892c183c95dc543c3e12adf8a5e8b9ca9d04f9445cced3ab256f29e998e69efaa633a7b60e1db5a867924ccab0a171d9d6e1098dfa15acde9553de599eaa56490c8f411e4985111f3d40bddfc5e301edb01547b01a886550a61158f7e2033c59707789bf7c854181d0c2e2a42a93cf09209747d7082e147eb8544de25c3eb14f2e35559ea0c0f5877f2f3fc92132c0ae9da4e45b2f6c866a224ea6d1f28c05320e287750fbc647368d41116e528014cc1852e5531d53e4af938374daba6cee4baa821ed07117253bb3601ddd00d59a3d7fb2ef1f5a2fbba7c429f0cf9a5b3462410fd833a69118f8be9c559b1000cc608fd877fb43f8e65c2d1302622b944462579056874b387208d90623fcdaf93920ca7a9e4ba64ea208758222ad868501cc2c345e2d3a5ea2a17e5069248138c8a79c0251185d29ee73e5afab5354769142d2bf0cb6712727aa6bf84a6245fcdae66e4938d84d1b9dd09a884818622080ff5f98942fb20acd7e0c916c2d5ea7ce6f7e173315384518f",
|
||||
"Expected": "5a2664252aba2d6e19d9600da582cdd1f09d7a890ac48e6b8da15ae7c6ff1856fc67a841ac2314d283ffa3ca81a0ecf7c27d89ef91a5a893297928f5da0245c99645676b481b7e20a566ee6a4f2481942bee191deec5544600bb2441fd0fb19e2ee7d801ad8911c6b7750affec367a4b29a22942c0f5f4744a4e77a8b654da2a82571037099e9c6d930794efe5cdca73c7b6c0844e386bdca8ea01b3d7807146bb81365e2cdc6475f8c23e0ff84463126189dc9789f72bbce2e3d2d114d728a272f1345122de23df54c922ec7a16e5c2a8f84da8871482bd258c20a7c09bbcd64c7a96a51029bbfe848736a6ba7bf9d931a9b7de0bcaf3635034d4958b20ae9ab3a95a147b0421dd5f7ebff46c971010ebfc4adbbe0ad94d5498c853e7142c450d8c71de4b2f84edbf8acd2e16d00c8115b150b1c30e553dbb82635e781379fe2a56360420ff7e9f70cc64c00aba7e26ed13c7c19622865ae07248daced36416080f35f8cc157a857ed70ea4f347f17d1bee80fa038abd6e39b1ba06b97264388b21364f7c56e192d4b62d9b161405f32ab1e2594e86243e56fcf2cb30d21adef15b9940f91af681da24328c883d892670c6aa47940867a81830a82b82716895db810df1b834640abefb7db2092dd92912cb9a735175bc447be40a503cf22dfe565b4ed7a3293ca0dfd63a507430b323ee248ec82e843b673c97ad730728cebc",
|
||||
"Name": "nagydani-4-qube",
|
||||
"Gas": 2730,
|
||||
"Gas": 8192,
|
||||
"NoBenchmark": false
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000200db34d0e438249c0ed685c949cc28776a05094e1c48691dc3f2dca5fc3356d2a0663bd376e4712839917eb9a19c670407e2c377a2de385a3ff3b52104f7f1f4e0c7bf7717fb913896693dc5edbb65b760ef1b00e42e9d8f9af17352385e1cd742c9b006c0f669995cb0bb21d28c0aced2892267637b6470d8cee0ab27fc5d42658f6e88240c31d6774aa60a7ebd25cd48b56d0da11209f1928e61005c6eb709f3e8e0aaf8d9b10f7d7e296d772264dc76897ccdddadc91efa91c1903b7232a9e4c3b941917b99a3bc0c26497dedc897c25750af60237aa67934a26a2bc491db3dcc677491944bc1f51d3e5d76b8d846a62db03dedd61ff508f91a56d71028125035c3a44cbb041497c83bf3e4ae2a9613a401cc721c547a2afa3b16a2969933d3626ed6d8a7428648f74122fd3f2a02a20758f7f693892c8fd798b39abac01d18506c45e71432639e9f9505719ee822f62ccbf47f6850f096ff77b5afaf4be7d772025791717dbe5abf9b3f40cff7d7aab6f67e38f62faf510747276e20a42127e7500c444f9ed92baf65ade9e836845e39c4316d9dce5f8e2c8083e2c0acbb95296e05e51aab13b6b8f53f06c9c4276e12b0671133218cc3ea907da3bd9a367096d9202128d14846cc2e20d56fc8473ecb07cecbfb8086919f3971926e7045b853d85a69d026195c70f9f7a823536e2a8f4b3e12e94d9b53a934353451094b81010001df3143a0057457d75e8c708b6337a6f5a4fd1a06727acf9fb93e2993c62f3378b37d56c85e7b1e00f0145ebf8e4095bd723166293c60b6ac1252291ef65823c9e040ddad14969b3b340a4ef714db093a587c37766d68b8d6b5016e741587e7e6bf7e763b44f0247e64bae30f994d248bfd20541a333e5b225ef6a61199e301738b1e688f70ec1d7fb892c183c95dc543c3e12adf8a5e8b9ca9d04f9445cced3ab256f29e998e69efaa633a7b60e1db5a867924ccab0a171d9d6e1098dfa15acde9553de599eaa56490c8f411e4985111f3d40bddfc5e301edb01547b01a886550a61158f7e2033c59707789bf7c854181d0c2e2a42a93cf09209747d7082e147eb8544de25c3eb14f2e35559ea0c0f5877f2f3fc92132c0ae9da4e45b2f6c866a224ea6d1f28c05320e287750fbc647368d41116e528014cc1852e5531d53e4af938374daba6cee4baa821ed07117253bb3601ddd00d59a3d7fb2ef1f5a2fbba7c429f0cf9a5b3462410fd833a69118f8be9c559b1000cc608fd877fb43f8e65c2d1302622b944462579056874b387208d90623fcdaf93920ca7a9e4ba64ea208758222ad868501cc2c345e2d3a5ea2a17e5069248138c8a79c0251185d29ee73e5afab5354769142d2bf0cb6712727aa6bf84a6245fcdae66e4938d84d1b9dd09a884818622080ff5f98942fb20acd7e0c916c2d5ea7ce6f7e173315384518f",
|
||||
"Expected": "bed8b970c4a34849fc6926b08e40e20b21c15ed68d18f228904878d4370b56322d0da5789da0318768a374758e6375bfe4641fca5285ec7171828922160f48f5ca7efbfee4d5148612c38ad683ae4e3c3a053d2b7c098cf2b34f2cb19146eadd53c86b2d7ccf3d83b2c370bfb840913ee3879b1057a6b4e07e110b6bcd5e958bc71a14798c91d518cc70abee264b0d25a4110962a764b364ac0b0dd1ee8abc8426d775ec0f22b7e47b32576afaf1b5a48f64573ed1c5c29f50ab412188d9685307323d990802b81dacc06c6e05a1e901830ba9fcc67688dc29c5e27bde0a6e845ca925f5454b6fb3747edfaa2a5820838fb759eadf57f7cb5cec57fc213ddd8a4298fa079c3c0f472b07fb15aa6a7f0a3780bd296ff6a62e58ef443870b02260bd4fd2bbc98255674b8e1f1f9f8d33c7170b0ebbea4523b695911abbf26e41885344823bd0587115fdd83b721a4e8457a31c9a84b3d3520a07e0e35df7f48e5a9d534d0ec7feef1ff74de6a11e7f93eab95175b6ce22c68d78a642ad642837897ec11349205d8593ac19300207572c38d29ca5dfa03bc14cdbc32153c80e5cc3e739403d34c75915e49beb43094cc6dcafb3665b305ddec9286934ae66ec6b777ca528728c851318eb0f207b39f1caaf96db6eeead6b55ed08f451939314577d42bcc9f97c0b52d0234f88fd07e4c1d7780fdebc025cfffcb572cb27a8c33963",
|
||||
"Name": "nagydani-4-pow0x10001",
|
||||
"Gas": 43690,
|
||||
"Gas": 131072,
|
||||
"NoBenchmark": false
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000400c5a1611f8be90071a43db23cc2fe01871cc4c0e8ab5743f6378e4fef77f7f6db0095c0727e20225beb665645403453e325ad5f9aeb9ba99bf3c148f63f9c07cf4fe8847ad5242d6b7d4499f93bd47056ddab8f7dee878fc2314f344dbee2a7c41a5d3db91eff372c730c2fdd3a141a4b61999e36d549b9870cf2f4e632c4d5df5f024f81c028000073a0ed8847cfb0593d36a47142f578f05ccbe28c0c06aeb1b1da027794c48db880278f79ba78ae64eedfea3c07d10e0562668d839749dc95f40467d15cf65b9cfc52c7c4bcef1cda3596dd52631aac942f146c7cebd46065131699ce8385b0db1874336747ee020a5698a3d1a1082665721e769567f579830f9d259cec1a836845109c21cf6b25da572512bf3c42fd4b96e43895589042ab60dd41f497db96aec102087fe784165bb45f942859268fd2ff6c012d9d00c02ba83eace047cc5f7b2c392c2955c58a49f0338d6fc58749c9db2155522ac17914ec216ad87f12e0ee95574613942fa615898c4d9e8a3be68cd6afa4e7a003dedbdf8edfee31162b174f965b20ae752ad89c967b3068b6f722c16b354456ba8e280f987c08e0a52d40a2e8f3a59b94d590aeef01879eb7a90b3ee7d772c839c85519cbeaddc0c193ec4874a463b53fcaea3271d80ebfb39b33489365fc039ae549a17a9ff898eea2f4cb27b8dbee4c17b998438575b2b8d107e4a0d66ba7fca85b41a58a8d51f191a35c856dfbe8aef2b00048a694bbccff832d23c8ca7a7ff0b6c0b3011d00b97c86c0628444d267c951d9e4fb8f83e154b8f74fb51aa16535e498235c5597dac9606ed0be3173a3836baa4e7d756ffe1e2879b415d3846bccd538c05b847785699aefde3e305decb600cd8fb0e7d8de5efc26971a6ad4e6d7a2d91474f1023a0ac4b78dc937da0ce607a45974d2cac1c33a2631ff7fe6144a3b2e5cf98b531a9627dea92c1dc82204d09db0439b6a11dd64b484e1263aa45fd9539b6020b55e3baece3986a8bffc1003406348f5c61265099ed43a766ee4f93f5f9c5abbc32a0fd3ac2b35b87f9ec26037d88275bd7dd0a54474995ee34ed3727f3f97c48db544b1980193a4b76a8a3ddab3591ce527f16d91882e67f0103b5cda53f7da54d489fc4ac08b6ab358a5a04aa9daa16219d50bd672a7cb804ed769d218807544e5993f1c27427104b349906a0b654df0bf69328afd3013fbe430155339c39f236df5557bf92f1ded7ff609a8502f49064ec3d1dbfb6c15d3a4c11a4f8acd12278cbf68acd5709463d12e3338a6eddb8c112f199645e23154a8e60879d2a654e3ed9296aa28f134168619691cd2c6b9e2eba4438381676173fc63c2588a3c5910dc149cf3760f0aa9fa9c3f5faa9162b0bf1aac9dd32b706a60ef53cbdb394b6b40222b5bc80eea82ba8958386672564cae3794f977871ab62337cf02e30049201ec12937e7ce79d0f55d9c810e20acf52212aca1d3888949e0e4830aad88d804161230eb89d4d329cc83570fe257217d2119134048dd2ed167646975fc7d77136919a049ea74cf08ddd2b896890bb24a0ba18094a22baa351bf29ad96c66bbb1a598f2ca391749620e62d61c3561a7d3653ccc8892c7b99baaf76bf836e2991cb06d6bc0514568ff0d1ec8bb4b3d6984f5eaefb17d3ea2893722375d3ddb8e389a8eef7d7d198f8e687d6a513983df906099f9a2d23f4f9dec6f8ef2f11fc0a21fac45353b94e00486f5e17d386af42502d09db33cf0cf28310e049c07e88682aeeb00cb833c5174266e62407a57583f1f88b304b7c6e0c84bbe1c0fd423072d37a5bd0aacf764229e5c7cd02473460ba3645cd8e8ae144065bf02d0dd238593d8e230354f67e0b2f23012c23274f80e3ee31e35e2606a4a3f31d94ab755e6d163cff52cbb36b6d0cc67ffc512aeed1dce4d7a0d70ce82f2baba12e8d514dc92a056f994adfb17b5b9712bd5186f27a2fda1f7039c5df2c8587fdc62f5627580c13234b55be4df3056050e2d1ef3218f0dd66cb05265fe1acfb0989d8213f2c19d1735a7cf3fa65d88dad5af52dc2bba22b7abf46c3bc77b5091baab9e8f0ddc4d5e581037de91a9f8dcbc69309be29cc815cf19a20a7585b8b3073edf51fc9baeb3e509b97fa4ecfd621e0fd57bd61cac1b895c03248ff12bdbc57509250df3517e8a3fe1d776836b34ab352b973d932ef708b14f7418f9eceb1d87667e61e3e758649cb083f01b133d37ab2f5afa96d6c84bcacf4efc3851ad308c1e7d9113624fce29fab460ab9d2a48d92cdb281103a5250ad44cb2ff6e67ac670c02fdafb3e0f1353953d6d7d5646ca1568dea55275a050ec501b7c6250444f7219f1ba7521ba3b93d089727ca5f3bbe0d6c1300b423377004954c5628fdb65770b18ced5c9b23a4a5a6d6ef25fe01b4ce278de0bcc4ed86e28a0a68818ffa40970128cf2c38740e80037984428c1bd5113f40ff47512ee6f4e4d8f9b8e8e1b3040d2928d003bd1c1329dc885302fbce9fa81c23b4dc49c7c82d29b52957847898676c89aa5d32b5b0e1c0d5a2b79a19d67562f407f19425687971a957375879d90c5f57c857136c17106c9ab1b99d80e69c8c954ed386493368884b55c939b8d64d26f643e800c56f90c01079d7c534e3b2b7ae352cefd3016da55f6a85eb803b85e2304915fd2001f77c74e28746293c46e4f5f0fd49cf988aafd0026b8e7a3bab2da5cdce1ea26c2e29ec03f4807fac432662b2d6c060be1c7be0e5489de69d0a6e03a4b9117f9244b34a0f1ecba89884f781c6320412413a00c4980287409a2a78c2cd7e65cecebbe4ec1c28cac4dd95f6998e78fc6f1392384331c9436aa10e10e2bf8ad2c4eafbcf276aa7bae64b74428911b3269c749338b0fc5075ad",
|
||||
"Expected": "d61fe4e3f32ac260915b5b03b78a86d11bfc41d973fce5b0cc59035cf8289a8a2e3878ea15fa46565b0d806e2f85b53873ea20ed653869b688adf83f3ef444535bf91598ff7e80f334fb782539b92f39f55310cc4b35349ab7b278346eda9bc37c0d8acd3557fae38197f412f8d9e57ce6a76b7205c23564cab06e5615be7c6f05c3d05ec690cba91da5e89d55b152ff8dd2157dc5458190025cf94b1ad98f7cbe64e9482faba95e6b33844afc640892872b44a9932096508f4a782a4805323808f23e54b6ff9b841dbfa87db3505ae4f687972c18ea0f0d0af89d36c1c2a5b14560c153c3fee406f5cf15cfd1c0bb45d767426d465f2f14c158495069d0c5955a00150707862ecaae30624ebacdd8ac33e4e6aab3ff90b6ba445a84689386b9e945d01823a65874444316e83767290fcff630d2477f49d5d8ffdd200e08ee1274270f86ed14c687895f6caf5ce528bd970c20d2408a9ba66216324c6a011ac4999098362dbd98a038129a2d40c8da6ab88318aa3046cb660327cc44236d9e5d2163bd0959062195c51ed93d0088b6f92051fc99050ece2538749165976233697ab4b610385366e5ce0b02ad6b61c168ecfbedcdf74278a38de340fd7a5fead8e588e294795f9b011e2e60377a89e25c90e145397cdeabc60fd32444a6b7642a611a83c464d8b8976666351b4865c37b02e6dc21dbcdf5f930341707b618cc0f03c3122646b3385c9df9f2ec730eec9d49e7dfc9153b6e6289da8c4f0ebea9ccc1b751948e3bb7171c9e4d57423b0eeeb79095c030cb52677b3f7e0b45c30f645391f3f9c957afa549c4e0b2465b03c67993cd200b1af01035962edbc4c9e89b31c82ac121987d6529dafdeef67a132dc04b6dc68e77f22862040b75e2ceb9ff16da0fca534e6db7bd12fa7b7f51b6c08c1e23dfcdb7acbd2da0b51c87ffbced065a612e9b1c8bba9b7e2d8d7a2f04fcc4aaf355b60d764879a76b5e16762d5f2f55d585d0c8e82df6940960cddfb72c91dfa71f6b4e1c6ca25dfc39a878e998a663c04fe29d5e83b9586d047b4d7ff70a9f0d44f127e7d741685ca75f11629128d916a0ffef4be586a30c4b70389cc746e84ebf177c01ee8a4511cfbb9d1ecf7f7b33c7dd8177896e10bbc82f838dcd6db7ac67de62bf46b6a640fb580c5d1d2708f3862e3d2b645d0d18e49ef088053e3a220adc0e033c2afcfe61c90e32151152eb3caaf746c5e377d541cafc6cbb0cc0fa48b5caf1728f2e1957f5addfc234f1a9d89e40d49356c9172d0561a695fce6dab1d412321bbf407f63766ffd7b6b3d79bcfa07991c5a9709849c1008689e3b47c50d613980bec239fb64185249d055b30375ccb4354d71fe4d05648fbf6c80634dfc3575f2f24abb714c1e4c95e8896763bf4316e954c7ad19e5780ab7a040ca6fb9271f90a8b22ae738daf6cb",
|
||||
"Name": "nagydani-5-square",
|
||||
"Gas": 10922,
|
||||
"Gas": 32768,
|
||||
"NoBenchmark": false
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000400c5a1611f8be90071a43db23cc2fe01871cc4c0e8ab5743f6378e4fef77f7f6db0095c0727e20225beb665645403453e325ad5f9aeb9ba99bf3c148f63f9c07cf4fe8847ad5242d6b7d4499f93bd47056ddab8f7dee878fc2314f344dbee2a7c41a5d3db91eff372c730c2fdd3a141a4b61999e36d549b9870cf2f4e632c4d5df5f024f81c028000073a0ed8847cfb0593d36a47142f578f05ccbe28c0c06aeb1b1da027794c48db880278f79ba78ae64eedfea3c07d10e0562668d839749dc95f40467d15cf65b9cfc52c7c4bcef1cda3596dd52631aac942f146c7cebd46065131699ce8385b0db1874336747ee020a5698a3d1a1082665721e769567f579830f9d259cec1a836845109c21cf6b25da572512bf3c42fd4b96e43895589042ab60dd41f497db96aec102087fe784165bb45f942859268fd2ff6c012d9d00c02ba83eace047cc5f7b2c392c2955c58a49f0338d6fc58749c9db2155522ac17914ec216ad87f12e0ee95574613942fa615898c4d9e8a3be68cd6afa4e7a003dedbdf8edfee31162b174f965b20ae752ad89c967b3068b6f722c16b354456ba8e280f987c08e0a52d40a2e8f3a59b94d590aeef01879eb7a90b3ee7d772c839c85519cbeaddc0c193ec4874a463b53fcaea3271d80ebfb39b33489365fc039ae549a17a9ff898eea2f4cb27b8dbee4c17b998438575b2b8d107e4a0d66ba7fca85b41a58a8d51f191a35c856dfbe8aef2b00048a694bbccff832d23c8ca7a7ff0b6c0b3011d00b97c86c0628444d267c951d9e4fb8f83e154b8f74fb51aa16535e498235c5597dac9606ed0be3173a3836baa4e7d756ffe1e2879b415d3846bccd538c05b847785699aefde3e305decb600cd8fb0e7d8de5efc26971a6ad4e6d7a2d91474f1023a0ac4b78dc937da0ce607a45974d2cac1c33a2631ff7fe6144a3b2e5cf98b531a9627dea92c1dc82204d09db0439b6a11dd64b484e1263aa45fd9539b6020b55e3baece3986a8bffc1003406348f5c61265099ed43a766ee4f93f5f9c5abbc32a0fd3ac2b35b87f9ec26037d88275bd7dd0a54474995ee34ed3727f3f97c48db544b1980193a4b76a8a3ddab3591ce527f16d91882e67f0103b5cda53f7da54d489fc4ac08b6ab358a5a04aa9daa16219d50bd672a7cb804ed769d218807544e5993f1c27427104b349906a0b654df0bf69328afd3013fbe430155339c39f236df5557bf92f1ded7ff609a8502f49064ec3d1dbfb6c15d3a4c11a4f8acd12278cbf68acd5709463d12e3338a6eddb8c112f199645e23154a8e60879d2a654e3ed9296aa28f134168619691cd2c6b9e2eba4438381676173fc63c2588a3c5910dc149cf3760f0aa9fa9c3f5faa9162b0bf1aac9dd32b706a60ef53cbdb394b6b40222b5bc80eea82ba8958386672564cae3794f977871ab62337cf03e30049201ec12937e7ce79d0f55d9c810e20acf52212aca1d3888949e0e4830aad88d804161230eb89d4d329cc83570fe257217d2119134048dd2ed167646975fc7d77136919a049ea74cf08ddd2b896890bb24a0ba18094a22baa351bf29ad96c66bbb1a598f2ca391749620e62d61c3561a7d3653ccc8892c7b99baaf76bf836e2991cb06d6bc0514568ff0d1ec8bb4b3d6984f5eaefb17d3ea2893722375d3ddb8e389a8eef7d7d198f8e687d6a513983df906099f9a2d23f4f9dec6f8ef2f11fc0a21fac45353b94e00486f5e17d386af42502d09db33cf0cf28310e049c07e88682aeeb00cb833c5174266e62407a57583f1f88b304b7c6e0c84bbe1c0fd423072d37a5bd0aacf764229e5c7cd02473460ba3645cd8e8ae144065bf02d0dd238593d8e230354f67e0b2f23012c23274f80e3ee31e35e2606a4a3f31d94ab755e6d163cff52cbb36b6d0cc67ffc512aeed1dce4d7a0d70ce82f2baba12e8d514dc92a056f994adfb17b5b9712bd5186f27a2fda1f7039c5df2c8587fdc62f5627580c13234b55be4df3056050e2d1ef3218f0dd66cb05265fe1acfb0989d8213f2c19d1735a7cf3fa65d88dad5af52dc2bba22b7abf46c3bc77b5091baab9e8f0ddc4d5e581037de91a9f8dcbc69309be29cc815cf19a20a7585b8b3073edf51fc9baeb3e509b97fa4ecfd621e0fd57bd61cac1b895c03248ff12bdbc57509250df3517e8a3fe1d776836b34ab352b973d932ef708b14f7418f9eceb1d87667e61e3e758649cb083f01b133d37ab2f5afa96d6c84bcacf4efc3851ad308c1e7d9113624fce29fab460ab9d2a48d92cdb281103a5250ad44cb2ff6e67ac670c02fdafb3e0f1353953d6d7d5646ca1568dea55275a050ec501b7c6250444f7219f1ba7521ba3b93d089727ca5f3bbe0d6c1300b423377004954c5628fdb65770b18ced5c9b23a4a5a6d6ef25fe01b4ce278de0bcc4ed86e28a0a68818ffa40970128cf2c38740e80037984428c1bd5113f40ff47512ee6f4e4d8f9b8e8e1b3040d2928d003bd1c1329dc885302fbce9fa81c23b4dc49c7c82d29b52957847898676c89aa5d32b5b0e1c0d5a2b79a19d67562f407f19425687971a957375879d90c5f57c857136c17106c9ab1b99d80e69c8c954ed386493368884b55c939b8d64d26f643e800c56f90c01079d7c534e3b2b7ae352cefd3016da55f6a85eb803b85e2304915fd2001f77c74e28746293c46e4f5f0fd49cf988aafd0026b8e7a3bab2da5cdce1ea26c2e29ec03f4807fac432662b2d6c060be1c7be0e5489de69d0a6e03a4b9117f9244b34a0f1ecba89884f781c6320412413a00c4980287409a2a78c2cd7e65cecebbe4ec1c28cac4dd95f6998e78fc6f1392384331c9436aa10e10e2bf8ad2c4eafbcf276aa7bae64b74428911b3269c749338b0fc5075ad",
|
||||
"Expected": "5f9c70ec884926a89461056ad20ac4c30155e817f807e4d3f5bb743d789c83386762435c3627773fa77da5144451f2a8aad8adba88e0b669f5377c5e9bad70e45c86fe952b613f015a9953b8a5de5eaee4566acf98d41e327d93a35bd5cef4607d025e58951167957df4ff9b1627649d3943805472e5e293d3efb687cfd1e503faafeb2840a3e3b3f85d016051a58e1c9498aab72e63b748d834b31eb05d85dcde65e27834e266b85c75cc4ec0135135e0601cb93eeeb6e0010c8ceb65c4c319623c5e573a2c8c9fbbf7df68a930beb412d3f4dfd146175484f45d7afaa0d2e60684af9b34730f7c8438465ad3e1d0c3237336722f2aa51095bd5759f4b8ab4dda111b684aa3dac62a761722e7ae43495b7709933512c81c4e3c9133a51f7ce9f2b51fcec064f65779666960b4e45df3900f54311f5613e8012dd1b8efd359eda31a778264c72aa8bb419d862734d769076bce2810011989a45374e5c5d8729fec21427f0bf397eacbb4220f603cf463a4b0c94efd858ffd9768cd60d6ce68d755e0fbad007ce5c2223d70c7018345a102e4ab3c60a13a9e7794303156d4c2063e919f2153c13961fb324c80b240742f47773a7a8e25b3e3fb19b00ce839346c6eb3c732fbc6b888df0b1fe0a3d07b053a2e9402c267b2d62f794d8a2840526e3ade15ce2264496ccd7519571dfde47f7a4bb16292241c20b2be59f3f8fb4f6383f232d838c5a22d8c95b6834d9d2ca493f5a505ebe8899503b0e8f9b19e6e2dd81c1628b80016d02097e0134de51054c4e7674824d4d758760fc52377d2cad145e259aa2ffaf54139e1a66b1e0c1c191e32ac59474c6b526f5b3ba07d3e5ec286eddf531fcd5292869be58c9f22ef91026159f7cf9d05ef66b4299f4da48cc1635bf2243051d342d378a22c83390553e873713c0454ce5f3234397111ac3fe3207b86f0ed9fc025c81903e1748103692074f83824fda6341be4f95ff00b0a9a208c267e12fa01825054cc0513629bf3dbb56dc5b90d4316f87654a8be18227978ea0a8a522760cad620d0d14fd38920fb7321314062914275a5f99f677145a6979b156bd82ecd36f23f8e1273cc2759ecc0b2c69d94dad5211d1bed939dd87ed9e07b91d49713a6e16ade0a98aea789f04994e318e4ff2c8a188cd8d43aeb52c6daa3bc29b4af50ea82a247c5cd67b573b34cbadcc0a376d3bbd530d50367b42705d870f2e27a8197ef46070528bfe408360faa2ebb8bf76e9f388572842bcb119f4d84ee34ae31f5cc594f23705a49197b181fb78ed1ec99499c690f843a4d0cf2e226d118e9372271054fbabdcc5c92ae9fefaef0589cd0e722eaf30c1703ec4289c7fd81beaa8a455ccee5298e31e2080c10c366a6fcf56f7d13582ad0bcad037c612b710fc595b70fbefaaca23623b60c6c39b11beb8e5843b6b3dac60f",
|
||||
"Name": "nagydani-5-qube",
|
||||
"Gas": 10922,
|
||||
"Gas": 32768,
|
||||
"NoBenchmark": false
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000400c5a1611f8be90071a43db23cc2fe01871cc4c0e8ab5743f6378e4fef77f7f6db0095c0727e20225beb665645403453e325ad5f9aeb9ba99bf3c148f63f9c07cf4fe8847ad5242d6b7d4499f93bd47056ddab8f7dee878fc2314f344dbee2a7c41a5d3db91eff372c730c2fdd3a141a4b61999e36d549b9870cf2f4e632c4d5df5f024f81c028000073a0ed8847cfb0593d36a47142f578f05ccbe28c0c06aeb1b1da027794c48db880278f79ba78ae64eedfea3c07d10e0562668d839749dc95f40467d15cf65b9cfc52c7c4bcef1cda3596dd52631aac942f146c7cebd46065131699ce8385b0db1874336747ee020a5698a3d1a1082665721e769567f579830f9d259cec1a836845109c21cf6b25da572512bf3c42fd4b96e43895589042ab60dd41f497db96aec102087fe784165bb45f942859268fd2ff6c012d9d00c02ba83eace047cc5f7b2c392c2955c58a49f0338d6fc58749c9db2155522ac17914ec216ad87f12e0ee95574613942fa615898c4d9e8a3be68cd6afa4e7a003dedbdf8edfee31162b174f965b20ae752ad89c967b3068b6f722c16b354456ba8e280f987c08e0a52d40a2e8f3a59b94d590aeef01879eb7a90b3ee7d772c839c85519cbeaddc0c193ec4874a463b53fcaea3271d80ebfb39b33489365fc039ae549a17a9ff898eea2f4cb27b8dbee4c17b998438575b2b8d107e4a0d66ba7fca85b41a58a8d51f191a35c856dfbe8aef2b00048a694bbccff832d23c8ca7a7ff0b6c0b3011d00b97c86c0628444d267c951d9e4fb8f83e154b8f74fb51aa16535e498235c5597dac9606ed0be3173a3836baa4e7d756ffe1e2879b415d3846bccd538c05b847785699aefde3e305decb600cd8fb0e7d8de5efc26971a6ad4e6d7a2d91474f1023a0ac4b78dc937da0ce607a45974d2cac1c33a2631ff7fe6144a3b2e5cf98b531a9627dea92c1dc82204d09db0439b6a11dd64b484e1263aa45fd9539b6020b55e3baece3986a8bffc1003406348f5c61265099ed43a766ee4f93f5f9c5abbc32a0fd3ac2b35b87f9ec26037d88275bd7dd0a54474995ee34ed3727f3f97c48db544b1980193a4b76a8a3ddab3591ce527f16d91882e67f0103b5cda53f7da54d489fc4ac08b6ab358a5a04aa9daa16219d50bd672a7cb804ed769d218807544e5993f1c27427104b349906a0b654df0bf69328afd3013fbe430155339c39f236df5557bf92f1ded7ff609a8502f49064ec3d1dbfb6c15d3a4c11a4f8acd12278cbf68acd5709463d12e3338a6eddb8c112f199645e23154a8e60879d2a654e3ed9296aa28f134168619691cd2c6b9e2eba4438381676173fc63c2588a3c5910dc149cf3760f0aa9fa9c3f5faa9162b0bf1aac9dd32b706a60ef53cbdb394b6b40222b5bc80eea82ba8958386672564cae3794f977871ab62337cf010001e30049201ec12937e7ce79d0f55d9c810e20acf52212aca1d3888949e0e4830aad88d804161230eb89d4d329cc83570fe257217d2119134048dd2ed167646975fc7d77136919a049ea74cf08ddd2b896890bb24a0ba18094a22baa351bf29ad96c66bbb1a598f2ca391749620e62d61c3561a7d3653ccc8892c7b99baaf76bf836e2991cb06d6bc0514568ff0d1ec8bb4b3d6984f5eaefb17d3ea2893722375d3ddb8e389a8eef7d7d198f8e687d6a513983df906099f9a2d23f4f9dec6f8ef2f11fc0a21fac45353b94e00486f5e17d386af42502d09db33cf0cf28310e049c07e88682aeeb00cb833c5174266e62407a57583f1f88b304b7c6e0c84bbe1c0fd423072d37a5bd0aacf764229e5c7cd02473460ba3645cd8e8ae144065bf02d0dd238593d8e230354f67e0b2f23012c23274f80e3ee31e35e2606a4a3f31d94ab755e6d163cff52cbb36b6d0cc67ffc512aeed1dce4d7a0d70ce82f2baba12e8d514dc92a056f994adfb17b5b9712bd5186f27a2fda1f7039c5df2c8587fdc62f5627580c13234b55be4df3056050e2d1ef3218f0dd66cb05265fe1acfb0989d8213f2c19d1735a7cf3fa65d88dad5af52dc2bba22b7abf46c3bc77b5091baab9e8f0ddc4d5e581037de91a9f8dcbc69309be29cc815cf19a20a7585b8b3073edf51fc9baeb3e509b97fa4ecfd621e0fd57bd61cac1b895c03248ff12bdbc57509250df3517e8a3fe1d776836b34ab352b973d932ef708b14f7418f9eceb1d87667e61e3e758649cb083f01b133d37ab2f5afa96d6c84bcacf4efc3851ad308c1e7d9113624fce29fab460ab9d2a48d92cdb281103a5250ad44cb2ff6e67ac670c02fdafb3e0f1353953d6d7d5646ca1568dea55275a050ec501b7c6250444f7219f1ba7521ba3b93d089727ca5f3bbe0d6c1300b423377004954c5628fdb65770b18ced5c9b23a4a5a6d6ef25fe01b4ce278de0bcc4ed86e28a0a68818ffa40970128cf2c38740e80037984428c1bd5113f40ff47512ee6f4e4d8f9b8e8e1b3040d2928d003bd1c1329dc885302fbce9fa81c23b4dc49c7c82d29b52957847898676c89aa5d32b5b0e1c0d5a2b79a19d67562f407f19425687971a957375879d90c5f57c857136c17106c9ab1b99d80e69c8c954ed386493368884b55c939b8d64d26f643e800c56f90c01079d7c534e3b2b7ae352cefd3016da55f6a85eb803b85e2304915fd2001f77c74e28746293c46e4f5f0fd49cf988aafd0026b8e7a3bab2da5cdce1ea26c2e29ec03f4807fac432662b2d6c060be1c7be0e5489de69d0a6e03a4b9117f9244b34a0f1ecba89884f781c6320412413a00c4980287409a2a78c2cd7e65cecebbe4ec1c28cac4dd95f6998e78fc6f1392384331c9436aa10e10e2bf8ad2c4eafbcf276aa7bae64b74428911b3269c749338b0fc5075ad",
|
||||
"Expected": "5a0eb2bdf0ac1cae8e586689fa16cd4b07dfdedaec8a110ea1fdb059dd5253231b6132987598dfc6e11f86780428982d50cf68f67ae452622c3b336b537ef3298ca645e8f89ee39a26758206a5a3f6409afc709582f95274b57b71fae5c6b74619ae6f089a5393c5b79235d9caf699d23d88fb873f78379690ad8405e34c19f5257d596580c7a6a7206a3712825afe630c76b31cdb4a23e7f0632e10f14f4e282c81a66451a26f8df2a352b5b9f607a7198449d1b926e27036810368e691a74b91c61afa73d9d3b99453e7c8b50fd4f09c039a2f2feb5c419206694c31b92df1d9586140cb3417b38d0c503c7b508cc2ed12e813a1c795e9829eb39ee78eeaf360a169b491a1d4e419574e712402de9d48d54c1ae5e03739b7156615e8267e1fb0a897f067afd11fb33f6e24182d7aaaaa18fe5bc1982f20d6b871e5a398f0f6f718181d31ec225cfa9a0a70124ed9a70031bdf0c1c7829f708b6e17d50419ef361cf77d99c85f44607186c8d683106b8bd38a49b5d0fb503b397a83388c5678dcfcc737499d84512690701ed621a6f0172aecf037184ddf0f2453e4053024018e5ab2e30d6d5363b56e8b41509317c99042f517247474ab3abc848e00a07f69c254f46f2a05cf6ed84e5cc906a518fdcfdf2c61ce731f24c5264f1a25fc04934dc28aec112134dd523f70115074ca34e3807aa4cb925147f3a0ce152d323bd8c675ace446d0fd1ae30c4b57f0eb2c23884bc18f0964c0114796c5b6d080c3d89175665fbf63a6381a6a9da39ad070b645c8bb1779506da14439a9f5b5d481954764ea114fac688930bc68534d403cff4210673b6a6ff7ae416b7cd41404c3d3f282fcd193b86d0f54d0006c2a503b40d5c3930da980565b8f9630e9493a79d1c03e74e5f93ac8e4dc1a901ec5e3b3e57049124c7b72ea345aa359e782285d9e6a5c144a378111dd02c40855ff9c2be9b48425cb0b2fd62dc8678fd151121cf26a65e917d65d8e0dacfae108eb5508b601fb8ffa370be1f9a8b749a2d12eeab81f41079de87e2d777994fa4d28188c579ad327f9957fb7bdecec5c680844dd43cb57cf87aeb763c003e65011f73f8c63442df39a92b946a6bd968a1c1e4d5fa7d88476a68bd8e20e5b70a99259c7d3f85fb1b65cd2e93972e6264e74ebf289b8b6979b9b68a85cd5b360c1987f87235c3c845d62489e33acf85d53fa3561fe3a3aee18924588d9c6eba4edb7a4d106b31173e42929f6f0c48c80ce6a72d54eca7c0fe870068b7a7c89c63cdda593f5b32d3cb4ea8a32c39f00ab449155757172d66763ed9527019d6de6c9f2416aa6203f4d11c9ebee1e1d3845099e55504446448027212616167eb36035726daa7698b075286f5379cd3e93cb3e0cf4f9cb8d017facbb5550ed32d5ec5400ae57e47e2bf78d1eaeff9480cc765ceff39db500",
|
||||
"Name": "nagydani-5-pow0x10001",
|
||||
"Gas": 174762,
|
||||
"Gas": 524288,
|
||||
"NoBenchmark": false
|
||||
}
|
||||
]
|
||||
|
|
|
|||
5476
core/vm/testdata/precompiles/p256Verify.json
vendored
Normal file
5476
core/vm/testdata/precompiles/p256Verify.json
vendored
Normal file
File diff suppressed because it is too large
Load diff
33
crypto/secp256r1/verifier.go
Normal file
33
crypto/secp256r1/verifier.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2024 The go-ethereum Authors
|
||||
// This file is part of the go-ethereum library.
|
||||
//
|
||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Package secp256r1 implements signature verification for the P256VERIFY precompile.
|
||||
package secp256r1
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"crypto/elliptic"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
// Verify checks the given signature (r, s) for the given hash and public key (x, y).
|
||||
func Verify(hash []byte, r, s, x, y *big.Int) bool {
|
||||
if x == nil || y == nil || !elliptic.P256().IsOnCurve(x, y) {
|
||||
return false
|
||||
}
|
||||
pk := &ecdsa.PublicKey{Curve: elliptic.P256(), X: x, Y: y}
|
||||
return ecdsa.Verify(pk, hash, r, s)
|
||||
}
|
||||
|
|
@ -236,9 +236,13 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||
VmConfig: vm.Config{
|
||||
EnablePreimageRecording: config.EnablePreimageRecording,
|
||||
},
|
||||
// Enables file journaling for the trie database. The journal files will be stored
|
||||
// within the data directory. The corresponding paths will be either:
|
||||
// - DATADIR/triedb/merkle.journal
|
||||
// - DATADIR/triedb/verkle.journal
|
||||
TrieJournalDirectory: stack.ResolvePath("triedb"),
|
||||
}
|
||||
)
|
||||
|
||||
if config.VMTrace != "" {
|
||||
traceConfig := json.RawMessage("{}")
|
||||
if config.VMTraceJsonConfig != "" {
|
||||
|
|
|
|||
|
|
@ -570,10 +570,10 @@ func (api *ConsensusAPI) GetBlobsV2(hashes []common.Hash) ([]*engine.BlobAndProo
|
|||
if len(hashes) > 128 {
|
||||
return nil, engine.TooLargeRequest.With(fmt.Errorf("requested blob count too large: %v", len(hashes)))
|
||||
}
|
||||
|
||||
available := api.eth.BlobTxPool().AvailableBlobs(hashes)
|
||||
getBlobsRequestedCounter.Inc(int64(len(hashes)))
|
||||
getBlobsAvailableCounter.Inc(int64(available))
|
||||
|
||||
// Optimization: check first if all blobs are available, if not, return empty response
|
||||
if available != len(hashes) {
|
||||
getBlobsV2RequestMiss.Inc(1)
|
||||
|
|
@ -600,14 +600,17 @@ func (api *ConsensusAPI) GetBlobsV2(hashes []common.Hash) ([]*engine.BlobAndProo
|
|||
// not found, return empty response
|
||||
return nil, nil
|
||||
}
|
||||
if sidecar.Version != 1 {
|
||||
if sidecar.Version != types.BlobSidecarVersion1 {
|
||||
log.Info("GetBlobs queried V0 transaction: index %v, blobhashes %v", index, sidecar.BlobHashes())
|
||||
return nil, nil
|
||||
}
|
||||
blobHashes := sidecar.BlobHashes()
|
||||
for bIdx, hash := range blobHashes {
|
||||
if idxes, ok := index[hash]; ok {
|
||||
proofs := sidecar.CellProofsAt(bIdx)
|
||||
proofs, err := sidecar.CellProofsAt(bIdx)
|
||||
if err != nil {
|
||||
return nil, engine.InvalidParams.With(err)
|
||||
}
|
||||
var cellProofs []hexutil.Bytes
|
||||
for _, proof := range proofs {
|
||||
cellProofs = append(cellProofs, proof[:])
|
||||
|
|
|
|||
|
|
@ -1517,13 +1517,8 @@ func TestBlockToPayloadWithBlobs(t *testing.T) {
|
|||
}
|
||||
|
||||
txs = append(txs, types.NewTx(&inner))
|
||||
sidecars := []*types.BlobTxSidecar{
|
||||
{
|
||||
Blobs: make([]kzg4844.Blob, 1),
|
||||
Commitments: make([]kzg4844.Commitment, 1),
|
||||
Proofs: make([]kzg4844.Proof, 1),
|
||||
},
|
||||
}
|
||||
sidecar := types.NewBlobTxSidecar(types.BlobSidecarVersion0, make([]kzg4844.Blob, 1), make([]kzg4844.Commitment, 1), make([]kzg4844.Proof, 1))
|
||||
sidecars := []*types.BlobTxSidecar{sidecar}
|
||||
|
||||
block := types.NewBlock(&header, &types.Body{Transactions: txs}, nil, trie.NewStackTrie(nil))
|
||||
envelope := engine.BlockToExecutableData(block, nil, sidecars, nil)
|
||||
|
|
|
|||
|
|
@ -70,9 +70,14 @@ func (a *simulatedBeaconAPI) loop() {
|
|||
if executable, _ := a.sim.eth.TxPool().Stats(); executable == 0 {
|
||||
break
|
||||
}
|
||||
select {
|
||||
case <-a.sim.shutdownCh:
|
||||
return
|
||||
default:
|
||||
a.sim.Commit()
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
for {
|
||||
|
|
|
|||
|
|
@ -39,16 +39,18 @@ type FullSyncTester struct {
|
|||
target common.Hash
|
||||
closed chan struct{}
|
||||
wg sync.WaitGroup
|
||||
exitWhenSynced bool
|
||||
}
|
||||
|
||||
// RegisterFullSyncTester registers the full-sync tester service into the node
|
||||
// stack for launching and stopping the service controlled by node.
|
||||
func RegisterFullSyncTester(stack *node.Node, backend *eth.Ethereum, target common.Hash) (*FullSyncTester, error) {
|
||||
func RegisterFullSyncTester(stack *node.Node, backend *eth.Ethereum, target common.Hash, exitWhenSynced bool) (*FullSyncTester, error) {
|
||||
cl := &FullSyncTester{
|
||||
stack: stack,
|
||||
backend: backend,
|
||||
target: target,
|
||||
closed: make(chan struct{}),
|
||||
exitWhenSynced: exitWhenSynced,
|
||||
}
|
||||
stack.RegisterLifecycle(cl)
|
||||
return cl, nil
|
||||
|
|
@ -76,7 +78,11 @@ func (tester *FullSyncTester) Start() error {
|
|||
// Stop in case the target block is already stored locally.
|
||||
if block := tester.backend.BlockChain().GetBlockByHash(tester.target); block != nil {
|
||||
log.Info("Full-sync target reached", "number", block.NumberU64(), "hash", block.Hash())
|
||||
|
||||
if tester.exitWhenSynced {
|
||||
go tester.stack.Close() // async since we need to close ourselves
|
||||
log.Info("Terminating the node")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -250,6 +250,9 @@ func (d *Downloader) findBeaconAncestor() (uint64, error) {
|
|||
check := (start + end) / 2
|
||||
|
||||
h := d.skeleton.Header(check)
|
||||
if h == nil {
|
||||
return 0, fmt.Errorf("filled skeleton header is missing: %d", check)
|
||||
}
|
||||
n := h.Number.Uint64()
|
||||
|
||||
var known bool
|
||||
|
|
|
|||
|
|
@ -535,9 +535,15 @@ func (d *Downloader) syncToHead() (err error) {
|
|||
|
||||
// If a part of blockchain data has already been written into active store,
|
||||
// disable the ancient style insertion explicitly.
|
||||
if origin >= frozen && frozen != 0 {
|
||||
if origin >= frozen && origin != 0 {
|
||||
d.ancientLimit = 0
|
||||
log.Info("Disabling direct-ancient mode", "origin", origin, "ancient", frozen-1)
|
||||
var ancient string
|
||||
if frozen == 0 {
|
||||
ancient = "null"
|
||||
} else {
|
||||
ancient = fmt.Sprintf("%d", frozen-1)
|
||||
}
|
||||
log.Info("Disabling direct-ancient mode", "origin", origin, "ancient", ancient)
|
||||
} else if d.ancientLimit > 0 {
|
||||
log.Debug("Enabling direct-ancient mode", "ancient", d.ancientLimit)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1150,6 +1150,9 @@ func (s *skeleton) cleanStales(filled *types.Header) error {
|
|||
if number < s.progress.Subchains[0].Head {
|
||||
// The skeleton chain is partially consumed, set the new tail as filled+1.
|
||||
tail := rawdb.ReadSkeletonHeader(s.db, number+1)
|
||||
if tail == nil {
|
||||
return fmt.Errorf("filled header is missing: %d", number+1)
|
||||
}
|
||||
if tail.ParentHash != filled.Hash() {
|
||||
return fmt.Errorf("filled header is discontinuous with subchain: %d %s, please file an issue", number, filled.Hash())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -439,8 +439,8 @@ func (f *TxFetcher) loop() {
|
|||
if want > maxTxAnnounces {
|
||||
txAnnounceDOSMeter.Mark(int64(want - maxTxAnnounces))
|
||||
|
||||
ann.hashes = ann.hashes[:want-maxTxAnnounces]
|
||||
ann.metas = ann.metas[:want-maxTxAnnounces]
|
||||
ann.hashes = ann.hashes[:maxTxAnnounces-used]
|
||||
ann.metas = ann.metas[:maxTxAnnounces-used]
|
||||
}
|
||||
// All is well, schedule the remainder of the transactions
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -1179,6 +1179,24 @@ func TestTransactionFetcherDoSProtection(t *testing.T) {
|
|||
size: 111,
|
||||
})
|
||||
}
|
||||
var (
|
||||
hashesC []common.Hash
|
||||
typesC []byte
|
||||
sizesC []uint32
|
||||
announceC []announce
|
||||
)
|
||||
for i := 0; i < maxTxAnnounces+2; i++ {
|
||||
hash := common.Hash{0x03, byte(i / 256), byte(i % 256)}
|
||||
hashesC = append(hashesC, hash)
|
||||
typesC = append(typesC, types.LegacyTxType)
|
||||
sizesC = append(sizesC, 111)
|
||||
|
||||
announceC = append(announceC, announce{
|
||||
hash: hash,
|
||||
kind: types.LegacyTxType,
|
||||
size: 111,
|
||||
})
|
||||
}
|
||||
testTransactionFetcherParallel(t, txFetcherTest{
|
||||
init: func() *TxFetcher {
|
||||
return NewTxFetcher(
|
||||
|
|
@ -1192,43 +1210,52 @@ func TestTransactionFetcherDoSProtection(t *testing.T) {
|
|||
// Announce half of the transaction and wait for them to be scheduled
|
||||
doTxNotify{peer: "A", hashes: hashesA[:maxTxAnnounces/2], types: typesA[:maxTxAnnounces/2], sizes: sizesA[:maxTxAnnounces/2]},
|
||||
doTxNotify{peer: "B", hashes: hashesB[:maxTxAnnounces/2-1], types: typesB[:maxTxAnnounces/2-1], sizes: sizesB[:maxTxAnnounces/2-1]},
|
||||
doTxNotify{peer: "C", hashes: hashesC[:maxTxAnnounces/2-1], types: typesC[:maxTxAnnounces/2-1], sizes: sizesC[:maxTxAnnounces/2-1]},
|
||||
doWait{time: txArriveTimeout, step: true},
|
||||
|
||||
// Announce the second half and keep them in the wait list
|
||||
doTxNotify{peer: "A", hashes: hashesA[maxTxAnnounces/2 : maxTxAnnounces], types: typesA[maxTxAnnounces/2 : maxTxAnnounces], sizes: sizesA[maxTxAnnounces/2 : maxTxAnnounces]},
|
||||
doTxNotify{peer: "B", hashes: hashesB[maxTxAnnounces/2-1 : maxTxAnnounces-1], types: typesB[maxTxAnnounces/2-1 : maxTxAnnounces-1], sizes: sizesB[maxTxAnnounces/2-1 : maxTxAnnounces-1]},
|
||||
doTxNotify{peer: "C", hashes: hashesC[maxTxAnnounces/2-1 : maxTxAnnounces-1], types: typesC[maxTxAnnounces/2-1 : maxTxAnnounces-1], sizes: sizesC[maxTxAnnounces/2-1 : maxTxAnnounces-1]},
|
||||
|
||||
// Ensure the hashes are split half and half
|
||||
isWaiting(map[string][]announce{
|
||||
"A": announceA[maxTxAnnounces/2 : maxTxAnnounces],
|
||||
"B": announceB[maxTxAnnounces/2-1 : maxTxAnnounces-1],
|
||||
"C": announceC[maxTxAnnounces/2-1 : maxTxAnnounces-1],
|
||||
}),
|
||||
isScheduled{
|
||||
tracking: map[string][]announce{
|
||||
"A": announceA[:maxTxAnnounces/2],
|
||||
"B": announceB[:maxTxAnnounces/2-1],
|
||||
"C": announceC[:maxTxAnnounces/2-1],
|
||||
},
|
||||
fetching: map[string][]common.Hash{
|
||||
"A": hashesA[:maxTxRetrievals],
|
||||
"B": hashesB[:maxTxRetrievals],
|
||||
"C": hashesC[:maxTxRetrievals],
|
||||
},
|
||||
},
|
||||
// Ensure that adding even one more hash results in dropping the hash
|
||||
doTxNotify{peer: "A", hashes: []common.Hash{hashesA[maxTxAnnounces]}, types: []byte{typesA[maxTxAnnounces]}, sizes: []uint32{sizesA[maxTxAnnounces]}},
|
||||
doTxNotify{peer: "B", hashes: hashesB[maxTxAnnounces-1 : maxTxAnnounces+1], types: typesB[maxTxAnnounces-1 : maxTxAnnounces+1], sizes: sizesB[maxTxAnnounces-1 : maxTxAnnounces+1]},
|
||||
doTxNotify{peer: "C", hashes: hashesC[maxTxAnnounces-1 : maxTxAnnounces+2], types: typesC[maxTxAnnounces-1 : maxTxAnnounces+2], sizes: sizesC[maxTxAnnounces-1 : maxTxAnnounces+2]},
|
||||
|
||||
isWaiting(map[string][]announce{
|
||||
"A": announceA[maxTxAnnounces/2 : maxTxAnnounces],
|
||||
"B": announceB[maxTxAnnounces/2-1 : maxTxAnnounces],
|
||||
"C": announceC[maxTxAnnounces/2-1 : maxTxAnnounces],
|
||||
}),
|
||||
isScheduled{
|
||||
tracking: map[string][]announce{
|
||||
"A": announceA[:maxTxAnnounces/2],
|
||||
"B": announceB[:maxTxAnnounces/2-1],
|
||||
"C": announceC[:maxTxAnnounces/2-1],
|
||||
},
|
||||
fetching: map[string][]common.Hash{
|
||||
"A": hashesA[:maxTxRetrievals],
|
||||
"B": hashesB[:maxTxRetrievals],
|
||||
"C": hashesC[:maxTxRetrievals],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -92,18 +92,18 @@ func (b *testBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumbe
|
|||
switch blockNr {
|
||||
case rpc.LatestBlockNumber:
|
||||
hash = rawdb.ReadHeadBlockHash(b.db)
|
||||
number := rawdb.ReadHeaderNumber(b.db, hash)
|
||||
if number == nil {
|
||||
number, ok := rawdb.ReadHeaderNumber(b.db, hash)
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
num = *number
|
||||
num = number
|
||||
case rpc.FinalizedBlockNumber:
|
||||
hash = rawdb.ReadFinalizedBlockHash(b.db)
|
||||
number := rawdb.ReadHeaderNumber(b.db, hash)
|
||||
if number == nil {
|
||||
number, ok := rawdb.ReadHeaderNumber(b.db, hash)
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
num = *number
|
||||
num = number
|
||||
case rpc.SafeBlockNumber:
|
||||
return nil, errors.New("safe block not found")
|
||||
default:
|
||||
|
|
@ -114,11 +114,11 @@ func (b *testBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumbe
|
|||
}
|
||||
|
||||
func (b *testBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
|
||||
number := rawdb.ReadHeaderNumber(b.db, hash)
|
||||
if number == nil {
|
||||
number, ok := rawdb.ReadHeaderNumber(b.db, hash)
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return rawdb.ReadHeader(b.db, hash, *number), nil
|
||||
return rawdb.ReadHeader(b.db, hash, number), nil
|
||||
}
|
||||
|
||||
func (b *testBackend) GetBody(ctx context.Context, hash common.Hash, number rpc.BlockNumber) (*types.Body, error) {
|
||||
|
|
@ -129,9 +129,9 @@ func (b *testBackend) GetBody(ctx context.Context, hash common.Hash, number rpc.
|
|||
}
|
||||
|
||||
func (b *testBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
|
||||
if number := rawdb.ReadHeaderNumber(b.db, hash); number != nil {
|
||||
if header := rawdb.ReadHeader(b.db, hash, *number); header != nil {
|
||||
return rawdb.ReadReceipts(b.db, hash, *number, header.Time, params.TestChainConfig), nil
|
||||
if number, ok := rawdb.ReadHeaderNumber(b.db, hash); ok {
|
||||
if header := rawdb.ReadHeader(b.db, hash, number); header != nil {
|
||||
return rawdb.ReadReceipts(b.db, hash, number, header.Time, params.TestChainConfig), nil
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
|
|
|
|||
|
|
@ -661,11 +661,7 @@ func testGetPooledTransaction(t *testing.T, blobTx bool) {
|
|||
To: testAddr,
|
||||
BlobHashes: []common.Hash{emptyBlobHash},
|
||||
BlobFeeCap: uint256.MustFromBig(common.Big1),
|
||||
Sidecar: &types.BlobTxSidecar{
|
||||
Blobs: emptyBlobs,
|
||||
Commitments: []kzg4844.Commitment{emptyBlobCommit},
|
||||
Proofs: []kzg4844.Proof{emptyBlobProof},
|
||||
},
|
||||
Sidecar: types.NewBlobTxSidecar(types.BlobSidecarVersion0, emptyBlobs, []kzg4844.Commitment{emptyBlobCommit}, []kzg4844.Proof{emptyBlobProof}),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
|||
|
|
@ -615,7 +615,7 @@ func (s *Syncer) Sync(root common.Hash, cancel chan struct{}) error {
|
|||
s.statelessPeers = make(map[string]struct{})
|
||||
s.lock.Unlock()
|
||||
|
||||
if s.startTime == (time.Time{}) {
|
||||
if s.startTime.IsZero() {
|
||||
s.startTime = time.Now()
|
||||
}
|
||||
// Retrieve the previous sync status from LevelDB and abort if already synced
|
||||
|
|
@ -1987,9 +1987,7 @@ func (s *Syncer) processAccountResponse(res *accountResponse) {
|
|||
func (s *Syncer) processBytecodeResponse(res *bytecodeResponse) {
|
||||
batch := s.db.NewBatch()
|
||||
|
||||
var (
|
||||
codes uint64
|
||||
)
|
||||
var codes uint64
|
||||
for i, hash := range res.hashes {
|
||||
code := res.codes[i]
|
||||
|
||||
|
|
@ -3113,6 +3111,10 @@ func (s *Syncer) reportSyncProgress(force bool) {
|
|||
if estBytes < 1.0 {
|
||||
return
|
||||
}
|
||||
// Cap the estimated state size using the synced size to avoid negative values
|
||||
if estBytes < float64(synced) {
|
||||
estBytes = float64(synced)
|
||||
}
|
||||
elapsed := time.Since(s.startTime)
|
||||
estTime := elapsed / time.Duration(synced) * time.Duration(estBytes)
|
||||
|
||||
|
|
|
|||
|
|
@ -953,42 +953,55 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
|
|||
}
|
||||
defer release()
|
||||
|
||||
vmctx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
|
||||
h := block.Header()
|
||||
blockContext := core.NewEVMBlockContext(h, api.chainContext(ctx), nil)
|
||||
|
||||
// Apply the customization rules if required.
|
||||
if config != nil {
|
||||
if overrideErr := config.BlockOverrides.Apply(&vmctx); overrideErr != nil {
|
||||
return nil, overrideErr
|
||||
if config.BlockOverrides != nil && config.BlockOverrides.Number.ToInt().Uint64() == h.Number.Uint64()+1 {
|
||||
// Overriding the block number to n+1 is a common way for wallets to
|
||||
// simulate transactions, however without the following fix, a contract
|
||||
// can assert it is being simulated by checking if blockhash(n) == 0x0 and
|
||||
// can behave differently during the simulation. (#32175 for more info)
|
||||
// --
|
||||
// Modify the parent hash and number so that downstream, blockContext's
|
||||
// GetHash function can correctly return n.
|
||||
h.ParentHash = h.Hash()
|
||||
h.Number.Add(h.Number, big.NewInt(1))
|
||||
}
|
||||
rules := api.backend.ChainConfig().Rules(vmctx.BlockNumber, vmctx.Random != nil, vmctx.Time)
|
||||
|
||||
if err := config.BlockOverrides.Apply(&blockContext); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rules := api.backend.ChainConfig().Rules(blockContext.BlockNumber, blockContext.Random != nil, blockContext.Time)
|
||||
precompiles = vm.ActivePrecompiledContracts(rules)
|
||||
if err := config.StateOverrides.Apply(statedb, precompiles); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
// Execute the trace
|
||||
if err := args.CallDefaults(api.backend.RPCGasCap(), vmctx.BaseFee, api.backend.ChainConfig().ChainID); err != nil {
|
||||
|
||||
// Execute the trace.
|
||||
if err := args.CallDefaults(api.backend.RPCGasCap(), blockContext.BaseFee, api.backend.ChainConfig().ChainID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var (
|
||||
isPrague1 = api.backend.ChainConfig().IsPrague1(vmctx.BlockNumber, vmctx.Time)
|
||||
isPrague1 = api.backend.ChainConfig().IsPrague1(blockContext.BlockNumber, blockContext.Time)
|
||||
distributorAddress = api.backend.ChainConfig().Berachain.Prague1.PoLDistributorAddress
|
||||
msg = args.ToMessage(vmctx.BaseFee, true, true, isPrague1, distributorAddress)
|
||||
msg = args.ToMessage(blockContext.BaseFee, true, true, isPrague1, distributorAddress)
|
||||
tx = args.ToTransaction(types.LegacyTxType, isPrague1, distributorAddress)
|
||||
traceConfig *TraceConfig
|
||||
)
|
||||
// Lower the basefee to 0 to avoid breaking EVM
|
||||
// invariants (basefee < feecap).
|
||||
if msg.GasPrice.Sign() == 0 {
|
||||
vmctx.BaseFee = new(big.Int)
|
||||
blockContext.BaseFee = new(big.Int)
|
||||
}
|
||||
if msg.BlobGasFeeCap != nil && msg.BlobGasFeeCap.BitLen() == 0 {
|
||||
vmctx.BlobBaseFee = new(big.Int)
|
||||
blockContext.BlobBaseFee = new(big.Int)
|
||||
}
|
||||
if config != nil {
|
||||
traceConfig = &config.TraceConfig
|
||||
}
|
||||
return api.traceTx(ctx, tx, msg, new(Context), vmctx, statedb, traceConfig, precompiles)
|
||||
return api.traceTx(ctx, tx, msg, new(Context), blockContext, statedb, traceConfig, precompiles)
|
||||
}
|
||||
|
||||
// traceTx configures a new tracer according to the provided configuration, and
|
||||
|
|
|
|||
|
|
@ -689,6 +689,7 @@ func TestTracingWithOverrides(t *testing.T) {
|
|||
Failed bool
|
||||
ReturnValue string
|
||||
}
|
||||
|
||||
var testSuite = []struct {
|
||||
blockNumber rpc.BlockNumber
|
||||
call ethapi.TransactionArgs
|
||||
|
|
@ -788,6 +789,25 @@ func TestTracingWithOverrides(t *testing.T) {
|
|||
},
|
||||
want: `{"gas":72666,"failed":false,"returnValue":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}`,
|
||||
},
|
||||
{ // Override blocknumber with block n+1 and query a blockhash (resolves issue #32175)
|
||||
blockNumber: rpc.LatestBlockNumber,
|
||||
call: ethapi.TransactionArgs{
|
||||
From: &accounts[0].addr,
|
||||
Input: newRPCBytes([]byte{
|
||||
byte(vm.PUSH1), byte(genBlocks),
|
||||
byte(vm.BLOCKHASH),
|
||||
byte(vm.PUSH1), 0x00,
|
||||
byte(vm.MSTORE),
|
||||
byte(vm.PUSH1), 0x20,
|
||||
byte(vm.PUSH1), 0x00,
|
||||
byte(vm.RETURN),
|
||||
}),
|
||||
},
|
||||
config: &TraceCallConfig{
|
||||
BlockOverrides: &override.BlockOverrides{Number: (*hexutil.Big)(big.NewInt(int64(genBlocks + 1)))},
|
||||
},
|
||||
want: fmt.Sprintf(`{"gas":59590,"failed":false,"returnValue":"%s"}`, backend.chain.GetHeaderByNumber(uint64(genBlocks)).Hash().Hex()),
|
||||
},
|
||||
/*
|
||||
pragma solidity =0.8.12;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,12 +48,11 @@ var (
|
|||
testSlot = common.HexToHash("0xdeadbeef")
|
||||
testValue = crypto.Keccak256Hash(testSlot[:])
|
||||
testBalance = big.NewInt(2e15)
|
||||
testTxHashes []common.Hash
|
||||
)
|
||||
|
||||
func newTestBackend(t *testing.T) (*node.Node, []*types.Block) {
|
||||
func newTestBackend(t *testing.T) (*node.Node, []*types.Block, []common.Hash) {
|
||||
// Generate test chain.
|
||||
genesis, blocks := generateTestChain()
|
||||
genesis, blocks, txHashes := generateTestChain()
|
||||
// Create node
|
||||
n, err := node.New(&node.Config{
|
||||
HTTPModules: []string{"debug", "eth", "admin"},
|
||||
|
|
@ -82,10 +81,10 @@ func newTestBackend(t *testing.T) (*node.Node, []*types.Block) {
|
|||
if _, err := ethservice.BlockChain().InsertChain(blocks[1:]); err != nil {
|
||||
t.Fatalf("can't import test blocks: %v", err)
|
||||
}
|
||||
return n, blocks
|
||||
return n, blocks, txHashes
|
||||
}
|
||||
|
||||
func generateTestChain() (*core.Genesis, []*types.Block) {
|
||||
func generateTestChain() (*core.Genesis, []*types.Block, []common.Hash) {
|
||||
genesis := &core.Genesis{
|
||||
Config: params.AllEthashProtocolChanges,
|
||||
Alloc: types.GenesisAlloc{
|
||||
|
|
@ -96,6 +95,7 @@ func generateTestChain() (*core.Genesis, []*types.Block) {
|
|||
ExtraData: []byte("test genesis"),
|
||||
Timestamp: 9000,
|
||||
}
|
||||
txHashes := make([]common.Hash, 0)
|
||||
generate := func(i int, g *core.BlockGen) {
|
||||
g.OffsetTime(5)
|
||||
g.SetExtra([]byte("test"))
|
||||
|
|
@ -111,15 +111,15 @@ func generateTestChain() (*core.Genesis, []*types.Block) {
|
|||
})
|
||||
tx, _ = types.SignTx(tx, types.LatestSignerForChainID(genesis.Config.ChainID), testKey)
|
||||
g.AddTx(tx)
|
||||
testTxHashes = append(testTxHashes, tx.Hash())
|
||||
txHashes = append(txHashes, tx.Hash())
|
||||
}
|
||||
_, blocks, _ := core.GenerateChainWithGenesis(genesis, ethash.NewFaker(), 1, generate)
|
||||
blocks = append([]*types.Block{genesis.ToBlock()}, blocks...)
|
||||
return genesis, blocks
|
||||
return genesis, blocks, txHashes
|
||||
}
|
||||
|
||||
func TestGethClient(t *testing.T) {
|
||||
backend, _ := newTestBackend(t)
|
||||
backend, _, txHashes := newTestBackend(t)
|
||||
client := backend.Attach()
|
||||
defer backend.Close()
|
||||
defer client.Close()
|
||||
|
|
@ -172,7 +172,7 @@ func TestGethClient(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"TestTraceTransaction",
|
||||
func(t *testing.T) { testTraceTransactions(t, client) },
|
||||
func(t *testing.T) { testTraceTransactions(t, client, txHashes) },
|
||||
},
|
||||
{
|
||||
"TestSetHead",
|
||||
|
|
@ -480,9 +480,9 @@ func testCallContract(t *testing.T, client *rpc.Client) {
|
|||
}
|
||||
}
|
||||
|
||||
func testTraceTransactions(t *testing.T, client *rpc.Client) {
|
||||
func testTraceTransactions(t *testing.T, client *rpc.Client, txHashes []common.Hash) {
|
||||
ec := New(client)
|
||||
for _, txHash := range testTxHashes {
|
||||
for _, txHash := range txHashes {
|
||||
// Struct logger
|
||||
_, err := ec.TraceTransaction(context.Background(), txHash, nil)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -83,11 +83,7 @@ func newBlobTx(sim *Backend, key *ecdsa.PrivateKey) (*types.Transaction, error)
|
|||
To: addr,
|
||||
AccessList: nil,
|
||||
BlobHashes: []common.Hash{testBlobVHash},
|
||||
Sidecar: &types.BlobTxSidecar{
|
||||
Blobs: []kzg4844.Blob{*testBlob},
|
||||
Commitments: []kzg4844.Commitment{testBlobCommit},
|
||||
Proofs: []kzg4844.Proof{testBlobProof},
|
||||
},
|
||||
Sidecar: types.NewBlobTxSidecar(types.BlobSidecarVersion0, []kzg4844.Blob{*testBlob}, []kzg4844.Commitment{testBlobCommit}, []kzg4844.Proof{testBlobProof}),
|
||||
})
|
||||
return types.SignTx(tx, types.LatestSignerForChainID(chainid), key)
|
||||
}
|
||||
|
|
|
|||
3
go.mod
3
go.mod
|
|
@ -24,7 +24,7 @@ require (
|
|||
github.com/ethereum/c-kzg-4844/v2 v2.1.0
|
||||
github.com/ethereum/go-verkle v0.2.2
|
||||
github.com/fatih/color v1.16.0
|
||||
github.com/ferranbt/fastssz v0.1.2
|
||||
github.com/ferranbt/fastssz v0.1.4
|
||||
github.com/fjl/gencodec v0.1.0
|
||||
github.com/fsnotify/fsnotify v1.6.0
|
||||
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff
|
||||
|
|
@ -101,6 +101,7 @@ require (
|
|||
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
|
||||
github.com/deepmap/oapi-codegen v1.6.0 // indirect
|
||||
github.com/dlclark/regexp2 v1.7.0 // indirect
|
||||
github.com/emicklei/dot v1.6.2 // indirect
|
||||
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61 // indirect
|
||||
github.com/getsentry/sentry-go v0.27.0 // indirect
|
||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||
|
|
|
|||
10
go.sum
10
go.sum
|
|
@ -108,14 +108,16 @@ github.com/dop251/goja v0.0.0-20230605162241-28ee0ee714f3 h1:+3HCtB74++ClLy8GgjU
|
|||
github.com/dop251/goja v0.0.0-20230605162241-28ee0ee714f3/go.mod h1:QMWlm50DNe14hD7t24KEqZuUdC9sOTy8W6XbCU1mlw4=
|
||||
github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y=
|
||||
github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM=
|
||||
github.com/emicklei/dot v1.6.2 h1:08GN+DD79cy/tzN6uLCT84+2Wk9u+wvqP+Hkx/dIR8A=
|
||||
github.com/emicklei/dot v1.6.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s=
|
||||
github.com/ethereum/c-kzg-4844/v2 v2.1.0 h1:gQropX9YFBhl3g4HYhwE70zq3IHFRgbbNPw0Shwzf5w=
|
||||
github.com/ethereum/c-kzg-4844/v2 v2.1.0/go.mod h1:TC48kOKjJKPbN7C++qIgt0TJzZ70QznYR7Ob+WXl57E=
|
||||
github.com/ethereum/go-verkle v0.2.2 h1:I2W0WjnrFUIzzVPwm8ykY+7pL2d4VhlsePn4j7cnFk8=
|
||||
github.com/ethereum/go-verkle v0.2.2/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
|
||||
github.com/ferranbt/fastssz v0.1.2 h1:Dky6dXlngF6Qjc+EfDipAkE83N5I5DE68bY6O0VLNPk=
|
||||
github.com/ferranbt/fastssz v0.1.2/go.mod h1:X5UPrE2u1UJjxHA8X54u04SBwdAQjG2sFtWs39YxyWs=
|
||||
github.com/ferranbt/fastssz v0.1.4 h1:OCDB+dYDEQDvAgtAGnTSidK1Pe2tW3nFV40XyMkTeDY=
|
||||
github.com/ferranbt/fastssz v0.1.4/go.mod h1:Ea3+oeoRGGLGm5shYAeDgu6PGUlcvQhE2fILyD9+tGg=
|
||||
github.com/fjl/gencodec v0.1.0 h1:B3K0xPfc52cw52BBgUbSPxYo+HlLfAgWMVKRWXUXBcs=
|
||||
github.com/fjl/gencodec v0.1.0/go.mod h1:Um1dFHPONZGTHog1qD1NaWjXJW/SPB38wPv0O8uZ2fI=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
|
|
@ -316,8 +318,8 @@ github.com/protolambda/zrnt v0.34.1 h1:qW55rnhZJDnOb3TwFiFRJZi3yTXFrJdGOFQM7vCwY
|
|||
github.com/protolambda/zrnt v0.34.1/go.mod h1:A0fezkp9Tt3GBLATSPIbuY4ywYESyAuc/FFmPKg8Lqs=
|
||||
github.com/protolambda/ztyp v0.2.2 h1:rVcL3vBu9W/aV646zF6caLS/dyn9BN8NYiuJzicLNyY=
|
||||
github.com/protolambda/ztyp v0.2.2/go.mod h1:9bYgKGqg3wJqT9ac1gI2hnVb0STQq7p/1lapqrqY1dU=
|
||||
github.com/prysmaticlabs/gohashtree v0.0.1-alpha.0.20220714111606-acbb2962fb48 h1:cSo6/vk8YpvkLbk9v3FO97cakNmUoxwi2KMP8hd5WIw=
|
||||
github.com/prysmaticlabs/gohashtree v0.0.1-alpha.0.20220714111606-acbb2962fb48/go.mod h1:4pWaT30XoEx1j8KNJf3TV+E3mQkaufn7mf+jRNb/Fuk=
|
||||
github.com/prysmaticlabs/gohashtree v0.0.4-beta h1:H/EbCuXPeTV3lpKeXGPpEV9gsUpkqOOVnWapUyeWro4=
|
||||
github.com/prysmaticlabs/gohashtree v0.0.4-beta/go.mod h1:BFdtALS+Ffhg3lGQIHv9HDWuHS8cTvHZzrHWxwOtGOs=
|
||||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
|
|
|
|||
|
|
@ -1581,7 +1581,7 @@ func (api *TransactionAPI) SendRawTransaction(ctx context.Context, input hexutil
|
|||
//
|
||||
// The account associated with addr must be unlocked.
|
||||
//
|
||||
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign
|
||||
// https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign
|
||||
func (api *TransactionAPI) Sign(addr common.Address, data hexutil.Bytes) (hexutil.Bytes, error) {
|
||||
// Look up the wallet containing the requested signer
|
||||
account := accounts.Account{Address: addr}
|
||||
|
|
@ -1640,11 +1640,7 @@ func (api *TransactionAPI) SignTransaction(ctx context.Context, args Transaction
|
|||
// no longer retains the blobs, only the blob hashes. In this step, we need
|
||||
// to put back the blob(s).
|
||||
if args.IsEIP4844() {
|
||||
signed = signed.WithBlobTxSidecar(&types.BlobTxSidecar{
|
||||
Blobs: args.Blobs,
|
||||
Commitments: args.Commitments,
|
||||
Proofs: args.Proofs,
|
||||
})
|
||||
signed = signed.WithBlobTxSidecar(types.NewBlobTxSidecar(types.BlobSidecarVersion0, args.Blobs, args.Commitments, args.Proofs))
|
||||
}
|
||||
data, err := signed.MarshalBinary()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -2768,11 +2768,7 @@ func TestFillBlobTransaction(t *testing.T) {
|
|||
},
|
||||
want: &result{
|
||||
Hashes: []common.Hash{emptyBlobHash},
|
||||
Sidecar: &types.BlobTxSidecar{
|
||||
Blobs: emptyBlobs,
|
||||
Commitments: []kzg4844.Commitment{emptyBlobCommit},
|
||||
Proofs: []kzg4844.Proof{emptyBlobProof},
|
||||
},
|
||||
Sidecar: types.NewBlobTxSidecar(types.BlobSidecarVersion0, emptyBlobs, []kzg4844.Commitment{emptyBlobCommit}, []kzg4844.Proof{emptyBlobProof}),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -2788,11 +2784,7 @@ func TestFillBlobTransaction(t *testing.T) {
|
|||
},
|
||||
want: &result{
|
||||
Hashes: []common.Hash{emptyBlobHash},
|
||||
Sidecar: &types.BlobTxSidecar{
|
||||
Blobs: emptyBlobs,
|
||||
Commitments: []kzg4844.Commitment{emptyBlobCommit},
|
||||
Proofs: []kzg4844.Proof{emptyBlobProof},
|
||||
},
|
||||
Sidecar: types.NewBlobTxSidecar(types.BlobSidecarVersion0, emptyBlobs, []kzg4844.Commitment{emptyBlobCommit}, []kzg4844.Proof{emptyBlobProof}),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -2818,11 +2810,7 @@ func TestFillBlobTransaction(t *testing.T) {
|
|||
},
|
||||
want: &result{
|
||||
Hashes: []common.Hash{emptyBlobHash},
|
||||
Sidecar: &types.BlobTxSidecar{
|
||||
Blobs: emptyBlobs,
|
||||
Commitments: []kzg4844.Commitment{emptyBlobCommit},
|
||||
Proofs: []kzg4844.Proof{emptyBlobProof},
|
||||
},
|
||||
Sidecar: types.NewBlobTxSidecar(types.BlobSidecarVersion0, emptyBlobs, []kzg4844.Commitment{emptyBlobCommit}, []kzg4844.Proof{emptyBlobProof}),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ type revertError struct {
|
|||
}
|
||||
|
||||
// ErrorCode returns the JSON error code for a revert.
|
||||
// See: https://github.com/ethereum/wiki/wiki/JSON-RPC-Error-Codes-Improvement-Proposal
|
||||
// See: https://ethereum.org/en/developers/docs/apis/json-rpc/#error-codes
|
||||
func (e *revertError) ErrorCode() int {
|
||||
return 3
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ func (e *TxIndexingError) Error() string {
|
|||
}
|
||||
|
||||
// ErrorCode returns the JSON error code for a revert.
|
||||
// See: https://github.com/ethereum/wiki/wiki/JSON-RPC-Error-Codes-Improvement-Proposal
|
||||
// See: https://ethereum.org/en/developers/docs/apis/json-rpc/#error-codes
|
||||
func (e *TxIndexingError) ErrorCode() int {
|
||||
return -32000 // to be decided
|
||||
}
|
||||
|
|
|
|||
|
|
@ -544,11 +544,8 @@ func (args *TransactionArgs) ToTransaction(defaultType int, isPrague1 bool, dist
|
|||
BlobFeeCap: uint256.MustFromBig((*big.Int)(args.BlobFeeCap)),
|
||||
}
|
||||
if args.Blobs != nil {
|
||||
data.(*types.BlobTx).Sidecar = &types.BlobTxSidecar{
|
||||
Blobs: args.Blobs,
|
||||
Commitments: args.Commitments,
|
||||
Proofs: args.Proofs,
|
||||
}
|
||||
// TODO(rjl493456442, marius) support V1
|
||||
data.(*types.BlobTx).Sidecar = types.NewBlobTxSidecar(types.BlobSidecarVersion0, args.Blobs, args.Commitments, args.Proofs)
|
||||
}
|
||||
|
||||
case types.DynamicFeeTxType:
|
||||
|
|
|
|||
|
|
@ -17,19 +17,18 @@
|
|||
package flags
|
||||
|
||||
import (
|
||||
"os/user"
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPathExpansion(t *testing.T) {
|
||||
user, _ := user.Current()
|
||||
home := HomeDir()
|
||||
var tests map[string]string
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
tests = map[string]string{
|
||||
`/home/someuser/tmp`: `\home\someuser\tmp`,
|
||||
`~/tmp`: user.HomeDir + `\tmp`,
|
||||
`~/tmp`: home + `\tmp`,
|
||||
`~thisOtherUser/b/`: `~thisOtherUser\b`,
|
||||
`$DDDXXX/a/b`: `\tmp\a\b`,
|
||||
`/a/b/`: `\a\b`,
|
||||
|
|
@ -40,7 +39,7 @@ func TestPathExpansion(t *testing.T) {
|
|||
} else {
|
||||
tests = map[string]string{
|
||||
`/home/someuser/tmp`: `/home/someuser/tmp`,
|
||||
`~/tmp`: user.HomeDir + `/tmp`,
|
||||
`~/tmp`: home + `/tmp`,
|
||||
`~thisOtherUser/b/`: `~thisOtherUser/b`,
|
||||
`$DDDXXX/a/b`: `/tmp/a/b`,
|
||||
`/a/b/`: `/a/b`,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/core/txpool"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/crypto/kzg4844"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/holiman/uint256"
|
||||
|
|
@ -50,6 +49,7 @@ type environment struct {
|
|||
signer types.Signer
|
||||
state *state.StateDB // apply state changes here
|
||||
tcount int // tx count in cycle
|
||||
size uint64 // size of the block we are building
|
||||
gasPool *core.GasPool // available gas used to pack transactions
|
||||
coinbase common.Address
|
||||
evm *vm.EVM
|
||||
|
|
@ -63,6 +63,11 @@ type environment struct {
|
|||
witness *stateless.Witness
|
||||
}
|
||||
|
||||
// txFits reports whether the transaction fits into the block size limit.
|
||||
func (env *environment) txFitsSize(tx *types.Transaction) bool {
|
||||
return env.size+tx.Size() < params.MaxBlockSize-maxBlockSizeBufferZone
|
||||
}
|
||||
|
||||
const (
|
||||
commitInterruptNone int32 = iota
|
||||
commitInterruptNewHead
|
||||
|
|
@ -70,6 +75,11 @@ const (
|
|||
commitInterruptTimeout
|
||||
)
|
||||
|
||||
// Block size is capped by the protocol at params.MaxBlockSize. When producing blocks, we
|
||||
// try to say below the size including a buffer zone, this is to avoid going over the
|
||||
// maximum size with auxiliary data added into the block.
|
||||
const maxBlockSizeBufferZone = 1_000_000
|
||||
|
||||
// newPayloadResult is the result of payload generation.
|
||||
type newPayloadResult struct {
|
||||
err error
|
||||
|
|
@ -96,12 +106,23 @@ type generateParams struct {
|
|||
}
|
||||
|
||||
// generateWork generates a sealing block based on the given parameters.
|
||||
func (miner *Miner) generateWork(params *generateParams, witness bool) *newPayloadResult {
|
||||
work, err := miner.prepareWork(params, witness)
|
||||
func (miner *Miner) generateWork(genParam *generateParams, witness bool) *newPayloadResult {
|
||||
work, err := miner.prepareWork(genParam, witness)
|
||||
if err != nil {
|
||||
return &newPayloadResult{err: err}
|
||||
}
|
||||
if !params.noTxs {
|
||||
|
||||
// Check withdrawals fit max block size.
|
||||
// Due to the cap on withdrawal count, this can actually never happen, but we still need to
|
||||
// check to ensure the CL notices there's a problem if the withdrawal cap is ever lifted.
|
||||
maxBlockSize := params.MaxBlockSize - maxBlockSizeBufferZone
|
||||
if genParam.withdrawals.Size() > maxBlockSize {
|
||||
return &newPayloadResult{err: errors.New("withdrawals exceed max block size")}
|
||||
}
|
||||
// Also add size of withdrawals to work block size.
|
||||
work.size += uint64(genParam.withdrawals.Size())
|
||||
|
||||
if !genParam.noTxs {
|
||||
interrupt := new(atomic.Int32)
|
||||
timer := time.AfterFunc(miner.config.Recommit, func() {
|
||||
interrupt.Store(commitInterruptTimeout)
|
||||
|
|
@ -113,8 +134,8 @@ func (miner *Miner) generateWork(params *generateParams, witness bool) *newPaylo
|
|||
log.Warn("Block building is interrupted", "allowance", common.PrettyDuration(miner.config.Recommit))
|
||||
}
|
||||
}
|
||||
body := types.Body{Transactions: work.txs, Withdrawals: genParam.withdrawals}
|
||||
|
||||
body := types.Body{Transactions: work.txs, Withdrawals: params.withdrawals}
|
||||
allLogs := make([]*types.Log, 0)
|
||||
for _, r := range work.receipts {
|
||||
allLogs = append(allLogs, r.Logs...)
|
||||
|
|
@ -261,6 +282,7 @@ func (miner *Miner) makeEnv(parent *types.Header, header *types.Header, coinbase
|
|||
return &environment{
|
||||
signer: types.MakeSigner(miner.chainConfig, header.Number, header.Time),
|
||||
state: state,
|
||||
size: uint64(header.Size()),
|
||||
coinbase: coinbase,
|
||||
header: header,
|
||||
witness: state.Witness(),
|
||||
|
|
@ -278,6 +300,7 @@ func (miner *Miner) commitTransaction(env *environment, tx *types.Transaction) e
|
|||
}
|
||||
env.txs = append(env.txs, tx)
|
||||
env.receipts = append(env.receipts, receipt)
|
||||
env.size += tx.Size()
|
||||
env.tcount++
|
||||
return nil
|
||||
}
|
||||
|
|
@ -299,10 +322,12 @@ func (miner *Miner) commitBlobTransaction(env *environment, tx *types.Transactio
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
env.txs = append(env.txs, tx.WithoutBlobTxSidecar())
|
||||
txNoBlob := tx.WithoutBlobTxSidecar()
|
||||
env.txs = append(env.txs, txNoBlob)
|
||||
env.receipts = append(env.receipts, receipt)
|
||||
env.sidecars = append(env.sidecars, sc)
|
||||
env.blobs += len(sc.Blobs)
|
||||
env.size += txNoBlob.Size()
|
||||
*env.header.BlobGasUsed += receipt.BlobGasUsed
|
||||
env.tcount++
|
||||
return nil
|
||||
|
|
@ -333,7 +358,11 @@ func (miner *Miner) applyTransaction(env *environment, tx *types.Transaction) (*
|
|||
}
|
||||
|
||||
func (miner *Miner) commitTransactions(env *environment, plainTxs, blobTxs *transactionsByPriceAndNonce, interrupt *atomic.Int32) error {
|
||||
gasLimit := env.header.GasLimit
|
||||
var (
|
||||
isOsaka = miner.chainConfig.IsOsaka(env.header.Number, env.header.Time)
|
||||
isCancun = miner.chainConfig.IsCancun(env.header.Number, env.header.Time)
|
||||
gasLimit = env.header.GasLimit
|
||||
)
|
||||
if env.gasPool == nil {
|
||||
env.gasPool = new(core.GasPool).AddGas(gasLimit)
|
||||
}
|
||||
|
|
@ -389,7 +418,7 @@ func (miner *Miner) commitTransactions(env *environment, plainTxs, blobTxs *tran
|
|||
// Most of the blob gas logic here is agnostic as to if the chain supports
|
||||
// blobs or not, however the max check panics when called on a chain without
|
||||
// a defined schedule, so we need to verify it's safe to call.
|
||||
if miner.chainConfig.IsCancun(env.header.Number, env.header.Time) {
|
||||
if isCancun {
|
||||
left := eip4844.MaxBlobsPerBlock(miner.chainConfig, env.header.Time) - env.blobs
|
||||
if left < int(ltx.BlobGas/params.BlobTxBlobGasPerBlob) {
|
||||
log.Trace("Not enough blob space left for transaction", "hash", ltx.Hash, "left", left, "needed", ltx.BlobGas/params.BlobTxBlobGasPerBlob)
|
||||
|
|
@ -406,18 +435,21 @@ func (miner *Miner) commitTransactions(env *environment, plainTxs, blobTxs *tran
|
|||
continue
|
||||
}
|
||||
|
||||
// Make sure all transactions after osaka have cell proofs
|
||||
if miner.chainConfig.IsOsaka(env.header.Number, env.header.Time) {
|
||||
if sidecar := tx.BlobTxSidecar(); sidecar != nil {
|
||||
if sidecar.Version == 0 {
|
||||
log.Info("Including blob tx with v0 sidecar, recomputing proofs", "hash", ltx.Hash)
|
||||
sidecar.Proofs = make([]kzg4844.Proof, 0, len(sidecar.Blobs)*kzg4844.CellProofsPerBlob)
|
||||
for _, blob := range sidecar.Blobs {
|
||||
cellProofs, err := kzg4844.ComputeCellProofs(&blob)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
// if inclusion of the transaction would put the block size over the
|
||||
// maximum we allow, don't add any more txs to the payload.
|
||||
if !env.txFitsSize(tx) {
|
||||
break
|
||||
}
|
||||
sidecar.Proofs = append(sidecar.Proofs, cellProofs...)
|
||||
|
||||
// Make sure all transactions after osaka have cell proofs
|
||||
if isOsaka {
|
||||
if sidecar := tx.BlobTxSidecar(); sidecar != nil {
|
||||
if sidecar.Version == types.BlobSidecarVersion0 {
|
||||
log.Info("Including blob tx with v0 sidecar, recomputing proofs", "hash", ltx.Hash)
|
||||
if err := sidecar.ToV1(); err != nil {
|
||||
txs.Pop()
|
||||
log.Warn("Failed to recompute cell proofs", "hash", ltx.Hash, "err", err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -500,6 +532,9 @@ func (miner *Miner) fillTransactions(interrupt *atomic.Int32, env *environment)
|
|||
if env.header.ExcessBlobGas != nil {
|
||||
filter.BlobFee = uint256.MustFromBig(eip4844.CalcBlobFee(miner.chainConfig, env.header))
|
||||
}
|
||||
if miner.chainConfig.IsOsaka(env.header.Number, env.header.Time) {
|
||||
filter.GasLimitCap = params.MaxTxGas
|
||||
}
|
||||
filter.OnlyPlainTxs, filter.OnlyBlobTxs = true, false
|
||||
pendingPlainTxs := miner.txpool.Pending(filter)
|
||||
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ func (h *httpServer) start() error {
|
|||
}
|
||||
// Log http endpoint.
|
||||
h.log.Info("HTTP server started",
|
||||
"endpoint", listener.Addr(), "auth", (h.httpConfig.jwtSecret != nil),
|
||||
"endpoint", listener.Addr(), "auth", h.httpConfig.jwtSecret != nil,
|
||||
"prefix", h.httpConfig.prefix,
|
||||
"cors", strings.Join(h.httpConfig.CorsAllowedOrigins, ","),
|
||||
"vhosts", strings.Join(h.httpConfig.Vhosts, ","),
|
||||
|
|
|
|||
|
|
@ -562,7 +562,7 @@ func (tab *Table) addReplacement(b *bucket, n *enode.Node) {
|
|||
}
|
||||
|
||||
func (tab *Table) nodeAdded(b *bucket, n *tableNode) {
|
||||
if n.addedToTable == (time.Time{}) {
|
||||
if n.addedToTable.IsZero() {
|
||||
n.addedToTable = time.Now()
|
||||
}
|
||||
n.addedToBucket = time.Now()
|
||||
|
|
|
|||
|
|
@ -496,6 +496,11 @@ type ChainConfig struct {
|
|||
PragueTime *uint64 `json:"pragueTime,omitempty"` // Prague switch time (nil = no fork, 0 = already on prague)
|
||||
OsakaTime *uint64 `json:"osakaTime,omitempty"` // Osaka switch time (nil = no fork, 0 = already on osaka)
|
||||
VerkleTime *uint64 `json:"verkleTime,omitempty"` // Verkle switch time (nil = no fork, 0 = already on verkle)
|
||||
BPO1Time *uint64 `json:"bpo1Time,omitempty"` // BPO1 switch time (nil = no fork, 0 = already on bpo1)
|
||||
BPO2Time *uint64 `json:"bpo2Time,omitempty"` // BPO2 switch time (nil = no fork, 0 = already on bpo2)
|
||||
BPO3Time *uint64 `json:"bpo3Time,omitempty"` // BPO3 switch time (nil = no fork, 0 = already on bpo3)
|
||||
BPO4Time *uint64 `json:"bpo4Time,omitempty"` // BPO4 switch time (nil = no fork, 0 = already on bpo4)
|
||||
BPO5Time *uint64 `json:"bpo5Time,omitempty"` // BPO5 switch time (nil = no fork, 0 = already on bpo5)
|
||||
|
||||
// TerminalTotalDifficulty is the amount of total difficulty reached by
|
||||
// the network that triggers the consensus upgrade.
|
||||
|
|
@ -661,6 +666,21 @@ func (c *ChainConfig) Description() string {
|
|||
if c.VerkleTime != nil {
|
||||
banner += fmt.Sprintf(" - Verkle: @%-10v\n", *c.VerkleTime)
|
||||
}
|
||||
if c.BPO1Time != nil {
|
||||
banner += fmt.Sprintf(" - BPO1: @%-10v\n", *c.BPO1Time)
|
||||
}
|
||||
if c.BPO2Time != nil {
|
||||
banner += fmt.Sprintf(" - BPO2: @%-10v\n", *c.BPO2Time)
|
||||
}
|
||||
if c.BPO3Time != nil {
|
||||
banner += fmt.Sprintf(" - BPO3: @%-10v\n", *c.BPO3Time)
|
||||
}
|
||||
if c.BPO4Time != nil {
|
||||
banner += fmt.Sprintf(" - BPO4: @%-10v\n", *c.BPO4Time)
|
||||
}
|
||||
if c.BPO5Time != nil {
|
||||
banner += fmt.Sprintf(" - BPO5: @%-10v\n", *c.BPO5Time)
|
||||
}
|
||||
return banner
|
||||
}
|
||||
|
||||
|
|
@ -677,6 +697,11 @@ type BlobScheduleConfig struct {
|
|||
Prague *BlobConfig `json:"prague,omitempty"`
|
||||
Osaka *BlobConfig `json:"osaka,omitempty"`
|
||||
Verkle *BlobConfig `json:"verkle,omitempty"`
|
||||
BPO1 *BlobConfig `json:"bpo1,omitempty"`
|
||||
BPO2 *BlobConfig `json:"bpo2,omitempty"`
|
||||
BPO3 *BlobConfig `json:"bpo3,omitempty"`
|
||||
BPO4 *BlobConfig `json:"bpo4,omitempty"`
|
||||
BPO5 *BlobConfig `json:"bpo5,omitempty"`
|
||||
}
|
||||
|
||||
// IsHomestead returns whether num is either equal to the homestead block or greater.
|
||||
|
|
@ -790,6 +815,31 @@ func (c *ChainConfig) IsVerkle(num *big.Int, time uint64) bool {
|
|||
return c.IsLondon(num) && isTimestampForked(c.VerkleTime, time)
|
||||
}
|
||||
|
||||
// IsBPO1 returns whether time is either equal to the BPO1 fork time or greater.
|
||||
func (c *ChainConfig) IsBPO1(num *big.Int, time uint64) bool {
|
||||
return c.IsLondon(num) && isTimestampForked(c.BPO1Time, time)
|
||||
}
|
||||
|
||||
// IsBPO2 returns whether time is either equal to the BPO2 fork time or greater.
|
||||
func (c *ChainConfig) IsBPO2(num *big.Int, time uint64) bool {
|
||||
return c.IsLondon(num) && isTimestampForked(c.BPO2Time, time)
|
||||
}
|
||||
|
||||
// IsBPO3 returns whether time is either equal to the BPO3 fork time or greater.
|
||||
func (c *ChainConfig) IsBPO3(num *big.Int, time uint64) bool {
|
||||
return c.IsLondon(num) && isTimestampForked(c.BPO3Time, time)
|
||||
}
|
||||
|
||||
// IsBPO4 returns whether time is either equal to the BPO4 fork time or greater.
|
||||
func (c *ChainConfig) IsBPO4(num *big.Int, time uint64) bool {
|
||||
return c.IsLondon(num) && isTimestampForked(c.BPO4Time, time)
|
||||
}
|
||||
|
||||
// IsBPO5 returns whether time is either equal to the BPO5 fork time or greater.
|
||||
func (c *ChainConfig) IsBPO5(num *big.Int, time uint64) bool {
|
||||
return c.IsLondon(num) && isTimestampForked(c.BPO5Time, time)
|
||||
}
|
||||
|
||||
// IsVerkleGenesis checks whether the verkle fork is activated at the genesis block.
|
||||
//
|
||||
// Verkle mode is considered enabled if the verkle fork time is configured,
|
||||
|
|
@ -866,6 +916,11 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
|
|||
{name: "prague1Time", timestamp: c.Berachain.Prague1.Time, optional: true},
|
||||
{name: "osakaTime", timestamp: c.OsakaTime, optional: true},
|
||||
{name: "verkleTime", timestamp: c.VerkleTime, optional: true},
|
||||
{name: "bpo1", timestamp: c.BPO1Time, optional: true},
|
||||
{name: "bpo2", timestamp: c.BPO2Time, optional: true},
|
||||
{name: "bpo3", timestamp: c.BPO3Time, optional: true},
|
||||
{name: "bpo4", timestamp: c.BPO4Time, optional: true},
|
||||
{name: "bpo5", timestamp: c.BPO5Time, optional: true},
|
||||
} {
|
||||
if lastFork.name != "" {
|
||||
switch {
|
||||
|
|
@ -915,6 +970,11 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
|
|||
{name: "cancun", timestamp: c.CancunTime, config: bsc.Cancun},
|
||||
{name: "prague", timestamp: c.PragueTime, config: bsc.Prague},
|
||||
{name: "osaka", timestamp: c.OsakaTime, config: bsc.Osaka},
|
||||
{name: "bpo1", timestamp: c.BPO1Time, config: bsc.BPO1},
|
||||
{name: "bpo2", timestamp: c.BPO2Time, config: bsc.BPO2},
|
||||
{name: "bpo3", timestamp: c.BPO3Time, config: bsc.BPO3},
|
||||
{name: "bpo4", timestamp: c.BPO4Time, config: bsc.BPO4},
|
||||
{name: "bpo5", timestamp: c.BPO5Time, config: bsc.BPO5},
|
||||
} {
|
||||
if cur.config != nil {
|
||||
if err := cur.config.validate(); err != nil {
|
||||
|
|
@ -1018,6 +1078,21 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int,
|
|||
if isForkTimestampIncompatible(c.VerkleTime, newcfg.VerkleTime, headTimestamp) {
|
||||
return newTimestampCompatError("Verkle fork timestamp", c.VerkleTime, newcfg.VerkleTime)
|
||||
}
|
||||
if isForkTimestampIncompatible(c.BPO1Time, newcfg.BPO1Time, headTimestamp) {
|
||||
return newTimestampCompatError("BPO1 fork timestamp", c.BPO1Time, newcfg.BPO1Time)
|
||||
}
|
||||
if isForkTimestampIncompatible(c.BPO2Time, newcfg.BPO2Time, headTimestamp) {
|
||||
return newTimestampCompatError("BPO2 fork timestamp", c.BPO2Time, newcfg.BPO2Time)
|
||||
}
|
||||
if isForkTimestampIncompatible(c.BPO3Time, newcfg.BPO3Time, headTimestamp) {
|
||||
return newTimestampCompatError("BPO3 fork timestamp", c.BPO3Time, newcfg.BPO3Time)
|
||||
}
|
||||
if isForkTimestampIncompatible(c.BPO4Time, newcfg.BPO4Time, headTimestamp) {
|
||||
return newTimestampCompatError("BPO4 fork timestamp", c.BPO4Time, newcfg.BPO4Time)
|
||||
}
|
||||
if isForkTimestampIncompatible(c.BPO5Time, newcfg.BPO5Time, headTimestamp) {
|
||||
return newTimestampCompatError("BPO5 fork timestamp", c.BPO5Time, newcfg.BPO5Time)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ const (
|
|||
MaxGasLimit uint64 = 0x7fffffffffffffff // Maximum the gas limit (2^63-1).
|
||||
GenesisGasLimit uint64 = 4712388 // Gas limit of the Genesis block.
|
||||
|
||||
MaxTxGas uint64 = 1 << 24 // Maximum transaction gas limit after eip-7825 (16,777,216).
|
||||
|
||||
MaximumExtraDataSize uint64 = 32 // Maximum size extra data may be after Genesis.
|
||||
ExpByteGas uint64 = 10 // Times ceil(log256(exponent)) for the EXP instruction.
|
||||
SloadGas uint64 = 50 // Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added.
|
||||
|
|
@ -163,6 +165,8 @@ const (
|
|||
Bls12381MapG1Gas uint64 = 5500 // Gas price for BLS12-381 mapping field element to G1 operation
|
||||
Bls12381MapG2Gas uint64 = 23800 // Gas price for BLS12-381 mapping field element to G2 operation
|
||||
|
||||
P256VerifyGas uint64 = 6900 // secp256r1 elliptic curve signature verifier gas price
|
||||
|
||||
// The Refund Quotient is the cap on how much of the used gas can be refunded. Before EIP-3529,
|
||||
// up to half the consumed gas could be refunded. Redefined as 1/5th in EIP-3529
|
||||
RefundQuotient uint64 = 2
|
||||
|
|
@ -173,8 +177,12 @@ const (
|
|||
BlobTxBlobGasPerBlob = 1 << 17 // Gas consumption of a single data blob (== blob byte size)
|
||||
BlobTxMinBlobGasprice = 1 // Minimum gas price for data blobs
|
||||
BlobTxPointEvaluationPrecompileGas = 50000 // Gas price for the point evaluation precompile.
|
||||
BlobTxMaxBlobs = 6
|
||||
BlobBaseCost = 1 << 13 // Base execution gas cost for a blob.
|
||||
|
||||
HistoryServeWindow = 8192 // Number of blocks to serve historical block hashes for, EIP-2935.
|
||||
|
||||
MaxBlockSize = 8_388_608 // maximum size of an RLP-encoded block
|
||||
)
|
||||
|
||||
// Bls12381G1MultiExpDiscountTable is the gas discount table for BLS12-381 G1 multi exponentiation operation
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ Subscriptions are deleted when the user sends an unsubscribe request or when the
|
|||
connection which was used to create the subscription is closed. This can be initiated by
|
||||
the client and server. The server will close the connection for any write error.
|
||||
|
||||
For more information about subscriptions, see https://github.com/ethereum/go-ethereum/wiki/RPC-PUB-SUB.
|
||||
For more information about subscriptions, see https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub
|
||||
|
||||
# Reverse Calls
|
||||
|
||||
|
|
|
|||
|
|
@ -150,6 +150,9 @@ func (args *SendTxArgs) ToTransaction() (*types.Transaction, error) {
|
|||
if args.AccessList != nil {
|
||||
al = *args.AccessList
|
||||
}
|
||||
if to == nil {
|
||||
return nil, fmt.Errorf("transaction recipient must be set for blob transactions")
|
||||
}
|
||||
data = &types.BlobTx{
|
||||
To: *to,
|
||||
ChainID: uint256.MustFromBig((*big.Int)(args.ChainID)),
|
||||
|
|
@ -164,11 +167,8 @@ func (args *SendTxArgs) ToTransaction() (*types.Transaction, error) {
|
|||
BlobFeeCap: uint256.MustFromBig((*big.Int)(args.BlobFeeCap)),
|
||||
}
|
||||
if args.Blobs != nil {
|
||||
data.(*types.BlobTx).Sidecar = &types.BlobTxSidecar{
|
||||
Blobs: args.Blobs,
|
||||
Commitments: args.Commitments,
|
||||
Proofs: args.Proofs,
|
||||
}
|
||||
// TODO(rjl493456442, marius) support V1
|
||||
data.(*types.BlobTx).Sidecar = types.NewBlobTxSidecar(types.BlobSidecarVersion0, args.Blobs, args.Commitments, args.Proofs)
|
||||
}
|
||||
|
||||
case args.MaxFeePerGas != nil:
|
||||
|
|
@ -219,7 +219,6 @@ func (args *SendTxArgs) validateTxSidecar() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
n := len(args.Blobs)
|
||||
// Assume user provides either only blobs (w/o hashes), or
|
||||
// blobs together with commitments and proofs.
|
||||
if args.Commitments == nil && args.Proofs != nil {
|
||||
|
|
@ -229,6 +228,7 @@ func (args *SendTxArgs) validateTxSidecar() error {
|
|||
}
|
||||
|
||||
// len(blobs) == len(commitments) == len(proofs) == len(hashes)
|
||||
n := len(args.Blobs)
|
||||
if args.Commitments != nil && len(args.Commitments) != n {
|
||||
return fmt.Errorf("number of blobs and commitments mismatch (have=%d, want=%d)", len(args.Commitments), n)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,11 +129,7 @@ func TestBlobTxs(t *testing.T) {
|
|||
BlobFeeCap: uint256.NewInt(700),
|
||||
BlobHashes: []common.Hash{hash},
|
||||
Value: uint256.NewInt(100),
|
||||
Sidecar: &types.BlobTxSidecar{
|
||||
Blobs: []kzg4844.Blob{blob},
|
||||
Commitments: []kzg4844.Commitment{commitment},
|
||||
Proofs: []kzg4844.Proof{proof},
|
||||
},
|
||||
Sidecar: types.NewBlobTxSidecar(types.BlobSidecarVersion0, []kzg4844.Blob{blob}, []kzg4844.Commitment{commitment}, []kzg4844.Proof{proof}),
|
||||
}
|
||||
tx := types.NewTx(b)
|
||||
data, err := json.Marshal(tx)
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue