polaris icon indicating copy to clipboard operation
polaris copied to clipboard

bug(core): events with the same name but different attributes will panic

Open neverDefined opened this issue 1 year ago • 2 comments

Cosmos emits events that have the same name but different attributes:

ctx.EventManager().EmitEvent(
			sdk.NewEvent(govtypes.EventTypeSubmitProposal,
				sdk.NewAttribute(govtypes.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", proposal.Id)),
			),
		)
		
	ctx.EventManager().EmitEvent(
		sdk.NewEvent(
			types.EventTypeSubmitProposal,
			sdk.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposalID)),
			sdk.NewAttribute(types.AttributeKeyProposalMessages, msgsStr),
		),
	)

this case is not handled and will cause the chain to panic.

neverDefined avatar Apr 17 '23 12:04 neverDefined

example :

https://github.com/cosmos/cosmos-sdk/blob/73c806414528f37bc81ff7a31004094e8e91efba/x/gov/keeper/msg_server.go#L73

https://github.com/cosmos/cosmos-sdk/blob/73c806414528f37bc81ff7a31004094e8e91efba/x/gov/keeper/proposal.go#L104

neverDefined avatar Apr 17 '23 14:04 neverDefined

temp fix #558 ignore all attributes on SubmitProposal event

calbera avatar Apr 17 '23 20:04 calbera