Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/eth/tracers"
"math/big"
"strings"
"time"
Expand All @@ -36,10 +35,10 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth/tracers"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/params"
Expand All @@ -50,6 +49,7 @@ import (

"github.com/Fantom-foundation/go-opera/evmcore"
"github.com/Fantom-foundation/go-opera/gossip/gasprice"
"github.com/Fantom-foundation/go-opera/inter/state"
"github.com/Fantom-foundation/go-opera/opera"
"github.com/Fantom-foundation/go-opera/utils/signers/gsignercache"
"github.com/Fantom-foundation/go-opera/utils/signers/internaltx"
Expand Down
4 changes: 2 additions & 2 deletions ethapi/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/Fantom-foundation/lachesis-base/inter/idx"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
notify "github.com/ethereum/go-ethereum/event"
Expand All @@ -36,6 +35,7 @@ import (
"github.com/Fantom-foundation/go-opera/evmcore"
"github.com/Fantom-foundation/go-opera/inter"
"github.com/Fantom-foundation/go-opera/inter/iblockproc"
"github.com/Fantom-foundation/go-opera/inter/state"
)

// PeerProgress is synchronization status of a peer
Expand Down Expand Up @@ -72,7 +72,7 @@ type Backend interface {
BlockByHash(ctx context.Context, hash common.Hash) (*evmcore.EvmBlock, error)
GetReceiptsByNumber(ctx context.Context, number rpc.BlockNumber) (types.Receipts, error)
GetTd(hash common.Hash) *big.Int
GetEVM(ctx context.Context, msg evmcore.Message, state state.StateDbInterface, header *evmcore.EvmHeader, vmConfig *vm.Config) (*vm.EVM, func() error, error)
GetEVM(ctx context.Context, msg evmcore.Message, state vm.StateDB, header *evmcore.EvmHeader, vmConfig *vm.Config) (*vm.EVM, func() error, error)
MinGasPrice() *big.Int
MaxGasLimit() uint64

Expand Down
2 changes: 1 addition & 1 deletion ethapi/tx_trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"

"github.com/Fantom-foundation/go-opera/evmcore"
"github.com/Fantom-foundation/go-opera/inter/state"
"github.com/Fantom-foundation/go-opera/opera"
"github.com/Fantom-foundation/go-opera/txtrace"
"github.com/Fantom-foundation/go-opera/utils/signers/gsignercache"
Expand Down
66 changes: 1 addition & 65 deletions evmcore/apply_fake_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,79 +19,15 @@ package evmcore
import (
"crypto/ecdsa"
"errors"
"math"
"math/big"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/Fantom-foundation/go-opera/inter"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"

"github.com/Fantom-foundation/go-opera/inter"
)

var FakeGenesisTime = inter.Timestamp(1608600000 * time.Second)

// ApplyFakeGenesis writes or updates the genesis block in db.
func ApplyFakeGenesis(statedb state.StateDbInterface, time inter.Timestamp, balances map[common.Address]*big.Int) (*EvmBlock, error) {
for acc, balance := range balances {
statedb.SetBalance(acc, balance)
}

// initial block
root, err := flush(statedb, true)
if err != nil {
return nil, err
}
block := genesisBlock(time, root)

return block, nil
}

func flush(statedb state.StateDbInterface, clean bool) (root common.Hash, err error) {
root, err = statedb.Commit(clean)
if err != nil {
return
}
err = statedb.Database().TrieDB().Commit(root, false, nil)
if err != nil {
return
}

if !clean {
err = statedb.Database().TrieDB().Cap(0)
}

return
}

// genesisBlock makes genesis block with pretty hash.
func genesisBlock(time inter.Timestamp, root common.Hash) *EvmBlock {
block := &EvmBlock{
EvmHeader: EvmHeader{
Number: big.NewInt(0),
Time: time,
GasLimit: math.MaxUint64,
Root: root,
TxHash: types.EmptyRootHash,
},
}

return block
}

// MustApplyFakeGenesis writes the genesis block and state to db, panicking on error.
func MustApplyFakeGenesis(statedb state.StateDbInterface, time inter.Timestamp, balances map[common.Address]*big.Int) *EvmBlock {
block, err := ApplyFakeGenesis(statedb, time, balances)
if err != nil {
log.Crit("ApplyFakeGenesis", "err", err)
}
return block
}

// FakeKey gets n-th fake private key.
func FakeKey(n uint32) *ecdsa.PrivateKey {
var keys = [100]string{
Expand Down
166 changes: 0 additions & 166 deletions evmcore/bench_test.go

This file was deleted.

Loading