-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new task: fevm_block_header (#1207)
* Add new task: fevm blockheader --------- Co-authored-by: Terry <[email protected]>
- Loading branch information
Showing
16 changed files
with
248 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,7 @@ var TaskLookup = map[string][]string{ | |
}, | ||
FEVMTask: { | ||
FEVMActorStats, | ||
FEVMBlockHeader, | ||
}, | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package fevm | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opencensus.io/tag" | ||
|
||
"github.com/filecoin-project/lily/metrics" | ||
"github.com/filecoin-project/lily/model" | ||
) | ||
|
||
type FEVMBlockHeader struct { | ||
tableName struct{} `pg:"fevm_block_header"` // nolint: structcheck | ||
|
||
// Height message was executed at. | ||
Height int64 `pg:",pk,notnull,use_zero"` | ||
|
||
// ETH Hash | ||
Hash string `pg:",notnull"` | ||
|
||
// Parent Block ETH Hash | ||
ParentHash string `pg:",notnull"` | ||
|
||
Miner string `pg:",notnull"` | ||
|
||
StateRoot string `pg:",notnull"` | ||
|
||
TransactionsRoot string `pg:",notnull"` | ||
ReceiptsRoot string `pg:",notnull"` | ||
Difficulty uint64 `pg:",use_zero"` | ||
Number uint64 `pg:",use_zero"` | ||
GasLimit uint64 `pg:",use_zero"` | ||
GasUsed uint64 `pg:",use_zero"` | ||
Timestamp uint64 `pg:",use_zero"` | ||
ExtraData string `pg:",notnull"` | ||
MixHash string `pg:",notnull"` | ||
Nonce string `pg:",notnull"` | ||
BaseFeePerGas string `pg:",notnull"` | ||
Size uint64 `pg:",use_zero"` | ||
Sha3Uncles string `pg:",notnull"` | ||
} | ||
|
||
func (f *FEVMBlockHeader) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error { | ||
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_block_header")) | ||
metrics.RecordCount(ctx, metrics.PersistModel, 1) | ||
return s.PersistModel(ctx, f) | ||
} | ||
|
||
type FEVMBlockHeaderList []*FEVMBlockHeader | ||
|
||
func (f FEVMBlockHeaderList) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error { | ||
if len(f) == 0 { | ||
return nil | ||
} | ||
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_block_header")) | ||
metrics.RecordCount(ctx, metrics.PersistModel, len(f)) | ||
return s.PersistModel(ctx, f) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package v1 | ||
|
||
func init() { | ||
patches.Register( | ||
22, | ||
` | ||
CREATE TABLE IF NOT EXISTS {{ .SchemaName | default "public"}}.fevm_block_header ( | ||
height BIGINT NOT NULL, | ||
hash TEXT, | ||
parent_hash TEXT, | ||
miner TEXT, | ||
state_root TEXT, | ||
transactions_root TEXT, | ||
receipts_root TEXT, | ||
difficulty BIGINT, | ||
number BIGINT, | ||
gas_limit BIGINT, | ||
gas_used BIGINT, | ||
timestamp BIGINT, | ||
extra_data TEXT, | ||
mix_hash TEXT, | ||
nonce TEXT, | ||
base_fee_per_gas TEXT, | ||
size BIGINT, | ||
sha3_uncles TEXT, | ||
PRIMARY KEY(height) | ||
); | ||
`, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.