diff --git a/contracts/script/output/31337/GroupMessages.json b/contracts/script/output/31337/GroupMessages.json new file mode 100644 index 00000000..0a15425f --- /dev/null +++ b/contracts/script/output/31337/GroupMessages.json @@ -0,0 +1,10 @@ +{ + "addresses": { + "groupMessagesDeployer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "groupMessagesImpl": "0xc0F115A19107322cFBf1cDBC7ea011C19EbDB4F8", + "groupMessagesProxy": "0xc96304e3c037f81dA488ed9dEa1D8F2a48278a75", + "groupMessagesProxyAdmin": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" + }, + "deploymentBlock": 107, + "latestUpgradeBlock": 107 +} \ No newline at end of file diff --git a/contracts/script/output/31337/IdentityUpdates.json b/contracts/script/output/31337/IdentityUpdates.json new file mode 100644 index 00000000..ca52f0e1 --- /dev/null +++ b/contracts/script/output/31337/IdentityUpdates.json @@ -0,0 +1,10 @@ +{ + "addresses": { + "identityUpdatesDeployer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "identityUpdatesImpl": "0x34B40BA116d5Dec75548a9e9A8f15411461E8c70", + "identityUpdatesProxy": "0xD0141E899a65C95a556fE2B27e5982A6DE7fDD7A", + "identityUpdatesProxyAdmin": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" + }, + "deploymentBlock": 109, + "latestUpgradeBlock": 109 +} \ No newline at end of file diff --git a/contracts/script/output/31337/group_messages_deployment.json b/contracts/script/output/31337/group_messages_deployment.json deleted file mode 100644 index d22c1632..00000000 --- a/contracts/script/output/31337/group_messages_deployment.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "addresses": { - "groupMessagesDeployer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", - "groupMessagesImpl": "0xe8D2A1E88c91DCd5433208d4152Cc4F399a7e91d", - "groupMessagesProxy": "0x5067457698Fd6Fa1C6964e416b3f42713513B3dD", - "groupMessagesProxyAdmin": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" - }, - "deploymentBlock": 100, - "latestUpgradeBlock": 100 -} \ No newline at end of file diff --git a/contracts/script/output/31337/identity_updates_deployment.json b/contracts/script/output/31337/identity_updates_deployment.json deleted file mode 100644 index 1ec61bc4..00000000 --- a/contracts/script/output/31337/identity_updates_deployment.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "addresses": { - "identityUpdatesDeployer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", - "identityUpdatesImpl": "0x18E317A7D70d8fBf8e6E893616b52390EbBdb629", - "identityUpdatesProxy": "0x4b6aB5F819A515382B0dEB6935D793817bB4af28", - "identityUpdatesProxyAdmin": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" - }, - "deploymentBlock": 102, - "latestUpgradeBlock": 102 -} \ No newline at end of file diff --git a/contracts/script/utils/Environment.sol b/contracts/script/utils/Environment.sol index 14ab89d4..1cc2a346 100644 --- a/contracts/script/utils/Environment.sol +++ b/contracts/script/utils/Environment.sol @@ -4,6 +4,6 @@ pragma solidity 0.8.28; import "forge-std/src/Script.sol"; contract Environment is Script { - string public constant XMTP_GROUP_MESSAGES_OUTPUT_JSON = "group_messages_deployment"; - string public constant XMTP_IDENTITY_UPDATES_OUTPUT_JSON = "identity_updates_deployment"; + string public constant XMTP_GROUP_MESSAGES_OUTPUT_JSON = "GroupMessages"; + string public constant XMTP_IDENTITY_UPDATES_OUTPUT_JSON = "IdentityUpdates"; } diff --git a/dev/baked/Dockerfile b/dev/baked/Dockerfile index ffe2de5d..06e75b9a 100644 --- a/dev/baked/Dockerfile +++ b/dev/baked/Dockerfile @@ -29,8 +29,8 @@ RUN dev/docker/anvil-background && \ sleep 5 RUN echo "export XMTPD_CONTRACTS_NODES_ADDRESS="$(jq -r '.deployedTo' build/Nodes.json)"" >> contracts.env && \ - echo "export XMTPD_CONTRACTS_MESSAGES_ADDRESS="$(jq -r '.deployedTo' build/GroupMessages.json)"" >> contracts.env && \ - echo "export XMTPD_CONTRACTS_IDENTITY_UPDATES_ADDRESS="$(jq -r '.deployedTo' build/IdentityUpdates.json)"" >> contracts.env + echo "export XMTPD_CONTRACTS_MESSAGES_ADDRESS="$(jq -r '.addresses.groupMessagesProxy' contracts/script/output/31337/GroupMessages.json)"" >> contracts.env && \ + echo "export XMTPD_CONTRACTS_IDENTITY_UPDATES_ADDRESS="$(jq -r '.addresses.identityUpdatesProxy' contracts/script/output/31337/IdentityUpdates.json)"" >> contracts.env # ACTUAL IMAGE ------------------------------------------------------- diff --git a/dev/contracts/common b/dev/contracts/common index a88be5a1..a8035b21 100644 --- a/dev/contracts/common +++ b/dev/contracts/common @@ -11,7 +11,7 @@ function forge_deploy_script() { fi echo -e "✅ GroupMessages contract deployed.\n" - cat script/output/31337/group_messages_deployment.json + cat script/output/31337/GroupMessages.json echo -e "\n" ;; @@ -23,7 +23,7 @@ function forge_deploy_script() { fi echo -e "✅ IdentityUpdates contract deployed.\n" - cat script/output/31337/identity_updates_deployment.json + cat script/output/31337/IdentityUpdates.json echo -e "\n" ;; diff --git a/dev/local.env b/dev/local.env index 482f2c3f..b934bddc 100755 --- a/dev/local.env +++ b/dev/local.env @@ -2,16 +2,19 @@ source dev/contracts/.env +# Anvil scripts output folder +ANVIL_SCRIPTS_OUTPUT=contracts/script/output/31337 + # DB Options export XMTPD_DB_WRITER_CONNECTION_STRING="postgres://postgres:xmtp@localhost:8765/postgres?sslmode=disable" # Contract Options export XMTPD_CONTRACTS_RPC_URL=$DOCKER_RPC_URL # From contracts/.env -XMTPD_CONTRACTS_NODES_ADDRESS="$(jq -r '.deployedTo' build/Nodes.json)" # Built by contracts/deploy-local +XMTPD_CONTRACTS_NODES_ADDRESS="$(jq -r '.deployedTo' build/Nodes.json)" # Built by contracts/deploy-local - TODO: move deployment to forge script export XMTPD_CONTRACTS_NODES_ADDRESS -XMTPD_CONTRACTS_MESSAGES_ADDRESS="$(jq -r '.deployedTo' build/GroupMessages.json)" # Built by contracts/deploy-local +XMTPD_CONTRACTS_MESSAGES_ADDRESS="$(jq -r '.addresses.groupMessagesProxy' ${ANVIL_SCRIPTS_OUTPUT}/GroupMessages.json)" # Built by contracts/deploy-local export XMTPD_CONTRACTS_MESSAGES_ADDRESS -XMTPD_CONTRACTS_IDENTITY_UPDATES_ADDRESS="$(jq -r '.deployedTo' build/IdentityUpdates.json)" # Built by contracts/deploy-local +XMTPD_CONTRACTS_IDENTITY_UPDATES_ADDRESS="$(jq -r '.addresses.identityUpdatesProxy' ${ANVIL_SCRIPTS_OUTPUT}/IdentityUpdates.json)" # Built by contracts/deploy-local export XMTPD_CONTRACTS_IDENTITY_UPDATES_ADDRESS export ANVIL_ACC_1_PRIVATE_KEY="0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d" diff --git a/go.mod b/go.mod index 8de162ae..fbec9ffe 100644 --- a/go.mod +++ b/go.mod @@ -29,6 +29,7 @@ require ( require ( github.com/golang-jwt/jwt/v5 v5.2.1 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 + github.com/valyala/fastjson v1.6.4 ) require ( diff --git a/go.sum b/go.sum index 6d9f6939..9ca86d01 100644 --- a/go.sum +++ b/go.sum @@ -1153,6 +1153,8 @@ github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3C github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ= +github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/vbatts/tar-split v0.11.6 h1:4SjTW5+PU11n6fZenf2IPoV8/tz3AaYHMWjf23envGs= diff --git a/pkg/blockchain/blockchainPublisher_test.go b/pkg/blockchain/blockchainPublisher_test.go index aee4e0b1..36bd99e2 100644 --- a/pkg/blockchain/blockchainPublisher_test.go +++ b/pkg/blockchain/blockchainPublisher_test.go @@ -47,7 +47,7 @@ func TestPublishIdentityUpdate(t *testing.T) { { name: "happy path", inboxId: testutils.RandomGroupID(), - identityUpdate: testutils.RandomBytes(100), + identityUpdate: testutils.RandomBytes(104), ctx: context.Background(), wantErr: false, }, diff --git a/pkg/testutils/config.go b/pkg/testutils/config.go index 0f7c456d..42eccff8 100644 --- a/pkg/testutils/config.go +++ b/pkg/testutils/config.go @@ -5,10 +5,12 @@ import ( "os" "path" "path/filepath" + "strings" "testing" "time" "github.com/stretchr/testify/require" + "github.com/valyala/fastjson" "github.com/xmtp/xmtpd/pkg/config" ) @@ -48,6 +50,7 @@ func rootPath(t *testing.T) string { /* * Parse the JSON file at this location to get the deployed contract info +TODO: deprecate in favor of getProxyAddress * */ func getDeployedTo(t *testing.T, fileName string) string { @@ -65,19 +68,40 @@ func getDeployedTo(t *testing.T, fileName string) string { return info.DeployedTo } +/* +* +Parse the JSON file at this location to get the deployed contract proxy address +* +*/ +func getProxyAddress(t *testing.T, fileName string) string { + data, err := os.ReadFile(fileName) + if err != nil { + t.Fatalf("Failed to read json: %v", err) + } + + switch { + case strings.Contains(fileName, "GroupMessages.json"): + return fastjson.GetString(data, "addresses", "groupMessagesProxy") + case strings.Contains(fileName, "IdentityUpdates.json"): + return fastjson.GetString(data, "addresses", "identityUpdatesProxy") + default: + return "" + } +} + func GetContractsOptions(t *testing.T) config.ContractsOptions { rootDir := rootPath(t) return config.ContractsOptions{ RpcUrl: BLOCKCHAIN_RPC_URL, - MessagesContractAddress: getDeployedTo( + MessagesContractAddress: getProxyAddress( t, - path.Join(rootDir, "./build/GroupMessages.json"), + path.Join(rootDir, "./contracts/script/output/31337/GroupMessages.json"), ), NodesContractAddress: getDeployedTo(t, path.Join(rootDir, "./build/Nodes.json")), - IdentityUpdatesContractAddress: getDeployedTo( + IdentityUpdatesContractAddress: getProxyAddress( t, - path.Join(rootDir, "./build/IdentityUpdates.json"), + path.Join(rootDir, "./contracts/script/output/31337/IdentityUpdates.json"), ), RefreshInterval: 100 * time.Millisecond, ChainID: 31337,