-
Notifications
You must be signed in to change notification settings - Fork 5
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
Fix panic in handleRPCFormContract #143
Comments
My guess is it's coming from here: https://github.com/SiaFoundation/coreutils/blob/b5e84c03d17f6f0f4ea5b7e33078b1db37308d4f/rhp/v4/server.go#L586C1-L596C3 // update renter input basis to reflect our funding basis
if basis != req.Basis {
hostInputs := formationTxn.SiacoinInputs[len(formationTxn.SiacoinInputs)-len(req.RenterInputs)]
formationTxn.SiacoinInputs = formationTxn.SiacoinInputs[:len(formationTxn.SiacoinInputs)-len(req.RenterInputs)]
txnset, err := s.chain.UpdateV2TransactionSet([]types.V2Transaction{formationTxn}, req.Basis, basis)
if err != nil {
return errorBadRequest("failed to update renter inputs from %q to %q: %v", req.Basis, basis, err)
}
formationTxn = txnset[0]
formationTxn.SiacoinInputs = append(formationTxn.SiacoinInputs, hostInputs)
} Looks like the order is mixed up: the renter inputs are first, followed by the host inputs, so it should be: // update renter input basis to reflect our funding basis
if basis != req.Basis {
--- hostInputs := formationTxn.SiacoinInputs[len(formationTxn.SiacoinInputs)-len(req.RenterInputs)]
--- formationTxn.SiacoinInputs = formationTxn.SiacoinInputs[:len(formationTxn.SiacoinInputs)-len(req.RenterInputs)]
+++ hostInputs := formationTxn.SiacoinInputs[len(req.RenterInputs):]
+++ formationTxn.SiacoinInputs = formationTxn.SiacoinInputs[:len(req.RenterInputs)]
txnset, err := s.chain.UpdateV2TransactionSet([]types.V2Transaction{formationTxn}, req.Basis, basis)
if err != nil {
return errorBadRequest("failed to update renter inputs from %q to %q: %v", req.Basis, basis, err)
}
formationTxn = txnset[0]
formationTxn.SiacoinInputs = append(formationTxn.SiacoinInputs, hostInputs)
} I'm wondering if we even need to be removing the host inputs before updating in the first place, though...? |
That was my initial feeling as well. Deployed a branch with a println within the |
This PR fixes all the NDFs apart from the [panic](SiaFoundation/coreutils#143 (comment)) which we will need to fix in `coreutils`.
Ran into a panic on our CI today while fixing tests. The panic is related to
handleRPCFormContract
.Seems like the server doesn't sufficiently validate some data received from the client and the client is sending potentially faulty data.
The text was updated successfully, but these errors were encountered: