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

Deploy the DependencyAudit contract and upgrade the service account #294

Closed
janezpodhostnik opened this issue Jun 10, 2024 · 1 comment
Closed

Comments

@janezpodhostnik
Copy link
Contributor

janezpodhostnik commented Jun 10, 2024

Overview

The dependency audit contract is responsible for emitting an event whenever there are any unstated dependencies (contracts) used in a transaction https://github.com/onflow/contract-updater/blob/main/contracts/DependencyAudit.cdc.

To use it the DependencyAudit contract has to be deployed to the service account, and the service account contract needs to be updated to include a call to the dependency audit contract: onflow/flow-core-contracts#430

1. Deploy DependencyAudit

[
    {
        "type": "Array",
        "value": [
            {
                "type": "Address",
                "value": "0x8624b52f9ddcd04a"
            },
            {
                "type": "Address",
                "value": "0xe467b9dd11fa00df"
            },
            {
                "type": "Address",
                "value": "0x8d0e87b65159ae63"
            },
            {
                "type": "Address",
                "value": "0x62430cf28c26d095"
            },
            {
                "type": "Address",
                "value": "0xf919ee77447b7497"
            },
            {
                "type": "Address",
                "value": "0x1654653399040a61"
            },
            {
                "type": "Address",
                "value": "0xf233dcee88fe0abe"
            },
            {
                "type": "Address",
                "value": "0x1d7e57aa55817448"
            },
            {
                "type": "Address",
                "value": "0xb19436aae4d94622"
            },
            {
                "type": "Address",
                "value": "0x220c1b4155f86f2f"
            }
        ]
    }
]

This corresponds to the following addresses:

8624b52f9ddcd04a, Epoch, IDTableStaking, ClusterQC, DKG
e467b9dd11fa00df, FlowServiceAccount, NodeVersionBeacon, RandomBeaconHistory, FlowStorageFees, EVM
8d0e87b65159ae63, FlowStakingCollection, LockedTokens
62430cf28c26d095, StakingProxy
f919ee77447b7497, FlowFees
1654653399040a61, FlowToken
f233dcee88fe0abe, FungibleToken, FungibleTokenMetadataViews, FungibleTokenSwitchboard, Burner
1d7e57aa55817448, NonFungibleToken, MetadataViews, ViewResolver
b19436aae4d94622, FiatToken
220c1b4155f86f2f, OnChainMultiSig

Note

These will be the addresses that are skipped when checking which dependencies are staged or not

2. Update FlowServiceAccount

--- a/deployed.txt
+++ b/contracts/FlowServiceAccount.cdc
@@ -2,6 +2,7 @@ import FungibleToken from 0xf233dcee88fe0abe
 import FlowToken from 0x1654653399040a61
 import FlowFees from 0xf919ee77447b7497
 import FlowStorageFees from 0xe467b9dd11fa00df
+import DependencyAudit from 0xe467b9dd11fa00df

 pub contract FlowServiceAccount {

@@ -191,6 +192,16 @@ pub contract FlowServiceAccount {
         }
     }

+    /// checkDependencies is called by the FVM at the end of the transaction execution
+    /// The `dependenciesAddresses` and `dependenciesNames` are the addresses and names of all the contracts that the transaction depends on.
+    /// The `authorizers` are the addresses of the accounts that authorized the transaction and the payer.
+    /// The FVM can call this even though it is private.
+    /// checkDependencies is not intended to be called by the user.
+    access(self) fun checkDependencies(_ dependenciesAddresses: [Address], _ dependenciesNames: [String], _ authorizers: [Address]) {
+        // forwad the call to the DependencyAudit, where the actual check is done.
+        DependencyAudit.checkDependencies(dependenciesAddresses, dependenciesNames, authorizers)
+    }
+
     init() {
         self.transactionFee = 0.0
         self.accountCreationFee = 0.0
@janezpodhostnik
Copy link
Contributor Author

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant