Skip to content

Commit 744faa5

Browse files
TerryhungTerry
andauthored
feat: add new task: fevm_transaction (#1213)
* Add new task: fevm_transaction * refactor the duplicate function * Add new schema for fevm transaction * Change the column schema * Change the type of maxfeepergas --------- Co-authored-by: Terry <[email protected]>
1 parent 9da9561 commit 744faa5

File tree

18 files changed

+275
-22
lines changed

18 files changed

+275
-22
lines changed

chain/datasource/datasource.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ func (t *DataSource) EthGetBlockByHash(ctx context.Context, blkHash ethtypes.Eth
144144
return t.node.EthGetBlockByHash(ctx, blkHash, fullTxInfo)
145145
}
146146

147+
func (t *DataSource) EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*ethtypes.EthTx, error) {
148+
return t.node.EthGetTransactionByHash(ctx, txHash)
149+
}
150+
147151
func (t *DataSource) EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*api.EthTxReceipt, error) {
148152
return t.node.EthGetTransactionReceipt(ctx, txHash)
149153
}

chain/indexer/integrated/processor/state.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import (
6161
// fevm task
6262
fevmblockheadertask "github.com/filecoin-project/lily/tasks/fevm/blockheader"
6363
fevmreceipttask "github.com/filecoin-project/lily/tasks/fevm/receipt"
64+
fevmtransactiontask "github.com/filecoin-project/lily/tasks/fevm/transaction"
6465
fevmactorstatstask "github.com/filecoin-project/lily/tasks/fevmactorstats"
6566

6667
"github.com/filecoin-project/lily/chain/indexer/tasktype"
@@ -647,6 +648,8 @@ func MakeProcessors(api tasks.DataSource, indexerTasks []string) (*IndexerProces
647648
out.TipsetsProcessors[t] = fevmblockheadertask.NewTask(api)
648649
case tasktype.FEVMReceipt:
649650
out.TipsetsProcessors[t] = fevmreceipttask.NewTask(api)
651+
case tasktype.FEVMTransaction:
652+
out.TipsetsProcessors[t] = fevmtransactiontask.NewTask(api)
650653

651654
case BuiltinTaskName:
652655
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, 11)
57+
require.Len(t, proc.tipsetsProcessors, 12)
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, 11)
411+
require.Len(t, proc.TipsetsProcessors, 12)
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
@@ -47,6 +47,7 @@ const (
4747
FEVMActorStats = "fevm_actor_stats"
4848
FEVMBlockHeader = "fevm_block_header"
4949
FEVMReceipt = "fevm_receipt"
50+
FEVMTransaction = "fevm_transaction"
5051
)
5152

5253
var AllTableTasks = []string{
@@ -95,6 +96,7 @@ var AllTableTasks = []string{
9596
FEVMActorStats,
9697
FEVMBlockHeader,
9798
FEVMReceipt,
99+
FEVMTransaction,
98100
}
99101

100102
var TableLookup = map[string]struct{}{
@@ -143,6 +145,7 @@ var TableLookup = map[string]struct{}{
143145
FEVMActorStats: {},
144146
FEVMBlockHeader: {},
145147
FEVMReceipt: {},
148+
FEVMTransaction: {},
146149
}
147150

148151
var TableComment = map[string]string{
@@ -191,6 +194,7 @@ var TableComment = map[string]string{
191194
FEVMActorStats: ``,
192195
FEVMBlockHeader: ``,
193196
FEVMReceipt: ``,
197+
FEVMTransaction: ``,
194198
}
195199

196200
var TableFieldComments = map[string]map[string]string{
@@ -296,4 +300,5 @@ var TableFieldComments = map[string]map[string]string{
296300
FEVMActorStats: {},
297301
FEVMBlockHeader: {},
298302
FEVMReceipt: {},
303+
FEVMTransaction: {},
299304
}

chain/indexer/tasktype/tasks.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ var TaskLookup = map[string][]string{
9595
FEVMActorStats,
9696
FEVMBlockHeader,
9797
FEVMReceipt,
98+
FEVMTransaction,
9899
},
99100
}
100101

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 = 45
104+
const TotalTableTasks = 46
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ type VMAPI interface {
8080
type EthModuleAPI interface {
8181
EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error)
8282
EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*api.EthTxReceipt, error)
83+
EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*ethtypes.EthTx, error)
8384
}
8485

8586
type MessageExecution struct {

lens/lily/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ type LilyAPI interface {
5858
EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error) //perm:read
5959
EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*api.EthTxReceipt, error) //perm:read
6060
ChainGetMessagesInTipset(ctx context.Context, tsk types.TipSetKey) ([]api.Message, error) //perm:read
61+
EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*ethtypes.EthTx, error) //perm:read
6162

6263
// trigger graceful shutdown
6364
Shutdown(context.Context) error

lens/lily/impl.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,10 @@ func (m *LilyNodeAPI) EthGetBlockByHash(ctx context.Context, blkHash ethtypes.Et
559559
return m.EthModuleAPI.EthGetBlockByHash(ctx, blkHash, fullTxInfo)
560560
}
561561

562+
func (m *LilyNodeAPI) EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*ethtypes.EthTx, error) {
563+
return m.EthModuleAPI.EthGetTransactionByHash(ctx, txHash)
564+
}
565+
562566
func (m *LilyNodeAPI) EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*api.EthTxReceipt, error) {
563567
return m.EthModuleAPI.EthGetTransactionReceipt(ctx, txHash)
564568
}

0 commit comments

Comments
 (0)