Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

DAO fork support #970

Merged
merged 10 commits into from
Jul 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ var filenameLowercase = 'mist';
var filenameUppercase = 'Mist';
var applicationName = 'Mist';
var electronVersion = '1.2.5';
var gethVersion = '1.4.7';
var gethVersion = '1.4.10';
var nodeUrls = {
'darwin-x64': 'https://github.com/ethereum/go-ethereum/releases/download/v1.4.7/geth-OSX-2016061509421-1.4.7-667a386.zip',
'linux-x64': 'https://github.com/ethereum/go-ethereum/releases/download/v1.4.7/geth-Linux64-20160615125500-1.4.7-667a386.tar.bz2',
'win32-x64': 'https://github.com/ethereum/go-ethereum/releases/download/v1.4.7/Geth-Win64-20160615094032-1.4.7-667a386.zip',
'linux-ia32': 'https://bintray.com/karalabe/ethereum/download_file?file_path=geth-1.4.7-stable-667a386-linux-386.tar.bz2',
'win32-ia32': 'https://bintray.com/karalabe/ethereum/download_file?file_path=geth-1.4.7-stable-667a386-windows-4.0-386.exe.zip'
'darwin-x64': 'https://github.com/ethereum/go-ethereum/releases/download/v1.4.10/geth-OSX-20160716155225-1.4.10-5f55d95.zip',
'linux-x64': 'https://github.com/ethereum/go-ethereum/releases/download/v1.4.10/geth-Linux64-20160716160600-1.4.10-5f55d95.tar.bz2',
'win32-x64': 'https://github.com/ethereum/go-ethereum/releases/download/v1.4.10/Geth-Win64-20160716155900-1.4.10-5f55d95.zip',
'linux-ia32': 'https://bintray.com/karalabe/ethereum/download_file?file_path=geth-1.4.10-stable-5f55d95-linux-386.tar.bz2',
'win32-ia32': 'https://bintray.com/karalabe/ethereum/download_file?file_path=geth-1.4.10-stable-5f55d95-windows-4.0-386.exe.zip'
};

var osVersions = [];
Expand Down
1 change: 1 addition & 0 deletions interface/.meteor/dev_bundle
2 changes: 1 addition & 1 deletion interface/.meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ecmascript-runtime@0.2.11
ejson@1.0.12
ethereum:accounts@0.3.10
ethereum:blocks@0.3.1
ethereum:dapp-styles@0.5.5
ethereum:dapp-styles@0.5.6
ethereum:elements@0.7.1
ethereum:tools@0.5.2
ethereum:web3@0.15.3
Expand Down
35 changes: 35 additions & 0 deletions interface/client/styles/forkChoice.import.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.fork-choice {
padding: @gridHeight @gridWidth;
text-align: justify;

h1 {
line-height: 1.2;
font-size: 180%;
padding-top: @gridHeight;
}

.dapp-block-button {
margin-top: @gridHeight;
width: 100%;
}

h3 {
color: @colorGrayDark;
}

.row p {
text-align: center;
}

.fork-whatever {
text-align: center;
font-weight: 500;
text-transform: uppercase;
padding-top: @gridHeight*1.5;
}

a {
font-weight: 600;
}

}
3 changes: 2 additions & 1 deletion interface/client/styles/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
@import 'menu.import.less';
@import 'browserbar.import.less';
@import 'popupWindows.import.less';
@import 'animations.import.less';
@import 'animations.import.less';
@import 'forkChoice.import.less';
37 changes: 7 additions & 30 deletions interface/client/templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,13 @@ Template.body.helpers({
if(_.isEmpty(location.hash)) {
$('title').text('Mist');
return 'layout_main';
}
if(~location.hash.indexOf('#loadingWindow')) {
return 'popupWindows_loadingWindow';
}
if(~location.hash.indexOf('#updateAvailable')) {
return 'popupWindows_updateAvailable';
}
if(~location.hash.indexOf('#splashScreen')) {
return 'popupWindows_splashScreen';
}
if(~location.hash.indexOf('#onboardingScreen')) {
return 'popupWindows_onboardingScreen';
}
if(~location.hash.indexOf('#importAccount')) {
return 'popupWindows_importAccount';
}
if(~location.hash.indexOf('#about')) {
return 'popupWindows_about';
}
if(location.hash === '#requestAccount') {
// $('title').text(TAPi18n.__('mist.popupWindows.requestAccount.title')
return 'popupWindows_requestAccount';
}
if(location.hash === '#unlockMasterPassword') {
// $('title').text(TAPi18n.__('mist.popupWindows.requestAccount.title')
return 'popupWindows_unlockMasterPassword';
}
if(location.hash === '#sendTransactionConfirmation') {
// $('title').text(TAPi18n.__('mist.popupWindows.requestAccount.title')
return 'popupWindows_sendTransactionConfirmation';
} else {
var renderWindow = location.hash.match(/#([a-zA-Z]*)_?/);

if (renderWindow.length>0)
return 'popupWindows_' + renderWindow[1];
else
return false;
}
}
});
Expand Down
33 changes: 33 additions & 0 deletions interface/client/templates/popupWindows/forkChoice.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template name="popupWindows_forkChoice">
<div class="fork-choice main-content">
<div class="col col-12">
<h1> {{i18n "mist.popupWindows.daoFork.title"}} </h1>
<p> {{{i18n "mist.popupWindows.daoFork.overview"}}} </p>
<p> {{{i18n "mist.popupWindows.daoFork.choice"}}} </p>
<p> <a href="https://www.ethereum.org/agreement" target="_blank">{{i18n "mist.popupWindows.daoFork.disclaimer"}} </a> </p>
<h3> {{i18n "mist.popupWindows.daoFork.question"}} </h3>
</div>

{{#if randomizer}}
<div class="row clear">
<div class="col col-6 fork-no">
<button class="dapp-block-button"> {{{i18n "mist.popupWindows.daoFork.no"}}} </button>
</div>
<div class="col col-6 fork-yes">
<button class="dapp-block-button"> {{{i18n "mist.popupWindows.daoFork.yes"}}} </button>
</div>
</div>
{{else}}
<div class="row clear">
<div class="col col-6 fork-yes">
<button class="dapp-block-button"> {{{i18n "mist.popupWindows.daoFork.yes"}}} </button>
</div>
<div class="col col-6 fork-no">
<button class="dapp-block-button"> {{{i18n "mist.popupWindows.daoFork.no"}}} </button>
</div>
</div>
{{/if}}

</div>
</template>

34 changes: 34 additions & 0 deletions interface/client/templates/popupWindows/forkChoice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

Template['popupWindows_forkChoice'].onCreated(function(){


})


Template['popupWindows_forkChoice'].events({
/**
Select DAO fork

@events
*/
'click .fork-yes button': function(){
ipc.send('forkChoice_choosen', 'true');
},
/**
Reject DAO fork

@events
*/
'click .fork-no button': function(){
ipc.send('forkChoice_choosen', 'false');
},
/**
Follow default

@events
*/
'click .fork-whatever a': function(e){
e.preventDefault();
ipc.send('forkChoice_choosen', null);
}
});
10 changes: 10 additions & 0 deletions interface/i18n/mist.en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,17 @@
"wrongPassword": "Wrong password.",
"importFailed": "Couldn't import the file, got: __error__"
}
},
"daoFork" : {
"title": "Important decision affecting your app",
"overview": "A new community-created blockchain will be available for activation at block #1920000, which is expected to arrive on July 20th 2016, in which the Ether balance of contract 0xbb9bc244d798123fde783fcc1c72d3bb8c189413 (commonly referred to as \"The DAO\") and all of its descendants will be moved to a withdraw contract due to an exploited bug in the original contract. This should restore funds from all contracts linked to the exploit and allow authenticated holders of \"The DAO\" tokens to redeem it for ether.",
"choice" : "<strong> This is a settings configuration, <em>not a vote</em></strong>, meaning that your wallet will operate on the blockchain of your choosing regardless of any other user's choice. Your ether and assets will exist in both chains and you will be able to switch back at a later date by resyncing your wallet.",
"question": "Do you want to activate the chain in which funds linked to the exploit are restored to a contract where they can be withdrawn by \"The DAO\" token holders?",
"disclaimer": "DISCLAIMER: READ BEFORE PROCEEDING",
"yes": "yes",
"no": "no"
}

}
},
"elements": {
Expand Down
52 changes: 52 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,62 @@ app.on('ready', function() {
// update menu, to show node switching possibilities
appMenu();
})
// FORK RELATED
.then(function hardForkOption() {
// open the fork popup
if (ethereumNode.isMainNetwork && !ethereumNode.daoFork) {

return new Q((resolve, reject) => {
var forkChoiceWindow = Windows.createPopup('forkChoice', {
primary: true,
electronOptions: {
width: 640,
height: 600,
},
});

forkChoiceWindow.on('close', function(){
app.quit();
});

// choose the fork side
ipc.on('forkChoice_choosen', function(e, daoFork) {
// prevent that it closes the app
forkChoiceWindow.removeAllListeners('close');
forkChoiceWindow.close();

ipc.removeAllListeners('forkChoice_choosen');

log.debug('Enable DAO Fork? ', daoFork);

// no need to restart
if(!daoFork)
return resolve();

// set forkside
ethereumNode.daoFork = daoFork;

// start node
ethereumNode.restart(ethereumNode.type, 'main')
.then(function nodeRestarted() {
appMenu();

resolve();
})
.catch((err) => {
log.error('Error restarting node', err);

reject(err);
});
});
});
}
})
.then(function getAccounts() {
return ethereumNode.send('eth_accounts', []);
})
.then(function onboarding(resultData) {

if (ethereumNode.isGeth && resultData.result && resultData.result.length === 0) {
log.info('No accounts setup yet, lets do onboarding first.');

Expand Down
16 changes: 16 additions & 0 deletions modules/ethereumNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,14 @@ class EthereumNode extends EventEmitter {
* @return {Promise}
*/
init () {


const ipcPath = getIpcPath();

// TODO: if connection to external node is successful then query it to
// determine node and network type

// check if the node is already running
return this._socket.connect({path: ipcPath})
.then(()=> {
this.state = STATES.CONNECTED;
Expand All @@ -140,6 +143,7 @@ class EthereumNode extends EventEmitter {
log.info(`Node type: ${this.defaultNodeType}`);
log.info(`Network: ${this.defaultNetwork}`);

// if not, start node yourself
return this._start(this.defaultNodeType, this.defaultNetwork)
.catch((err) => {
log.error('Failed to start node', err);
Expand Down Expand Up @@ -288,6 +292,9 @@ class EthereumNode extends EventEmitter {
this._saveUserData('node', this._type);
this._saveUserData('network', this._network);

// FORK RELATED
this._saveUserData('daoFork', this.daoFork);

return this._socket.connect({ path: ipcPath }, {
timeout: 30000 /* 30s */
})
Expand Down Expand Up @@ -370,6 +377,10 @@ class EthereumNode extends EventEmitter {
args = (nodeType === 'geth')
? ['--fast', '--cache', '512']
: ['--unsafe-transactions'];

// FORK RELATED
if(nodeType === 'geth' && this.daoFork)
args.push((this.daoFork === 'true') ? '--support-dao-fork' : '--oppose-dao-fork');
}

let nodeOptions = Settings.nodeOptions;
Expand Down Expand Up @@ -502,6 +513,9 @@ class EthereumNode extends EventEmitter {

this.defaultNodeType = Settings.nodeType || this._loadUserData('node') || DEFAULT_NODE_TYPE;
this.defaultNetwork = Settings.network || this._loadUserData('network') || DEFAULT_NETWORK;

// FORK RELATED
this.daoFork = this._loadUserData('daoFork');
}


Expand All @@ -521,6 +535,8 @@ class EthereumNode extends EventEmitter {


_saveUserData (path, data) {
if(!data) return; // return so we dont write null, or other invalid data

const fullPath = this._buildFilePath(path);

try {
Expand Down
33 changes: 31 additions & 2 deletions modules/menuItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ var createMenu = function(webviews) {
};


const restartNode = function(newType, newNetwork) {
const restartNode = function(newType, newNetwork, daoFork) { // FORK RELATED
newNetwork = newNetwork || ethereumNode.network;

// FORK RELATED
if(daoFork)
ethereumNode.daoFork = daoFork;

log.info('Switch node', newType, newNetwork);

return ethereumNode.restart(newType, newNetwork)
Expand Down Expand Up @@ -350,7 +354,7 @@ var menuTempl = function(webviews) {
label: i18n.t('mist.applicationMenu.develop.ethereumNode'),
submenu: [
{
label: 'Geth 1.4.7 (Go)',
label: 'Geth 1.4.10 (Go)',
checked: ethereumNode.isOwnNode && ethereumNode.isGeth,
enabled: ethereumNode.isOwnNode,
type: 'checkbox',
Expand Down Expand Up @@ -396,6 +400,31 @@ var menuTempl = function(webviews) {
}
]});

// add fork support
devToolsMenu.push({
label: i18n.t('"The DAO" Fork'),
submenu: [
{
label: 'Support DAO Fork',//i18n.t('mist.applicationMenu.develop.mainNetwork'),
checked: ethereumNode.isOwnNode && (ethereumNode.daoFork !== 'false'),
enabled: ethereumNode.isOwnNode && (ethereumNode.daoFork === 'false'),
type: 'checkbox',
click: function(){
restartNode(ethereumNode.type, ethereumNode.network, 'true');
}
},
{
label: 'Don\'t Support DAO Fork',
checked: ethereumNode.isOwnNode && (ethereumNode.daoFork === 'false'),
enabled: ethereumNode.isOwnNode && (ethereumNode.daoFork !== 'false'),
type: 'checkbox',
click: function(){
restartNode(ethereumNode.type, ethereumNode.network, 'false');
}
}
]});


devToolsMenu.push({
label: (global.mining) ? i18n.t('mist.applicationMenu.develop.stopMining') : i18n.t('mist.applicationMenu.develop.startMining'),
accelerator: 'CommandOrControl+Shift+M',
Expand Down
Loading