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

added custom signers #718

Merged
merged 31 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9fc18de
Add files via upload
0xarmagan Jul 29, 2024
8af54f1
Update 07-24-core-devs-call.md
0xarmagan Jul 29, 2024
1bb846e
fix broken RPC url
vanshika-srivastava Jul 29, 2024
683d1c8
fix all the broken anchors and hyperlinks
vanshika-srivastava Jul 31, 2024
edc86c6
chore: fix some comments (#702)
zhoufanjin Jul 31, 2024
0244f05
shutterized -> to change to shutter enabled
vanshika-srivastava Aug 1, 2024
4a5ca3c
Merge branch 'main' into dev
vanshika-srivastava Aug 1, 2024
8db8770
fix core dev call layout
vanshika-srivastava Aug 2, 2024
4550427
Core Devs Call Notes July 31, 2024
0xarmagan Aug 6, 2024
86d3056
remove custom signer from interact page
vanshika-srivastava Aug 6, 2024
76868df
fix: 07-31-core-devs-call format
zengzengzenghuy Aug 6, 2024
6461c4f
Core Devs Call Notes Aug 7, 2024
0xarmagan Aug 9, 2024
03e5df4
"Liquid Staking" Page Update (#709)
iamjackgale Aug 12, 2024
aa150fb
Update _generate_validator_keys_wagyu.md (#710)
theChim9 Aug 12, 2024
ef62199
Update voluntary-exit.md (#711)
theChim9 Aug 12, 2024
d222223
Add files via upload
0xarmagan Aug 23, 2024
c0deaae
Update 08-21-core-devs-call.md
0xarmagan Aug 23, 2024
5a2569c
Update 08-07-core-devs-call.md
0xarmagan Aug 23, 2024
b35f1e8
Merge branch 'main' into dev
vanshika-srivastava Aug 26, 2024
aec2c12
Updates 08-21-core-devs-call.md for a small typo
vanshika-srivastava Aug 26, 2024
8f6fca4
Core Devs call notes Aug 28
0xarmagan Aug 31, 2024
9b89786
feat: Cookbook Onboard integration (#715)
ClockRide Sep 2, 2024
97b2046
Update 08-28-core-devs-call.md - fix format
vanshika-srivastava Sep 2, 2024
9090c86
Added dRPC to community Faucets (#698)
maradeeym Sep 2, 2024
46c76b9
chore(bridges): update deprecated url to https://github.com/tokenbridge/
zengzengzenghuy Sep 8, 2024
a79b5c3
add section for running node with eth swarm setup
vanshika-srivastava Sep 11, 2024
fed4767
feat(bridges): add Hashi integration overview
zengzengzenghuy Sep 16, 2024
01d820f
chore(bridges): add testnet contracts for Hashi integration
zengzengzenghuy Sep 17, 2024
9e9710c
fix: error
zengzengzenghuy Sep 17, 2024
be2b4fc
Merge branch 'main' into dev
vanshika-srivastava Sep 17, 2024
98c04a7
added custom signers guides
skundu42 Sep 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions docs/bridges/About Token Bridges/hashi-integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
---
sidebar_position: 5
title: Hashi Integration
description: How do the bridges work after Hashi integration
keywords: [amb bridge, arbitrary message bridge, omnibridge, xdai bridge, hashi]
---

# Hashi integration

The proposal of Hashi integration on Gnosis Chain's bridges (AMB & Omnibridge, xDAI bridge) is [approved by Gnosis DAO members](https://forum.gnosis.io/t/gip-93-should-gnosisdao-support-the-integration-of-hashi-within-gnosis-chains-canonical-bridges/8245/5) on April 2nd, 2024. The integration introduces advanced security measures, mitigates systemic risks, and ensures the Gnosis Chain ecosystem remains resilient against the evolving landscape of security threats. With the efforts from Cross-Chain Alliance and Gnosis team, the integration is going toward production.

## What’s new?

1. Hashi Manager contract: New contract. Set reporters, adapters, and threshold parameters used by the bridge contract.
2. New variables/function:
1. HASHI_ENABLED: New variable. When set to true, every message can be approved by Hashi, but the message need not to be approved by Hashi for it to get executed.
2. HASHI_MANDATORY: New variable. When set to true, every message has to be approved by Hashi before execution.
3. isApprovedByHashi(bytes32 msgId): New public function. Return whether a message w.r.t a message Id is approved by Hashi.
4. setHashiManager(address HashiManager): New function, onlyOwner. Set Hashi Manager contract on the bridge contract.
3. Modified events:
1. xDAI Bridge: in xDAI bridge, a `bytes32 nonce` is added into `UserRequestForAffirmation` and `UserRequestForSignature` events.
1. `event UserRequestForAffirmation(address recipient, uint256 value)` is changed to `event UserRequestForAffirmation(address recipient, uint256 value, bytes32 nonce)`
2. `event UserRequestForSignature(address recipient, uint256 value)` is changed to `UserRequestForSignature(address recipient, uint256 value bytes32 nonce)`

## AMB & Omnibridge

![](../../../static/img/bridges/hashi/Hashi-Gnosis-AMB.png)

For Omnibridge / AMB:

**Ethereum → Gnosis Chain**

1. User approves token for Foreign Omnibridge
2. User calls ForeignOmnibridge.relayTokens(address token, address receiver, uint256 amount)
1. ForeignOmnibridge calls ForeignAMB.requireToPassMessage()
2. ForeignAMB check if HASHI_IS_ENABLED is true, and call Yaho.dispatchMessage
3. Off chain relayer detects MessageDispatched event from Yaho and call Yaho.relayMessagesToAdapters to relay message to each reporters.
4. Reporters relay the messageId and message hash to adapter contract on Gnosis Chain.
5. Light Client based oracle only stores hashes on Gnosis Chain.
3. If Hashi is enabled & mandatory, off chain executor calls Gnosis Chain’s Yaru.executeMessages(), which check if the hash is agreed upon a threshold amount of adapters (set in Hashi Manager contract) adapters and set isApprovedByHashi(messageId) to true eventually.
4. Bridge validators detects UserRequestForAffirmation event and call HomeAMB.executeAffirmation. If Hashi is enabled & mandatory, this step has to wait after step 3.

**Gnosis Chain → Ethereum**

1. User approves token for Home Omnibridge
2. User calls HomeOmnibridge.relayTokens(address token, address receiver, uint256 amount)
1. HomeOmnibridge calls HomeAMB.requireToPassMessage()
2. HomeAMB check if HASHI_IS_ENABLED is true, and call Yaho.dispatchMessage
3. Off chain relayer detects MessageDispatched event from Yaho and call Yaho.relayMessagesToAdapters to relay message to each reporters.
4. Reporters relay the messageId and message hash to adapter contract on Ethereum.
3. Bridge validators detects UserRequestForSignature event and call HomeAMB.submitSignatures.
4. If Hashi is enabled & mandatory, off chain executor calls Ethereum’s Yaru.executeMessages(), which check if the hash is agreed upon adapters and set isApprovedByHashi(messageId) to true eventually.
5. User claims token by calling Ethereum’s ForeignAMB.executeSignatures().

## xDAI briddge

![](../../../static/img/bridges/hashi/Hashi-Gnosis-AMB.png)

**Ethereum → Gnosis Chain**

1. User approves token for Foreign xDAI bridge.
2. User calls ForeignXDAIBridge.relayTokens(address receiver, uint256 amount)
1. ForeignXDAIBridge check if HASHI_IS_ENABLED is true, and call Yaho.dispatchMessage
2. Off chain relayer detects MessageDispatched event from Yaho and call Yaho.relayMessagesToAdapters to relay message to each reporters.
3. Reporters relay the messageId and message hash to adapter contract on Gnosis Chain.
4. Light Client based oracle only stores hashes on Gnosis Chain.
3. If Hashi is enabled & mandatory, off chain executor calls Gnosis Chain’s Yaru.executeMessages(), which check if the hash is agreed upon a threshold amount of adapters (set in Hashi Manager contract) and set isApprovedByHashi(messageId) to true eventually.
4. Bridge validators detects UserRequestForAffirmation event and call HomexDAIBridge.executeAffirmation. If Hashi is enabled & mandatory, this step has to wait after step 3. Block Reward contract emits AddedReceiver event, which will mint equivalent amount of xDAI to receiver in the next block.

**Gnosis Chain → Ethereum**

1. User calls HomexDAIBridge.relayTokens(address receiver, uint256 amount) or transfer xDAI to HomexDAIBridge without msg.data.
1. HomexDAIBridge check if HASHI_IS_ENABLED is true, and call Yaho.dispatchMessage
2. Off chain relayer detects MessageDispatched event from Yaho and call Yaho.relayMessagesToAdapters to relay message to each reporters.
3. Reporters relay the messageId and message hash to adapter contract on Ethereum.
2. Bridge validators detects UserRequestForSignature event and call HomexDAIBridge.submitSignatures.
3. If Hashi is enabled & mandatory, off chain executor calls Ethereum’s Yaru.executeMessages(), which check if the hash is agreed upon adapters and set isApprovedByHashi(messageId) to true eventually.
4. User claims token by calling Ethereum’s ForeignxDAIBridge.executeSignatures(). DAI is transfer to the receiver eventually.

# Testnet environment

For testing purpose, we've set up testnet environemnt. Users are welcome to experiment with the testnet environments:

- Sepolia addresses
1. ForeignAMB: [0x2F62433e00168af10c70bc39e2fDbEe5DaCA257b](https://sepolia.etherscan.io/address/0x2F62433e00168af10c70bc39e2fDbEe5DaCA257b)
2. Hashi Manager: [0x6C5F4F8a719bF054D6b08E3cCc27a5f208Ec8766](https://sepolia.etherscan.io/address/0x6C5F4F8a719bF054D6b08E3cCc27a5f208Ec8766#writeProxyContract)
- Chiado addresses
1. Home AMB: [0xAF18353BF369897Aab18ec225422F921be9F7eC6](https://gnosis-chiado.blockscout.com/address/0xAF18353BF369897Aab18ec225422F921be9F7eC6?tab=contract)
2. Hashi Manager: [0xe505cD6522E9A1c2309a915f83dDCA9addaC0895](https://gnosis-chiado.blockscout.com/address/0xe505cD6522E9A1c2309a915f83dDCA9addaC0895?tab=contract_code)
3. AMB BridgeHelper: [0x3fba3D7Ae204a684E4359A3fC211C18EA155cd78](https://gnosis-chiado.blockscout.com/address/0x3fba3D7Ae204a684E4359A3fC211C18EA155cd78)

## Omnibridge

- Sepolia address
1. Foreign Omnibridge: [0xc4e06E44B2d1e148beFAa3cB2012A985EFe7032a](https://sepolia.etherscan.io/address/0xc4e06E44B2d1e148beFAa3cB2012A985EFe7032a)
2. WETH Router: [0x65E64139f202F89cb6b4bFc140bf01Cda1886465](https://sepolia.etherscan.io/address/0x65E64139f202F89cb6b4bFc140bf01Cda1886465#code)
- Chiado address
1. Home Omnibridge: [0xB866dC5321Ca41a22938A7afD5Bc3c5069975874](https://gnosis-chiado.blockscout.com/address/0xB866dC5321Ca41a22938A7afD5Bc3c5069975874?tab=write_proxy)

## xDAI

- Sepolia addresses
1. Foreign xDAI: [0x97589968FA7ef153af44C6F5d0Fb9AcaEA97AC94](https://sepolia.etherscan.io/address/0x97589968FA7ef153af44C6F5d0Fb9AcaEA97AC94)
2. Hashi Manager: [0x90d3c0c9BCb317E80A459B0126257665186E59fa](https://sepolia.etherscan.io/address/0x90d3c0c9bcb317e80a459b0126257665186e59fa#code)
- Chiado addresses
1. Home xDAI: [0x867696eA1cfA243aB909797022D0A0C99BdACcF1](https://gnosis-chiado.blockscout.com/address/0x867696eA1cfA243aB909797022D0A0C99BdACcF1?tab=contract)
2. Hashi Manager: [0x5b745C021ef62f90862a812EB6763f5758e51eE2](https://gnosis-chiado.blockscout.com/address/0x5b745C021ef62f90862a812EB6763f5758e51eE2?tab=contract)
3. xDAI Bridge Helper: [0xA7bE47d1111baFDb2f0E9ce8D6431508aC2fd98e](https://gnosis-chiado.blockscout.com/address/0xA7bE47d1111baFDb2f0E9ce8D6431508aC2fd98e#code)

## Reference

1. AMB contracts: https://github.com/crosschain-alliance/tokenbridge-contracts/tree/feat/hashi-integration-amb
2. xDAI bridge contracts: https://github.com/crosschain-alliance/tokenbridge-contracts/tree/feat/hashi-integration-xdai-bridge
3. Test: https://github.com/crosschain-alliance/tokenbridge-contracts-migration-tests
4. Audits: https://crosschain-alliance.gitbook.io/hashi/v0.2/audit-report#gnosis-bridge-hashi-integration
5. Hashi: https://crosschain-alliance.gitbook.io/hashi/v0.2/introduction
10 changes: 5 additions & 5 deletions docs/node/Node Tools/eth-docker.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
title: eth-docker
title: Eth-docker
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# eth-docker
# Eth-docker

[eth-docker](https://eth-docker.net/) is a docker automation project for Ethereum consensus and execution clients. It aims to make running a Ethereum staking full node simpler than setting everything up manually, while allowing the user choice when it comes to the exact client mix they wish to run.
[Eth-docker](https://eth-docker.net/) is a docker automation project for Ethereum consensus and execution clients. It aims to make running a Ethereum staking full node simpler than setting everything up manually, while allowing the user choice when it comes to the exact client mix they wish to run.

eth-docker allows user to set up Gnosis clients by answering simple dialog-based questions on terminal.
Eth-docker allows user to set up Gnosis clients by answering simple dialog-based questions on terminal.

## References
1. eth-docker Docs: https://eth-docker.net/
1. Eth-docker Docs: https://eth-docker.net/
2. Github: https://github.com/eth-educators/eth-docker


Expand Down
Empty file.
35 changes: 35 additions & 0 deletions docs/technicalguides/custom-signers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
sidebar_position: 4
sidebar_label: Custom Signers
---

# Custom Signers

Custom signers allow developers to inject their own signing mechanisms tailored to specific use cases. This flexibility enhances security, usability, and adaptability in different environments, such as multi-signature wallets or smart contract interactions.

## Why Use Custom Signers?

### Tailored Signing Methods
With custom signers, you can personalize the signing process to fit your dApp’s specific needs. This could mean automatic signing for trusted operations, requiring additional confirmation for sensitive actions, or integrating unique hardware devices for enhanced security.Users can now interact with dapps by just using their emails or passkeys.

### Enhanced Security
Custom signers give developers more control over how and where signing keys are stored. This can include signing transactions in hardware security modules (HSMs), using a multi-sig contract, or requiring multi-factor authentication before a transaction is signed.

### Optimized for Specific Use Cases
Whether you’re dealing with privacy-focused transactions, or social recovery mechanisms, custom signers can be configured to handle the specific logic needed. They allow for flexibility in crafting unique user flows that require specialized transaction signing methods.




<CardContainer>
<Card
title="Privy"
subtitle="Guide to intgerate Privy Wallet and SDK"
url="/technicalguides/custom-signers/privy"
/>
<Card
title="Dynamic"
subtitle="Guide to intgerate Dynamic Wallet and SDK"
url="/technicalguides/custom-signers/dynamic"
/>
</CardContainer>
142 changes: 142 additions & 0 deletions docs/technicalguides/custom-signers/dynamic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
---
description: Dynamic offers smart and beautiful login flows for crypto-native users, simple onboarding flows for everyone else, and powerful developer tools that go beyond authentication.
keywords: [dynamic ,custom-signers]
---

# Dynamic

Dynamic offers smart and beautiful login flows for crypto-native users, simple onboarding flows for everyone else, and powerful developer tools that go beyond authentication. This is a basic guide which demonstrates the integration of Dynamic wallet with Gnosis chain and generate offchain user signatures.

![Dynamic Image](../../../static/img/signers/dynamic.png)


## Guide

- Create a NextJs application from scratch

```
npx create-next-app dynamic-gnosis
# install with Tailwind
```
- Install Dynamic labs SDK & some other dependencies

```
npm install @dynamic-labs/ethereum @dynamic-labs/ethers-v6 @dynamic-labs/sdk-react-core
```

- Create an account at [Dynamic Web App](https://app.dynamic.xyz/) and choose the Ethereum Sandbox option.
In the dashboard, enable the networks you want to allow your users. For our example we will enable Gnosis network. Also make sure you have Email as an authentication enabled for your users. This helps create a wallet by just using user's email.

- In the [developers section](https://app.dynamic.xyz/dashboard/developer/api), copy the Environment ID, we will need this in the next step.

- Initialize the SDK in your **layout.tsx** file like this. The goal is to initialize the SDK as early as possible when loading you application. Put your Environment ID in the proper variable.
Make sure you have **EthersExtension** also added in the extensions variable, this will be useful later!
```
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<DynamicContextProvider
settings={{
environmentId: "<Replace with you own Environment ID>",
walletConnectors: [EthereumWalletConnectors],
walletConnectorExtensions: [EthersExtension],
}}
>
<body className={inter.className}>{children}</body>
</DynamicContextProvider>
</html>
);
}

```


- Create a components folder and inside that create a component **DynamicWidgetButton.tsx** and here we need to declare our DynamicWidget component provided to us by Dynamic SDK.

```
export const DynamicWidgetButton: React.FC = () => {
return (
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', marginBottom: '20px' }}>
<Title level={3} style={{ marginBottom: '20px' }}>Wallet Interaction</Title>
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<DynamicWidget />
</div>
</div>
);
};

```

- Now we can use and initialize the Dynamic wallet anywhere in our app by just using the above component!

- Let's create our Main component in **page.tsx** file.

In this file, we will [**useDynamicContext**](https://docs.dynamic.xyz/sdks/react-sdk/hooks/usedynamiccontext#header) provided by the dynamic sdk to fetch the wallet connected. We will also use this same wallet to execute all our ethers expression.

```
const { primaryWallet } = useDynamicContext();
```

- In our application, we have built a basic **Signer** component which uses the connected Dynamic wallet to generate a signature from the user.


```
const signMessage = async () => {
if (!primaryWallet) {
console.error("No primary wallet connected");
return;
}

try {
const signedMessage = await primaryWallet.connector.signMessage('You are signing an example message');
if (signedMessage) {
setSignature(signedMessage);
} else {
setSignature(null);
}
} catch (error) {
console.error("Error signing message:", error);
setSignature(null);
}
};
```

You can also see that the **signMessage** function is provided by the Dynamic SDK. So cool!

## Using ethers

The last piece of component, I want to discuss is the **getBalance** component. Although Dybamic also gives a component to fetch user balance, this function is created to demonstrate how you can use standard ethers expression to build out your app further.

```
const getBalance = async () => {
if (!primaryWallet) {
console.error("No primary wallet connected");
return null;
}

const provider = await primaryWallet.connector?.ethers?.getRpcProvider();

if (!provider) {
console.error("No provider available");
return null;
}
try {
const balance = await provider.getBalance(primaryWallet.address);
console.log(balance);
return balance;
} catch (error) {
console.error("Error getting balance:", error);
return null;
}
};

```

## Demo Application

You can check out this [**repository**](https://github.com/gnosischain/developer-resources/tree/main/custom-signers/dynamic-gnosis) for the full stack application demo.

Loading
Loading