diff --git a/cmd/replication/main.go b/cmd/replication/main.go index fb40b661..40de3557 100644 --- a/cmd/replication/main.go +++ b/cmd/replication/main.go @@ -57,9 +57,10 @@ func main() { var wg sync.WaitGroup doneC := make(chan bool, 1) tracing.GoPanicWrap(ctx, &wg, "main", func(ctx context.Context) { - db, err := db.NewDB( + db, err := db.NewNamespacedDB( ctx, options.DB.WriterConnectionString, + utils.BuildNamespace(options), options.DB.WaitForDB, options.DB.ReadTimeout, ) diff --git a/dev/contracts/deploy-ephemeral b/dev/contracts/deploy-ephemeral index cfc6f0bc..3f6e2a3c 100755 --- a/dev/contracts/deploy-ephemeral +++ b/dev/contracts/deploy-ephemeral @@ -5,4 +5,4 @@ source dev/contracts/.env cd ./contracts -forge create --legacy --json --rpc-url $DOCKER_RPC_URL --private-key $PRIVATE_KEY "$1:$2" \ No newline at end of file +forge create --legacy --json --broadcast --rpc-url $DOCKER_RPC_URL --private-key $PRIVATE_KEY "$1:$2" \ No newline at end of file diff --git a/dev/contracts/deploy-local b/dev/contracts/deploy-local index 698a1a60..495a52b1 100755 --- a/dev/contracts/deploy-local +++ b/dev/contracts/deploy-local @@ -1,6 +1,8 @@ #!/bin/bash # Deploy the smart contracts to the local anvil node +set -euo pipefail + source dev/contracts/.env # Make sure the build directory exists @@ -10,7 +12,7 @@ cd ./contracts # Deploy a contract and save the output (which includes the contract address) to a JSON file to be used in tests function deploy_contract() { - forge create --legacy --json --rpc-url $DOCKER_RPC_URL --private-key $PRIVATE_KEY "$1:$2" > ../build/$2.json + forge create --legacy --json --broadcast --rpc-url $DOCKER_RPC_URL --private-key $PRIVATE_KEY "$1:$2" > ../build/$2.json } deploy_contract src/GroupMessages.sol GroupMessages diff --git a/dev/contracts/deploy-testnet b/dev/contracts/deploy-testnet index 6aa410e3..d5a18abc 100755 --- a/dev/contracts/deploy-testnet +++ b/dev/contracts/deploy-testnet @@ -8,6 +8,7 @@ cd ./contracts function deploy_contract() { forge create \ --rpc-url $RPC_URL \ + --broadcast \ --chain=241320161 \ --compiler-version=0.8.28 \ --verify \ diff --git a/pkg/utils/namespace.go b/pkg/utils/namespace.go new file mode 100644 index 00000000..67276c16 --- /dev/null +++ b/pkg/utils/namespace.go @@ -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] +}