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

[BCI-2538]: Updates Examples Directory #364

Merged
merged 9 commits into from
Mar 12, 2024

Conversation

chris-de-leon-cll
Copy link
Contributor

@chris-de-leon-cll chris-de-leon-cll commented Feb 28, 2024

Changes

  • removes proxy-consumer
  • adds a new folder aggregator_consumer with starknet-foundry integrated
  • removes the original aggregator-consumer example folder (keeping this around for reference - will remove it once everything has been updated)
  • removes typescript, node.js, hardhat, starknet.js, etc.
  • updates the original consumer.cario and price_consumer.cairo contracts for compatibility with cairo v2.5.4
  • adds new cairo tests for consumer.cairo and price_consumer.cairo- every function on both of these contracts has a corresponding test case
  • updates the README
    • adds a section on what packages/software needs to be installed and includes relevant links
    • adds section on what command to use for running tests via snforge (local devnet)
  • converts the original typescript scripts to cairo tests that can be called via snforge (so that users can see how the contracts work via a local devnet)
    • consumerValidator.ts - not applicable (this doesn't use consumer.cairo or price_consumer.cairo)
    • deploy_accounts.ts - not applicable (handled programmatically in cairo test cases)
    • deploy_contracts.ts - the test cases have helper functions which use the snforge library to compile and deploy contracts
    • readContinuously.ts - not applicable (this runs an infinite loop that reads the latest round data every 3 seconds)
    • readDecimals.ts - has a corresponding cairo test case
    • readLatestRound.ts - has a corresponding cairo test case
    • updateLatestRound.ts - has a corresponding cairo test case
  • update CI pipelines and github actions to automatically run the test cases
    • adds a new github action (.github/install-starknet-foundry/action.yml) that installs starknet-foundry
    • adds a new github action (.github/workflow/examples.yml) that runs the aggregator_consumer example test cases via snforge test
    • removes packages-ts/starknet
    • removes Makefile command test-integration-contracts

Delayed (will be tackled in a follow up PR)

  • update the README
    • add a section on how to use sncast scripts (live testnet)
  • convert the original typescript scripts to sncast scripts that interact with starknet testnet (so that users can see how the contracts work against a live network)
    • consumerValidator.ts
    • deploy_accounts.ts
    • deploy_contracts.ts
    • readContinuously.ts
    • readDecimals.ts
    • readLatestRound.ts
    • updateLatestRound.ts

Known Issues / Limitations

  • Null address checks of the form address.is_zero() have been commented out due to compile errors - looking into why these are occurring even when the zeroable module is imported
    • This has been resolved. The solution was to remove the edition property from Scarb.toml, which was automatically added by snforge init:
       # Scarb.toml
      
       # ...
      
       [package]
       edition = 2023_11
      
       # ...
  • Some of the contracts from the chainlink-starknet/contracts folder have been copied into the examples directory and modified slightly for compatibility with snforge. All the modifications are minor - they mostly involved creating new interfaces for dispatchers and renaming import paths. Also, to elaborate more on "compatibility for snforge", the test cases use a function declare(<ContractName>) for contract deployment, and this function only works if references a contract that is exported from the lib.cairo file in the src folder. I'm curious to understand if there's a better way to reference the original contracts without having to duplicate them in the examples folder
    • This has been resolved. The solution was to remove the edition field from Scarb.toml (see above) and to also add the following to Scarb.toml so that the tests could find the contract artifacts:
       # Scarb.toml
       
       # ...
      
       [[target.starknet-contract]]
       build-external-contracts = [
       	"chainlink::emergency::sequencer_uptime_feed::SequencerUptimeFeed",
       	"chainlink::ocr2::mocks::mock_aggregator::MockAggregator",
       ]
       
       # ...

Makefile Outdated Show resolved Hide resolved
…n for running example test cases with starknet foundry, removes test-integration-contracts
@cl-sonarqube-production
Copy link

Copy link
Collaborator

@archseer archseer left a comment

Choose a reason for hiding this comment

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

Nice work!

@archseer archseer merged commit 021f7fd into develop Mar 12, 2024
17 of 20 checks passed
@archseer archseer deleted the feat/BCI-2538-update-examples branch March 12, 2024 04:58
@chris-de-leon-cll chris-de-leon-cll changed the title Updates Examples Directory [BCI-2538]: Updates Examples Directory Mar 18, 2024
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.

2 participants