We had always intended to use a small, tight scripting language to write out contracts for EOS, and the initial choice was Wren. A few weeks back I managed to run a test with an empty contract. This revealed performance of about 1000 transactions per second; far too slow for our target performance.
Over the past couple of weeks the EOS development team has pivoted away from the Wren programming language and embraced Web Assembly. Today we would like to update everyone on the progress and initial results we have achieved.
Background on Web Assembly
Web Assembly is an emerging industry standard backed by Microsoft, Google, and Apple. The goal of this standard is to make it possible to run untrusted high-performance code in your browser. Web Assembly is a game changer, it will enable high performance web applications such as video and image editing and games.
WebAssembly provides a universal compile target that enables applications to be developed in any language. Currently there are compilers for C, C++, and Rust. There is even work going on to compile Solidity to Web Assembly.
EOS Integration
A few weeks ago we introduced a hypothetical currency smart contract written in Wren. Today we will show an actual working implementation written in "C" and compiled to Web Assembly (WASM). We then used EOS transactions to create an account (@simplecoin) and upload the WASM code to the test blockchain.
At this stage of development everything is still in rapid flux and there are some rough edges that will be smoothed out before our official public test network this summer. For example, the message definitions and deserialization boiler plate can be replaced with a simple code generator that takes input similar to our hypothetical example.
That said, here is an example of what the contract looks like in C today:
typedef struct {
AccountName from;
AccountName to;
uint64_t amount;
String* memo;
} Transfer;
void Transfer_unpack( DataStream* ds, Transfer* transfer )
{
AccountName_unpack( ds, &transfer->from );
AccountName_unpack( ds, &transfer->to );
uint64_unpack( ds, &transfer->amount );
String_unpack( ds, &transfer->memo );
}
typedef struct {
uint64_t balance;
} Balance;
/** Constructor called once when code is first uploaded */
void onInit() {
static Balance initial;
static AccountName simplecoin;
AccountName_initCString( &simplecoin, "simplecoin", 10 );
initial.balance = 1000*1000;
store( &simplecoin, sizeof(AccountName), &initial, sizeof(Balance));
}
/** Message handler when Transfer message is delivered to @simplecoin */
void onApply_Transfer_simplecoin() {
static char buffer[100];
int read = readMessage( buffer, 100 ); /** load message content */
static Transfer message;
static DataStream ds;
DataStream_init( &ds, buffer, read );
Transfer_unpack( &ds, &message ); /* unpack it */
static Balance from_balance;
static Balance to_balance;
to_balance.balance = 0;
read = load( &message.from, sizeof(message.from),
&from_balance.balance, sizeof(from_balance.balance) );
assert( read == sizeof(Balance), "no existing balance" );
assert( from_balance.balance >= message.amount, "insufficient funds" );
load( &message.to, sizeof(message.to),
&to_balance.balance, sizeof(to_balance.balance) );
to_balance.balance += message.amount;
from_balance.balance -= message.amount;
if( from_balance.balance )
store( &message.from, sizeof(AccountName),
&from_balance.balance, sizeof(from_balance.balance) );
else
remove( &message.from, sizeof(AccountName) );
store( &message.to, sizeof(message.to),
&to_balance.balance, sizeof(to_balance.balance) );
}
This code was compiled using the WasmFiddle interface to generate the WebAssembly (WASM). It uses several simple API calls such as readMessage
, load
and store
to fetch and store information from the blockchain.
This particular contract will create 1 million coins and allocate them to the account @simplecoin, then it will allow @simplecoin to transfer these coins to other accounts which in turn can transfer them to others.
Initial Benchmarks
I created a unit test that would load this contract and then construct individual transactions to transfer funds from @simplecoin to @init1 1000 times.
auto start = fc::time_point::now();
for( uint32_t i = 0; i < 1000; ++i )
{
eos::chain::SignedTransaction trx;
trx.emplaceMessage("simplecoin", "simplecoin",
vector<AccountName>{"init1"}, "Transfer",
types::Transfer{"simplecoin", "init1", 1+i, "memo"} );
trx.expiration = db.head_block_time() + 100;
trx.set_reference_block(db.head_block_id());
db.push_transaction(trx);
}
auto end = fc::time_point::now();
idump(( 1000*1000000.0 / (end-start).count() ) );
The final result yielded about 50,000 transfers per second average over many different runs. Keep in mind that these early results have many things that impact performance for better and for worse. It is too early to draw conclusions on the final chain performance, but 50,000 sequential actions per second is a lot closer to the area we want to be - Facebook and Visa and so on.
This performance was measured on a 2014 iMac with a 4Ghz Intel Core i7 CPU.
Comparison to Wren
The reason Wren was slower was it had to compile the code every time and there was no easy way to cache the compiled results. It turns out that the speed of Wren is highly dependent upon running a program for a long period of time relative to its initial startup cost. This is the opposite of what we want for a smart contract platform that runs many quick programs.
The WebAssembly library we are using compiles Web Assembly (WASM) into native x86 instructions using the LLVM compiler library. This enables WASM to run at up to 80% of native speed, which is far faster than any interpreted language, and certainly faster if the Just-in-Time (JIT) compilation optimization kicks in for every single run
The Path Forward
Now that we have proven the concept of WebAssembly based contracts and verified that their single threaded performance is already industry leading, we will continue to flush out the APIs we expose to Web Assembly and look at adding support for higher level languages and tools to make it easier for developers than writing in C.
Our initial test networks will focus on stability of code and APIs and will execute contracts within a single thread; however, the design of EOS.IO software architecture will allow us to switch to multi-threaded execution without having to hard fork the blockchain. As you can see from our initial benchmarks, even a single threaded implementation of EOS is still industry leading with plenty of headroom for today’s applications.
Stay Informed
Sign up to our mailing list at https://eos.io to stay informed about the latest developments and the coming EOS Token Sale.
Really excited about EOS!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Yeah I'll be watching this one closely
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@jeremybro, University of Sydney just created a Blockchain capable of 440,000 transactions per second > https://steemit.com/steemit/@blockrush/440-000-transactions-sec-blockchain-by-university-of-sydney-blockrush
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
50,000 Tx per second @ zero transaction fees! Wow, compare that to Bitcoin or Visa.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Bitcoin is going to be much more like gold than Visa. Bitshares, BitUSD, Steem Dollars, EOS etc. are going to be much better ways to carry out normal economic activity on a block chain.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
That certainly seems to be what's happening. I'm anxious to see whether the proposed changes to Bitcoin, in the Bitcoin Scaling agreement actually make it better or worse.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@johnsmith, University of Sydney's new Blockchain could reach over 440,000 transactions per second > https://steemit.com/steemit/@blockrush/440-000-transactions-sec-blockchain-by-university-of-sydney-blockrush
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
going fast like this? ;} signed up to get stay informed in getting latest updates for that EOS Token sale
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
But I thought I saw 300,000 tx/s in the EOS presentation a month ago?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
At this point, bitcoins transaction fees aren't much better than visa's (right this moment, mycelium suggests a $1.81 fee to send $10 worth of Bitcoin). And even when it's not congested, it's definitely a lot slower than visa. :-(
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@dantheman thanks so much for sharing. You are a legend. I want to get in touch with you again with regards to a project
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@penguinpablo, University of Sydney's Blockchain could reach over 440,000 transactions per second > https://steemit.com/steemit/@blockrush/440-000-transactions-sec-blockchain-by-university-of-sydney-blockrush
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
thats some sick stats
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@kingscrown, the a new Blockchain by the university of Sydney is capable of reaching over 440,000 transactions per second > https://steemit.com/steemit/@blockrush/440-000-transactions-sec-blockchain-by-university-of-sydney-blockrush
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Very exciting I am not really up tp date with these scripting languages but from what I am reading Web Assembly looks like a perfect fit.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@carface, let us know of what you think of the new Blockchain by University of Sydney which is capable of reaching over 440,000 transactions per second! > https://steemit.com/steemit/@blockrush/440-000-transactions-sec-blockchain-by-university-of-sydney-blockrush
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Loving these updates as you make progress! Thank you.
Is that how you plan to achieve the "millions of transactions a second" which has been thrown around as a target for massive enterprise scale adoption? So, for example, if you get to something like 75,000 / per second single threaded as the technical upper limit, you could hypothetically reach the desired output by just having multiple nodes and apps/chains (for lack of better terminology) doing things in parallel at the same time in ways that don't conflict with each other?
So much learning Wren. I guess I need to dive back into C. Heheh. :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Yes, millions of TPS is achieved through parallelism and horizontal scalability. If we assume 50K TPS per-thread, then a 128 core single machine may be able to achieve 6M. Of course, there are some sequential steps and other factors that will limit this, but I believe that a 128 core machine will be able to achieve millions of TPS with properly parallelized applications.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks, Dan.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@dantheman, do not forget to check out the Blockchain system by University of Sydney which is capable of over 440,000 transactions per second while supporting both public and private networks > https://steemit.com/steemit/@blockrush/440-000-transactions-sec-blockchain-by-university-of-sydney-blockrush
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Millions of TPS from just single machine? That would be a game changer. EOS is starting to sound better and better.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
And at record low prices
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
hello folks, what do you think of the 440,000 transactions per second Blockchain by University of Sydney? > https://steemit.com/steemit/@blockrush/440-000-transactions-sec-blockchain-by-university-of-sydney-blockrush
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
You can also do WASM with Python
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Not at this time. Here is the list of available compilers
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
You are kinda correct... in that the support is very weak at this time....
at ton of 3rd party modules I tend to install with pip would likely not work... and the feature set and edge cases in creating the bytecode are more rampant than I'd like...
Not counting manually transpiling into C or C++....
... or counting introspection madness in something like this disassembly tool
https://github.com/athre0z/wasm
You got these at least I have seen a few others somewhere might have tried them don't remember...
PyPy.js as WASM bytecode
or
Compile Python -> LLVM -> asm.js -> binary.wasm
It should be noted all the WASM stuff is still fairly new... and I have yet to see a pure WASM VM for Python
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Very limited too bad
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@furion, what do you think of the 440,000 transactions per second Blockchain by the University of Sydney? > https://steemit.com/steemit/@blockrush/440-000-transactions-sec-blockchain-by-university-of-sydney-blockrush
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Moving EOS to Web Assembly is a good strategic choice. No doubt that Wasm can become ultimate web standard in the coming years. So the first decentralized computer which utilizes wasm (if done right) will be able to spawn a lot of exciting innovation on top of it. Happy that you got it @dantheman!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
so invest in EOS when I can?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@hipster, what do you think of the new 440,000 transactions per second Blockchain by the University of Sydney? > https://steemit.com/steemit/@blockrush/440-000-transactions-sec-blockchain-by-university-of-sydney-blockrush
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Amazing, 50,000 transfers per second, this will definitely be the game changer, WebAssembly is the technology to look forward for, glad to learn that EOS is working on it extensively.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Looking at the code , those api are standard c library apis or something that was created for this? How is c code compiled to webassembly ? Is this code available in github?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
It's all on GitHub, we can expose any API we want. Compiled via wasmfiddle. All content in the post.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Looking forward to jumping on the ICO. Thanks to the way the ICO is structured, looks like little fish like me will get our chance to get a piece of this.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
in the future this time is now in the past!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I know bitshares was ...
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
confirmed.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I coded in C, C++ more that a decade ago and moved on to Java and JS. It may be the time to comeback to roots. Thanks for the detailed post. Looking forward to contribute programmatically. See u in DC.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hi Dan, I see your pay out has been declined, I come across this more often at other posts, and now it's even you ?! Why is a payout being declined and how can someone prevent this from happening ? Would love to hear from you.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Cool! You should check out https://github.com/dcodeIO/AssemblyScript it's a subset of typescript compiled down to wasm using binaryen.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Well written article, the last time I programmed anything was in the DOS days, but you wrote this detailed enough, even this old fart could understand it.
Thanks
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I left my programming days back in DOS too.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Next EVM use webassembly.
What are the other strengths in EOS?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
On the one hand, this is a surprise, a good timed one. ;) 50k, and we're talking about sequential tx speed. :O
On the other hand, thanks for introducing web assembly to me, I've never heard of it before, and it's awesome as far as I could tell as a non-programmer.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Wow. This is so awesome.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Transfers be like:
Warp speed!
Good work btw!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Its like the Fiber of blockchains.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @dantheman!
Your post was mentioned in my hit parade in the following category:
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
thats what I like, plenty of technical "meat" - that's the reason I believe in this project. I'm looking forward to see more technical posts and to participate in ico. Keep it up!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Now, I entered the school stage.Good luck with your good posts.I'm looking forward to working with you.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks for the update boss, who know this can be the first Ico to a billion 👀😱🤑
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Sounds like you're making progress
faster than even you were expecting...
@pocketechange
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congrats on the progress so far.
Can't wait to see what is to come!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Frankly speaking, looks like difficult but simultaneously interesting! Thanks, @dantheman! :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
It is good that other compilers arriving. We could see a gazillion of buffer overflow attacks if C was the only option.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Great information right there, thanks for sharing.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Performance is everything when it comes to the scalability that will be required for EOS. Loving the dynamic head on solution to issues!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Just had a look into WASM, that is indeed a game changer. Wow!
Thanks for sharing this update!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
i'm really looking forward to this, btw i love this kind of content keep ti up my man, u'r unique ;)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Awesome stuff! Incredibly excited for EOS! Cheers mate!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@dantheman I remember you saying something among the lines of "Playing with WebAssembly, seems pretty cool" in the Telegram chat, and now we're seeing it being integrates into EOS for amazing new opportunities. You're doing amazing work!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
thanX for the update.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I keep my fingers crossed for stopping. Where to talk about how to produce code that tests ten code?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks @dantheman for keeping us aware of strategic decisions. You mentioned: "adding support for higher level languages and tools to make it easier for developers than writing in C.". I believe it is a very important feature. I suspect that a majority of smart contract developers will prefer kind of L4G scripting langage for most dapps (excluding Ethereum as a DAPP on EOS, of course).
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
so will they run EOS on ethereum or will ethereum be run on EOS ?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Wow web Assembly sounds amazing. Just being able to compile something written in C or C++ and just run it through a web browser with good performance. That would be unbelievable.
Thanks for the update!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
OMGOMGOMG EOSEOSEOS
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I'm officially an EOS hype boy thanks to @matt-a (and I'm still patiently waiting for my sticker!!) . Watched and read everything I could. I'm excited for our future!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hi a noob here, just wondering what the line through the value means? Sorry for silly question! Thanks :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Incredibly excited for the future. Absolute cutting edge and you already have a successful body of work preceding you. Can't wait to dig a little deeper. :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@dantheman, let us know of what you think of the Blockchain by University of Sydney which is capable of over 440,000 transactions a second > https://steemit.com/steemit/@blockrush/440-000-transactions-sec-blockchain-by-university-of-sydney-blockrush
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Very interesting project. Really excited to see people already embracing WASM.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
“Everything the State says is a lie, and everything it has it has stolen.”
― Friedrich Nietzsche
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Crypto Exchange In Australia?
This is a good article on the best crypto exchange Australia!?Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit