From fa1e1bab271c8f9ba8df749f40e0e9157bc0c4bb Mon Sep 17 00:00:00 2001 From: racytech <82003208+racytech@users.noreply.github.com> Date: Fri, 12 Jan 2024 14:42:08 +0300 Subject: [PATCH] Tests v13 fix (#9200) --- core/types/blob_tx.go | 42 +++++++++++++++++++++++++++++--- tests/testdata | 2 +- turbo/stages/mock/mock_sentry.go | 6 +++++ 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/core/types/blob_tx.go b/core/types/blob_tx.go index d2bede77c..32547e054 100644 --- a/core/types/blob_tx.go +++ b/core/types/blob_tx.go @@ -1,6 +1,7 @@ package types import ( + "errors" "fmt" "io" "math/big" @@ -47,15 +48,50 @@ func (stx BlobTx) GetBlobGas() uint64 { } func (stx BlobTx) AsMessage(s Signer, baseFee *big.Int, rules *chain.Rules) (Message, error) { - msg, err := stx.DynamicFeeTransaction.AsMessage(s, baseFee, rules) - if err != nil { - return Message{}, err + msg := Message{ + nonce: stx.Nonce, + gasLimit: stx.Gas, + gasPrice: *stx.FeeCap, + tip: *stx.Tip, + feeCap: *stx.FeeCap, + to: stx.To, + amount: *stx.Value, + data: stx.Data, + accessList: stx.AccessList, + checkNonce: true, } + if !rules.IsCancun { + return msg, errors.New("BlobTx transactions require Cancun") + } + if baseFee != nil { + overflow := msg.gasPrice.SetFromBig(baseFee) + if overflow { + return msg, fmt.Errorf("gasPrice higher than 2^256-1") + } + } + msg.gasPrice.Add(&msg.gasPrice, stx.Tip) + if msg.gasPrice.Gt(stx.FeeCap) { + msg.gasPrice.Set(stx.FeeCap) + } + var err error + msg.from, err = stx.Sender(s) msg.maxFeePerBlobGas = *stx.MaxFeePerBlobGas msg.blobHashes = stx.BlobVersionedHashes return msg, err } +func (stx *BlobTx) Sender(signer Signer) (libcommon.Address, error) { + if sc := stx.from.Load(); sc != nil { + return sc.(libcommon.Address), nil + } + addr, err := signer.Sender(stx) + if err != nil { + return libcommon.Address{}, err + } + stx.from.Store(addr) + return addr, nil +} + func (stx BlobTx) Hash() libcommon.Hash { if hash := stx.hash.Load(); hash != nil { return *hash.(*libcommon.Hash) diff --git a/tests/testdata b/tests/testdata index 06e276776..428f218d7 160000 --- a/tests/testdata +++ b/tests/testdata @@ -1 +1 @@ -Subproject commit 06e276776bc87817c38f6efb492bf6f4527fa904 +Subproject commit 428f218d7d6f4a52544e12684afbfe6e2882ffbf diff --git a/turbo/stages/mock/mock_sentry.go b/turbo/stages/mock/mock_sentry.go index eb973d9d7..14c839777 100644 --- a/turbo/stages/mock/mock_sentry.go +++ b/turbo/stages/mock/mock_sentry.go @@ -608,6 +608,12 @@ func (ms *MockSentry) insertPoWBlocks(chain *core.ChainPack) error { return nil } + for i := 0; i < chain.Length(); i++ { + if err := chain.Blocks[i].HashCheck(); err != nil { + return err + } + } + // Send NewBlock message b, err := rlp.EncodeToBytes(ð.NewBlockPacket{ Block: chain.Blocks[n-1],