Skip to content

Commit

Permalink
upgrade again
Browse files Browse the repository at this point in the history
  • Loading branch information
trajan0x committed Jan 14, 2024
1 parent ef15e53 commit 36cc617
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 39 deletions.
1 change: 0 additions & 1 deletion ethergo/backends/anvil/hardfork.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func (h Hardfork) ToChainConfig(chainID *big.Int) *params.ChainConfig {
// https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/tangerine-whistle.md
if h >= Tangerine {
baseConfig.EIP150Block = big.NewInt(0)
baseConfig.EIP150Hash = params.MainnetChainConfig.EIP150Hash
}

// https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/spurious-dragon.md
Expand Down
3 changes: 1 addition & 2 deletions ethergo/backends/simulated/multibackend/chainid.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func NewConfigWithChainID(chainID *big.Int) *params.ChainConfig {
DAOForkBlock: util.CopyBigInt(params.AllEthashProtocolChanges.DAOForkBlock),
DAOForkSupport: params.AllEthashProtocolChanges.DAOForkSupport,
EIP150Block: util.CopyBigInt(params.AllEthashProtocolChanges.EIP150Block),
EIP150Hash: params.AllEthashProtocolChanges.EIP150Hash,
EIP155Block: util.CopyBigInt(params.AllEthashProtocolChanges.EIP155Block),
EIP158Block: util.CopyBigInt(params.AllEthashProtocolChanges.EIP158Block),
ByzantiumBlock: util.CopyBigInt(params.AllEthashProtocolChanges.ByzantiumBlock),
Expand Down Expand Up @@ -62,6 +61,6 @@ func NewSimulatedBackendWithConfig(alloc core.GenesisAlloc, gasLimit uint64, con
backend.filterSystem = filters.NewFilterSystem(filterBackend, filters.Config{})
backend.events = filters.NewEventSystem(backend.filterSystem, false)

backend.rollback(blockchain.CurrentBlock())
backend.rollback(blockchain.GetBlock(blockchain.CurrentBlock().Hash(), blockchain.CurrentBlock().Number.Uint64()))
return backend
}
2 changes: 0 additions & 2 deletions ethergo/chain/client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ var (
DAOForkBlock: big.NewInt(0),
DAOForkSupport: true,
EIP150Block: big.NewInt(0),
EIP150Hash: ethCommon.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
Expand All @@ -151,7 +150,6 @@ var (
DAOForkBlock: big.NewInt(0),
DAOForkSupport: true,
EIP150Block: big.NewInt(0),
EIP150Hash: ethCommon.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
Expand Down
4 changes: 2 additions & 2 deletions ethergo/chain/gas/londinium/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ func (l LondoniumSuite) TestLondoniumConfig() {
newConfig := gasprice.Config{
Blocks: int(gofakeit.Int64()),
Percentile: gofakeit.Number(1, 100),
MaxHeaderHistory: int(gofakeit.Int64()),
MaxBlockHistory: int(gofakeit.Int64()),
MaxHeaderHistory: gofakeit.Uint64(),
MaxBlockHistory: gofakeit.Uint64(),
Default: defaultPrice,
MaxPrice: big.NewInt(0).Mul(defaultPrice, big.NewInt(2)),
IgnorePrice: big.NewInt(0).Div(defaultPrice, big.NewInt(2)),
Expand Down
4 changes: 2 additions & 2 deletions ethergo/chain/gas/londinium/gasprice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ type testBackend struct {

func (b *testBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) {
if number == rpc.LatestBlockNumber {
return b.chain.CurrentBlock().Header(), nil
return b.chain.CurrentBlock(), nil
}
return b.chain.GetHeaderByNumber(uint64(number)), nil
}

func (b *testBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) {
if number == rpc.LatestBlockNumber {
return b.chain.CurrentBlock(), nil
return b.chain.GetBlockByHash(b.chain.CurrentBlock().Hash()), nil
}
return b.chain.GetBlockByNumber(uint64(number)), nil
}
Expand Down
2 changes: 1 addition & 1 deletion ethergo/chain/gas/london/oracle_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (h HeightOracleBackend) GetReceipts(ctx context.Context, hash common.Hash)

var receipts types.Receipts

err = receipts.DeriveFields(h.ChainConfig(), hash, block.NumberU64(), block.Transactions())
err = receipts.DeriveFields(h.ChainConfig(), hash, block.NumberU64(), block.BaseFee(), block.Transactions())
if err != nil {
return nil, fmt.Errorf("could not derive receipts from block: %w", err)
}
Expand Down
5 changes: 4 additions & 1 deletion ethergo/submitter/db/txdb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,10 @@ func (s Store) PutTXS(ctx context.Context, txs ...db.TX) error {
return fmt.Errorf("could not marshall tx to json: %w", err)
}

msg, err := util.TxToCall(tx)
newTX := new(types.Transaction)
err = newTX.UnmarshalBinary(marshalledTX)

Check failure on line 265 in ethergo/submitter/db/txdb/store.go

View workflow job for this annotation

GitHub Actions / Lint (ethergo)

ineffectual assignment to err (ineffassign)

msg, err := util.TxToCall(newTX)
if err != nil {
return fmt.Errorf("could not recover signer from tx: %w", err)
}
Expand Down
30 changes: 2 additions & 28 deletions ethergo/util/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ package util

import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
ethCore "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/pkg/errors"
"math/big"
)

// TxToCall converts a transaction to a call.
func TxToCall(transaction Transaction) (*ethereum.CallMsg, error) {
rawMsg, err := ethCore.TransactionToMessage(&transaction, types.LatestSignerForChainID(transaction.ChainId()), nil)
func TxToCall(transaction *types.Transaction) (*ethereum.CallMsg, error) {
rawMsg, err := ethCore.TransactionToMessage(transaction, types.LatestSignerForChainID(transaction.ChainId()), nil)
if err != nil {
return nil, errors.Wrap(err, "could not convert to call")
}
Expand All @@ -27,27 +25,3 @@ func TxToCall(transaction Transaction) (*ethereum.CallMsg, error) {
Data: transaction.Data(),
}, nil
}

// Transaction is an interface for everything needed to convert a transaction to a call.
type Transaction interface {
// ChainId returns the chain id.
ChainId() *big.Int
// To returns the to address.
To() *common.Address
// GasPrice returns the gas price.
GasPrice() *big.Int
// GasFeeCap returns the gas fee cap.
GasFeeCap() *big.Int
// GasTipCap returns the gas tip cap.
GasTipCap() *big.Int
// Gas returns the gas limit.
Gas() uint64
// Value returns the value of the tx.
Value() *big.Int
// Data returns the data of the tx.
Data() []byte
// AsMessage converts the transaction to a message.
AsMessage(s types.Signer, baseFee *big.Int) (types.Message, error)
}

var _ Transaction = &types.Transaction{}

0 comments on commit 36cc617

Please sign in to comment.