Skip to content
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

Some opinions on the new models #1117

Open
wants to merge 2 commits into
base: frrist/etl-pkg
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/transform/gorm/models/chainmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Message struct {
GasPremium types.DbToken
Method uint64
Params []byte
Signature []byte
}

type ParsedMessageParams struct {
Expand Down
9 changes: 5 additions & 4 deletions pkg/transform/gorm/models/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ type MessageReceipt struct {
}

type Receipt struct {
Index int64 `gorm:"primaryKey"`
ExitCode int64
GasUsed int64
Return []byte
Index int64 `gorm:"primaryKey"`
ExitCode int64
GasUsed int64
Return []byte
EventsRoot types.DbCid
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo:

types.DbCID and not types.DbCid

}
9 changes: 3 additions & 6 deletions pkg/transform/gorm/models/vmmessages.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import "github.com/filecoin-project/lily/pkg/transform/gorm/types"
type VmMessage struct {
Source types.DbCID `gorm:"primaryKey"`
Cid types.DbCID `gorm:"primaryKey"`
To types.DbAddr
From types.DbAddr
Value types.DbToken
Method uint64
Params []byte
Receipt Receipt `gorm:"embedded"`
Message Message `gorm:"embedded"`
Receipt Receipt `gorm:"embedded"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it is true that VM messages are basically messages, many of the fields such as GasLimit, GasFee, and GasPremium are all 0. Similarly, VMMessages do not contain a Signature, nor do their receipts contain an EventRoot (less sure on this, but a hunch). I think it may be more efficient to avoid embedding the Message and Receipt structures in VmMessgae and instead take a subset of the fields that are populated. wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at gorm Embedded Structs has me thinking that it's better to have common non-null types between Message and VmMessage wrapped like:

type BaseMessage struct {
  To
  From
  Value
  Method
  Params
}

which can then be respectively added as an embedded struct for both Message and VmMessage. This way it'll be easier to see what they do have in common and what they don't. But this is also not a ⛰️ I'm gonna die on lol.

Error string
Index uint64
}