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

Immutable SmartContract objects #313

Merged
merged 4 commits into from
May 23, 2021
Merged

Immutable SmartContract objects #313

merged 4 commits into from
May 23, 2021

Conversation

Sriep
Copy link
Contributor

@Sriep Sriep commented May 22, 2021

Currently, a new SmartContract object is made for each time a smart contract is called. This is unnecessary as all the SmartContract does is hold a list of handlers and endpoints for smart contract calls. This PR makes seven immutable SmartContract objects, one for each type of smart contract.

  • SmartContractInterface: Remove methods that change or access the underlying SmartContract object. It needs to immutable.
  • The only reason the underlying SmartContract object was needed was to access HandlerStats or ExecutionStats, so add accessors for this to the SmartContractInterface.
  • Modify smartcontracts to implement the new SmartContractInterface methods and remove or make local mutatling methods removed from SmartContractInterface.
  • Change existing code to use the new SmartContractInterface methods rather than SmartContract objects.
  • Remove factory.
  • Update setupsc.

This PR addresses issues raised by #104. Also related to issue #260.

@Sriep Sriep requested a review from bbist May 22, 2021 13:58
Copy link
Contributor

@bbist bbist left a comment

Choose a reason for hiding this comment

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

Looks much better.

@Sriep Sriep merged commit 9050671 into master May 23, 2021
@Sriep Sriep deleted the sci-refactro branch May 23, 2021 08:17
peterlimg added a commit that referenced this pull request May 28, 2021
* vc-false-stuck:
  Do not run computeState in goroutine in AddNotarizedBlock
  Fix issue in fetching blocks from sharders
  🐛 AddChallenge: randomise validators (#312)
  🔨 Immutable SmartContract objects (#313)
  check for duplicate blobbers (#272)
  🐛 Conversion Fix For Core
  🐛 Fix invalid type conversion
  🔨 New smart contract factroy (#295)
  Feature: httpclientutil and round tests (#288)
  Feature: add cache and common unit tests (#261)
  Update nginx.conf
  Update nginx.conf
  Feature: add datastore and ememorystore unit tests (#262)
  Feature: smartcontractinterface and tokenpool tests (#291)
  Feature: add encryption and logging unit tests (#264)
  Feature block unit tests (#248)
  🐛 Add mutex to mapIndex (#282)
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.

None yet

2 participants