Skip to content

Commit

Permalink
go-ethereum v1.14.5 update
Browse files Browse the repository at this point in the history
Vendored go-ethereum is now:

v1.14.5
  • Loading branch information
attente committed Jun 7, 2024
1 parent d096aa7 commit fdfb7c1
Show file tree
Hide file tree
Showing 225 changed files with 13,817 additions and 13,398 deletions.
4 changes: 2 additions & 2 deletions cmd/ethkit/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func NewHeader(b *types.Block) *Header {
Nonce: b.Header().Nonce,
BaseFee: b.Header().BaseFee,
WithdrawalsHash: b.Header().WithdrawalsHash,
Size: b.Size(),
Size: b.Header().Size(),
// TotalDifficulty: b.Difficulty(),
TransactionsHash: TransactionsHash(*b),
}
Expand Down Expand Up @@ -235,7 +235,7 @@ func NewBlock(b *types.Block) *Block {
Nonce: b.Header().Nonce,
BaseFee: b.Header().BaseFee,
WithdrawalsHash: b.Header().WithdrawalsHash,
Size: b.Size(),
Size: b.Header().Size(),
// TotalDifficulty: b.Difficulty(),
Uncles: b.Uncles(),
Transactions: b.Transactions(),
Expand Down
2 changes: 1 addition & 1 deletion ethreceipts/ethreceipts.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ func (l *ReceiptsListener) processBlocks(blocks ethmonitor.Blocks, subscribers [
txn.Hash(), i, block.NumberU64(), len(block.Transactions()), err,
)
} else {
receipts[i].message = &txnMsg
receipts[i].message = txnMsg
}
}

Expand Down
7 changes: 4 additions & 3 deletions ethreceipts/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/0xsequence/ethkit"
"github.com/0xsequence/ethkit/go-ethereum/common"
"github.com/0xsequence/ethkit/go-ethereum/core"
"github.com/0xsequence/ethkit/go-ethereum/core/types"
)

Expand All @@ -14,7 +15,7 @@ type Receipt struct {
Reorged bool // chain reorged / removed the txn

transaction *types.Transaction
message *types.Message // TOOD: this intermediate type is lame.. with new ethrpc we can remove
message *core.Message // TODO: this intermediate type is lame.. with new ethrpc we can remove
receipt *types.Receipt
logs []*types.Log
}
Expand Down Expand Up @@ -143,7 +144,7 @@ func (r *Receipt) From() common.Address {
if r.receipt != nil {
return r.receipt.From
} else if r.message != nil {
return r.message.From()
return r.message.From
} else {
return common.Address{}
}
Expand All @@ -153,7 +154,7 @@ func (r *Receipt) To() common.Address {
if r.receipt != nil {
return r.receipt.To
} else if r.message != nil {
to := r.message.To()
to := r.message.To
if to == nil {
return common.Address{}
} else {
Expand Down
15 changes: 12 additions & 3 deletions ethrpc/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func IntoBlock(raw json.RawMessage, ret **types.Block) error {
if len(raw) == 0 {
return ethereum.NotFound
}

// Decode header and transactions
var (
head *types.Header
Expand Down Expand Up @@ -88,8 +88,17 @@ func IntoBlock(raw json.RawMessage, ret **types.Block) error {
txs = append(txs, tx.tx)
}

// return types.NewBlockWithHeader(head).WithBody(txs, uncles), nil
block := types.NewBlockWithHeader(head).WithBody(txs, nil).WithWithdrawals(body.Withdrawals)
/*
return types.NewBlockWithHeader(head).WithBody(types.Body{
Transactions: txs,
Uncles: uncles,
Withdrawals: body.Withdrawals,
}), nil
*/
block := types.NewBlockWithHeader(head).WithBody(types.Body{
Transactions: txs,
Withdrawals: body.Withdrawals,
})

// TODO: Remove this, we shouldn't need to use the block cache
// in order for it to contain the correct block hash
Expand Down
25 changes: 16 additions & 9 deletions ethtxn/ethtxn.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/0xsequence/ethkit/ethrpc"
"github.com/0xsequence/ethkit/go-ethereum"
"github.com/0xsequence/ethkit/go-ethereum/common"
"github.com/0xsequence/ethkit/go-ethereum/core"
"github.com/0xsequence/ethkit/go-ethereum/core/types"
)

Expand Down Expand Up @@ -158,23 +159,29 @@ func SendTransaction(ctx context.Context, provider *ethrpc.Provider, signedTx *t

var zeroBigInt = big.NewInt(0)

func AsMessage(txn *types.Transaction) (types.Message, error) {
func AsMessage(txn *types.Transaction) (*core.Message, error) {
return AsMessageWithSigner(txn, types.NewLondonSigner(txn.ChainId()), nil)
}

// AsMessageWithSigner decodes a transaction payload, and will check v, r, s values and skips
// zero'd numbers which is the case for Polygon state sync transactions:
// https://wiki.polygon.technology/docs/pos/state-sync/how-state-sync-works#state-sync-logs-and-bor-block-receipt
func AsMessageWithSigner(txn *types.Transaction, signer types.Signer, baseFee *big.Int) (types.Message, error) {
func AsMessageWithSigner(txn *types.Transaction, signer types.Signer, baseFee *big.Int) (*core.Message, error) {
v, r, s := txn.RawSignatureValues()
if v.Cmp(zeroBigInt) == 0 && r.Cmp(zeroBigInt) == 0 && s.Cmp(zeroBigInt) == 0 {
m := types.NewMessage(
common.Address{}, txn.To(), txn.Nonce(), txn.Value(),
txn.Gas(), txn.GasPrice(), txn.GasFeeCap(), txn.GasTipCap(),
txn.Data(), txn.AccessList(), true,
)
return m, nil
return &core.Message{
To: txn.To(),
Nonce: txn.Nonce(),
Value: txn.Value(),
GasLimit: txn.Gas(),
GasPrice: txn.GasPrice(),
GasFeeCap: txn.GasFeeCap(),
GasTipCap: txn.GasTipCap(),
Data: txn.Data(),
AccessList: txn.AccessList(),
SkipAccountChecks: true,
}, nil
} else {
return txn.AsMessage(signer, baseFee)
return core.TransactionToMessage(txn, signer, baseFee)
}
}
4 changes: 2 additions & 2 deletions ethwallet/ethwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ func (w *Wallet) SignTx(tx *types.Transaction, chainID *big.Int) (*types.Transac
return nil, err
}

msg, err := signedTx.AsMessage(signer, nil)
msg, err := ethtxn.AsMessageWithSigner(signedTx, signer, nil)
if err != nil {
return nil, err
}

sender := msg.From()
sender := msg.From
if sender != w.hdnode.Address() {
return nil, fmt.Errorf("signer mismatch: expected %s, got %s", w.hdnode.Address().Hex(), sender.Hex())
}
Expand Down
Loading

0 comments on commit fdfb7c1

Please sign in to comment.