diff --git a/build/openrpc/full.json.gz b/build/openrpc/full.json.gz index 65a8c57e6b9..70eee01c4b2 100644 Binary files a/build/openrpc/full.json.gz and b/build/openrpc/full.json.gz differ diff --git a/chain/eth_transaction_hash_lookup.go b/chain/ethhashlookup/eth_transaction_hash_lookup.go similarity index 94% rename from chain/eth_transaction_hash_lookup.go rename to chain/ethhashlookup/eth_transaction_hash_lookup.go index a7debc5a65d..9bd966b68a8 100644 --- a/chain/eth_transaction_hash_lookup.go +++ b/chain/ethhashlookup/eth_transaction_hash_lookup.go @@ -1,4 +1,4 @@ -package chain +package ethhashlookup import ( "database/sql" @@ -26,11 +26,15 @@ var pragmas = []string{ var ddls = []string{ `CREATE TABLE IF NOT EXISTS tx_hash_lookup ( - hash TEXT PRIMARY KEY, - cid TEXT NOT NULL, + hash TEXT PRIMARY KEY UNIQUE, + cid TEXT NOT NULL UNIQUE, epoch INT NOT NULL )`, + `CREATE UNIQUE INDEX IF NOT EXISTS tx_hash_lookup_hash_uindex ON tx_hash_lookup (hash)`, + + `CREATE INDEX IF NOT EXISTS tx_hash_lookup_epoch_index ON tx_hash_lookup (epoch)`, + // metadata containing version of schema `CREATE TABLE IF NOT EXISTS _meta ( version UINT64 NOT NULL UNIQUE diff --git a/documentation/en/default-lotus-config.toml b/documentation/en/default-lotus-config.toml index 4f2148552f7..0191950f5ad 100644 --- a/documentation/en/default-lotus-config.toml +++ b/documentation/en/default-lotus-config.toml @@ -343,11 +343,11 @@ #ActorEventDatabasePath = "" -[EthTxHashConfig] +[Fevm] # EnableEthHashToFilecoinCidMapping enables storing a mapping of eth transaction hashes to filecoin message Cids # # type: bool - # env var: LOTUS_ETHTXHASHCONFIG_ENABLEETHHASHTOFILECOINCIDMAPPING - #EnableEthHashToFilecoinCidMapping = true + # env var: LOTUS_FEVM_ENABLEETHHASHTOFILECOINCIDMAPPING + #EnableEthHashToFilecoinCidMapping = false diff --git a/itests/eth_hash_lookup_test.go b/itests/eth_hash_lookup_test.go index 7188a34e41c..062ab91fc3d 100644 --- a/itests/eth_hash_lookup_test.go +++ b/itests/eth_hash_lookup_test.go @@ -122,7 +122,7 @@ func TestTransactionHashLookupNoDb(t *testing.T) { kit.MockProofs(), kit.ThroughRPC(), kit.WithCfgOpt(func(cfg *config.FullNode) error { - cfg.EthTxHashConfig.EnableEthHashToFilecoinCidMapping = false + cfg.Fevm.EnableEthHashToFilecoinCidMapping = false return nil }), ) diff --git a/itests/fevm_test.go b/itests/fevm_test.go index af29f83a8de..f6d6351422c 100644 --- a/itests/fevm_test.go +++ b/itests/fevm_test.go @@ -19,7 +19,7 @@ import ( "github.com/filecoin-project/lotus/itests/kit" ) -// TestFEVMBasic does a basic fevm contract installation and invocation +// TestFEVMBasic does a basic ethhash contract installation and invocation func TestFEVMBasic(t *testing.T) { // TODO the contract installation and invocation can be lifted into utility methods // He who writes the second test, shall do that. diff --git a/itests/kit/node_opts.go b/itests/kit/node_opts.go index aed6772c588..efaed8861e2 100644 --- a/itests/kit/node_opts.go +++ b/itests/kit/node_opts.go @@ -299,7 +299,7 @@ func HistoricFilterAPI(dbpath string) NodeOpt { func EthTxHashLookup() NodeOpt { return WithCfgOpt(func(cfg *config.FullNode) error { - cfg.EthTxHashConfig.EnableEthHashToFilecoinCidMapping = true + cfg.Fevm.EnableEthHashToFilecoinCidMapping = true return nil }) } diff --git a/node/builder_chain.go b/node/builder_chain.go index 82827f06ac5..ac5aa239686 100644 --- a/node/builder_chain.go +++ b/node/builder_chain.go @@ -260,7 +260,7 @@ func ConfigFullNode(c interface{}) Option { Override(new(events.EventAPI), From(new(modules.EventAPI))), Override(new(full.EthEventAPI), modules.EthEventAPI(cfg.ActorEvent)), - Override(new(full.EthModuleAPI), modules.EthModuleAPI(cfg.EthTxHashConfig)), + Override(new(full.EthModuleAPI), modules.EthModuleAPI(cfg.Fevm)), ) } diff --git a/node/config/def.go b/node/config/def.go index 079023417bf..cc301b27625 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -107,8 +107,8 @@ func DefaultFullNode() *FullNode { MaxFilterResults: 10000, MaxFilterHeightRange: 2880, // conservative limit of one day }, - EthTxHashConfig: EthTxHashConfig{ - EnableEthHashToFilecoinCidMapping: true, + Fevm: FevmConfig{ + EnableEthHashToFilecoinCidMapping: false, }, } } diff --git a/node/config/doc_gen.go b/node/config/doc_gen.go index ed60cea3608..b411e8bf92e 100644 --- a/node/config/doc_gen.go +++ b/node/config/doc_gen.go @@ -391,14 +391,6 @@ see https://lotus.filecoin.io/storage-providers/advanced-configurations/market/# Comment: ``, }, }, - "EthTxHashConfig": []DocField{ - { - Name: "EnableEthHashToFilecoinCidMapping", - Type: "bool", - - Comment: `EnableEthHashToFilecoinCidMapping enables storing a mapping of eth transaction hashes to filecoin message Cids`, - }, - }, "FeeConfig": []DocField{ { Name: "DefaultMaxFee", @@ -407,6 +399,14 @@ see https://lotus.filecoin.io/storage-providers/advanced-configurations/market/# Comment: ``, }, }, + "FevmConfig": []DocField{ + { + Name: "EnableEthHashToFilecoinCidMapping", + Type: "bool", + + Comment: `EnableEthHashToFilecoinCidMapping enables storing a mapping of eth transaction hashes to filecoin message Cids`, + }, + }, "FullNode": []DocField{ { Name: "Client", @@ -445,8 +445,8 @@ see https://lotus.filecoin.io/storage-providers/advanced-configurations/market/# Comment: ``, }, { - Name: "EthTxHashConfig", - Type: "EthTxHashConfig", + Name: "Fevm", + Type: "FevmConfig", Comment: ``, }, diff --git a/node/config/types.go b/node/config/types.go index 9d9634570f6..c64f14a5dd3 100644 --- a/node/config/types.go +++ b/node/config/types.go @@ -22,13 +22,13 @@ type Common struct { // FullNode is a full node config type FullNode struct { Common - Client Client - Wallet Wallet - Fees FeeConfig - Chainstore Chainstore - Cluster UserRaftConfig - ActorEvent ActorEventConfig - EthTxHashConfig EthTxHashConfig + Client Client + Wallet Wallet + Fees FeeConfig + Chainstore Chainstore + Cluster UserRaftConfig + ActorEvent ActorEventConfig + Fevm FevmConfig } // // Common @@ -694,7 +694,7 @@ type ActorEventConfig struct { // Set upper bound on index size } -type EthTxHashConfig struct { +type FevmConfig struct { // EnableEthHashToFilecoinCidMapping enables storing a mapping of eth transaction hashes to filecoin message Cids EnableEthHashToFilecoinCidMapping bool } diff --git a/node/impl/full/eth.go b/node/impl/full/eth.go index b0150cf0bf7..dcce668b71a 100644 --- a/node/impl/full/eth.go +++ b/node/impl/full/eth.go @@ -25,9 +25,9 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/lotus/chain" "github.com/filecoin-project/lotus/chain/actors" builtinactors "github.com/filecoin-project/lotus/chain/actors/builtin" + "github.com/filecoin-project/lotus/chain/ethhashlookup" "github.com/filecoin-project/lotus/chain/events/filter" "github.com/filecoin-project/lotus/chain/messagepool" "github.com/filecoin-project/lotus/chain/stmgr" @@ -1791,7 +1791,7 @@ func (m EthTxHashManager) Apply(ctx context.Context, from, to *types.TipSet) err type EthTxHashManager struct { StateAPI StateAPI - TransactionHashLookup *chain.TransactionHashLookup + TransactionHashLookup *ethhashlookup.TransactionHashLookup } func (m EthTxHashManager) Revert(ctx context.Context, from, to *types.TipSet) error { @@ -1816,7 +1816,7 @@ func WaitForMpoolUpdates(ctx context.Context, ch <-chan api.MpoolUpdate, manager log.Errorf("error converting filecoin message to eth tx: %s", err) } - err = manager.TransactionHashLookup.InsertTxHash(ethTx.Hash, u.Message.Cid(), chain.MemPoolEpoch) + err = manager.TransactionHashLookup.InsertTxHash(ethTx.Hash, u.Message.Cid(), ethhashlookup.MemPoolEpoch) if err != nil { log.Errorf("error inserting tx mapping to db: %s", err) } diff --git a/node/modules/ethmodule.go b/node/modules/ethmodule.go index a16b7534dc8..9a4bcce0986 100644 --- a/node/modules/ethmodule.go +++ b/node/modules/ethmodule.go @@ -6,7 +6,7 @@ import ( "go.uber.org/fx" - "github.com/filecoin-project/lotus/chain" + "github.com/filecoin-project/lotus/chain/ethhashlookup" "github.com/filecoin-project/lotus/chain/events" "github.com/filecoin-project/lotus/chain/messagepool" "github.com/filecoin-project/lotus/chain/stmgr" @@ -17,7 +17,7 @@ import ( "github.com/filecoin-project/lotus/node/repo" ) -func EthModuleAPI(cfg config.EthTxHashConfig) func(helpers.MetricsCtx, repo.LockedRepo, fx.Lifecycle, *store.ChainStore, *stmgr.StateManager, EventAPI, *messagepool.MessagePool, full.StateAPI, full.ChainAPI, full.MpoolAPI) (*full.EthModule, error) { +func EthModuleAPI(cfg config.FevmConfig) func(helpers.MetricsCtx, repo.LockedRepo, fx.Lifecycle, *store.ChainStore, *stmgr.StateManager, EventAPI, *messagepool.MessagePool, full.StateAPI, full.ChainAPI, full.MpoolAPI) (*full.EthModule, error) { return func(mctx helpers.MetricsCtx, r repo.LockedRepo, lc fx.Lifecycle, cs *store.ChainStore, sm *stmgr.StateManager, evapi EventAPI, mp *messagepool.MessagePool, stateapi full.StateAPI, chainapi full.ChainAPI, mpoolapi full.MpoolAPI) (*full.EthModule, error) { em := &full.EthModule{ Chain: cs, @@ -38,7 +38,7 @@ func EthModuleAPI(cfg config.EthTxHashConfig) func(helpers.MetricsCtx, repo.Lock return nil, err } - transactionHashLookup, err := chain.NewTransactionHashLookup(filepath.Join(dbPath + "txHash.db")) + transactionHashLookup, err := ethhashlookup.NewTransactionHashLookup(filepath.Join(dbPath, "txhash.db")) if err != nil { return nil, err }