The five element Descriptor from Cyrus Adkisson's Solidity walkthrough
Historical Significance
A tutorial contract whose behaviour depends on a compiler quirk rather than on what it says: an uninitialised local array of a value type was given a storage reference, so writing to what looks like a temporary variable writes to slot zero instead. It is the ancestor of the uninitialised storage pointer bug that later cost real money, preserved here in a teaching example where it cost nothing.
Context
Frontier era deployment by Cyrus Adkisson, from his Solidity teaching repository.
Key Facts
Description
A Descriptor from the array passer chapter of cyrusadkisson/solidity-baby-steps, returning uint16[5] filled with 34, 876, 4, 67 and 66. Because solc 0.1.x gave an uninitialised local array of value type a storage reference at slot zero, getDescription writes those five numbers into the contract's own storage before returning them, so this constant function costs gas and is not callable statically. Deployed fifteen minutes before the two three element Descriptors at 0xadccb16c0cc9cc2c419a30f7d58466b7139f91c2 and 0x9fb0b5c0cbbd30a9e8ce9c81c686a797121d69b8.
Source Verified
Heuristic Analysis
The following characteristics were detected through bytecode analysis and may not be accurate.
Frontier Era
The initial release of Ethereum. A bare-bones implementation for technical users.
Bytecode Overview
Verified Source Available
Source verified through compiler archaeology and exact bytecode matching.
View Verification ProofShow source code (Solidity)
// Submitted by EthereumHistory (ethereumhistory.com)
/***
* _ _ ___ ______ _ _ _____ _ _ _____
* | | | |/ _ \ | ___ \ \ | |_ _| \ | | __ \
* | | | / /_\ \| |_/ / \| | | | | \| | | \/
* | |/\| | _ || /| . ` | | | | . ` | | __
* \ /\ / | | || |\ \| |\ |_| |_| |\ | |_\ \
* \/ \/\_| |_/\_| \_\_| \_/\___/\_| \_/\____/
*
* This contract DOES NOT WORK
*/
contract Descriptor {
function getDescription() constant returns (uint16[5]){
uint16[5] somevar;
somevar[0] = 34;
somevar[1] = 876;
somevar[2] = 4;
somevar[3] = 67;
somevar[4] = 66;
return somevar;
}
}
contract ArrayPasser {
address creator;
/***
* 1. Declare a 3x3 map of Tiles
***/
uint8 mapsize = 3;
Tile[3][3] tiles;
struct Tile
{
/***
* 2. A tile is comprised of the owner, elevation and a pointer to a
* contract that explains what the tile looks like
****/
address owner;
uint8 elevation;
Descriptor descriptor;
}
/***
* 3. Upon construction, initialize the internal map elevations.
* The Descriptors start uninitialized.
***/
function ArrayPasser(uint8[9] incmap)
{
creator = msg.sender;
uint8 counter = 0;
for(uint8 y = 0; y < mapsize; y++)
{
for(uint8 x = 0; x < mapsize; x++)
{
tiles[x][y].elevation = incmap[counter];
counter = counter + 1;
}
}
}
/***
* 4. After contract mined, check the map elevations
***/
function getElevations() constant returns (uint8[3][3])
{
uint8[3][3] memory elevations;
for(uint8 y = 0; y < mapsize; y++)
{
for(uint8 x = 0; x < mapsize; x++)
{
elevations[x][y] = tiles[x][y].elevation;
}
}
return elevations;
}
/***
* 5. Load descriptors
***/
function loadDescriptors()
{
Descriptor d = new Descriptor();
for(uint8 y = 0; y < mapsize; y++)
{
for(uint8 x = 0; x < mapsize; x++)
{
tiles[x][y].descriptor = d;
}
}
}
/***
* 6. get Description of a tile at x,y
***/
uint16[5] anothervar;
function getTileDescription(uint8 x, uint8 y)
{
Descriptor desc = tiles[x][y].descriptor; // get the descriptor for this tile
anothervar = desc.getDescription(); // get the description from the descriptor
// TODO validate the description
// TODO convert it to JSON
// save it to a variable for constant retrieval elsewhere
return;
}
/***
* 7. retrieve it
***/
function retrieveAnothervar() constant returns (uint16[5])
{
return anothervar;
}
/**********
Standard kill() function to recover funds
**********/
function kill()
{
if (msg.sender == creator)
{
suicide(creator); // kills this contract and sends remaining funds back to creator
}
}
}External Links
Related contracts
GetBalance
Same deployerCyrus Adkisson experimental getter (Sep 2015) exposing the ether balance of a hardcoded address via getMyBalance(). Verified byte-for-byte with soljson v0.1.1.
0x759ad4...239a87August 26, 2015Contract 0xddcd64...a08e7b
Same deployerThe greeter tutorial contract: it stores a greeting set at deployment and can be shut down by its owner.
0xddcd64...a08e7bAugust 26, 2015basicInfoGetter
Same deployerA tour of the EVM globals, carrying the constructor of the file it was copied from
0xad826c...d33547August 31, 2015Contract 0x3ea0db...b922e0
Same deployerThe basic info getter from the solidity-baby-steps tutorials, a read only window onto the block and message globals.
0x3ea0db...b922e0August 31, 2015Contract 0xba575c...78733f
Same deployerA contract built to probe what the msg globals actually return, endowed with 5 ETH, deployed 1 September 2015.
0xba575c...78733fSeptember 1, 2015Contract 0x8b180c...c084df
Same deployerA third deployment of the msgExaminer that records its own creation message
0x8b180c...c084dfSeptember 1, 2015