go-perun
go-perun copied to clipboard
channel: Change AdjudicatorReq to embed SignedState
The idea was that a State, together with the sigs, becomes a Transaction because it progresses the channel. But the naming wasn't very good apparently (and it doesn't contain Params).
Now looking at it, it would probably be cleaner to also change the AdjudicatorReq to contain, or even embed, a SignedState and then remove the Params and Tx fields. Because otherwise the ledger channel's SignedState is scrambled from fields of the AdjudicatorReq whereas the sub-channels are directly passed as SignedStates. You could then also add a SignedState() getter to the channel machine.
Originally posted by @sebastianst in https://github.com/hyperledger-labs/go-perun/pull/119#discussion_r657216229
This brings me to the following somewhat related aspect, which I would like to point out here. We may consider addressing both aspects here.
Summary. We are using AdjudicatorReq for Register and Withdraw, but each of the methods only use part of the AdjudicatorReq and have or will have additional custom parameters. It might be cleaner to use custom request types for each of them instead.
Details. Here is the Adjudicator type for reference.
AdjudicatorReq struct {
Params *Params
Acc wallet.Account
Tx Transaction
Idx Index // Always the own index
Secondary bool // Optimized secondary call protocol
}
Register requires Params and Tx (i.e., State and Sigs) from AdjudicatorReq, plus it will require the same for each of the submitted sub-states after the virtual channel change. It does not use Account and Idx at all. Secondary is for gas optimization.
Withdraw requires the channel identifier from Params, the participant's account address derived from Acc, and the participant's balance contained in Transaction. It additionally requires the states of the sub-channels. It does not use Secondary.
Suggestion.
Use separate Request Types for Register and Withdraw.
- Register Request Type: Consider removing
AccandIdx. Include the Params, State, and Sigs of subchannels. - Withdraw Request Type: Remove
Secondary. Include states of subchannels.