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

[DEBUG Attempt] subscription service contract debug notes #100

Draft
wants to merge 3 commits into
base: subscription-service-contract
Choose a base branch
from

Conversation

Jovonni
Copy link

@Jovonni Jovonni commented Sep 6, 2024

Not sure if this is helpful @rabi-siddique , but I noticed a few things here that may or may not be relevant.

  1. When isolating it, i see what you mean, timer is undefined in some tests, and not in others
  2. I noticed the timer in the terms was not always available.
  3. was able to isolate it to here:
  const currentTimeRecord = await E(timer).getCurrentTimestamp();
  1. I also see @Chris-Hibbert 's await await observation, and that might have caused an issue too when you trying to access the timer from promise space const timerService = await await chainTimerServiceP; -- its awaiting the promise, and then awaiting the things thats resolved from the promise.
  2. it might have been some confusion when you are doing things with the timer inside of the contract, and outside of it, sometimes I have to make sure I am handling those object right in my test flow -- like this. When using E here, it was undefined, as you mentioned.
await E(timer).getCurrentTimestamp();
  1. Notice my debugger lines here, it helped me step through the flow to see when exactly timer was defined and undefined. This may be helpful moving forward on this.

These logs don't show the issue anymore. The issue wasn't the contract ,it was the test trying to access the timer to invoke it

I Now see @turadg branch, I think I ended up down a similar path

These following tests logs don't show this error anymore:

TypeError#1: Cannot deliver getCurrentTimestamp to target; typeof target is undefined
jovonni@jovonnis-MBP contract % yarn test                                                           
Debugger attached.
Debugger attached.
  ⚠ The timeout option has been disabled to help with debugging.

start proposal module evaluating
  ✔ bundle-source › bundleSource() bundles the contract for use with zoe (1.6s)
    ℹ 92e77a300d7f604141bf3cec46c0cd9f761cf809b0bb2bc5b10fafa3ec9bea9d7ed2e3f820882f3b4078268fb3c1f1f16520c0c29342d2c2a80d604545056893
    ℹ Object @Alleged: BundleInstallation {}
bundles/ bundle-assetContract.js valid: 174 files bundled at 2024-09-05T23:40:18.836Z
timer::66 Object [Alleged: ManualTimer] {
  advanceBy: [Function: value],
  advanceTo: [Function: value],
  cancel: [Function: value],
  delay: [Function: value],
  getClock: [Function: value],
  getCurrentTimestamp: [Function: value],
  getTimerBrand: [Function: value],
  makeNotifier: [Function: value],
  makeRepeater: [Function: value],
  repeatAfter: [Function: value],
  setWakeup: [Function: setWakeup],
  wakeAt: [Function: value],
  tick: [Function: tick],
  tickN: [AsyncFunction: tickN]
}
Debugger attached.
agoric: run: running /Users/jovonni/Documents/projects/dapp-offer-up/contract/scripts/build-contract-deployer.js
start proposal module evaluating
Debugger attached.
/Users/jovonni/Documents/projects/dapp-offer-up/contract/bundles bundle-offer-up.js valid: 174 files bundled at 2024-09-06T02:11:33.438Z
Waiting for the debugger to disconnect...
Waiting for the debugger to disconnect...
  ✔ build-proposal › proposal builder generates compressed bundles less than 1MB (7.1s)
    ℹ agoric run stdout: agoric: run: Deploy script will run with Node.js ESM
      bundle-source --to /Users/jovonni/Documents/projects/dapp-offer-up/contract/bundles /Users/jovonni/Documents/projects/dapp-offer-up/contract/src/offer-up.contract.js offer-up
      creating start-offer-up-permit.json
      creating start-offer-up.js
      You can now run a governance submission command like:
        agd tx gov submit-proposal swingset-core-eval start-offer-up-permit.json start-offer-up.js \
          --title="Enable <something>" --description="Evaluate start-offer-up.js" --deposit=1000000ubld \
          --gas=auto --gas-adjustment=1.2
      Remember to install bundles before submitting the proposal:
        agd tx swingset install-bundle @/Users/jovonni/.agoric/cache/b1-c1966edb4d2966c3b6b98fb829ae2820463d817729c316db8aa52320befa1be88cc629828760f0f7b995e7046a152d50c09b3bb96304e56b0c9673835122df78.json
        agd tx swingset install-bundle @/Users/jovonni/.agoric/cache/b1-e2de2ddd74e002a03a3e611d66465eea5f7f94424fa4cb8f05000edbb180c49fd1b09a04537d923dad9dda4ace5ff7a4d921a9dc7cb28b1ab0f406152b31e1f4.json
      
      
    ℹ {
        bundleId: 'b1-c1966edb4d2966c3b6b98fb829ae2820463d817729c316db8aa52320befa1be88cc629828760f0f7b995e7046a152d50c09b3bb96304e56b0c9673835122df78',
        compressedSize: '0.3552742004394531 MB',
      }
    ℹ {
        bundleId: 'b1-e2de2ddd74e002a03a3e611d66465eea5f7f94424fa4cb8f05000edbb180c49fd1b09a04537d923dad9dda4ace5ff7a4d921a9dc7cb28b1ab0f406152b31e1f4',
        compressedSize: '0.15810394287109375 MB',
      }
startOfferUpContract()...
  ✔ contract › Install the contract (4.6s)
    ℹ Object @Alleged: BundleInstallation {}
  ✔ contract › Start the contract (6.2s)
    ℹ Object @Alleged: InstanceHandle {}
terms: 74 {
  subscriptionPrice: { brand: Object [Alleged: PlayMoney brand] {}, value: 10000000n },
  timerService: Object [Alleged: ManualTimer] {
    advanceBy: [Function: value],
    advanceTo: [Function: value],
    cancel: [Function: value],
    delay: [Function: value],
    getClock: [Function: value],
    getCurrentTimestamp: [Function: value],
    getTimerBrand: [Function: value],
    makeNotifier: [Function: value],
    makeRepeater: [Function: value],
    repeatAfter: [Function: value],
    setWakeup: [Function: setWakeup],
    wakeAt: [Function: value],
    tick: [Function: tick],
    tickN: [AsyncFunction: tickN]
  }
}
timer 183 Object [Alleged: ManualTimer] {
  advanceBy: [Function: value],
  advanceTo: [Function: value],
  cancel: [Function: value],
  delay: [Function: value],
  getClock: [Function: value],
  getCurrentTimestamp: [Function: value],
  getTimerBrand: [Function: value],
  makeNotifier: [Function: value],
  makeRepeater: [Function: value],
  repeatAfter: [Function: value],
  setWakeup: [Function: setWakeup],
  wakeAt: [Function: value],
  tick: [Function: tick],
  tickN: [AsyncFunction: tickN]
}
permittedPowers:  {
  consume: {
    zoe: Object [Alleged: ZoeService] {},
    chainStorage: Object [Alleged: chainStorage] {
      makeChildNode: [AsyncFunction: makeChildNode],
      setValue: [AsyncFunction: setValue]
    },
    startUpgradable: [AsyncFunction: startUpgradable],
    board: { getId: [Function (anonymous)] },
    timer: Object [Alleged: ManualTimer] {
      advanceBy: [Function: value],
      advanceTo: [Function: value],
      cancel: [Function: value],
      delay: [Function: value],
      getClock: [Function: value],
      getCurrentTimestamp: [Function: value],
      getTimerBrand: [Function: value],
      makeNotifier: [Function: value],
      makeRepeater: [Function: value],
      repeatAfter: [Function: value],
      setWakeup: [Function: setWakeup],
      wakeAt: [Function: value],
      tick: [Function: tick],
      tickN: [AsyncFunction: tickN]
    }
  },
  brand: { consume: { IST: [Promise] }, produce: { Item: [Object] } },
  issuer: { consume: { IST: [Promise] }, produce: { Item: [Object] } },
  installation: { consume: { offerUp: [Promise] } },
  instance: { produce: { offerUp: [Object] } }
}
chainTimerServiceP,  undefined
timerService proposal:  undefined
privateArgs in contract:  {
  timerService: Object [Alleged: ManualTimer] {
    advanceBy: [Function: value],
    advanceTo: [Function: value],
    cancel: [Function: value],
    delay: [Function: value],
    getClock: [Function: value],
    getCurrentTimestamp: [Function: value],
    getTimerBrand: [Function: value],
    makeNotifier: [Function: value],
    makeRepeater: [Function: value],
    repeatAfter: [Function: value],
    setWakeup: [Function: setWakeup],
    wakeAt: [Function: value],
    tick: [Function: tick],
    tickN: [AsyncFunction: tickN]
  }
}
privateArgs in contract:  {
  timerService: Object [Alleged: ManualTimer] {
    advanceBy: [Function: value],
    advanceTo: [Function: value],
    cancel: [Function: value],
    delay: [Function: value],
    getClock: [Function: value],
    getCurrentTimestamp: [Function: value],
    getTimerBrand: [Function: value],
    makeNotifier: [Function: value],
    makeRepeater: [Function: value],
    repeatAfter: [Function: value],
    setWakeup: [Function: setWakeup],
    wakeAt: [Function: value],
    tick: [Function: tick],
    tickN: [AsyncFunction: tickN]
  }
}
privateArgs in contract:  { timerService: undefined }
CoreEval script: started contract Object [Alleged: InstanceHandle] {}
CoreEval script: share via agoricNames: Object [Alleged: Item brand] {}
offerUp (re)started
bundles/ bundle-centralSupply.js valid: 125 files bundled at 2024-09-05T22:03:40.566Z
terms::99 {
  subscriptionPrice: { brand: Object [Alleged: ZDEFAULT brand] {}, value: 10000000n },
  timerService: Object [Alleged: ManualTimer] {
    advanceBy: [Function: value],
    advanceTo: [Function: value],
    cancel: [Function: value],
    delay: [Function: value],
    getClock: [Function: value],
    getCurrentTimestamp: [Function: value],
    getTimerBrand: [Function: value],
    makeNotifier: [Function: value],
    makeRepeater: [Function: value],
    repeatAfter: [Function: value],
    setWakeup: [Function: setWakeup],
    wakeAt: [Function: value],
    tick: [Function: tick],
    tickN: [AsyncFunction: tickN]
  },
  issuers: {
    Price: Object [Alleged: ZDEFAULT issuer] {},
    Item: Object [Alleged: Item issuer] {}
  },
  brands: {
    Price: Object [Alleged: ZDEFAULT brand] {},
    Item: Object [Alleged: Item brand] {}
  }
}
  ✘ [fail]: contract › Trade in IST rather than play money
    ℹ Alice gives {
        Price: {
          brand: Object @Alleged: ZDEFAULT brand {},
          value: 10000000n,
        },
      }
    ℹ Alice payout brand Object @Alleged: Item brand {}
    ℹ Alice payout value Object @copyBag {
        payload: [],
      }
  ✘ [fail]: contract › use the code that will go on chain to start the contract
    ℹ Alice gives {
        Price: {
          brand: Object @Alleged: ZDEFAULT brand {},
          value: 10000000n,
        },
      }
    ℹ Alice payout brand Object @Alleged: Item brand {}
    ℹ Alice payout value Object @copyBag {
        payload: [],
      }
terms::99 {
  subscriptionPrice: { brand: Object [Alleged: ZDEFAULT brand] {}, value: 10000000n },
  timerService: undefined,
  issuers: {
    Price: Object [Alleged: ZDEFAULT issuer] {},
    Item: Object [Alleged: Item issuer] {}
  },
  brands: {
    Price: Object [Alleged: ZDEFAULT brand] {},
    Item: Object [Alleged: Item brand] {}
  }
}
timerService 100 Object [Alleged: ManualTimer] {
  advanceBy: [Function: value],
  advanceTo: [Function: value],
  cancel: [Function: value],
  delay: [Function: value],
  getClock: [Function: value],
  getCurrentTimestamp: [Function: value],
  getTimerBrand: [Function: value],
  makeNotifier: [Function: value],
  makeRepeater: [Function: value],
  repeatAfter: [Function: value],
  setWakeup: [Function: setWakeup],
  wakeAt: [Function: value],
  tick: [Function: tick],
  tickN: [AsyncFunction: tickN]
}
timerService 100 undefined
timer 106 Object [Alleged: ManualTimer] {
  advanceBy: [Function: value],
  advanceTo: [Function: value],
  cancel: [Function: value],
  delay: [Function: value],
  getClock: [Function: value],
  getCurrentTimestamp: [Function: value],
  getTimerBrand: [Function: value],
  makeNotifier: [Function: value],
  makeRepeater: [Function: value],
  repeatAfter: [Function: value],
  setWakeup: [Function: setWakeup],
  wakeAt: [Function: value],
  tick: [Function: tick],
  tickN: [AsyncFunction: tickN]
}
timer 106 Object [Alleged: ManualTimer] {
  advanceBy: [Function: value],
  advanceTo: [Function: value],
  cancel: [Function: value],
  delay: [Function: value],
  getClock: [Function: value],
  getCurrentTimestamp: [Function: value],
  getTimerBrand: [Function: value],
  makeNotifier: [Function: value],
  makeRepeater: [Function: value],
  repeatAfter: [Function: value],
  setWakeup: [Function: setWakeup],
  wakeAt: [Function: value],
  tick: [Function: tick],
  tickN: [AsyncFunction: tickN]
}
currentTimeRecord: { absValue: 0n, timerBrand: Object [Alleged: timerBrand] {} }
currentTimeRecord: { absValue: 0n, timerBrand: Object [Alleged: timerBrand] {} }
timerService:: Object [Alleged: ManualTimer] {
  advanceBy: [Function: value],
  advanceTo: [Function: value],
  cancel: [Function: value],
  delay: [Function: value],
  getClock: [Function: value],
  getCurrentTimestamp: [Function: value],
  getTimerBrand: [Function: value],
  makeNotifier: [Function: value],
  makeRepeater: [Function: value],
  repeatAfter: [Function: value],
  setWakeup: [Function: setWakeup],
  wakeAt: [Function: value],
  tick: [Function: tick],
  tickN: [AsyncFunction: tickN]
}
timerService:: undefined


  contract › Trade in IST rather than play money
  test/test-contract.js:141

   140:   t.log('Alice payout value', actual.value);
   141:   t.deepEqual(actual, proposal.want.Items); 
   142:                                             

  Difference (- actual, + expected):

    {
      brand: Object @Alleged: Item brand {},
      value: Object @copyBag {
        payload: [
  +       [
  +         {
  +           serviceStarted: {
  +             absValue: 0n,
  +             timerBrand: Object @Alleged: timerBrand {},
  +           },
  +           serviceType: 'Netflix',
  +         },
  +         1n,
  +       ],
        ],
      },
    }

  › alice (file://test/test-contract.js:141:5)
  › async file://test/test-contract.js:215:3



  contract › use the code that will go on chain to start the contract
  test/test-contract.js:141

   140:   t.log('Alice payout value', actual.value);
   141:   t.deepEqual(actual, proposal.want.Items); 
   142:                                             

  Difference (- actual, + expected):

    {
      brand: Object @Alleged: Item brand {},
      value: Object @copyBag {
        payload: [
  +       [
  +         {
  +           serviceStarted: {
  +             absValue: 0n,
  +             timerBrand: Object @Alleged: timerBrand {},
  +           },
  +           serviceType: 'Netflix',
  +         },
  +         1n,
  +       ],
        ],
      },
    }

  › alice (file://test/test-contract.js:141:5)
  › async file://test/test-contract.js:292:3



  2 tests failed
Waiting for the debugger to disconnect...
Waiting for the debugger to disconnect...
jovonni@jovonnis-MBP contract % 

idk if this is progress, but wanted to put my notes somewhere

@Jovonni Jovonni added the bug Something isn't working label Sep 6, 2024
@Jovonni
Copy link
Author

Jovonni commented Sep 6, 2024

As i debugged it, where you see my random console.logs() as I was thinking, those helped me see where and when timer was there and not @rabi-siddique with the javascript debugger stepping over each line

@rabi-siddique rabi-siddique removed their request for review October 4, 2024 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant