I was following a course tutorial to create a small decentralized bank application using dfinity's internet computer. the main.mo file is as follows:

import Debug "mo:base/Debug";
import Float "mo:base/Float";
import Time "mo:base/Time";

actor DBank {
  stable var currentValue: Float = 300;
  stable var startTime = Time.now();
  Debug.print(debug_show(currentValue));

  public func topUp(amount: Float){
    currentValue += amount;
    Debug.print(debug_show(currentValue));
  };

  public func withdraw(amount: Float){
    let tempValue: Float = currentValue - amount;
    if(tempValue >= 0){
        currentValue -= amount;
        Debug.print(debug_show(currentValue));
    } else{
      Debug.print("Withdrawal amount is more than Balance.")
    }
  };

  public query func checkBalance(): async Float{
    return currentValue;
  };

  public func compound() {
    let currentTime = Time.now();
    let timeElapsedNS = currentTime - startTime;
    let timeElapsedSec = timeElapsedNS / 1_000_000_000;
    currentValue := currentValue * (1.01 ** Float.fromInt(timeElapsedSec));
  };

}
The Candid Interface was working until I changed the the data type of currentValue from Nat to float. It showed a warning when i ran dfx deploy on the terminal:
user***@hp:~/ic-projects/dbank$ dfx deploy
Deploying all canisters.
All canisters have already been created.
Building canisters...
Building frontend...
Installing canisters...
WARNING!
Candid interface compatibility check failed for canister 'dbank'.
You are making a BREAKING change. Other canisters or frontend clients relying on your canister may stop working.

Method checkBalance: func () -> (float64) query is not a subtype of func () -> (nat) query
Do you want to proceed? yes/No
yes

I do not have the original warning, I tried to recreate it so float64 and nat might be interchanged.

On deployment the Candid UI shows this: An error happened in Candid canister: Error: Server returned an error: Code: 400 (Bad Request) Body: Specified ingress_expiry not within expected range: Minimum allowed expiry: 2023-02-06 19:04:14.511184689 UTC Maximum allowed expiry: 2023-02-06 19:09:44.511184689 UTC Provided expiry: 2023-02-06 19:25:14.339 UTC Local replica time: 2023-02-06 19:04:14.511189299 UTC

at _.query (http://127.0.0.1:8000/index.js:2:8821)
at async http://127.0.0.1:8000/index.js:2:100976
at async getRemoteDidJs (http://127.0.0.1:8000/index.js:2:266158)
at async Object.fetchActor (http://127.0.0.1:8000/index.js:2:265243)
at async http://127.0.0.1:8000/index.js:2:271946

I was thinking whether this could be a problem from Time module but couldn't find much about it, as the module documentation page has been removed.

Looked up the ingress_expiry problem and tried it's solutions: the local machine's time is correct and in sync with the actual time. Using wsl1 in vscode, it is the latest version i suppose as running wsl --update shows you have the latest version

The breaking change warning in the question description was orginally prompted for the checkBalance() function but I could not include anything worthwhile.

3

There are 3 best solutions below

0
On

In my case, below command worked.

sudo hwclock -s
2
On

Your Ubuntu clock is not synchronized with system clock. Write this command in terminal of ubuntu sudo apt-get install ntp .This command will synchronize your ubuntu time with your system. Make sure your system has correct time and date.

0
On

This was caused because of unsyncronized time between Ubuntu and system time. On running this sudo hwclock -s on the Ubuntu terminal and redeploying the app will eliminate the error.