stratisproject / StratisBitcoinFullNode

Bitcoin full node in C#
https://stratisplatform.com
MIT License
788 stars 312 forks source link

SmartContracts: Add support for SC conditional compilation based on STRATSC as a target #1546

Closed mwherman2000 closed 5 years ago

mwherman2000 commented 6 years ago

Add the ability to conditionally compile code (e.g. fields and/or methods) based on whether the C# code is targeting the onchain Stratis SmartContract framework or the code is to be used offchain.

#if STRATSC
...
#else
...
#endf

...for example, structs/fields/methods for onchain and offchain data management to support an onchain-offchain symmetric programming and data management model.

Reference: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-if#examples

CC: @codingupastorm

dangershony commented 6 years ago

I don't think there will ever be a case to run a smart contract off-chain, can you give examples?

Onchain is limiting very much what can be executed so why limit yourself for offchain execution. Also is there a need to have determinisem in offchian scenarious?

Basically off chain IMO just means typical programs we normally use C# for.

mwherman2000 commented 6 years ago

My specific goal isn't to be able to run an "as is" SC offchain but rather have significant data management components (e.g. entity serialization) be able to be used on-chain and off-chain supporting different persistence providers (e.g. Stratis SC on-chain storage, NEO SC on-chain storage, #DIYDLT on-chain storage, SQL Server or mysql off-chain storage, JSON files, SharePoint lists, Salesforce custom objects, etc.)

My enterprise distributed applications model looks like this (conceptual architecture)....

image

mwherman2000 commented 6 years ago

That being said, the test harness for the SSC Visual Studio template is pretty interesting. I've already created a version of it that persists all of the SSC storage operations to JSON ...why not also support a SQL Server back end? ...or Salesforce?

Smart Data = Entities wrapped in code ....on-chain or off-chain.

mwherman2000 commented 6 years ago

Here's another use case: To remove support for selected SSC-specific blacklisted data types from my cross-platform data management code.

rowandh commented 5 years ago

Closing as we're of the view that preprocessor directives would add unnecessary complexity to contract development and we have no plans to support them.

That said, it's easy for anyone to modify the CSharpParseOptions passed to the syntax tree parser and add their own preprocessor directives if they desire.