Skip to content

Error on oracle.Bootstrap() #10

Description

@chipchipzero

As your tutorial, I've tried to create sample oracle project. Here is my main.go

package main

import (
  "time"

  framework "github.com/hyplabs/dfinity-oracle-framework"
  "github.com/hyplabs/dfinity-oracle-framework/models"
)

func main() {
  weatherApiKey := "WEATHER_API_KEY"
  weatherBitApiKey := "WEATHER_BIT_API_KEY"
  tokyoEndpoints := []models.Endpoint{
    {
      Endpoint: "http://api.weatherapi.com/v1/current.json?key="+weatherApiKey+"&q=Tokyo,JP",
      JSONPaths: map[string]string{
        "temperature_celsius": "$.current.temp_c",
      },
    },
    {
      Endpoint: "https://api.weatherbit.io/v2.0/current?key="+weatherBitApiKey+"&city=Tokyo&country=JP",
      JSONPaths: map[string]string{
        "temperature_celsius": "$.data[0].temp",
      },
    },
  }
  delhiEndpoints := []models.Endpoint{
    {
      Endpoint: "http://api.weatherapi.com/v1/current.json?key="+weatherApiKey+"&q=Delhi,IN",
      JSONPaths: map[string]string{
        "temperature_celsius": "$.current.temp_c",
      },
    },
    {
      Endpoint: "https://api.weatherbit.io/v2.0/current?key="+weatherBitApiKey+"&city=Delhi&country=IN",
      JSONPaths: map[string]string{
        "temperature_celsius": "$.data[0].temp",
      },
    },
  }
  config := models.Config{
    CanisterName:   "sample_oracle",
    UpdateInterval: 1 * time.Minute,
  }
  engine := models.Engine{
    Metadata: []models.MappingMetadata{
      {Key: "Tokyo", Endpoints: tokyoEndpoints},
      {Key: "Delhi", Endpoints: delhiEndpoints},
    },
  }
  oracle := framework.NewOracle(&config, &engine)
  oracle.Bootstrap()
  oracle.Run()
}

After run ./sample-oracle

{"level":"info","msg":"Creating new project sample_oracle...","time":"2022-03-21T09:50:07+07:00"}
{"level":"info","msg":"Updating canister code...","time":"2022-03-21T09:50:07+07:00"}
{"level":"info","msg":"Stopping existing DFX instances...","time":"2022-03-21T09:50:07+07:00"}
{"level":"info","msg":"Sleeping 5 seconds to allow local network to finish shutting down...","time":"2022-03-21T09:50:07+07:00"}
{"level":"info","msg":"Starting DFX in the background...","time":"2022-03-21T09:50:12+07:00"}
Starting webserver for /_/
binding to: 127.0.0.1:54278
Mar 21 02:50:12.085 INFO ic-starter. Configuration: ValidatedConfig { replica_path: Some("/Users/macintoshhd/.cache/dfinity/versions/0.8.4/replica"), replica_version: "0.8.0", log_level: Warning, cargo_bin: "cargo", cargo_opts: "", state_dir: "/Users/macintoshhd/dfx-learning/sample-oracle/sample_oracle/.dfx/state/replicated_state", http_listen_addr: 127.0.0.1:0, http_port_file: Some("/Users/macintoshhd/dfx-learning/sample-oracle/sample_oracle/.dfx/replica-configuration/replica-1.port"), metrics_addr: None, provisional_whitelist: Some(All), artifact_pool_dir: "/Users/macintoshhd/dfx-learning/sample-oracle/sample_oracle/.dfx/state/replicated_state/node-100/ic_consensus_pool", crypto_root: "/Users/macintoshhd/dfx-learning/sample-oracle/sample_oracle/.dfx/state/replicated_state/node-100/crypto", state_manager_root: "/Users/macintoshhd/dfx-learning/sample-oracle/sample_oracle/.dfx/state/replicated_state/node-100/state", registry_local_store_path: "/Users/macintoshhd/dfx-learning/sample-oracle/sample_oracle/.dfx/state/replicated_state/ic_registry_local_store", unit_delay: None, initial_notary_delay: Some(600ms), detect_consensus_starvation: None, consensus_pool_backend: Some("rocksdb"), state_dir_holder: None }, Application: starter
Mar 21 02:50:12.085 INFO Use existing replica configuration "/Users/macintoshhd/dfx-learning/sample-oracle/sample_oracle/.dfx/state/replicated_state/ic.json5", Application: starter
Mar 21 02:50:12.085 INFO Executing "/Users/macintoshhd/.cache/dfinity/versions/0.8.4/replica" "--replica-version" "0.8.0" "--config-file" "/Users/macintoshhd/dfx-learning/sample-oracle/sample_oracle/.dfx/state/replicated_state/ic.json5", Application: starter
Mar 21 02:50:12.546 WARN s:x37z7-pjl63-npq3a-2i5ry-ujfe7-6jgqk-m3snv-iiuw5-p4slk-pf65o-eqe/n:5mo3n-ebyty-ewq7a-j53ep-hwgo2-uwsza-r7d2m-j3je2-burw6-xlk3c-nae/ic_p2p/download_management PeerManagerImpl::new(): relay_config = None
version: 0.7.0
 Mar 21 09:50:12.603 INFO Log Level: INFO
 Mar 21 09:50:12.603 INFO Starting server. Listening on http://127.0.0.1:8000/
{"level":"info","msg":"Sleeping 5 seconds to allow local network to set up enough that we can make requests...","time":"2022-03-21T09:50:14+07:00"}
{"level":"info","msg":"Creating writer identity...","time":"2022-03-21T09:50:19+07:00"}
{"level":"info","msg":"Checking if canister already exists...","time":"2022-03-21T09:50:19+07:00"}
{"level":"error","msg":"Could not determine if canister exists: Creating a wallet canister on the local network.\nThe wallet canister on the \"local\" network for user \"default\" is \"rwlgt-iiaaa-aaaaa-aaaaa-cai\"\nCannot find canister id. Please issue 'dfx canister create sample_oracle'.\n","time":"2022-03-21T09:50:23+07:00"}
{"level":"info","msg":"Creating canister...","time":"2022-03-21T09:50:23+07:00"}
{"level":"info","msg":"Building canister...","time":"2022-03-21T09:50:25+07:00"}
{"level":"info","msg":"Installing canister...","time":"2022-03-21T09:50:26+07:00"}
{"level":"info","msg":"Checking if canister is running...","time":"2022-03-21T09:50:32+07:00"}
{"error":null,"level":"error","msg":"Could not determine canister status: Canister status call result for sample_oracle.\nStatus: Running\nControllers: rwlgt-iiaaa-aaaaa-aaaaa-cai\nMemory allocation: 0\nCompute allocation: 0\nFreezing threshold: 2_592_000\nMemory Size: Nat(413629)\nBalance: 4_000_000_000_000 Cycles\nModule hash: 0xac0aa4a256e41d822d0571c8df6aa2b159ee526cb0eee3e8227462e0e17c7c81\n","time":"2022-03-21T09:50:35+07:00"}
panic: Could not determine canister status: Canister status call result for sample_oracle.
Status: Running
Controllers: rwlgt-iiaaa-aaaaa-aaaaa-cai
Memory allocation: 0
Compute allocation: 0
Freezing threshold: 2_592_000
Memory Size: Nat(413629)
Balance: 4_000_000_000_000 Cycles
Module hash: 0xac0aa4a256e41d822d0571c8df6aa2b159ee526cb0eee3e8227462e0e17c7c81


goroutine 1 [running]:
github.com/hyplabs/dfinity-oracle-framework.(*Oracle).Bootstrap(0xc00011bf58, 0xc0000a0d10, 0x13a588a)
	/Users/macintoshhd/go/pkg/mod/github.com/hyplabs/dfinity-oracle-framework@v0.0.0-20210416070853-c804a74c2750/framework.go:72 +0x425
main.main()
	/Users/macintoshhd/dfx-learning/sample-oracle/main.go:52 +0x66d

Then I run this command dfx canister call sample_oracle get_map, it returns (null)

➜  sample_oracle git:(master) ✗ dfx canister status sample_oracle
Canister status call result for sample_oracle.
Status: Running
Controllers: rwlgt-iiaaa-aaaaa-aaaaa-cai
Memory allocation: 0
Compute allocation: 0
Freezing threshold: 2_592_000
Memory Size: Nat(413629)
Balance: 4_000_000_000_000 Cycles
Module hash: 0xac0aa4a256e41d822d0571c8df6aa2b159ee526cb0eee3e8227462e0e17c7c81
➜  sample_oracle git:(master) ✗ dfx canister call sample_oracle get_map
(null)

So, I think there is error(s) somewhere on oracle.Bootstrap(), can not get weather data.
Please help! Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions