Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Partially) Remove 30000 #450

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

(Partially) Remove 30000 #450

wants to merge 6 commits into from

Conversation

shjortConcordium
Copy link
Contributor

Purpose

Remove some of the hardcoded 30000 energy on contract updates.

Changes

Removed 30000 energy from updates in the wCCD, voting and eSealing dApps

Checklist

  • My code follows the style of this project.
  • The code compiles without warnings.
  • I have performed a self-review of the changes.
  • I have documented my code, in particular the intent of the
    hard-to-understand areas.
  • (If necessary) I have updated the CHANGELOG.

maxContractExecutionEnergy: Energy.create(30000n),
address: contractAddress,
receiveName,
maxContractExecutionEnergy: invokeResult.usedEnergy,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a small margin EPSILON_ENERGY will help in cases where someone else uses the front end at the same time and the state of the smart contract has changed between the simulation and the execution of the transaction.

    const maxContractExecutionEnergy = Energy.create(dryRunResult.usedEnergy.value + EPSILON_ENERGY);

https://github.com/Concordium/concordium-dapp-examples/blob/main/trackAndTrace/frontend/src/track_and_trace_contract.tsx#L63

Applies to the other examples below as well.

});

if (invokeResult.tag === 'failure') {
throw Error('Transaction would fail!');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful if that error message reports the reason for the failure. The following, I suggest to cover:

    const fullEntryPointName = `${contractName.value}.${entryPoint.value}`;

    if (!res || res.tag === 'failure') {
        const rejectReason = JSON.stringify(
            ((res as InvokeContractFailedResult)?.reason as RejectedReceive)?.rejectReason
        );

        throw new Error(
            `RPC call 'invokeContract' on method '${fullEntryPointName}' of contract '${contractIndex}' failed.
            ${rejectReason !== undefined ? `Reject reason: ${rejectReason}` : ''}`
        );
    }

Reason for adding this reporting of errors now:
Before, people who reported problems while using this front end were able to give us a "failedTransactionHash" that we could use for further investigation. We don't have this anymore, so reporting potential problems here is what we have to rely on now.

This comment applies to the other examples as well.

Copy link
Collaborator

@soerenbf soerenbf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DOBEN are you taking lead on this? We should ideally also either

  • deploy these, or
  • roll back the version bumps until we do deploy them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants