Skip to content

Commit

Permalink
Merge branch 'ethereum:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticroentgen authored Dec 23, 2024
2 parents ad96c5f + 341647f commit ab8ab34
Show file tree
Hide file tree
Showing 94 changed files with 4,625 additions and 371 deletions.
18 changes: 15 additions & 3 deletions accounts/abi/bind/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@ import (
// WaitMined waits for tx to be mined on the blockchain.
// It stops waiting when the context is canceled.
func WaitMined(ctx context.Context, b DeployBackend, tx *types.Transaction) (*types.Receipt, error) {
return WaitMinedHash(ctx, b, tx.Hash())
}

// WaitMinedHash waits for a transaction with the provided hash to be mined on the blockchain.
// It stops waiting when the context is canceled.
func WaitMinedHash(ctx context.Context, b DeployBackend, hash common.Hash) (*types.Receipt, error) {
queryTicker := time.NewTicker(time.Second)
defer queryTicker.Stop()

logger := log.New("hash", tx.Hash())
logger := log.New("hash", hash)
for {
receipt, err := b.TransactionReceipt(ctx, tx.Hash())
receipt, err := b.TransactionReceipt(ctx, hash)
if err == nil {
return receipt, nil
}
Expand All @@ -61,7 +67,13 @@ func WaitDeployed(ctx context.Context, b DeployBackend, tx *types.Transaction) (
if tx.To() != nil {
return common.Address{}, errors.New("tx is not contract creation")
}
receipt, err := WaitMined(ctx, b, tx)
return WaitDeployedHash(ctx, b, tx.Hash())
}

// WaitDeployedHash waits for a contract deployment transaction with the provided hash and returns the on-chain
// contract address when it is mined. It stops waiting when ctx is canceled.
func WaitDeployedHash(ctx context.Context, b DeployBackend, hash common.Hash) (common.Address, error) {
receipt, err := WaitMinedHash(ctx, b, hash)
if err != nil {
return common.Address{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion accounts/external/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transactio
switch tx.Type() {
case types.LegacyTxType, types.AccessListTxType:
args.GasPrice = (*hexutil.Big)(tx.GasPrice())
case types.DynamicFeeTxType, types.BlobTxType:
case types.DynamicFeeTxType, types.BlobTxType, types.SetCodeTxType:
args.MaxFeePerGas = (*hexutil.Big)(tx.GasFeeCap())
args.MaxPriorityFeePerGas = (*hexutil.Big)(tx.GasTipCap())
default:
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/blockrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func blockTestCmd(ctx *cli.Context) error {
return errors.New("path argument required")
}
var (
collected = collectJSONFiles(path)
collected = collectFiles(path)
results []testResult
)
for _, fname := range collected {
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/eofparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var jt vm.JumpTable
const initcode = "INITCODE"

func init() {
jt = vm.NewPragueEOFInstructionSetForTesting()
jt = vm.NewEOFInstructionSetForTesting()
}

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/eofparse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func FuzzEofParsing(f *testing.F) {
// And do the fuzzing
f.Fuzz(func(t *testing.T, data []byte) {
var (
jt = vm.NewPragueEOFInstructionSetForTesting()
jt = vm.NewEOFInstructionSetForTesting()
c vm.Container
)
cpy := common.CopyBytes(data)
Expand Down
4 changes: 2 additions & 2 deletions cmd/evm/internal/t8ntool/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ type ExecutionResult struct {
CurrentExcessBlobGas *math.HexOrDecimal64 `json:"currentExcessBlobGas,omitempty"`
CurrentBlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed,omitempty"`
RequestsHash *common.Hash `json:"requestsHash,omitempty"`
Requests [][]byte `json:"requests,omitempty"`
Requests [][]byte `json:"requests"`
}

type executionResultMarshaling struct {
Requests []hexutil.Bytes `json:"requests,omitempty"`
Requests []hexutil.Bytes `json:"requests"`
}

type ommer struct {
Expand Down
4 changes: 2 additions & 2 deletions cmd/evm/internal/t8ntool/gen_execresult.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/evm/internal/t8ntool/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func Transaction(ctx *cli.Context) error {
r.Address = sender
}
// Check intrinsic gas
if gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil,
if gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil,
chainConfig.IsHomestead(new(big.Int)), chainConfig.IsIstanbul(new(big.Int)), chainConfig.IsShanghai(new(big.Int), 0)); err != nil {
r.Error = err
results = append(results, r)
Expand Down
11 changes: 8 additions & 3 deletions cmd/evm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,15 @@ func tracerFromFlags(ctx *cli.Context) *tracing.Hooks {
}
}

// collectJSONFiles walks the given path and accumulates all files with json
// extension.
func collectJSONFiles(path string) []string {
// collectFiles walks the given path. If the path is a directory, it will
// return a list of all accumulates all files with json extension.
// Otherwise (if path points to a file), it will return the path.
func collectFiles(path string) []string {
var out []string
if info, err := os.Stat(path); err == nil && !info.IsDir() {
// User explicitly pointed out a file, ignore extension.
return []string{path}
}
err := filepath.Walk(path, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/staterunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func stateTestCmd(ctx *cli.Context) error {
// If path is provided, run the tests at that path.
if len(path) != 0 {
var (
collected = collectJSONFiles(path)
collected = collectFiles(path)
results []testResult
)
for _, fname := range collected {
Expand Down
8 changes: 8 additions & 0 deletions cmd/evm/t8n_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,14 @@ func TestT8n(t *testing.T) {
output: t8nOutput{alloc: true, result: true},
expOut: "exp.json",
},
{ // Prague test, EIP-7702 transaction
base: "./testdata/33",
input: t8nInput{
"alloc.json", "txs.json", "env.json", "Prague", "",
},
output: t8nOutput{alloc: true, result: true},
expOut: "exp.json",
},
} {
args := []string{"t8n"}
args = append(args, tc.output.get()...)
Expand Down
3 changes: 2 additions & 1 deletion cmd/evm/testdata/1/exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
}
],
"currentDifficulty": "0x20000",
"gasUsed": "0x5208"
"gasUsed": "0x5208",
"requests": null
}
}
3 changes: 2 additions & 1 deletion cmd/evm/testdata/13/exp2.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
],
"currentDifficulty": "0x20000",
"gasUsed": "0x109a0",
"currentBaseFee": "0x36b"
"currentBaseFee": "0x36b",
"requests": null
}
}
3 changes: 2 additions & 1 deletion cmd/evm/testdata/14/exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"currentDifficulty": "0x2000020000000",
"receipts": [],
"gasUsed": "0x0",
"currentBaseFee": "0x500"
"currentBaseFee": "0x500",
"requests": null
}
}
3 changes: 2 additions & 1 deletion cmd/evm/testdata/14/exp2.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"receipts": [],
"currentDifficulty": "0x1ff8020000000",
"gasUsed": "0x0",
"currentBaseFee": "0x500"
"currentBaseFee": "0x500",
"requests": null
}
}
3 changes: 2 additions & 1 deletion cmd/evm/testdata/14/exp_berlin.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"receipts": [],
"currentDifficulty": "0x1ff9000000000",
"gasUsed": "0x0",
"currentBaseFee": "0x500"
"currentBaseFee": "0x500",
"requests": null
}
}
3 changes: 2 additions & 1 deletion cmd/evm/testdata/19/exp_arrowglacier.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"currentDifficulty": "0x2000000200000",
"receipts": [],
"gasUsed": "0x0",
"currentBaseFee": "0x500"
"currentBaseFee": "0x500",
"requests": null
}
}
25 changes: 13 additions & 12 deletions cmd/evm/testdata/19/exp_grayglacier.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"result": {
"stateRoot": "0x6f058887ca01549716789c380ede95aecc510e6d1fdc4dbf67d053c7c07f4bdc",
"txRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"receipts": [],
"currentDifficulty": "0x2000000004000",
"gasUsed": "0x0",
"currentBaseFee": "0x500"
}
}
"result": {
"stateRoot": "0x6f058887ca01549716789c380ede95aecc510e6d1fdc4dbf67d053c7c07f4bdc",
"txRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"receipts": [],
"currentDifficulty": "0x2000000004000",
"gasUsed": "0x0",
"currentBaseFee": "0x500",
"requests": null
}
}
3 changes: 2 additions & 1 deletion cmd/evm/testdata/19/exp_london.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"currentDifficulty": "0x2000080000000",
"receipts": [],
"gasUsed": "0x0",
"currentBaseFee": "0x500"
"currentBaseFee": "0x500",
"requests": null
}
}
3 changes: 2 additions & 1 deletion cmd/evm/testdata/23/exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
}
],
"currentDifficulty": "0x20000",
"gasUsed": "0x520b"
"gasUsed": "0x520b",
"requests": null
}
}
3 changes: 2 additions & 1 deletion cmd/evm/testdata/24/exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
],
"currentDifficulty": null,
"gasUsed": "0x10306",
"currentBaseFee": "0x500"
"currentBaseFee": "0x500",
"requests": null
}
}
3 changes: 2 additions & 1 deletion cmd/evm/testdata/25/exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
],
"currentDifficulty": null,
"gasUsed": "0x5208",
"currentBaseFee": "0x460"
"currentBaseFee": "0x460",
"requests": null
}
}
3 changes: 2 additions & 1 deletion cmd/evm/testdata/26/exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"currentDifficulty": null,
"gasUsed": "0x0",
"currentBaseFee": "0x500",
"withdrawalsRoot": "0x4921c0162c359755b2ae714a0978a1dad2eb8edce7ff9b38b9b6fc4cbc547eb5"
"withdrawalsRoot": "0x4921c0162c359755b2ae714a0978a1dad2eb8edce7ff9b38b9b6fc4cbc547eb5",
"requests": null
}
}
3 changes: 2 additions & 1 deletion cmd/evm/testdata/28/exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"currentBaseFee": "0x9",
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"currentExcessBlobGas": "0x0",
"blobGasUsed": "0x20000"
"blobGasUsed": "0x20000",
"requests": null
}
}
3 changes: 2 additions & 1 deletion cmd/evm/testdata/29/exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"currentBaseFee": "0x9",
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"currentExcessBlobGas": "0x0",
"blobGasUsed": "0x0"
"blobGasUsed": "0x0",
"requests": null
}
}
3 changes: 2 additions & 1 deletion cmd/evm/testdata/3/exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
}
],
"currentDifficulty": "0x20000",
"gasUsed": "0x521f"
"gasUsed": "0x521f",
"requests": null
}
}
5 changes: 3 additions & 2 deletions cmd/evm/testdata/30/exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"currentBaseFee": "0x7",
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"currentExcessBlobGas": "0x0",
"blobGasUsed": "0x0"
"blobGasUsed": "0x0",
"requests": null
}
}
}
1 change: 1 addition & 0 deletions cmd/evm/testdata/33/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This test sets some EIP-7702 delegations and calls them.
30 changes: 30 additions & 0 deletions cmd/evm/testdata/33/alloc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"0x8a0a19589531694250d570040a0c4b74576919b8": {
"nonce": "0x00",
"balance": "0x0de0b6b3a7640000",
"code": "0x600060006000600060007310000000000000000000000000000000000000015af1600155600060006000600060007310000000000000000000000000000000000000025af16002553d600060003e600051600355",
"storage": {
"0x01": "0x0100",
"0x02": "0x0100",
"0x03": "0x0100"
}
},
"0x000000000000000000000000000000000000aaaa": {
"nonce": "0x00",
"balance": "0x4563918244f40000",
"code": "0x58808080600173703c4b2bd70c169f5717101caee543299fc946c75af100",
"storage": {}
},
"0x000000000000000000000000000000000000bbbb": {
"nonce": "0x00",
"balance": "0x29a2241af62c0000",
"code": "0x6042805500",
"storage": {}
},
"0x71562b71999873DB5b286dF957af199Ec94617F7": {
"nonce": "0x00",
"balance": "0x6124fee993bc0000",
"code": "0x",
"storage": {}
}
}
14 changes: 14 additions & 0 deletions cmd/evm/testdata/33/env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"currentCoinbase": "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentGasLimit": "71794957647893862",
"currentNumber": "1",
"currentTimestamp": "1000",
"currentRandom": "0",
"currentDifficulty": "0",
"blockHashes": {},
"ommers": [],
"currentBaseFee": "7",
"parentUncleHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"withdrawals": [],
"parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
Loading

0 comments on commit ab8ab34

Please sign in to comment.