Skip to content

Commit 4aa0e37

Browse files
TerryhungTerry
andauthored
feat: add new task: fevm_block_header (#1207)
* Add new task: fevm blockheader --------- Co-authored-by: Terry <[email protected]>
1 parent 7e61323 commit 4aa0e37

File tree

16 files changed

+248
-31
lines changed

16 files changed

+248
-31
lines changed

chain/datasource/datasource.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/filecoin-project/lotus/api"
1919
"github.com/filecoin-project/lotus/chain/state"
2020
"github.com/filecoin-project/lotus/chain/types"
21+
"github.com/filecoin-project/lotus/chain/types/ethtypes"
2122
"github.com/filecoin-project/lotus/chain/vm"
2223
lru "github.com/hashicorp/golang-lru"
2324
"github.com/ipfs/go-cid"
@@ -147,6 +148,10 @@ func (t *DataSource) TipSetBlockMessages(ctx context.Context, ts *types.TipSet)
147148
return t.node.MessagesForTipSetBlocks(ctx, ts)
148149
}
149150

151+
func (t *DataSource) EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error) {
152+
return t.node.EthGetBlockByHash(ctx, blkHash, fullTxInfo)
153+
}
154+
150155
// TipSetMessageReceipts returns the blocks and messages in `pts` and their corresponding receipts from `ts` matching block order in tipset (`pts`).
151156
// TODO replace with lotus chainstore method when https://github.com/filecoin-project/lotus/pull/9186 lands
152157
func (t *DataSource) TipSetMessageReceipts(ctx context.Context, ts, pts *types.TipSet) ([]*lens.BlockMessageReceipts, error) {

chain/indexer/integrated/processor/state.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import (
5959
msapprovaltask "github.com/filecoin-project/lily/tasks/msapprovals"
6060

6161
// fevm task
62+
fevmblockheadertask "github.com/filecoin-project/lily/tasks/fevm/blockheader"
6263
fevmactorstatstask "github.com/filecoin-project/lily/tasks/fevmactorstats"
6364

6465
"github.com/filecoin-project/lily/chain/indexer/tasktype"
@@ -641,6 +642,8 @@ func MakeProcessors(api tasks.DataSource, indexerTasks []string) (*IndexerProces
641642
//
642643
case tasktype.FEVMActorStats:
643644
out.TipsetProcessors[t] = fevmactorstatstask.NewTask(api)
645+
case tasktype.FEVMBlockHeader:
646+
out.TipsetsProcessors[t] = fevmblockheadertask.NewTask(api)
644647

645648
case BuiltinTaskName:
646649
out.ReportProcessors[t] = indexertask.NewTask(api)

chain/indexer/integrated/processor/state_internal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestNewProcessor(t *testing.T) {
5454
require.Equal(t, t.Name(), proc.name)
5555
require.Len(t, proc.actorProcessors, 24)
5656
require.Len(t, proc.tipsetProcessors, 10)
57-
require.Len(t, proc.tipsetsProcessors, 9)
57+
require.Len(t, proc.tipsetsProcessors, 10)
5858
require.Len(t, proc.builtinProcessors, 1)
5959

6060
require.Equal(t, gasoutput.NewTask(nil), proc.tipsetsProcessors[tasktype.GasOutputs])

chain/indexer/integrated/processor/state_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,6 @@ func TestMakeProcessorsAllTasks(t *testing.T) {
408408
require.NoError(t, err)
409409
require.Len(t, proc.ActorProcessors, 24)
410410
require.Len(t, proc.TipsetProcessors, 10)
411-
require.Len(t, proc.TipsetsProcessors, 9)
411+
require.Len(t, proc.TipsetsProcessors, 10)
412412
require.Len(t, proc.ReportProcessors, 1)
413413
}

chain/indexer/tasktype/table_tasks.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const (
4545
VerifiedRegistryVerifiedClient = "verified_registry_verified_client"
4646
VerifiedRegistryClaim = "verified_registry_claim"
4747
FEVMActorStats = "fevm_actor_stats"
48+
FEVMBlockHeader = "fevm_block_header"
4849
)
4950

5051
var AllTableTasks = []string{
@@ -91,6 +92,7 @@ var AllTableTasks = []string{
9192
VerifiedRegistryVerifiedClient,
9293
VerifiedRegistryClaim,
9394
FEVMActorStats,
95+
FEVMBlockHeader,
9496
}
9597

9698
var TableLookup = map[string]struct{}{
@@ -137,6 +139,7 @@ var TableLookup = map[string]struct{}{
137139
VerifiedRegistryVerifiedClient: {},
138140
VerifiedRegistryClaim: {},
139141
FEVMActorStats: {},
142+
FEVMBlockHeader: {},
140143
}
141144

142145
var TableComment = map[string]string{
@@ -183,6 +186,7 @@ var TableComment = map[string]string{
183186
VerifiedRegistryVerifiedClient: ``,
184187
VerifiedRegistryClaim: ``,
185188
FEVMActorStats: ``,
189+
FEVMBlockHeader: ``,
186190
}
187191

188192
var TableFieldComments = map[string]map[string]string{
@@ -286,4 +290,5 @@ var TableFieldComments = map[string]map[string]string{
286290
VerifiedRegistryVerifiedClient: {},
287291
VerifiedRegistryClaim: {},
288292
FEVMActorStats: {},
293+
FEVMBlockHeader: {},
289294
}

chain/indexer/tasktype/tasks.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ var TaskLookup = map[string][]string{
9393
},
9494
FEVMTask: {
9595
FEVMActorStats,
96+
FEVMBlockHeader,
9697
},
9798
}
9899

chain/indexer/tasktype/tasks_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TestMakeAllTaskAliasNames(t *testing.T) {
101101
}
102102

103103
func TestMakeAllTaskNames(t *testing.T) {
104-
const TotalTableTasks = 43
104+
const TotalTableTasks = 44
105105
actual, err := tasktype.MakeTaskNames(tasktype.AllTableTasks)
106106
require.NoError(t, err)
107107
// if this test fails it means a new task name was added, update the above test

lens/interface.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/filecoin-project/go-state-types/abi"
1212
"github.com/filecoin-project/lotus/api"
1313
"github.com/filecoin-project/lotus/chain/types"
14+
"github.com/filecoin-project/lotus/chain/types/ethtypes"
1415
"github.com/filecoin-project/lotus/chain/vm"
1516
"github.com/filecoin-project/specs-actors/actors/util/adt"
1617
"github.com/ipfs/go-cid"
@@ -21,6 +22,7 @@ type API interface {
2122
ChainAPI
2223
StateAPI
2324
VMAPI
25+
EthModuleAPI
2426

2527
GetMessageExecutionsForTipSet(ctx context.Context, ts, pts *types.TipSet) ([]*MessageExecution, error)
2628
}
@@ -74,6 +76,10 @@ type VMAPI interface {
7476
BurnFundsFn(ctx context.Context, ts *types.TipSet) (ShouldBurnFn, error)
7577
}
7678

79+
type EthModuleAPI interface {
80+
EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error)
81+
}
82+
7783
type MessageExecution struct {
7884
Cid cid.Cid
7985
StateRoot cid.Cid

lens/lily/api.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/filecoin-project/go-state-types/abi"
99
"github.com/filecoin-project/lotus/api"
1010
"github.com/filecoin-project/lotus/chain/types"
11+
"github.com/filecoin-project/lotus/chain/types/ethtypes"
1112
"github.com/ipfs/go-cid"
1213
"github.com/libp2p/go-libp2p/core/peer"
1314

@@ -40,20 +41,21 @@ type LilyAPI interface {
4041
// SyncState returns the current status of the chain sync system.
4142
SyncState(context.Context) (*api.SyncState, error) //perm:read
4243

43-
ChainHead(context.Context) (*types.TipSet, error) //perm:read
44-
ChainGetBlock(context.Context, cid.Cid) (*types.BlockHeader, error) //perm:read
45-
ChainReadObj(context.Context, cid.Cid) ([]byte, error) //perm:read
46-
ChainStatObj(context.Context, cid.Cid, cid.Cid) (api.ObjStat, error) //perm:read
47-
ChainGetTipSet(context.Context, types.TipSetKey) (*types.TipSet, error) //perm:read
48-
ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error) //perm:read
49-
ChainGetTipSetAfterHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error) //perm:read
50-
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error) //perm:read
51-
ChainGetParentReceipts(context.Context, cid.Cid) ([]*types.MessageReceipt, error) //perm:read
52-
ChainGetParentMessages(context.Context, cid.Cid) ([]api.Message, error) //perm:read
53-
ChainSetHead(context.Context, types.TipSetKey) error //perm:read
54-
ChainGetGenesis(context.Context) (*types.TipSet, error) //perm:read
55-
ChainPrune(ctx context.Context, opts api.PruneOpts) error //perm:read
56-
ChainHotGC(ctx context.Context, opts api.HotGCOpts) error //perm:read
44+
ChainHead(context.Context) (*types.TipSet, error) //perm:read
45+
ChainGetBlock(context.Context, cid.Cid) (*types.BlockHeader, error) //perm:read
46+
ChainReadObj(context.Context, cid.Cid) ([]byte, error) //perm:read
47+
ChainStatObj(context.Context, cid.Cid, cid.Cid) (api.ObjStat, error) //perm:read
48+
ChainGetTipSet(context.Context, types.TipSetKey) (*types.TipSet, error) //perm:read
49+
ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error) //perm:read
50+
ChainGetTipSetAfterHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error) //perm:read
51+
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error) //perm:read
52+
ChainGetParentReceipts(context.Context, cid.Cid) ([]*types.MessageReceipt, error) //perm:read
53+
ChainGetParentMessages(context.Context, cid.Cid) ([]api.Message, error) //perm:read
54+
ChainSetHead(context.Context, types.TipSetKey) error //perm:read
55+
ChainGetGenesis(context.Context) (*types.TipSet, error) //perm:read
56+
ChainPrune(ctx context.Context, opts api.PruneOpts) error //perm:read
57+
ChainHotGC(ctx context.Context, opts api.HotGCOpts) error //perm:read
58+
EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error) //perm:read
5759

5860
// trigger graceful shutdown
5961
Shutdown(context.Context) error

lens/lily/impl.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/filecoin-project/lotus/chain/state"
1616
"github.com/filecoin-project/lotus/chain/stmgr"
1717
"github.com/filecoin-project/lotus/chain/types"
18+
"github.com/filecoin-project/lotus/chain/types/ethtypes"
1819
"github.com/filecoin-project/lotus/chain/vm"
1920
"github.com/filecoin-project/lotus/node/impl/common"
2021
"github.com/filecoin-project/lotus/node/impl/full"
@@ -55,6 +56,7 @@ type LilyNodeAPI struct {
5556
full.ChainAPI
5657
full.StateAPI
5758
full.SyncAPI
59+
full.EthModuleAPI
5860
common.CommonAPI
5961
Events *events.Events
6062
Scheduler *schedule.Scheduler
@@ -553,6 +555,10 @@ func (m *LilyNodeAPI) ComputeBaseFee(ctx context.Context, ts *types.TipSet) (abi
553555
return m.ChainAPI.Chain.ComputeBaseFee(ctx, ts)
554556
}
555557

558+
func (m *LilyNodeAPI) EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error) {
559+
return m.EthModuleAPI.EthGetBlockByHash(ctx, blkHash, fullTxInfo)
560+
}
561+
556562
// MessagesForTipSetBlocks returns messages stored in the blocks of the specified tipset, messages may be duplicated
557563
// across the returned set of BlockMessages.
558564
func (m *LilyNodeAPI) MessagesForTipSetBlocks(ctx context.Context, ts *types.TipSet) ([]*lens.BlockMessages, error) {

0 commit comments

Comments
 (0)