Skip to content

Instantly share code, notes, and snippets.

View romanman's full-sized avatar

Roman Mandeleil romanman

View GitHub Profile
contract Ballot {
// Create a new ballot with $(_numProposals) different proposals.
function Ballot(uint8 _numProposals) {
address sender = msg.sender;
chairperson = sender;
numProposals = _numProposals;
}
// Give $(voter) the right to vote on this ballot.
// May only be called by $(chairperson).
Running 1 test case...
Entering test suite "EthereumTests"
Entering test suite "StateTests"
Entering test case "userDefinedFileState"
*** [ 08:47:54 | main ] Testing user defined test: /root/cpp-poc-7/tests/StateTests/stInitCodeTest.json
=S= [ 08:47:54 | main ] Executing {[CREATE]/0$1+599@1<-a94f5374… #22} on 14cf9687b4d7c09eb76c31dc1eeb7c1ee1b2658b891eda5243852c261f55a754
=S= [ 08:47:54 | main ] f8618001820257800196600a80600c6000396000f200600160008035811a81001ca08a0295e29365e00c233a822920622ec2476f89a2fb8bb2b4a9519c226dedb5a1a010338f935d058199680913c8c864919d2b8d091acd561cddc8a252c72b0326a8
EVM [ 08:47:54 | main ]
STACK
MEMORY
Running 1 test case...
Entering test suite "EthereumTests"
Entering test suite "StateTests"
Entering test case "userDefinedFileState"
*** [ 10:42:42 | main ] Testing user defined test: /root/cpp-poc-7/tests/StateTests/stInitCodeTest.json
=S= [ 10:42:42 | main ] Executing {[CREATE]/0$1+590@3<-a94f5374… #22} on 2974910d080e91cfa47d432d338ce689777dd10e15dc13cd2817edc157aa5b97
=S= [ 10:42:42 | main ] f861800382024e800196600a80600c6000396000f200600160008035811a81001ba0075203471abeffa60d9766fcdd33d4c02050841e2e1f0b86ee13ee72237baa62a07d10656fd6049aecb8e760d35cb9f49efcc3033aa9f587b9762b65190ff4960a
EVM [ 10:42:42 | main ]
STACK
MEMORY
turn:
http://www.ethergit.com/raw-transaction/b609708553831adb3d0f6ddeef1d5e27240288a1d568c6d8f2fd32323e5876ca
into:
http://imgur.com/LLKOA2g
the RLP encode rules can be found here:
https://github.com/ethereum/wiki/wiki/RLP
important points
import org.ethereum.core.Block;
import org.ethereum.core.Genesis;
import org.ethereum.core.Transaction;
import org.ethereum.core.TransactionReceipt;
import org.ethereum.crypto.ECKey;
import org.ethereum.crypto.HashUtil;
import org.ethereum.facade.Ethereum;
import org.ethereum.facade.EthereumFactory;
import org.ethereum.listener.EthereumListenerAdapter;
import org.ethereum.net.p2p.HelloMessage;
{
"encseed" : "957e46d54c10da45351554eb60d731b164043743dfb212ccf1827491a01cf344b390e4ac5af640e4f54ff28b046e48dc84094b99011d72ca79f2da9aa2792f4d2b8545455ca8dbba15d69048b3f95eccfed2d19427abcb2c9483e7491163eb1b",
"ethaddr" : "ba73facb4f8291f09f27f90fe1213537b910065e",
"email" : "[email protected]",
"btcaddr" : "1JEQr5LHrY8yVmWFaB31BVa9Y6sLQ9Kg41"
}
[ {
"op" : "PUSH1",
"pc" : "0",
"gas" : "9375",
"stack" : [ ],
"memory" : "",
"storage" : {
"eb958b3d36129feb1b68fe68dde79c19087eaccb627dfc448f85a46b0d4b9451" : "5b693efb982a0d267a95ba4dae9c70063dc24416613530146521905fe6612da8",
"e508bd3a9bbbca7f989089a584f379340118d1a353f62d70804525d8bc55e26d" : "e7cab0eb11e3b8880441028015bcd3c53bd33bf344c8cbcc6a1a1ad87bd83337",
"755acf8297287fb246a5659b1894b1649a603121941e2ee5aa324060a210b05c" : "064dda2b3c0ce96cc85b8afc9dddfcfd0d7607576c9b6d2ff01f5068e46da780",
private static byte[] decrypt(byte[] data, byte[] key)
{
// 16 bytes is the IV size for AES256
try
{
PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
byte[] ivBytes = new byte[16];
System.arraycopy(data, 0, ivBytes, 0, ivBytes.length); // Get iv from data
byte[] dataonly = new byte[data.length - ivBytes.length];
System.arraycopy(data, ivBytes.length, dataonly, 0, data.length - ivBytes.length);
package test.ethereum.dht;
import org.ethereum.net.dht.Bucket;
import org.ethereum.net.dht.Peer;
import org.junit.Test;
import org.spongycastle.util.encoders.Hex;
import java.util.List;
import static org.ethereum.net.dht.DHTUtils.getAllLeafs;
[8efbc0bd822c0407b2341d5a966e19fc1471c811a467e3431e4dcb597b73c408], [f86e808609184e72a0008201f4940c979a4978b72f3d32516cf5c98d2f1145758db4891b0d04202f47ec0000801ba095af6787ef393c3b1b36badb65f51a0592abfcda9f6d6bab1a8bd67923a32292a052b00cc67397723e668ccd94ef858f3a0d0be135698468041cd0fb7ae1d53e3a]
[ef2188fbe91f8ced97db6d98dbfe76e4ccfa1c6fd83300f1fb545cbb3444a8d5], [f86e018609184e72a0008201f4942a771b44282d515b8067c25eaaf588c9e4c7d8fd890eb0e1682e32dc0000801ca036fb9122d81261931233e970ca033aee67bb97a01208af49ab6c230a138e8919a004c529772996dee84f4b976c8059c78fa0d32bb7afc593cb379f7f7dbb868c87]
[3a03f3d33072c114e950f91019c11cf95343f4210f5bb2dc47d8804b5be086fc], [f86e028609184e72a0008201f4945393c4e20293f941c17afe17223ed1e001260597890929589c9981040000801ca0739b99193fb5b905d1e2b2120cfabeafc439d98df915fe085ae66e6d568ce4cca0f8aac8493764fb48279a50d338162426ed8e3e9f2febff3b7060d0e638221a12]
[95ae99c1f83719c20a8140e085416e12a87624df7c951cbb784f85c096b4ee7f], [f916bd038609184e72a000830186a08080b916696103e85a1215610014576000602052