Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EIP-4844: fix wiring of maxFeePerBlobGas #7981

Merged
merged 4 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/types/blob_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
23 changes: 23 additions & 0 deletions tests/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}
1 change: 1 addition & 0 deletions tests/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
18 changes: 12 additions & 6 deletions tests/state_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand All @@ -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"`
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata
Submodule testdata updated 99 files
+1 −84 BlockchainTests/GeneralStateTests/stTransactionTest/ValueOverflow.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/01_tloadBeginningTxn.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/02_tloadAfterTstore.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/03_tloadAfterStoreIs0.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/04_tloadAfterCall.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/05_tloadReentrancy.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/06_tstoreInReentrancyCall.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/07_tloadAfterReentrancyStore.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/08_revertUndoesTransientStore.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/09_revertUndoesAll.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/10_revertUndoesStoreAfterReturn.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/11_tstoreDelegateCall.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/12_tloadDelegateCall.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/13_tloadStaticCall.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/14_revertAfterNestedStaticcall.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/15_tstoreCannotBeDosd.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/16_tloadGas.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/17_tstoreGas.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/18_tloadAfterStore.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/19_oogUndoesTransientStore.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/20_oogUndoesTransientStoreInCall.json
+15 −13 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/21_tstoreCannotBeDosdOOO.json
+240 −208 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/transStorageOK.json
+450 −390 EIPTests/BlockchainTests/StateTests/stEIP1153-transientStorage/transStorageReset.json
+17 −15 EIPTests/BlockchainTests/StateTests/stEIP4844-blobtransactions/blobhashListBounds3.json
+17 −15 EIPTests/BlockchainTests/StateTests/stEIP4844-blobtransactions/blobhashListBounds4.json
+10 −9 EIPTests/BlockchainTests/StateTests/stEIP4844-blobtransactions/blobhashListBounds5.json
+12 −11 EIPTests/BlockchainTests/StateTests/stEIP4844-blobtransactions/createBlobhashTx.json
+13 −12 EIPTests/BlockchainTests/StateTests/stEIP4844-blobtransactions/emptyBlobhashList.json
+17 −15 EIPTests/BlockchainTests/StateTests/stEIP4844-blobtransactions/opcodeBlobhBounds.json
+17 −15 EIPTests/BlockchainTests/StateTests/stEIP4844-blobtransactions/opcodeBlobhashOutOfRange.json
+13 −12 EIPTests/BlockchainTests/StateTests/stEIP4844-blobtransactions/wrongBlobhashVersion.json
+480 −440 EIPTests/BlockchainTests/StateTests/stEIP5656-MCOPY/MCOPY.json
+1,572 −1,443 EIPTests/BlockchainTests/StateTests/stEIP5656-MCOPY/MCOPY_copy_cost.json
+507 −463 EIPTests/BlockchainTests/StateTests/stEIP5656-MCOPY/MCOPY_memory_expansion_cost.json
+144 −132 EIPTests/BlockchainTests/StateTests/stEIP5656-MCOPY/MCOPY_memory_hash.json
+1,095 −0 EIPTests/BlockchainTests/StateTests/stExample/blobtxExample.json
+21 −18 EIPTests/BlockchainTests/bcEIP1153-transientStorage/tloadDoesNotPersistAcrossBlocks.json
+15 −13 EIPTests/BlockchainTests/bcEIP1153-transientStorage/tloadDoesNotPersistCrossTxn.json
+45 −38 EIPTests/BlockchainTests/bcEIP1153-transientStorage/transStorageBlockchain.json
+39 −37 EIPTests/BlockchainTests/bcEIP4844-blobtransactions/blockWithAllTransactionTypes.json
+138 −0 EIPTests/BlockchainTests/bcExample/cancunExample.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/01_tloadBeginningTxn.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/02_tloadAfterTstore.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/03_tloadAfterStoreIs0.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/04_tloadAfterCall.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/05_tloadReentrancy.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/06_tstoreInReentrancyCall.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/07_tloadAfterReentrancyStore.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/08_revertUndoesTransientStore.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/09_revertUndoesAll.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/10_revertUndoesStoreAfterReturn.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/11_tstoreDelegateCall.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/12_tloadDelegateCall.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/13_tloadStaticCall.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/14_revertAfterNestedStaticcall.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/15_tstoreCannotBeDosd.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/16_tloadGas.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/17_tstoreGas.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/18_tloadAfterStore.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/19_oogUndoesTransientStore.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/20_oogUndoesTransientStoreInCall.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/21_tstoreCannotBeDosdOOO.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/transStorageOK.json
+5 −3 EIPTests/StateTests/stEIP1153-transientStorage/transStorageReset.json
+9 −7 EIPTests/StateTests/stEIP4844-blobtransactions/blobhashListBounds3.json
+9 −7 EIPTests/StateTests/stEIP4844-blobtransactions/blobhashListBounds4.json
+8 −6 EIPTests/StateTests/stEIP4844-blobtransactions/blobhashListBounds5.json
+10 −8 EIPTests/StateTests/stEIP4844-blobtransactions/createBlobhashTx.json
+11 −9 EIPTests/StateTests/stEIP4844-blobtransactions/emptyBlobhashList.json
+9 −7 EIPTests/StateTests/stEIP4844-blobtransactions/opcodeBlobhBounds.json
+9 −7 EIPTests/StateTests/stEIP4844-blobtransactions/opcodeBlobhashOutOfRange.json
+11 −9 EIPTests/StateTests/stEIP4844-blobtransactions/wrongBlobhashVersion.json
+28 −26 EIPTests/StateTests/stEIP5656-MCOPY/MCOPY.json
+82 −80 EIPTests/StateTests/stEIP5656-MCOPY/MCOPY_copy_cost.json
+30 −28 EIPTests/StateTests/stEIP5656-MCOPY/MCOPY_memory_expansion_cost.json
+14 −12 EIPTests/StateTests/stEIP5656-MCOPY/MCOPY_memory_hash.json
+249 −0 EIPTests/StateTests/stExample/blobtxExample.json
+189 −0 src/BlockchainTestsFiller/InvalidBlocks/bcExpectSection/result_CancunEnvConvertionFiller.json
+57 −9 src/BlockchainTestsFiller/InvalidBlocks/bcExpectSection/result_MergeEnvConvertionFiller.json
+57 −9 src/BlockchainTestsFiller/InvalidBlocks/bcExpectSection/result_ShanghaiEnvConvertionFiller.json
+56 −8 src/BlockchainTestsFiller/InvalidBlocks/bcExpectSection/result_eip1559EnvConvertionFiller.json
+56 −8 src/BlockchainTestsFiller/InvalidBlocks/bcExpectSection/result_legacyEnvConvertionFiller.json
+6 −6 src/EIPTestsFiller/BlockchainTests/bcEIP4844-blobtransactions/blockWithAllTransactionTypesFiller.yml
+83 −0 src/EIPTestsFiller/BlockchainTests/bcExample/cancunExampleFiller.json
+3 −3 src/EIPTestsFiller/StateTests/stEIP4844-blobtransactions/blobhashListBounds3Filler.yml
+3 −3 src/EIPTestsFiller/StateTests/stEIP4844-blobtransactions/blobhashListBounds4Filler.yml
+4 −4 src/EIPTestsFiller/StateTests/stEIP4844-blobtransactions/blobhashListBounds5Filler.yml
+3 −3 src/EIPTestsFiller/StateTests/stEIP4844-blobtransactions/createBlobhashTxFiller.yml
+3 −3 src/EIPTestsFiller/StateTests/stEIP4844-blobtransactions/emptyBlobhashListFiller.yml
+3 −3 src/EIPTestsFiller/StateTests/stEIP4844-blobtransactions/opcodeBlobhBoundsFiller.yml
+3 −3 src/EIPTestsFiller/StateTests/stEIP4844-blobtransactions/opcodeBlobhashOutOfRangeFiller.yml
+3 −3 src/EIPTestsFiller/StateTests/stEIP4844-blobtransactions/wrongBlobhashVersionFiller.yml
+1 −1 src/EIPTestsFiller/StateTests/stEIP5656-MCOPY/MCOPY_copy_costFiller.yml
+70 −0 src/EIPTestsFiller/StateTests/stExample/blobtxExampleFiller.yml
+207 −0 src/GeneralStateTestsFiller/stExpectSection/result_cancunEnvConvertionFiller.json
+81 −7 src/GeneralStateTestsFiller/stExpectSection/result_eip1559EnvConvertionFiller.json
+66 −10 src/GeneralStateTestsFiller/stExpectSection/result_legacyEnvConvertionFiller.json
+81 −7 src/GeneralStateTestsFiller/stExpectSection/result_mergeEnvConvertionFiller.json