Skip to content

Commit

Permalink
tests v13 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
racytech committed Jan 11, 2024
1 parent f690301 commit b67c750
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
42 changes: 39 additions & 3 deletions core/types/blob_tx.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package types

import (
"errors"
"fmt"
"io"
"math/big"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata
6 changes: 6 additions & 0 deletions turbo/stages/mock/mock_sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(&eth.NewBlockPacket{
Block: chain.Blocks[n-1],
Expand Down

0 comments on commit b67c750

Please sign in to comment.