diff --git a/core/types/blob_tx.go b/core/types/blob_tx.go index 459c16179..94c99cb5d 100644 --- a/core/types/blob_tx.go +++ b/core/types/blob_tx.go @@ -51,6 +51,7 @@ func (stx BlobTx) AsMessage(s Signer, baseFee *big.Int, rules *chain.Rules) (Mes if err != nil { return Message{}, err } + msg.maxFeePerBlobGas = *stx.MaxFeePerBlobGas msg.blobHashes = stx.BlobVersionedHashes return msg, err } diff --git a/go.mod b/go.mod index f39a02cf4..ddaab4d6a 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,7 @@ require ( github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d github.com/hashicorp/golang-lru/arc/v2 v2.0.4 github.com/hashicorp/golang-lru/v2 v2.0.4 - github.com/holiman/uint256 v1.2.2 + github.com/holiman/uint256 v1.2.3 github.com/huandu/xstrings v1.4.0 github.com/huin/goupnp v1.2.0 github.com/jackpal/go-nat-pmp v1.0.2 diff --git a/go.sum b/go.sum index b9ee1d66e..bd86ba9e1 100644 --- a/go.sum +++ b/go.sum @@ -429,8 +429,8 @@ github.com/hashicorp/golang-lru/v2 v2.0.4 h1:7GHuZcgid37q8o5i3QI9KMT4nCWQQ3Kx3Ov github.com/hashicorp/golang-lru/v2 v2.0.4/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= -github.com/holiman/uint256 v1.2.2 h1:TXKcSGc2WaxPD2+bmzAsVthL4+pEN0YwXcL5qED83vk= -github.com/holiman/uint256 v1.2.2/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= +github.com/holiman/uint256 v1.2.3 h1:K8UWO1HUJpRMXBxbmaY1Y8IAMZC/RsKB+ArEnnK4l5o= +github.com/holiman/uint256 v1.2.3/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= diff --git a/tests/block_test.go b/tests/block_test.go index a0c2bf81e..ed67f10f5 100644 --- a/tests/block_test.go +++ b/tests/block_test.go @@ -58,3 +58,26 @@ func TestBlockchain(t *testing.T) { } }) } + +func TestBlockchainEIP(t *testing.T) { + defer log.Root().SetHandler(log.Root().GetHandler()) + log.Root().SetHandler(log.LvlFilterHandler(log.LvlError, log.StderrHandler)) + + bt := new(testMatcher) + + // EOF is not supported yet + bt.skipLoad(`^StateTests/stEOF/`) + + // TODO(yperbasis): fix me + bt.skipLoad(`^StateTests/stEIP4844-blobtransactions/`) + bt.skipLoad(`^StateTests/stExample/`) + + // TODO(yperbasis): re-enable checkStateRoot + checkStateRoot := false + + bt.walk(t, blockEipTestDir, func(t *testing.T, name string, test *BlockTest) { + if err := bt.checkFailure(t, test.Run(t, checkStateRoot)); err != nil { + t.Error(err) + } + }) +} diff --git a/tests/init_test.go b/tests/init_test.go index 02ade70c4..36ad41182 100644 --- a/tests/init_test.go +++ b/tests/init_test.go @@ -35,6 +35,7 @@ import ( var ( baseDir = filepath.Join(".", "testdata") blockTestDir = filepath.Join(baseDir, "BlockchainTests") + blockEipTestDir = filepath.Join(baseDir, "EIPTests", "BlockchainTests") stateTestDir = filepath.Join(baseDir, "GeneralStateTests") transactionTestDir = filepath.Join(baseDir, "TransactionTests") rlpTestDir = filepath.Join(baseDir, "RLPTests") diff --git a/tests/state_test_util.go b/tests/state_test_util.go index a0b72f5eb..119f30b6f 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -68,7 +68,7 @@ func (t *StateTest) UnmarshalJSON(in []byte) error { type stJSON struct { Env stEnv `json:"env"` Pre types.GenesisAlloc `json:"pre"` - Tx stTransactionMarshaling `json:"transaction"` + Tx stTransaction `json:"transaction"` Out hexutility.Bytes `json:"out"` Post map[string][]stPostState `json:"post"` } @@ -85,7 +85,7 @@ type stPostState struct { } } -type stTransactionMarshaling struct { +type stTransaction struct { GasPrice *math.HexOrDecimal256 `json:"gasPrice"` MaxFeePerGas *math.HexOrDecimal256 `json:"maxFeePerGas"` MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas"` @@ -96,6 +96,7 @@ type stTransactionMarshaling struct { Data []string `json:"data"` Value []string `json:"value"` AccessLists []*types2.AccessList `json:"accessLists,omitempty"` + BlobGasFeeCap *math.HexOrDecimal256 `json:"maxFeePerBlobGas,omitempty"` } //go:generate gencodec -type stEnv -field-override stEnvMarshaling -out gen_stenv.go @@ -375,7 +376,7 @@ func vmTestBlockHash(n uint64) libcommon.Hash { return libcommon.BytesToHash(crypto.Keccak256([]byte(big.NewInt(int64(n)).String()))) } -func toMessage(tx stTransactionMarshaling, ps stPostState, baseFee *big.Int) (core.Message, error) { +func toMessage(tx stTransaction, ps stPostState, baseFee *big.Int) (core.Message, error) { // Derive sender from private key if present. var from libcommon.Address if len(tx.PrivateKey) > 0 { @@ -458,6 +459,11 @@ func toMessage(tx stTransactionMarshaling, ps stPostState, baseFee *big.Int) (co gpi := big.Int(*gasPrice) gasPriceInt := uint256.NewInt(gpi.Uint64()) + var blobFeeCap *big.Int + if tx.BlobGasFeeCap != nil { + blobFeeCap = (*big.Int)(tx.BlobGasFeeCap) + } + // TODO the conversion to int64 then uint64 then new int isn't working! msg := types.NewMessage( from, @@ -466,13 +472,13 @@ func toMessage(tx stTransactionMarshaling, ps stPostState, baseFee *big.Int) (co value, uint64(gasLimit), gasPriceInt, - uint256.NewInt(feeCap.Uint64()), - uint256.NewInt(tipCap.Uint64()), + uint256.MustFromBig(&feeCap), + uint256.MustFromBig(&tipCap), data, accessList, false, /* checkNonce */ false, /* isFree */ - uint256.NewInt(tipCap.Uint64()), + uint256.MustFromBig(blobFeeCap), ) return msg, nil diff --git a/tests/testdata b/tests/testdata index 06e276776..9b6382b12 160000 --- a/tests/testdata +++ b/tests/testdata @@ -1 +1 @@ -Subproject commit 06e276776bc87817c38f6efb492bf6f4527fa904 +Subproject commit 9b6382b122140b5479a4ff6152ccf1459440ddff