Skip to content

Commit

Permalink
Merge #4554
Browse files Browse the repository at this point in the history
4554: Remove dual authorizers for system transaction r=janezpodhostnik a=janezpodhostnik

closes: #4291

PR #4298 added another authorizer to the system transaction so that the Heartbeat resources could be moved from the epoch account to the service account. Which was done here: onflow/service-account#243

Now that that is done, the epoch account does not need to participate in the service transaction anymore.

Co-authored-by: Janez Podhostnik <janez.podhostnik@gmail.com>
  • Loading branch information
bors[bot] and janezpodhostnik committed Aug 8, 2023
2 parents e2ac1cf + 0b561f5 commit 2bc0a96
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 59 deletions.

This file was deleted.

43 changes: 2 additions & 41 deletions fvm/blueprints/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,6 @@ func SystemChunkTransaction(chain flow.Chain) (*flow.TransactionBody, error) {
return nil, fmt.Errorf("could not get system contracts for chain: %w", err)
}

// this is only true for testnet, sandboxnet and mainnet.
if contracts.Epoch.Address != chain.ServiceAddress() {
// Temporary workaround because the heartbeat resources need to be moved
// to the service account:
// - the system chunk will attempt to load both Epoch and VersionBeacon
// resources from either the service account or the staking account
// - the service account committee can then safely move the resources
// at any time
// - once the resources are moved, this workaround should be removed
// after version v0.31.0
return systemChunkTransactionDualAuthorizers(chain, contracts)
}

tx := flow.NewTransactionBody().
SetScript(
[]byte(templates.ReplaceAddresses(
Expand All @@ -51,35 +38,9 @@ func SystemChunkTransaction(chain flow.Chain) (*flow.TransactionBody, error) {
},
)),
).
AddAuthorizer(contracts.Epoch.Address).
SetGasLimit(SystemChunkTransactionGasLimit)

return tx, nil
}

// systemChunkTransactionTemplateDualAuthorizer is the same as systemChunkTransactionTemplate
// but it looks for the heartbeat resources on two different accounts.
//
//go:embed scripts/systemChunkTransactionTemplateDualAuthorizer.cdc
var systemChunkTransactionTemplateDualAuthorizer string

func systemChunkTransactionDualAuthorizers(
chain flow.Chain,
contracts *systemcontracts.SystemContracts,
) (*flow.TransactionBody, error) {

tx := flow.NewTransactionBody().
SetScript(
[]byte(templates.ReplaceAddresses(
systemChunkTransactionTemplateDualAuthorizer,
templates.Environment{
EpochAddress: contracts.Epoch.Address.Hex(),
NodeVersionBeaconAddress: contracts.NodeVersionBeacon.Address.Hex(),
},
)),
).
// The heartbeat resources needed by the system tx have are on the service account,
// therefore, the service account is the only authorizer needed.
AddAuthorizer(chain.ServiceAddress()).
AddAuthorizer(contracts.Epoch.Address).
SetGasLimit(SystemChunkTransactionGasLimit)

return tx, nil
Expand Down

0 comments on commit 2bc0a96

Please sign in to comment.