-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### TL;DR Added database namespace support based on private key and contract address ### What changed? - Introduced a new `BuildNamespace` function that generates a unique namespace using the node's private key and contract address - Modified the replication service to use namespaced database connections - The namespace is a 12-character hex string derived from the Keccak256 hash of the private key and contract address ### How to test? 1. Start multiple nodes with different private keys 2. Verify each node creates its database tables under a unique namespace 3. Confirm that data remains isolated between different node instances <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new method for database initialization that supports namespacing. - Added a function to compute a namespace based on server options. - Added a `--broadcast` option for contract deployment commands, enabling transaction broadcasting. - **Bug Fixes** - Enhanced error handling during database and component initialization to ensure graceful application exits. - Improved reliability of deployment scripts with better error handling and control flow. - Updated deployment scripts to reflect changes in contract deployment processes. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
8 changed files
with
27 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package utils | ||
|
||
import ( | ||
ethcrypto "github.com/ethereum/go-ethereum/crypto" | ||
"github.com/xmtp/xmtpd/pkg/config" | ||
) | ||
|
||
func BuildNamespace(options config.ServerOptions) string { | ||
hash := ethcrypto.Keccak256( | ||
[]byte(options.Signer.PrivateKey), | ||
[]byte(options.Contracts.NodesContractAddress), | ||
) | ||
|
||
return HexEncode(hash)[:12] | ||
} |