Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoff Stuart authored and raulk committed Jan 13, 2023
1 parent 9c6258d commit c5c19db
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 36 deletions.
Binary file modified build/openrpc/full.json.gz
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chain
package ethhashlookup

import (
"database/sql"
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions documentation/en/default-lotus-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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


2 changes: 1 addition & 1 deletion itests/eth_hash_lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}),
)
Expand Down
2 changes: 1 addition & 1 deletion itests/fevm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion itests/kit/node_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
2 changes: 1 addition & 1 deletion node/builder_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
)
}

Expand Down
4 changes: 2 additions & 2 deletions node/config/def.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ func DefaultFullNode() *FullNode {
MaxFilterResults: 10000,
MaxFilterHeightRange: 2880, // conservative limit of one day
},
EthTxHashConfig: EthTxHashConfig{
EnableEthHashToFilecoinCidMapping: true,
Fevm: FevmConfig{
EnableEthHashToFilecoinCidMapping: false,
},
}
}
Expand Down
20 changes: 10 additions & 10 deletions node/config/doc_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions node/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions node/impl/full/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions node/modules/ethmodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand All @@ -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
}
Expand Down

0 comments on commit c5c19db

Please sign in to comment.