EOS - Developer’s Log Stardate 201707.3

in #eos7 years ago (edited)

Today I met with the team to discuss the challenges of making smart contracts both easy to develop and easy to execute in parallel. If you are familiar with the challenges associated with parallel execution then you know the general rule that all data must be owned by a single thread. In terms of blockchains, that means all accounts need to own their data. Owning data means that no other thread of execution may read or write the data except by asynchronous message passing.

The Current Balance Problem

Suppose you want to read the current balance of another contract, something that seems like it should be trivial. If the balance is “owned” by another account, say the currency contract, then your contract cannot “read it”. You could attempt to query it by asynchronous communication, but that would be liking sending your bank a letter asking for a balance update and waiting for a response in the mail. By the time you get the response (if you get a response), the balance may already be out of date.

Fortunately, EOS makes it easy for one account to monitor all deposits and withdraws. In this case the reader contract would maintain its own logic duplicating the balance calculation and storage of the currency contract. This approach is also error prone because any small difference in behavior could result in your balance calculation differing from the currency contract.

Another alternative is to use an oracle that will notify your contract of the balance while simultaneously delivering a message to the currency contract. The currency contract will reject the transaction if the oracle lied, therefore, your contact can trust the balance reported. Once again this only lets you know the balance for the split second your transaction is applied and creates a new problem that your transaction can be invalidated if other user actions are modifying your balance at the same instance.

The underlying challenge here is that the balance data is owned by a different thread and therefore it cannot be reliably read and used when needed.

Redefining the Problem

Under the above model, all data is owned by a single account and its code. This makes each account like its own blockchain and communication among accounts tricky. Fortunately, GPU developers have used another parallelization strategy: SMID - single instruction multiple data. Stated more generally, a GPU executes the exact same code over many independent instances of the data. Every pixel and/or vertex is modified by the same set of instructions.

Imagine for a moment that every account balance was represented as pixel in an image. Imagine that a smart contract was defined like a shader. A pixel shader can only write to a single pixel, but it can read from any number of other read-only sources.

Under this model a currency contract is not defined as code that operates on a mapping of account name to balance, but instead as code that operates on a single balance belonging to a single account. The currency contract would not be able to read other accounts balances, but it would know with certainty that all accounts were running the same code.

What would such a contract look like?

void apply_simplecoin_transfer() {
   static Transfer message;
   static uint64_t balance = 0;
   load( thisContract(), “balance”, balance );
   
   readMessage( message  );
   requireNotify( {message.from, message.to} );
   
   if( thisAccount() == message.to ) {
      balance += message.amount;
   } else if ( thisAccount() == message.from ) {
      assert( message.amount < balance, "insufficient funds" )
      balance -= message.amount;
   }
   
   if( balance ) store( “balance”, balance );
   else remove( “balance”, balance );
}

Notice there are a few subtle differences:

  1. The apply method only modifies a single balance
  2. The behavior of the contract depends upon the value of thisAccount()
  3. The load() method takes an extra parameter specifying the current contract
  4. The store() and remove() methods always use the “balance” key rather than an account key.

If we assume all accounts run this exact same code on their private data, we can still guarantee that there are no double spends. This is possible because every account requires both the sender and receiver to be notified of the message or the message will be rejected (both parties can be notified in parallel).

The receiver knows that the sender must have sufficient funds or the receiver will reject the message; therefore, the receiver can safely increment its own balance. Likewise, the sender knows the receiver will increment his balance so he decrements his own.

What does this give us?

Well now that we have this design pattern we have separated “code” from “data” in terms of parallelization. A single account can now run code provided by other accounts and the code provided by other accounts can now read all data belonging to an account.

Suppose you wanted to build a social media platform where vote weight is proportional to current balance. This is something that requires the social media account to have the ability to read your balance and modify someone else’s post vote totals. In the ideal world it would be nice for @alice to vote for @bob while @sam is voting for @bill. This could be achieved as follows:

void apply_social_vote() {
   readMessage( vote );
   if( vote.for == thisContract() ) {
      load( thisContract(), vote.postid, post );
      post.totalvotes += vote.weight;
      store( vote.postid, post );
   } 
   
   if( vote.voter == thisAccount() ) {
      static uint64_t balance = 0;
      load( "simplecoin", "balance", balance );
      assert( balance >= vote.weight, “insufficient balance for vote weight” );
   }
}

In this case the contract code does two different things depending upon which data it is operating on. If it is operating on the receiver of the vote, then it increments the total votes. If it is operating on the sender, then it simply verifies the vote.weight <= the balance.

It should be noted that the vote receiver is still unable to read the vote giver’s balance. However, in this model two votes can be processed by 4 different accounts in parallel and it will work so long as the voter reports a vote weight that is accurate.

While it may not be possible to read someone else’s balance while modifying your state, it is possible to read your own balance from the “simplecoin” contract from within the “social” contract.

What is everything so complicated?

As programmers we would love to read whatever we want, whenever we want, and let the computer figure things out. The naive approach is to simply put locks around data. If two people “happen” to read the data at the same time, then one will wait for the other. Unfortunately for blockchain developers, the outcome of these race conditions is not deterministic and therefore could break consensus.

A New Hope

There is a way to allow one account to read another account’s balance; the transaction can declare that it requires read access. The blockchain’s transaction scheduler can then ensure that no one that requires write access will execute code at the same time. Using the old approach to simplecoin (one contract owning all the data), this would create a lot of congestion around that contract as everyone needing to read would be blocking those who want to write and everyone would be bottlenecked by a single contract.

However, using the new approach to simplecoin, the probability that two transactions need to access the same account data at the same time is much lower. This will reduce lock contention and maximize throughput.

Conclusion

Parallelism is hard, especially when you need things to be deterministic while accessing shared data. Fortunately, there are solutions available and design patterns proven by those who design GPUs and computer graphics algorithms.

Disclaimer Nothing in this blog post should be construed to imply any particular feature or functionality of the EOS.IO software. All software designs subject to change as necessary.

Sort:  
There are 4 pages
Pages

My apologies, key board shortcuts ended up submitting this before I was done and I had not yet declined payouts.

And why should you not be allowed to be upvoted just like the rest of us? I think your posts are very valuable and we are a legion who thinks the same. Take Our Upvotes! Never Decline!

Agreed.

Because payouts are declined it is obviously unecessary. It is actually helpful to the community. It would be better to say " thank you for declining payouts"

@fyrstikken, self-upvoting might be part of the reasons why a new platform could overtake Steemit > https://steemit.com/steemit/@blockrush/is-wildspark-the-steemit-killer-blockrush

You know what to put in the next update so

Yeah U Are Right Offcoure He Know What To Put In The Next Update so

battletoads

Like a mother apologizing for giving birth. Come on now, Dan! Accept and reap your rewards!

I, personally, knowing that you don't even need it, feel great giving you a 100% upvote. You've navigated the majority of this into existence, and that's something to be proud of. I understand being humble, but you have the right to be proud. You've emancipated and liberated countless human beings with your work. Take time to reflect on that. If you have that ability and execute it, you damn well better believe you have the right to take pride in it all.

Dude, you're spearheading some seriously revolutionary shit. Just saying. It's (well, was) the 4th of July! Independence! Emancipation! Sovereignty! FREEDOM! That is what you are doing. Reward the shit out of this post as hard as you can. You and your Dad are straight up on George Washington levels in my eyes.

The platforms that now exist now give myself, my family, my friends, and those that I care about, and society at large a one way ticket to life, liberty, and the pursuit of happiness. And on a cryptographically secure route! We live in some wild times . . . This is pioneer territory . . .

I guess that I'm just writing to say that I don't think that you should apologize for anything. You all have bestowed upon the Earth something fierce! A tool that two human beings can utilize to facilitate the transfer of value as they see fit. True liberation. Take pride in it, and sleep well.

HAPPY (late) 4TH OF JULYYYY!!!

</drunken4thofJulyRant>

Thank you Dan for keeping us updated.

Congrats by the way for the EOS initial coin offer.
Follow me @Yehey

Go get yourself i nive Dinner @Dan, you've earned it ;)

I had the same thing a few days ago and it was annoying. That's why i normally leave the tags empty until i'm absolutely ready to publish...

i have fallowed you .. and i will vote u
fallow me please and tell me when u do it
tnx

🐳 WhaleBoT says: @ndnd92, warning: vote/follow begging is shunned upon, watch out or I'll EAT YA! 🙁

Mr @Dan, your hard work at Steemit might not last if Steemit does not live to its role in maintaining and development Steemit.
With your attention divided between Steemit and EOS, Steemit is needs Steemit Inc now more than ever. There is a new Steemit killer arising > https://steemit.com/steemit/@blockrush/is-wildspark-the-steemit-killer-blockrush

No need to apologize. Total newbie minnow here, but from what I've seen, Steemit is a win-win environment. The stronger you are, the stronger the community is.

So, enjoy!

Hi thanks for this update, I have been on the edge of whether to invest or not for a while. Now I see it on the exchanges I am a bit confused, is it most probably going to be cheaper if I buy from the ICO or off the exchange or is it anybodys guess? Thanks.

from the EOS.IO website I gather that EOS does not support/encourage any transaction made on exchanges. So I would not risk it (i.e. poloniex, kraken etc..)

Thanks yeh, I've just read Jerry Banfield's post about investing in ICO's and I'm going off them now! Although saying that, everytime a new exciting one pops up I'm like I must have this one! Then the rush dies down again until the next time!

Thank you for the update - great to see this level of communication from a lead dev!

What language do i need to become a eos developer? Have been looking for a learning project to get me back into programming.

Their github repo is mainly C++14. So knowing C++ should be sufficient I think.

When talking about programming does make a headache. But we must understand this.

Even Word press is also ok for beginner or can go with C++ , .net platform etc...

excellent question ,, want an answer too

lots of year of practice with C++ , C and block-chain technology

Cool, will be getting some tonight, glad they have it in Kraken with a few pairs (ETH, BTC, USD, EUR)

Thanks @dan !!

This post received a 2.2% upvote from @randowhale thanks to @dontstopmenow! For more information, click here!

It's always nice to get an update about a project that many are investing in, and knowing that the minds behind said projects are actually truly interested in what they're doing.

Much luck with the new challenges, but if anyone is suited for solving them it's none other than you, Dan.

Cheers.

I agree @crypt0

If this is a ether killer, would it be wise to dump your ether reserves if you are going to hold eos for the long term? Seems counter productive to invest in something thats suppose to be killed by something else your invested in. Its like investing in batamax and vhs at the same time

I look at it as hedging my bets. I love Ethereum and am heavily invested in it, but EOS shows a lot of promise and could solve some of Ethereum's thornier issues. However Ethereum has first mover advantage much like Bitcoin does. I have no idea which smart contracts platform will ultimately win out in the end. So I'm buying both. And I also bought into the Tezos ICO. I think there's a very good chance all 3 investments will be highly profitable. Why own one slice of the smart contract pie when you can stick your fingers in multiple pieces?

It's all depending on your tolerance for risk. For me I just can't handle it. I bought into EOS and there's been so many swings, I can't sleep at night. I don't have much cash right now, so it makes me pretty nervous when I have 30 grand out there. I tried day trading when I should have just held onto it and missed out huge. Sold a bunch at 6 then bought a little bit back at 6 thinking it was on its way up again and it plummeted the last day and a half. Only time will tell.

I have a pretty high tolerance for risk as I try to look at EOS with a long-term perspective. The real value won't come for at least a year anyway after the actual EOS blockchain launches. What we have right now is 100% speculation, pure & simple. 30 grand is a lot; if you're down now, I would just forget about it for a while and check back in a few months to see how things are going.

I screwed up round 0 pretty bad. Bought a ton then sold most of it when trading first started, happy with a roughly 1.5x return and thinking the price would immediately crash. Instead it went up 6x and I was just kicking myself for not holding. Now I've looking to re-buy if we go lower down, or maybe start cost averaging my way back in if we stay at this level for a while.

Sorry to hear that. I wish I just bought some than left for a few days. Sadly my ocd wont let me just forget about it. I am always buying and selling. Have most of my money sitting in ether right now. Bought about 2000 units of eos at around $2.55 a unit. I guess it is a small enough sum where I can just forget about it for 6 months. The challenge is, if it takes the same path that steem did, it will be a long time before it goes back up to $6. Steem has never made its way back up to $3 and its been a year or more.Nevertheless, seeing that a lot of people probably ended up paying $6 plus for their eos, I am pretty sure those people will be holding for the long term

What would be a good rebuy point? You would think anyone actually still left holding bags of eos paid over $3 so anyone that is still in it has no incentive to sell

Now is actually a pretty good rebuy point as it seems to be building a base at this level. I bought back 1000 EOS yesterday when the price briefly dipped below 0.01 ETH/EOS, and will buy more if it continues to hover around the current price.

Bought about 2000 units of eos at around $2.55 a unit.

That's looking like a pretty smart entry point as long as you're willing to let it sit and not looking for a quick flip. If it does go down further from here, then I'll be looking to make a series of small buys, cost averaging my way in and lowering my overall cost basis until we hit bottom. If the price hits the round 0 ICO price or below, I'll pile in with 20 or 30 more ETH.

In the long term, my target is to accumulate 10,000 EOS by the end of the year long ICO. For something like this where it's really hard to predict price swings, I think cost averaging is King. That's basically how I accumulated all my Steem Power, with lots of small buys while the Steem price was falling. And now Steem has turned into my 2nd best investment ever after Ethereum. Happily, the EOS ICO structure is a wet dream for anyone wanting to cost average, as you can just spread your ETH out over time, fire & forget and not worry about the emotional component of trading on the market. So participating in the ICO rounds with small amounts + timed larger buys on the market when price dips = potential winning strategy.

Awesome that's what I plan to do . I started with about 10,000 EOS, sadly now I am only down to 2000 and am sitting on a bunch of ETH I bought at a high point - about $256 per unit. I never got the chance to buy in lower because it took me 2 months to get trading at a large volume amount. Nevertheless thanks for the advice. I will be holding for the year and hopefully this will turn into another ether. I just have to stop looking at the prices on a daily basis and maybe only look once a week lol.

But in fact - what will happen with all the purchased etherium? Will they throw him out for a cheap sale?

I doubt they will dump all at once. That wouldn't make sense; in order to get the most money the EOS team will probably sell gradually so as not to move the market too much.

Thanks for the reponse by the way.

Keep up the great work!

Nice post mate. It's very good to see some techie here.

Much coding will produce much pine sol, Dan unit. Much pin sol. Heterogenous computing is agreeable.

may-the-source-be-with-you.jpg

Much gratitude for free pinesol upvote from @jamesc1. Much pine sol to you!

Nice info. Thanks :)

It seems the Red Belly Blockchain being developed in Sydney may address the timing and attacks issues. Here is their whitepaper if anyone is interested. http://poseidon.it.usyd.edu.au/~concurrentsystems/doc/ConsensusRedBellyBlockchain.pdf

Thanks for the updates. Got in on the EOS ICO, should have bought more in the first 5 day opening period as that was the time to buy 😎

Loading...

I have steemit, bts and Eos will join the party too

Smart move 🍷

i will wait a little bit more and then try my luck

Basically a dan larimer investment. Why not add golos tu the mix? :)

@dan - You're posting again in person... welcome back! ;)

Thanks for your efforts! It is amazing to have such a advance new coin! I like BTS and steemit as they have give me some income. I am going to invest in EOS for my new furture! Hope all of us can be success I think! Keep it! Once again thank you!

My question, for the security of our financial transactions, the manna application is very suitable for us to use, because in these few days many transactions failed in the transaction process, here are some events from my friends, please explain @dan

Amazing you are looking at this from this perspective! Really looking forward. Parallelism efficiency (then performance) is the key problem here. But we also don't want to restrict too much and allow diversity of code execution. The ability to use atomic actions by the blockchain would allow this "efficiency" to scale better. Then it's just matter of aligning the current hardware to the software. And that can be done at driver level by manufactures (or in partnership model, like NVIDIA mostly does).

Very useful for beginners like me, but I have not fully understood the concept and implementation. For newcomers like me, understanding this kind of article is a difficult thing, however I try to follow every development of your comments and posts @dan. This is amazing, happy to keep following every content of your blog and I will follow every development. thanks for sharing

@dan that is what most of the people on @steemit are looking for. U have had a good impression and have sheared a good article in a proper way and proper context. All the best brother. Stay blessed and keep steeming..
@naseerbhat

Well done post You deserve for getting Upvote from me. I appreciate on it and like it so much . Waiting for your latest post. Keep your good work and steeming on. Let's walk to my blog. I have a latest post. Your upvote is high motivation for me. Almost all Steemians do their best on this site. Keep steeming and earning.

This comment has received a 0.08 % upvote from @booster thanks to: @hamzaoui.

It's great to read about the progress being made in parallel execution.

very helpful , eos is very good

I read this, and started nodding along, pretending I knew what you were talking about..... but no..... as I got further in, my brain started feeling twitchy, and my eyes got tired. Please don't tell me I'm the only one :D

Exactly same thing......

Hi man, I think you need to have studied computer science to make much sense of it to be honest ! ;)

Ha hey man. Yeah I think zero knowledge at all is a slight obstacle. Worth a try though

It worked for me, I just read it slow and a few times. Come back and try again though if you think your going to invest in someones contract one day.. Your going to have money in the game. Lol

Okay I'll try again....

Looking forward to more technical updates

I've been seeing a lot of you lately. "I know a good sandwich when I see one"

@dan Does it make me sound like too big of a newb to say that reading this post you have written makes me feel cool, like I have access to some advanced technical lecture or briefing only available to those activiely taking part in changing the wotld. It's dope as fuck how detailed you get into the complexity of not just a durable agreement but the true challenge of how the agreement is automatically executed and tracked on the blockchain? Can I ask you honestly, where do you think EOS will ultimately fall within the smart contract ecosystem? Will there still be a smart contract ecosystem with plenty of room for all the current players (stratis, ETH, ETC, etc...no pun intended)? Or do you see it as winner take all with EOS succeeding where ETH failed?

Very helpful post 👍

thank you Dan for your time and effort to make Steem big
im not very good in writing programs but those who can
have many advantages ! SteemOn

image

How can a little girl defeat the genius human icon that Albert Einstein has been holding? What an unbelievable but real story. Nicole Barr, a 12-year-old from Essex, scored an IQ of 162 on a Mensa IQ test. The score is two points higher than Einstein and the addition of this boy also exceeded the score of genius physicist, Stephen Hawking.

Someone is said to be a genius if he gets an IQ test score above 140. So that means Nicole is really a genius. Her's father, Jim Barr took Nicole to take the test with a premonition that his daughter would be accepted at Mensa.

image

"I hope she can do well. I know she has the speed of mind in solving problems and puzzles. I do not want to press her so we consider this for fun. I had the thought that she would go to Mensa but when I saw the result I thought 'Wow! This is really a high score! '. Until finally I realized that it was the highest score in the test, " said Jim.

Launched from Mashable, a spokesman for Mensa said IQ Nicole took him to the first level of the population. Only children can get more than 161 IQ because it is the maximum IQ for adults. The test Nicole followed was a test for a small child. Even so, @dan
IQ score 162 is rarely found. Nicole herself has an ideals in the field of drama performances. She even practiced in her spare time. But she also has other ideals that step into the medical realm as a pediatrician. Wow so cool 12-year-old child can defeat Einstein. Do you still remember your IQ score?

Thank's for you all steemit friends, don't forget to upvote and comment

good.. keep steemit go further.

So, GPU manufacturing is far from uselessness for crypto.

Nature #Photography
Original photo by @bushkil
image

How abt security Then. Understood its only read only but no harm is knowing the balance???

Hi Dan, I'm not that knowledgable about blockchain processing, but I'm wondering if anything can be learned by studying the way Visa and Mastercard handle the enormous number of transactions they process. These transactions are many magnitudes higher than what we currently see on crypto blockchains. Is there something that could be incorporated from their methods and techniques?

EOS is being designed to process as many transactions as Visa and Mastercard - that is one of EOS's USP's.

That will be awesome

Thanks for the response, this is great news!

hi , pls i am new to steemit and crypto, and blogging is my hobby, you can follow me @dkinx

Follow me and I Follow you and we like

i just followed u,follow me back

If you follow each other, you will be going in a circle:)

don't tell them that, let them produce electricity :D

wow....nice....upvote and resteem

Far to technical for me?,but I hope you sort the problem out because all steemit users will benefit.
I sometimes forget about all the hard work you and your team put into steemit. I would lie to say thanks,keep up the good work it's much appreciated

What is better then to have a stronger gpu or cpu

I love your posts! Keep em coming!!!

Great post. This Eos contract also can reduce a lot of work pressure from block chain miners who have to execute Hashes to confirm transactions.

New EOS Contract would give liberty and better data storage optimisation at both sender and receiver's end.

I understood absolutely everything about that...NOT! However, I read it anyway, so I could decipher enough to know it's relevance & that others are on it! 🤔🤓

Hey friend help me,I just learned steemit.
Promote me .

Would you be recommending Python?

Great Blog, Keep up the good work!

There are 4 pages
Pages