Skip to content

Commit

Permalink
feat: add more description for fevm models (#1231)
Browse files Browse the repository at this point in the history
* add more description for fevm models


---------

Co-authored-by: Terry <[email protected]>
  • Loading branch information
Terryhung and Terry authored Jun 15, 2023
1 parent 85d7f42 commit 1469217
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 56 deletions.
41 changes: 24 additions & 17 deletions model/fevm/blockheader.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,37 @@ type FEVMBlockHeader struct {

// 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"`

// ETH Address of the miner who mined this block.
Miner string `pg:",notnull"`

// Block state root ETH hash.
StateRoot string `pg:",notnull"`

// Set to a hardcoded value which is used by some clients to determine if has no transactions.
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"`
// Hash of the transaction receipts trie.
ReceiptsRoot string `pg:",notnull"`
// ETH mining difficulty.
Difficulty uint64 `pg:",use_zero"`
// The number of the current block.
Number uint64 `pg:",use_zero"`
// Maximum gas allowed in this block.
GasLimit uint64 `pg:",use_zero"`
// The actual amount of gas used in this block.
GasUsed uint64 `pg:",use_zero"`
// The block time.
Timestamp uint64 `pg:",use_zero"`
// Arbitrary additional data as raw bytes.
ExtraData string `pg:",notnull"`
MixHash string `pg:",notnull"`
Nonce string `pg:",notnull"`
// The base fee value.
BaseFeePerGas string `pg:",notnull"`
// Block size.
Size uint64 `pg:",use_zero"`
Sha3Uncles string `pg:",notnull"`
}

func (f *FEVMBlockHeader) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
Expand Down
14 changes: 7 additions & 7 deletions model/fevm/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ type FEVMContract struct {

// Height message was executed at.
Height int64 `pg:",pk,notnull,use_zero"`

// Actor address.
ActorID string `pg:",notnull"`

// Actor Address in ETH
// Actor Address in ETH.
EthAddress string `pg:",notnull"`

ByteCode string `pg:",notnull"`
// Contract Bytecode.
ByteCode string `pg:",notnull"`
// Contract Bytecode is encoded in hash by Keccak256.
ByteCodeHash string `pg:",notnull"`

// Balance of EVM actor in attoFIL.
Balance string `pg:"type:numeric,notnull"`
Nonce uint64 `pg:",use_zero"`
// The next actor nonce that is expected to appear on chain.
Nonce uint64 `pg:",use_zero"`
}

func (f *FEVMContract) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
Expand Down
39 changes: 25 additions & 14 deletions model/fevm/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,34 @@ type FEVMReceipt struct {

// Height message was executed at.
Height int64 `pg:",pk,notnull,use_zero"`

// Message CID
Message string `pg:",use_zero"`

TransactionHash string `pg:",notnull"`
TransactionIndex uint64 `pg:",use_zero"`
BlockHash string `pg:",notnull"`
BlockNumber uint64 `pg:",use_zero"`
From string `pg:",notnull"`
To string `pg:",notnull"`
ContractAddress string `pg:",notnull"`
Status uint64 `pg:",use_zero"`
// Hash of transaction.
TransactionHash string `pg:",notnull"`
// Integer of the transactions index position in the block.
TransactionIndex uint64 `pg:",use_zero"`
// Hash of the block where this transaction was in.
BlockHash string `pg:",notnull"`
// Block number where this transaction was in.
BlockNumber uint64 `pg:",use_zero"`
// ETH Address of the sender.
From string `pg:",notnull"`
// ETH Address of the receiver.
To string `pg:",notnull"`
// The contract address created, if the transaction was a contract creation, otherwise null.
ContractAddress string `pg:",notnull"`
// 0 indicates transaction failure , 1 indicates transaction succeeded.
Status uint64 `pg:",use_zero"`
// The total amount of gas used when this transaction was executed in the block.
CumulativeGasUsed uint64 `pg:",use_zero"`
GasUsed uint64 `pg:",use_zero"`
EffectiveGasPrice int64 `pg:",use_zero"`
LogsBloom string `pg:",notnull"`
Logs string `pg:",type:jsonb"`
// The actual amount of gas used in this block.
GasUsed uint64 `pg:",use_zero"`
// The actual value per gas deducted from the senders account.
EffectiveGasPrice int64 `pg:",use_zero"`
// Includes the bloom filter representation of the logs
LogsBloom string `pg:",notnull"`
// Array of log objects, which this transaction generated.
Logs string `pg:",type:jsonb"`
}

func (f *FEVMReceipt) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
Expand Down
2 changes: 1 addition & 1 deletion model/fevm/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type FEVMTrace struct {
Value string `pg:"type:numeric,notnull"`
// Method called on To (receiver).
Method uint64 `pg:",notnull,use_zero"`
// Params contained in message encode in eth bytes.
// Method in readable name.
ParsedMethod string `pg:",notnull"`
// ActorCode of To (receiver).
ActorCode string `pg:",notnull"`
Expand Down
50 changes: 33 additions & 17 deletions model/fevm/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,41 @@ type FEVMTransaction struct {

// Height message was executed at.
Height int64 `pg:",pk,notnull,use_zero"`

Hash string `pg:",pk,notnull"`
ChainID uint64 `pg:",use_zero"`
Nonce uint64 `pg:",use_zero"`
BlockHash string `pg:",notnull"`
BlockNumber uint64 `pg:",use_zero"`
TransactionIndex uint64 `pg:",use_zero"`
From string `pg:",notnull"`
To string `pg:",notnull"`
Value string `pg:",notnull"`
Type uint64 `pg:",use_zero"`
Input string `pg:",notnull"`
Gas uint64 `pg:",use_zero"`
MaxFeePerGas string `pg:"type:numeric,notnull"`
// Hash of transaction.
Hash string `pg:",pk,notnull"`
// EVM network id.
ChainID uint64 `pg:",use_zero"`
// A sequentially incrementing counter which indicates the transaction number from the account.
Nonce uint64 `pg:",use_zero"`
// Hash of the block where this transaction was in.
BlockHash string `pg:",notnull"`
// Block number where this transaction was in.
BlockNumber uint64 `pg:",use_zero"`
// Integer of the transactions index position in the block.
TransactionIndex uint64 `pg:",use_zero"`
// ETH Address of the sender.
From string `pg:",notnull"`
// ETH Address of the receiver.
To string `pg:",notnull"`
// Amount of FIL to transfer from sender to recipient.
Value string `pg:",notnull"`
// Type of transactions.
Type uint64 `pg:",use_zero"`
// The data sent along with the transaction.
Input string `pg:",notnull"`
// Gas provided by the sender.
Gas uint64 `pg:",use_zero"`
// The maximum fee per unit of gas willing to be paid for the transaction.
MaxFeePerGas string `pg:"type:numeric,notnull"`
// The maximum price of the consumed gas to be included as a tip to the validator.
MaxPriorityFeePerGas string `pg:"type:numeric,notnull"`
AccessList string `pg:",type:jsonb"`
V string `pg:",notnull"`
R string `pg:",notnull"`
S string `pg:",notnull"`
// Transaction’s signature. Recovery Identifier.
V string `pg:",notnull"`
// Transaction’s signature. Outputs of an ECDSA signature.
R string `pg:",notnull"`
// Transaction’s signature. Outputs of an ECDSA signature.
S string `pg:",notnull"`
}

func (f *FEVMTransaction) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
Expand Down

0 comments on commit 1469217

Please sign in to comment.