-
Notifications
You must be signed in to change notification settings - Fork 35
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
[WIP] Add broadcast confirm sig logic #188
base: develop
Are you sure you want to change the base?
Conversation
|
||
// GetSignBytes returns the Keccak256 hash of the transaction. | ||
func (msg ConfirmSigMsg) GetSignBytes() []byte { | ||
return nil |
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 hope the sdk doesn't complain about this?
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.
Works for include deposit message right now so i'm assuming we won't have a problem?
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.
left first thoughts
Applying above changes. Also removing ability to broadcast arbitrary confirm sigs via flags for now as there is no natural mechanism for validating such signatures |
Codecov Report
@@ Coverage Diff @@
## develop #188 +/- ##
===========================================
- Coverage 52.02% 49.44% -2.59%
===========================================
Files 28 30 +2
Lines 1359 1430 +71
===========================================
Hits 707 707
- Misses 538 609 +71
Partials 114 114
Continue to review full report at Codecov.
|
return includeCmd | ||
} | ||
|
||
var broadcastSigsCmd = &cobra.Command{ |
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.
Although the anteHandler for this msg will fail if the sig is wrong, we should do client side validation here before sending off the message.
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.
Shaping up great! The flow looks correct to me.
} | ||
|
||
// validate inputs/confirmation signatures if not a fee utxo or deposit utxo | ||
if !input.IsDeposit() && !input.IsFee() { |
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.
If the input is a deposit or fee, we should not return sdk.Result{}
. It should be an error. There are no confirm signature for these kinds of inputs. Otherwise this will get sent to the handler
return ErrInvalidSignature("invalid signature provided").Result() | ||
} | ||
|
||
_, ok := ds.GetOutput(ctx, input.Position) |
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.
do we need this if we're already doing GetTxWithPoisition
?
if err != nil { | ||
return ErrInvalidInput(fmt.Sprintf("failed to retrieve exit information on input, %v", in.Position)).Result() | ||
} else if exited { | ||
return ErrExitedInput(fmt.Sprintf("a parent of the input has exited. Position: %v", in.Position)).Result() |
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.
can we make this message better w.r.t confirm signatures? like 'cannot include confirm signatures of a input transaction that has exited..."
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// NewSpendHandler sets the inputs of a spend msg to spent and creates new |
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.
incorrect doc
return func(ctx sdk.Context, msg sdk.Msg) sdk.Result { | ||
confirmSigMsg, ok := msg.(msgs.ConfirmSigMsg) | ||
if !ok { | ||
panic("Msg does not implement SpendMsg") |
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.
msg
|
||
for i := 0; i < len(tx1.Transaction.Inputs); i++ { | ||
// TODO: Is TxIndex sufficient? Also should likely check output index? | ||
if tx1.Transaction.Inputs[i].Position.TxIndex != confirmSigMsg.Input1.Position.TxIndex { |
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.
can we add an Equals
method to Input
and simply to if tx1.Transaction.Input[i].Position.Equals(...)
{ do the thing}.
Typically do not want to use continue
. Should wrap the state updates within the if
block for when it should happen. Makes it easier to read.
panic("Msg does not implement SpendMsg") | ||
} | ||
|
||
/* Get tx, update tx data with confirm sigs, and store updated tx object */ |
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.
Instead of doing single comments like this. Can you break that up and comment the places where each point occurs
|
||
// SpendMsg implements the RLP interface through `Transaction` | ||
type ConfirmSigMsg struct { | ||
Input1 plasma.Input |
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.
do we have to restrict to 2 inputs. Why not include as many inputs as someone likes. []Input
(Fixes #148)
Adds the ability to broadcast confirm signatures without spending inputs. Requesting feedback on signature requirements, confirmSigMsg struct, and information to be stored in datastore. Tests pending.