Hey, the goal is to only deploy the contract once on testnet.
Other contracts depend on the id, so it needs to be identical.
With deploying it aka using forc deploy --testnet --default-salt they do deploy with the same ID, but it differs to local.
I’ve spent quite some time with @Voxelot to go through it, we discovered the following:
salt is honored correctly
storage slots are identical
bytecode differs
Here’s our deployment process:
it’s a monorepo
I run pnpm dlx fuels build to build contracts and put the typegen output into the ts sdk
The ts sdk then runs all tests for the sdk (which includes deploying to local using launchTestNode)
those tests all check out
then running tests inside the contracts using cargo test. They also make use of the bytecode etc, all checks out
then running forc deploy —default-salt —testnet in a specific contract’s folder
this is where the id changes
Our current hunch is that forc is bundled differently with fuels than using forc directly. For some reason using forc deploy and using npx fuels build produce slightly different bytecodes.
Using latest fuelup toolchain and fuels 0.92.0 for build (aka build + typegen)
@xpluscal It all comes down to which build profile you’re using to build.
I think the confusion comes from the fact that these methods have different defaults:
forc build — defaults to --debug
forc deploy — defaults to --release
And you’ve been comparing the results of the outputs between build vs. deploy.
$ forc build --help
--build-profile <BUILD_PROFILE>
The name of the build profile to use
[default: debug] # <—————————————————— DEBUG
$ forc deploy --help
--build-profile <BUILD_PROFILE>
The name of the build profile to use
[default: release] # <———————————————— RELEASE
@anderson so given the following use case, what would be your suggested approach?
Contract A makes calls to Contract B
Hence Contract A has the ContractId of Contract B as a const
We want the tests to work, hence Contract B needs to have the same ContractId when doing forc build and cargo test to test
We want it to work when deployed, hence forc deploy for Contract B and pnpm dlx fuels build to generate bytecode and typegen to also have the same ContractId for Contract B
Would you recommendation then be to run the tests with the --release flag?
Or deploy with debug…
The first one seems more reasonable, just couldn’t find anything in the docs.