fix: update contract definition after syncing with DRE

This commit is contained in:
ppe
2023-03-20 18:22:24 +01:00
committed by just_ppe
parent 013bae4a02
commit d5856c3f21
2 changed files with 12 additions and 5 deletions

View File

@@ -492,6 +492,14 @@ export class HandlerBasedContract<State> implements Contract<State> {
if (contractEvaluationOptions.remoteStateSyncEnabled && !contractEvaluationOptions.useKVStorage) {
remoteState = await this.getRemoteContractState(contractTxId);
cachedState = await this.maybeSyncStateWithRemoteSource(remoteState, upToSortKey, cachedState);
const maybeEvolvedSrcTxId = Evolve.evolvedSrcTxId(cachedState?.cachedValue?.state);
if (maybeEvolvedSrcTxId && maybeEvolvedSrcTxId !== contractDefinition.srcTxId) {
// even though the state will be synced, the CacheableStateEvaluator will
// still try to init it in the WASM module (https://github.com/warp-contracts/warp/issues/372)
// if the state struct definition has changed via evolve - there is a risk of panic in Rust.
// that's why the contract definition has to be updated.
contractDefinition = await definitionLoader.load<State>(contractTxId, maybeEvolvedSrcTxId);
}
}
if (!remoteState && sortedInteractions.length == 0) {