-
Notifications
You must be signed in to change notification settings - Fork 252
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: use typed events #1030
feat: use typed events #1030
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1030 +/- ##
==========================================
- Coverage 50.50% 50.46% -0.04%
==========================================
Files 71 71
Lines 4390 4391 +1
==========================================
- Hits 2217 2216 -1
- Misses 1946 1947 +1
- Partials 227 228 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
|
||
// EventPayForBlob defines an event that is emitted with the signer and blob size | ||
// at the end of a pay for blob txn | ||
message EventPayForBlob { |
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.
So we are changing event.type from payforblob
to blob.EventPayForBlob
or am I missing something here? If we are changing event type then relevant test (TestSubmitWirePayForBlob
) in integration_test.go
can be updated.
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.
Yes, there's a pending task in this PR for the same
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.
My bad, I overlooked the draft status and checklist (used to GitLab PRs 😅 ). My apologies 🙏
@evan-forbes since we're changing the event name, in order to follow convention from the typed events ADR in cosmos-sdk, this will be a breaking change |
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.
Good catch 👍 the older way was deprecated.
@@ -61,9 +61,12 @@ func (k Keeper) PayForBlob(goCtx context.Context, msg *types.MsgPayForBlob) (*ty | |||
gasToConsume := uint64(shares.MsgSharesUsed(int(msg.BlobSize)) * GasPerMsgShare) | |||
ctx.GasMeter().ConsumeGas(gasToConsume, payForBlobGasDescriptor) | |||
|
|||
ctx.EventManager().EmitEvent( | |||
err := ctx.EventManager().EmitTypedEvent( | |||
types.NewPayForBlobEvent(sdk.AccAddress(msg.Signer).String(), msg.GetBlobSize()), |
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.
types.NewPayForBlobEvent(sdk.AccAddress(msg.Signer).String(), msg.GetBlobSize()), | |
types.NewPayForBlobEvent(msg.Signer, msg.GetBlobSize()), |
I guess the msg.Signer
already contains the account address in Bech32 format. What do you think?
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.
second this, we should be able to just use the signer. We can test manually by looking at the events in one of the integration tests
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.
It doesn't look like that the conversion is as is, I'll confirm via a test
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.
@rahulghangas Did you manage to check if it is the same?
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.
@sweexordious msg.Signer
is the raw form while the .String()
method encodes it in bech32. Removing the above logic will be breaking change
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.
I tried an example and apparently the msg.Signer
contains:
cosmos1n5c5wmz5s2n0d8zpr5ldcl45nkjclaqktls7gd
while sdk.AccAddress(msg.Signer).String()
returns:
cosmos1vdhhxmt0wvckudtrx4mk6734wvexuvry8pa8qu34d3jxxmp5x4hxk6nrd3shz6m5d3enwemycqe9zf
Which one do we want?
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.
After we align on one, should we add a unit test that verifies an event is emitted with the appropriate signer?
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.
I'm leaning towards first, since it's more compact and helps us reduce on-chain storage
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.
Refactor integration test
Where does this happen? It doesn't appear applicable to this PR.
what's left for this? just reviewer feedback? |
It doesn't, I've removed it from the checklist. Initially the idea was to change the test because the attribute key was hardcoded, but I've made it such that it infers the type name from the struct itself |
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.
[not blocking] can we please update this section
Lines 30 to 32 in 29d47af
## Events | |
- [`NewPayForBlobEvent`](https://github.com/celestiaorg/celestia-app/pull/213/files#diff-1ce55bda42cf160deca2e5ea1f4382b65f3b689c7e00c88085d7ce219e77303dR17-R21) is emitted with the signer's address and size of the message that is paid for. |
## Events
- `PayForBlobEvent` is emitted with the signer's address and size of the message that is paid for.
Alternatively, we can also copy something like this: https://github.com/cosmos/cosmos-sdk/blob/16c772d900f530d16518491b19f60cfef9d713af/x/bank/README.md?plain=1#L339-L353
4789456
to
3f5bd02
Compare
@@ -61,9 +61,12 @@ func (k Keeper) PayForBlob(goCtx context.Context, msg *types.MsgPayForBlob) (*ty | |||
gasToConsume := uint64(shares.MsgSharesUsed(int(msg.BlobSize)) * GasPerMsgShare) | |||
ctx.GasMeter().ConsumeGas(gasToConsume, payForBlobGasDescriptor) | |||
|
|||
ctx.EventManager().EmitEvent( | |||
err := ctx.EventManager().EmitTypedEvent( | |||
types.NewPayForBlobEvent(sdk.AccAddress(msg.Signer).String(), msg.GetBlobSize()), |
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.
After we align on one, should we add a unit test that verifies an event is emitted with the appropriate signer?
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.
LGTM!! thanks for this @rahulghangas
- [x] switch to typed event for `blob` module' - [ ] ~~Refactor integration test~~ - [x] Closes celestiaorg#968
blob
module'Refactor integration testEmitEvent
toEmitTypedEvent
#968