Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e35: remove system contract #10016

Merged
merged 10 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 cmd/evm/internal/t8ntool/transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

"github.com/holiman/uint256"
"github.com/ledgerwatch/erigon-lib/common/datadir"
"github.com/ledgerwatch/erigon/core/state/temporal"
"github.com/ledgerwatch/erigon-lib/kv/temporal/temporaltest"
"github.com/ledgerwatch/erigon/eth/consensuschain"
"github.com/ledgerwatch/log/v3"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -294,7 +294,7 @@ func Main(ctx *cli.Context) error {
return h
}

_, db, _ := temporal.NewTestDB(nil, datadir.New(""), nil)
_, db, _ := temporaltest.NewTestDB(nil, datadir.New(""))
defer db.Close()

tx, err := db.BeginRw(context.Background())
Expand Down
5 changes: 2 additions & 3 deletions cmd/integration/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path/filepath"
"strings"

"github.com/ledgerwatch/erigon-lib/kv/temporal"
"github.com/ledgerwatch/log/v3"
"github.com/spf13/cobra"
"golang.org/x/sync/semaphore"
Expand All @@ -16,8 +17,6 @@ import (
kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx"

"github.com/ledgerwatch/erigon/cmd/utils"
"github.com/ledgerwatch/erigon/core/state/temporal"
"github.com/ledgerwatch/erigon/core/systemcontracts"
"github.com/ledgerwatch/erigon/migrations"
"github.com/ledgerwatch/erigon/turbo/debug"
"github.com/ledgerwatch/erigon/turbo/logging"
Expand Down Expand Up @@ -106,7 +105,7 @@ func openDB(opts kv2.MdbxOpts, applyMigrations bool, logger log.Logger) (kv.RwDB
}
if h3 {
_, _, agg := allSnapshots(context.Background(), db, logger)
tdb, err := temporal.New(db, agg, systemcontracts.SystemContractCodeLookup[chain])
tdb, err := temporal.New(db, agg)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/integration/commands/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/c2h5oh/datasize"
"github.com/erigontech/mdbx-go/mdbx"
lru "github.com/hashicorp/golang-lru/arc/v2"
"github.com/ledgerwatch/erigon-lib/etconfig2"
"github.com/ledgerwatch/log/v3"
"github.com/ledgerwatch/secp256k1"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -1732,7 +1733,7 @@ func allSnapshots(ctx context.Context, db kv.RoDB, logger log.Logger) (*freezebl
_allSnapshotsSingleton = freezeblocks.NewRoSnapshots(snapCfg, dirs.Snap, 0, logger)
_allBorSnapshotsSingleton = freezeblocks.NewBorRoSnapshots(snapCfg, dirs.Snap, 0, logger)
var err error
_aggSingleton, err = libstate.NewAggregator(ctx, dirs, ethconfig.HistoryV3AggregationStep, db, logger)
_aggSingleton, err = libstate.NewAggregator(ctx, dirs, etconfig2.HistoryV3AggregationStep, db, logger)
if err != nil {
panic(err)
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/rpcdaemon/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"strings"
"time"

"github.com/ledgerwatch/erigon-lib/etconfig2"
"github.com/ledgerwatch/erigon-lib/kv/temporal"
"github.com/ledgerwatch/log/v3"
"github.com/spf13/cobra"
"golang.org/x/sync/semaphore"
Expand Down Expand Up @@ -50,8 +52,6 @@ import (
"github.com/ledgerwatch/erigon/consensus/ethash"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/core/state"
"github.com/ledgerwatch/erigon/core/state/temporal"
"github.com/ledgerwatch/erigon/core/systemcontracts"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/eth/ethconfig"
"github.com/ledgerwatch/erigon/node"
Expand Down Expand Up @@ -380,7 +380,7 @@ func RemoteServices(ctx context.Context, cfg *httpcfg.HttpCfg, logger log.Logger
allSnapshots.LogStat("remote")
allBorSnapshots.LogStat("remote")

if agg, err = libstate.NewAggregator(ctx, cfg.Dirs, ethconfig.HistoryV3AggregationStep, db, logger); err != nil {
if agg, err = libstate.NewAggregator(ctx, cfg.Dirs, etconfig2.HistoryV3AggregationStep, db, logger); err != nil {
return nil, nil, nil, nil, nil, nil, nil, ff, nil, fmt.Errorf("create aggregator: %w", err)
}
_ = agg.OpenFolder(true) //TODO: must use analog of `OptimisticReopenWithDB`
Expand Down Expand Up @@ -438,7 +438,7 @@ func RemoteServices(ctx context.Context, cfg *httpcfg.HttpCfg, logger log.Logger
cfg.StateCache.StateV3 = histV3Enabled
if histV3Enabled {
logger.Info("HistoryV3", "enable", histV3Enabled)
db, err = temporal.New(rwKv, agg, systemcontracts.SystemContractCodeLookup[cc.ChainName])
db, err = temporal.New(rwKv, agg)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, err
}
Expand Down
7 changes: 3 additions & 4 deletions core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,20 @@ import (
"fmt"
"math/big"

"github.com/ledgerwatch/erigon-lib/etconfig2"
"github.com/ledgerwatch/log/v3"

"github.com/ledgerwatch/erigon-lib/chain"
libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/common/length"
"github.com/ledgerwatch/erigon-lib/kv"
state2 "github.com/ledgerwatch/erigon-lib/state"
"github.com/ledgerwatch/erigon/core/types/accounts"
"github.com/ledgerwatch/erigon/eth/ethconfig"

"github.com/ledgerwatch/erigon/consensus"
"github.com/ledgerwatch/erigon/consensus/merge"
"github.com/ledgerwatch/erigon/consensus/misc"
"github.com/ledgerwatch/erigon/core/state"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/core/types/accounts"
"github.com/ledgerwatch/erigon/core/vm"
"github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/erigon/rlp"
Expand Down Expand Up @@ -308,7 +307,7 @@ func (cp *ChainPack) NumberOfPoWBlocks() int {
// values. Inserting them into BlockChain requires use of FakePow or
// a similar non-validating proof of work implementation.
func GenerateChain(config *chain.Config, parent *types.Block, engine consensus.Engine, db kv.RwDB, n int, gen func(int, *BlockGen)) (*ChainPack, error) {
histV3 := ethconfig.EnableHistoryV4InTest
histV3 := etconfig2.EnableHistoryV4InTest
if config == nil {
config = params.TestChainConfig
}
Expand Down
6 changes: 3 additions & 3 deletions core/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/common/datadir"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon-lib/kv/temporal/temporaltest"
"github.com/ledgerwatch/erigon/core"
"github.com/ledgerwatch/erigon/core/state/temporal"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/turbo/rpchelper"
"github.com/ledgerwatch/erigon/turbo/stages/mock"
Expand All @@ -28,7 +28,7 @@ import (
func TestGenesisBlockHashes(t *testing.T) {
t.Parallel()
logger := log.New()
_, db, _ := temporal.NewTestDB(t, datadir.New(t.TempDir()), nil)
_, db, _ := temporaltest.NewTestDB(t, datadir.New(t.TempDir()))
check := func(network string) {
genesis := core.GenesisBlockByChainName(network)
tx, err := db.BeginRw(context.Background())
Expand Down Expand Up @@ -88,7 +88,7 @@ func TestGenesisBlockRoots(t *testing.T) {
func TestCommitGenesisIdempotency(t *testing.T) {
t.Parallel()
logger := log.New()
_, db, _ := temporal.NewTestDB(t, datadir.New(t.TempDir()), nil)
_, db, _ := temporaltest.NewTestDB(t, datadir.New(t.TempDir()))
tx, err := db.BeginRw(context.Background())
require.NoError(t, err)
defer tx.Rollback()
Expand Down
4 changes: 2 additions & 2 deletions core/rawdb/rawdbhelpers/rawdbhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package rawdbhelpers
import (
"encoding/binary"

"github.com/ledgerwatch/erigon-lib/etconfig2"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/eth/ethconfig"
)

func IdxStepsCountV3(tx kv.Tx) float64 {
Expand All @@ -14,7 +14,7 @@ func IdxStepsCountV3(tx kv.Tx) float64 {
fstTxNum := binary.BigEndian.Uint64(fst)
lstTxNum := binary.BigEndian.Uint64(lst)

return float64(lstTxNum-fstTxNum) / float64(ethconfig.HistoryV3AggregationStep)
return float64(lstTxNum-fstTxNum) / float64(etconfig2.HistoryV3AggregationStep)
}
return 0
}
2 changes: 1 addition & 1 deletion core/rawdb/rawdbreset/reset_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon-lib/kv/backup"
"github.com/ledgerwatch/erigon-lib/kv/kvcfg"
"github.com/ledgerwatch/erigon-lib/kv/temporal"
"github.com/ledgerwatch/erigon-lib/state"
"github.com/ledgerwatch/erigon/core"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/core/rawdb/blockio"
"github.com/ledgerwatch/erigon/core/state/temporal"
"github.com/ledgerwatch/erigon/eth/stagedsync"
"github.com/ledgerwatch/erigon/eth/stagedsync/stages"
"github.com/ledgerwatch/erigon/turbo/services"
Expand Down
9 changes: 4 additions & 5 deletions core/state/domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (

"github.com/c2h5oh/datasize"
datadir2 "github.com/ledgerwatch/erigon-lib/common/datadir"
"github.com/ledgerwatch/erigon-lib/etconfig2"
"github.com/ledgerwatch/erigon-lib/kv/temporal"
"github.com/ledgerwatch/log/v3"
"github.com/stretchr/testify/require"
"golang.org/x/sync/semaphore"
Expand All @@ -15,9 +17,6 @@ import (
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon-lib/kv/mdbx"
"github.com/ledgerwatch/erigon-lib/state"
"github.com/ledgerwatch/erigon/core/state/temporal"
"github.com/ledgerwatch/erigon/core/systemcontracts"
"github.com/ledgerwatch/erigon/eth/ethconfig"
)

func dbCfg(label kv.Label, path string) mdbx.MdbxOpts {
Expand Down Expand Up @@ -53,7 +52,7 @@ func dbAggregatorOnDatadir(t *testing.T, ddir string) (kv.RwDB, *state.Aggregato
db := dbCfg(kv.ChainDB, dirs.Chaindata).MustOpen()
t.Cleanup(db.Close)

agg, err := state.NewAggregator(context.Background(), dirs, ethconfig.HistoryV3AggregationStep, db, logger)
agg, err := state.NewAggregator(context.Background(), dirs, etconfig2.HistoryV3AggregationStep, db, logger)
require.NoError(t, err)
t.Cleanup(agg.Close)
err = agg.OpenFolder(false)
Expand All @@ -72,7 +71,7 @@ func runAggregatorOnActualDatadir(t *testing.T, datadir string) {
ctx := context.Background()
db, agg := dbAggregatorOnDatadir(t, datadir)

tdb, err := temporal.New(db, agg, systemcontracts.SystemContractCodeLookup["sepolia"])
tdb, err := temporal.New(db, agg)
require.NoError(t, err)

tx, err := tdb.BeginTemporalRw(context.Background())
Expand Down
5 changes: 2 additions & 3 deletions core/test/domains_restart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"testing"
"time"

"github.com/ledgerwatch/erigon-lib/kv/temporal"
types2 "github.com/ledgerwatch/erigon-lib/types"

"github.com/holiman/uint256"
Expand All @@ -34,8 +35,6 @@
"github.com/ledgerwatch/erigon-lib/state"
reset2 "github.com/ledgerwatch/erigon/core/rawdb/rawdbreset"
state2 "github.com/ledgerwatch/erigon/core/state"
"github.com/ledgerwatch/erigon/core/state/temporal"
"github.com/ledgerwatch/erigon/core/systemcontracts"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/core/types/accounts"
"github.com/ledgerwatch/erigon/crypto"
Expand Down Expand Up @@ -70,8 +69,8 @@
})
require.NoError(t, err)

chain := networkname.Test

Check failure on line 72 in core/test/domains_restart_test.go

View workflow job for this annotation

GitHub Actions / tests-windows (windows-2022)

chain declared and not used

Check failure on line 72 in core/test/domains_restart_test.go

View workflow job for this annotation

GitHub Actions / tests-windows (windows-2022)

chain declared and not used

Check failure on line 72 in core/test/domains_restart_test.go

View workflow job for this annotation

GitHub Actions / tests (ubuntu-22.04)

chain declared and not used (typecheck)
tdb, err := temporal.New(db, agg, systemcontracts.SystemContractCodeLookup[chain])
tdb, err := temporal.New(db, agg)
require.NoError(t, err)
db = tdb
return db, agg, path
Expand Down
4 changes: 2 additions & 2 deletions core/vm/gas_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"testing"

"github.com/ledgerwatch/erigon-lib/common/hexutil"
"github.com/ledgerwatch/erigon-lib/kv/temporal/temporaltest"
"github.com/ledgerwatch/erigon-lib/wrap"
"github.com/ledgerwatch/log/v3"

Expand All @@ -36,7 +37,6 @@ import (
"github.com/ledgerwatch/erigon-lib/kv/memdb"

"github.com/ledgerwatch/erigon/core/state"
"github.com/ledgerwatch/erigon/core/state/temporal"
"github.com/ledgerwatch/erigon/core/vm/evmtypes"
"github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/erigon/turbo/rpchelper"
Expand Down Expand Up @@ -146,7 +146,7 @@ var createGasTests = []struct {

func TestCreateGas(t *testing.T) {
t.Parallel()
_, db, _ := temporal.NewTestDB(t, datadir.New(t.TempDir()), nil)
_, db, _ := temporaltest.NewTestDB(t, datadir.New(t.TempDir()))
for i, tt := range createGasTests {
address := libcommon.BytesToAddress([]byte("contract"))

Expand Down
6 changes: 6 additions & 0 deletions erigon-lib/etconfig2/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package etconfig2

// AggregationStep number of transactions in smalest static file
const HistoryV3AggregationStep = 1_562_500 // = 100M / 64. Dividers: 2, 5, 10, 20, 50, 100, 500

const EnableHistoryV4InTest = true
6 changes: 5 additions & 1 deletion erigon-lib/kv/kvcache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ import (
"testing"

"github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/common/datadir"
"github.com/ledgerwatch/erigon-lib/gointerfaces"
"github.com/ledgerwatch/erigon-lib/gointerfaces/remote"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon-lib/kv/memdb"
"github.com/ledgerwatch/erigon-lib/kv/temporal/temporaltest"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -104,7 +106,9 @@ func TestEviction(t *testing.T) {
cfg.CacheSize = 21
cfg.NewBlockWait = 0
c := New(cfg)
db := memdb.NewTestDB(t)

dirs := datadir.New(t.TempDir())
_, db, _ := temporaltest.NewTestDB(t, dirs)
k1, k2 := [20]byte{1}, [20]byte{2}

var id uint64
Expand Down
Loading
Loading