deroproject / DIPS

Dero Improvements Proposals.
4 stars 5 forks source link

DERO Virtual Machine Inbuilt Functions Suggestions #1

Open CaptainDero opened 4 years ago

CaptainDero commented 4 years ago

DVM(DERO Virtual Machine) Enhancements

Suggestions are invited for inbuilt functions for DERO Virtual Machine DVM which will enhance DVM and take it closer to some real use cases.

DERO Virtual Machine (DVM)

DERO Virtual Machine represents entire DERO Smart Contracts eco-system which runs on the DERO block chain.

Read more about DVM and DERO Smart Contracts.

DVM Documentation

DVM is a decentralized platform that runs both public and private smart contracts: applications that run exactly as programmed without any possibility of downtime, censorship, fraud or third-party interference.Public Smart contracts are open versions. However, the DVM is being designed to support Private Smart Contracts where everything is hidden, eg parties, and information involved. Smart Contracts are nothing but rules which apply on transacting parties.

Current version of DVM is an interpretor based system to avoid security vulneribilities, issues and compiler backdoors. This also allows easy audits of Smart Contracts for quality,bug-testing and security assurances. DVM supports a new language DVM-BASIC.

DVM apps run on a from scratch custom built privacy supporting, encrypted blockchain, an enormously powerful shared global infrastructure that can move value around and represent the ownership of assets/property without leaking any information.No one knows who owns what and who transferred to whom.

Example Factorial program

' This is a comment
// This comment is supported
/* this is multi-line comment  */
 Function Factorial(s Uint64) Uint64   // this is a commment
    10  DIM result,scopy as Uint64     /* this is also comment */
    15  LET scopy =  s
    20  LET result = 1
    30  LET result = result * s
    40  LET s = s - 1
    50  IF s >= 2 THEN GOTO 30
    60  PRINTF "FACTORIAL of %d = %d" scopy result 
    70  RETURN result
End Function

DVM are written in a DVM-BASIC custom BASIC style language with line numbers.

DVM supports uint64 and string data-types.

DVM interprets the smart-contract and processes the SC line-line

A SC execution must return 0 to persist any changes made during execution. During execution, no panics should occur.

CaptainDero commented 4 years ago

Read and learn more about DERO DVM and Smart Contracts on stargate testnet.

lory7741 commented 4 years ago

IDEA FOR DVM:

IDEA FOR DERO PROJECT:

lory7741 commented 4 years ago

about random number, is it possible to use next tx block hash to create the random number?

i found also an interesting paper about random number on bitcoin

2015-1015.pdf

1902.07986.pdf

WEBSITES: https://www.ginar.io/ https://www.cloudflare.com/leagueofentropy/ https://blocking.net/7155/ethereum-2-0-randomness/

Nelbert442 commented 4 years ago

While we did come together and make functions for errors and returning balances when they occurred during testing earlier this year, I know there was once discussion about solving this issue to where if a SC errored out, the sent value(s) would be returned.

just to expand on what I was mentioning, I know one example was this and I believe others had some other similar versions as well:

error function: https://github.com/Nelbert442/DERO_Stargate_SC/blob/master/timebox_payment.bas#L28

the call of the function supplying value as a parameter: https://github.com/Nelbert442/DERO_Stargate_SC/blob/master/timebox_payment.bas#L87

Slixe commented 4 years ago
ghost commented 4 years ago
lory7741 commented 4 years ago

DERO API/SDK for dapp developers

https://www.programmableweb.com/category/blockchain/sdks

examples: https://github.com/eosio/eosio-java https://developer.samsung.com/blockchain/platform

Lebowski1234 commented 4 years ago

Hashing functions:

SHA-256 Keccak-256

Also function to convert string to bytes for input into hashing functions.

pojira commented 4 years ago

BLOCK_TIMESTAMP := get the unix time (uint64) of a block from within a smart contract

rationale:

alongside BLOCK_HEIGHT, it would be useful to have BLOCK_TIMESTAMP, because block times can change and it's useful to make smart contract actions conditional on time

as a concrete example, I'm looking at implementing a 'Harberger tax' smart contract for digital asset ownership, in which owners periodically engage in a kind of auction. but i don't want the auction period to be dependent on the block time.

something like BLOCK_HEIGHT that just returns the unix timestamp of the last block would be ideal: the condition would be something like "on the first block after timestamp T, allow [or disallow] action A".

action A would be something like "user makes a bid", but only within a particular time window.

pojira commented 4 years ago

VALIDATE_SIGNATURE(DATA, SIGNATURE, ADDRESS) := returns TRUE if SIGNATURE is valid from ADDRESS on DATA, otherwise FALSE

rationale:

to perform smart contract actions on the basis of external data, it will often be necessary for some 'oracle' to supply the data. but we do not want to bloat the blockchain with storage of this data. alternatively, we can have the oracle sign the data (DATA) with a private key corresponding to a dero address (ADDRESS). the smart contract user can then supply the data DATA and the resulting signature SIGNATURE in the relevant smart contract call, and then the smart contract can validate the data by checking that the signature is valid using VALIDATE_SIGNATURE. the smart contract can then perform the desired action without requiring DATA to be stored by the oracle in the on-chain database.

pojira commented 4 years ago

I also second the suggestion for permitting smart contract functions to call functions from other smart contracts. This allows some contract to supply services to other contracts which can consume them, and is a key ingredient in the vibrancy of the Ethereum ecosystem. See the links below.

A related feature is the ability on Ethereum for a contract to deploy new contracts. Effectively, in Ethereum, smart contracts are no less powerful than human agents.

https://dappsforbeginners.wordpress.com/tutorials/interactions-between-contracts/ https://zupzup.org/smart-contract-interaction/ https://ethereum.stackexchange.com/questions/44383/creating-a-function-that-calls-another-contract

Lebowski1234 commented 3 years ago

Can I please make a feature request for two functions to be added to the Golang code:

  1. In walletapi package: function for signing a hash (e.g. Keccak256) with an account and returning the signature.

  2. Function that takes a hash and signature as inputs, and returns the account address that was used to produce the signature.

The usage of these two functions would be proving that a given address has signed the hash of a string. To be clear, these functions are not DVM functions, but are Golang library functions for other software that imports dero. They would be used off-chain.

Cryptomancien commented 3 years ago
derotester commented 3 years ago

FUNCTIONS TO ADD:

Uint64 SC_DERO_BALANCE(): return dero balance in SC wallet

Uint64 SC_TOKEN_BALANCE(): return token balance in SC wallet

SEND_TOKEN_TO_ADDRESS(a String, amount Uint64): send token deposited in SC wallet

BURN_SC_TOKEN or BURN_VALUE(amount Uint64): burn token deposited in SC wallet

similar to send_token_to_address a registred tx that prove the burn

BURN_SC_DERO or BURN_DERO(amount Uint64): burn token deposited in SC wallet

similar to send_token_to_address a registred tx that prove the burn

LadTy commented 3 years ago

What was already mentioned but I would find really useful:

Additional (very important to me):