Skip to content

Commit

Permalink
Merge pull request #89 from jnordberg/system-contracts
Browse files Browse the repository at this point in the history
Bios boot
  • Loading branch information
thekevinbrown authored Oct 9, 2019
2 parents e4fe7cf + 16cc6eb commit a5b162c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/cli/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ const versionFromUrl = (url: string) => {
/**
* Constructs the name of the current Lamington Docker image
* @author Kevin Brown <github.com/thekevinbrown>
* @author Johan Nordberg <github.com/jnordberg>
* @returns Docker image name
*/
const dockerImageName = async () => {
await ConfigManager.loadConfigFromDisk();

return `lamington:eos.${versionFromUrl(ConfigManager.eos)}-cdt.${versionFromUrl(
ConfigManager.cdt
)}`;
)}-contracts.${ConfigManager.contracts}`;
};

/**
Expand All @@ -84,6 +85,7 @@ export const imageExists = async () => {
* Configures and builds the docker image
* @author Kevin Brown <github.com/thekevinbrown>
* @author Mitch Pierias <github.com/MitchPierias>
* @author Johan Nordberg <github.com/jnordberg>
*/
export const buildImage = async () => {
// Log notification
Expand All @@ -92,14 +94,25 @@ export const buildImage = async () => {
await rimraf(TEMP_DOCKER_DIRECTORY);
await mkdirp(TEMP_DOCKER_DIRECTORY);
// Write a Dockerfile so Docker knows what to build.
const systemDeps = [
'build-essential',
'ca-certificates',
'cmake',
'curl',
'git',
'wget',
]
await writeFile(
path.join(TEMP_DOCKER_DIRECTORY, 'Dockerfile'),
`
FROM ubuntu:18.04
RUN apt-get update --fix-missing && apt-get install -y --no-install-recommends wget curl ca-certificates
RUN apt-get update --fix-missing && apt-get install -y --no-install-recommends ${systemDeps.join(' ')}
RUN wget ${ConfigManager.cdt} && apt-get install -y ./*.deb && rm -f *.deb
RUN wget ${ConfigManager.eos} && apt-get install -y ./*.deb && rm -f *.deb
RUN eos_ver=$(ls /usr/opt/eosio | head -n 1); \
git clone --depth 1 --branch ${ConfigManager.contracts} https://github.com/EOSIO/eosio.contracts.git /usr/opt/eosio.contracts &&\
cd /usr/opt/eosio.contracts && ./build.sh -e "/usr/opt/eosio/$eos_ver" -c /usr/opt/eosio.cdt
RUN apt-get clean && rm -rf /tmp/* /var/tmp/* && rm -rf /var/lib/apt/lists/*
`.replace(/\t/gm, '')
);
Expand Down
10 changes: 10 additions & 0 deletions src/configManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const CONFIGURATION_FILE_NAME = '.lamingtonrc';
export interface LamingtonConfig {
cdt: string;
eos: string;
contracts: string;
keepAlive?: boolean;
outDir?: string;
exclude?: Array<string>;
Expand All @@ -49,6 +50,7 @@ export enum LamingtonDebugLevel {
const DEFAULT_CONFIG = {
eos:'',
cdt:'',
contracts:'v1.8.0-rc1',
debug:LamingtonDebugLevel.NONE,
debugTransactions: false,
keepAlive: false,
Expand Down Expand Up @@ -183,6 +185,14 @@ export class ConfigManager {
return (ConfigManager.config && ConfigManager.config.cdt) || '';
}

/**
* Returns the current eosio.contracts configuration
* @author Johan Nordberg <github.com/jnordberg>
*/
static get contracts() {
return (ConfigManager.config && ConfigManager.config.contracts) || 'master';
}

/**
* Returns the container keep alive setting or false
* @author Mitch Pierias <github.com/MitchPierias>
Expand Down
31 changes: 30 additions & 1 deletion src/scripts/init_blockchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ nodeos -e -p eosio -d /mnt/dev/data \
--max-transaction-time=1000 \
--http-validate-host=false \
--plugin eosio::producer_plugin \
--plugin eosio::producer_api_plugin \
--plugin eosio::chain_api_plugin \
--plugin eosio::http_plugin \
--http-server-address=0.0.0.0:8888 \
Expand All @@ -34,10 +35,38 @@ do
sleep 1s
done

syskey_pub=EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
syskey_priv=5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
contracts_dir=/usr/opt/eosio.contracts/build/contracts

echo "=== lamington: setup wallet: lamington ==="
# First key import is for eosio system account
cleos wallet create -n eosiomain --to-console | tail -1 | sed -e 's/^"//' -e 's/"$//' > eosiomain_wallet_password.txt
cleos wallet import -n eosiomain --private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
cleos wallet import -n eosiomain --private-key $syskey_priv

echo "=== lamington: create system accounts ==="
declare -a system_accounts=("bpay" "msig" "names" "ram" "ramfee" "saving" "stake" "token" "vpay" "rex")
sleep 1s
for account in "${system_accounts[@]}"; do
cleos create account eosio "eosio.$account" $syskey_pub
done

echo "=== lamington: activate protocol features ==="
curl --silent --output /dev/null -X POST localhost:8888/v1/producer/schedule_protocol_feature_activations \
-d '{"protocol_features_to_activate": ["0ec7e080177b2c02b278d5088611686b49d739925a92d9bfcacd7fc6b74053bd"]}'
sleep 2s

echo "=== lamington: install system contracts ==="
cleos set contract eosio "$contracts_dir/eosio.system" -p eosio@active
cleos set contract eosio.token "$contracts_dir/eosio.token"
cleos set contract eosio.msig "$contracts_dir/eosio.msig"

echo "=== lamington: create tokens ==="
cleos push action eosio.token create '[ "eosio", "1000000000.0000 EOS"]' -p eosio.token
cleos push action eosio.token issue '["eosio", "100000000.0000 EOS", "memo"]\' -p eosio

echo "=== lamington: init system contract ==="
cleos push action eosio init '[0, "4,EOS"]' -p eosio@active

# put the background nodeos job to foreground for docker run
fg %1

0 comments on commit a5b162c

Please sign in to comment.