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

Support named networks, Amoy blockchain and Banksia network #412

Merged
merged 136 commits into from
Jul 11, 2024

Conversation

tahpot
Copy link
Member

@tahpot tahpot commented Apr 4, 2024

Closes #411 #420 #421

@tahpot tahpot self-assigned this Apr 4, 2024
@tahpot tahpot changed the title Feature/411 refactor dids Support named networks and banksia Apr 7, 2024
@tahpot tahpot changed the title Support named networks and banksia Support named networks, Amoy blockchain and Banksia network Apr 7, 2024
@tahpot tahpot changed the base branch from main to develop April 7, 2024 22:36
},
}

export const BLOCKCHAIN_CHAINIDS: Record<BlockchainAnchor, string> = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The blockchain hex ids are defined in two places, risk of unsync and confusion on why one to use.
See other comment regarding a blockchain definition object.


/**
* @todo Deprecate in favour of `NETWORK_DEFINITIONS`
*/
export const CONTRACT_ADDRESS : Record<CONTRACT_NAMES, Record<string, string | null>> = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deprecated CONTRACT_ADDRESS still holds info not in the network defintiions, such as for the DID registry addresses.

I gues we should have a similar object for the DID VDA, gathering the registry address, its blockchain and other related information (name registry?).

Chris and others added 21 commits July 9, 2024 11:05
- Updated `proof` related code
- Updated test script
- Added `Test.md`
- Updated `.env.example` file
- Added `Test.md` file
- Updated .env.example file
- Added `Test.md` file
- Updated .env.example file
- Added `Test.md` file
- Updated the .env.example file
- Added `Test.md` file
- Updated `.env.example` file
- Separte `stake_and_lock.test.ts` from the `user_write.test.ts`

[vda-common-test] Added `owner()` function to the `ERC20Manager`
- Added `owner()` function
- Update `addInitialData()`: general users can run the tests
@tahpot
Copy link
Member Author

tahpot commented Jul 10, 2024

@ITStar10

Have you addressed this feedback?

The target_chain is hardcoded in a lot of the tests. This should be in an environment variable for all packages, for consistency and easy updating.

Also see my other code comments.

@tahpot tahpot merged commit 977cdd1 into develop Jul 11, 2024
@tahpot tahpot deleted the feature/411-refactor-dids branch July 11, 2024 03:17
@tahpot
Copy link
Member Author

tahpot commented Jul 15, 2024

v4 Release Notes

Breaking changes

Separating DID blockchain from Verida Network blockchain

The protocol previously had the concept of a Verida Network, which was anchored to a single blockchain. In order to maximize flexibility and handle blockchains going offline (such as Mumbai which has been shut down), the protocol now separates the blockchain used to anchor a did and the blockchain anchoring the Verida network.

The protocol supports:

  • Verida Network: The Verida network being connected to (ie: BANKSIA, MYRTLE, DEVNET). This corresponds to the storage nodes available on that network and the protocol smart contracts deployed to the blockchain anchoring that Verida network.
  • Blockchain Anchor: A blockchain (ie: Polygon Amoy)

DID's can now be anchored to any blockchain (or linked with any other DID method). The storage nodes for an application context are stored in the DID document, which has a reference to the Verida network associated with the storage nodes. In this way, it's possible to have a single DID document that is used across multiple Verida networks.

As a result, the way a connection is established has changed. ClientConfig configures the Verida Network using network instead of environment:

        const DID_CLIENT_CONFIG: AccountNodeDIDClientConfig = {
            callType: "web3",
            web3Config: {
                privateKey: BLOCKCHAIN_PRIVATE_KEY
            }
        }
        import { AccountNodeDIDClientConfig, Network } from "@verida/types";
        const account = new AutoAccount({
            privateKey: "0xabc123...",
            network: Network.MYRTLE,
            didClientConfig: DID_CLIENT_CONFIG
        })
        const did = (await account.did()).toLowerCase()

        const client = new Client({
            network: Network.MYRTLE
        })

        await client.connect(account)
        const context = await client.openContext(contextName)

Storage node authentication

Authentication between storage nodes and clients requires signing a consent message (containing a generated nonce) to ensure the DID controller is the one requesting access to the encrypted storage node data.

For enhanced flexibility and security, the expected signing key has changed from the master DID account key to the context signing key.

Other key changes:

  • [client-ts] client.getPublicProfile() supports a new networkFallback parameter (boolean) indicating if the profile should be loaded from the network if it's not available from the caching server
  • [client-ts] Network.getRecord() now requires the network parameter
  • [client-ts] Bug fixes relating to fetching public credentials, closing databases and sending inbox messages to full storage nodes
  • [verifiable-credentials] Fix: credentialData was raw JSON, not a VC meeting the W3C spec as expected

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

Successfully merging this pull request may close these issues.

Refactor how DIDs and Verida networks work
3 participants