Skip to content
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

chore(chain): separate v1 and v2 contract update code #1743

Merged
merged 12 commits into from
Dec 17, 2024
17 changes: 1 addition & 16 deletions bus/bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,9 +687,6 @@ func (b *Bus) formContract(ctx context.Context, hostSettings rhpv2.HostSettings,
return api.ContractMetadata{}, fmt.Errorf("couldn't add transaction set to the pool: %w", err)
}

// broadcast the transaction set
go b.s.BroadcastTransactionSet(txnSet)
ChrisSchinnerl marked this conversation as resolved.
Show resolved Hide resolved

return api.ContractMetadata{
ID: contract.ID(),
HostKey: contract.HostKey(),
Expand Down Expand Up @@ -727,9 +724,6 @@ func (b *Bus) formContractV2(ctx context.Context, hk types.PublicKey, hostIP str
return api.ContractMetadata{}, fmt.Errorf("failed to add v2 transaction set to the pool: %w", err)
}

// broadcast the transaction set
go b.s.BroadcastV2TransactionSet(res.FormationSet.Basis, res.FormationSet.Transactions)

contract := res.Contract
return api.ContractMetadata{
ID: contract.ID,
Expand Down Expand Up @@ -805,14 +799,11 @@ func (b *Bus) renewContractV1(ctx context.Context, cs consensus.State, gp api.Go
// renew contract
gc := gouging.NewChecker(gp.GougingSettings, gp.ConsensusState)
prepareRenew := b.prepareRenew(cs, rev, hs.Address, b.w.Address(), renterFunds, minNewCollateral, endHeight, expectedNewStorage)
newRevision, txnSet, contractPrice, fundAmount, err := b.rhp3Client.Renew(ctx, gc, rev, renterKey, c.HostKey, hs.SiamuxAddr(), prepareRenew, b.w.SignTransaction)
newRevision, _, contractPrice, fundAmount, err := b.rhp3Client.Renew(ctx, gc, rev, renterKey, c.HostKey, hs.SiamuxAddr(), prepareRenew, b.w.SignTransaction)
if err != nil {
return api.ContractMetadata{}, err
}

// broadcast the transaction set
b.s.BroadcastTransactionSet(txnSet)

return api.ContractMetadata{
ID: newRevision.ID(),
HostKey: newRevision.HostKey(),
Expand Down Expand Up @@ -863,7 +854,6 @@ func (b *Bus) renewContractV2(ctx context.Context, cs consensus.State, h api.Hos
}

var contract cRhp4.ContractRevision
var txnSet cRhp4.TransactionSet
if c.EndHeight() == endHeight {
// when refreshing, the 'collateral' is added on top of the existing
// collateral so we account for that by subtracting the rolled over
Expand All @@ -880,7 +870,6 @@ func (b *Bus) renewContractV2(ctx context.Context, cs consensus.State, h api.Hos
Collateral: collateral,
})
contract = res.Contract
txnSet = res.RenewalSet
} else {
var res cRhp4.RPCRenewContractResult
res, err = b.rhp4Client.RenewContract(ctx, h.PublicKey, h.V2SiamuxAddr(), b.cm, signer, cs, settings.Prices, rev, rhpv4.RPCRenewContractParams{
Expand All @@ -890,15 +879,11 @@ func (b *Bus) renewContractV2(ctx context.Context, cs consensus.State, h api.Hos
ProofHeight: endHeight,
})
contract = res.Contract
txnSet = res.RenewalSet
}
if err != nil {
return api.ContractMetadata{}, err
}

// broadcast the transaction set
b.s.BroadcastV2TransactionSet(txnSet.Basis, txnSet.Transactions)

return api.ContractMetadata{
ID: contract.ID,
HostKey: h.PublicKey,
Expand Down
Loading
Loading