-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add new task: fevm_block_header #1207
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 int64 `pg:",use_zero"` | ||
Number int64 `pg:",use_zero"` | ||
GasLimit int64 `pg:",use_zero"` | ||
GasUsed int64 `pg:",use_zero"` | ||
Timestamp int64 `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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these
int64
? The Lotus implementation has these asuint64
.