Created
February 25, 2019 21:09
-
-
Save bl4ck5un/f4e593043fd06f7bbaf8b9ec42cbff10 to your computer and use it in GitHub Desktop.
Difference between the old and the new cryptokitties' geneScience smart contract
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/old.sol b/new.sol | |
index 0184107..1419bcd 100644 | |
--- a/old.sol | |
+++ b/new.sol | |
@@ -1,16 +1,35 @@ | |
pragma solidity ^0.4.18; | |
- | |
+contract KittyCoreInterface { | |
+ function cooAddress() public returns(address); | |
+} | |
/// @title GeneScience implements the trait calculation for new kitties | |
-/// @author Axiom Zen, Dieter Shirley <[email protected]> (https://github.com/dete), Fabiano P. Soriani <[email protected]> (https://github.com/flockonus), Jordan Schalm <[email protected]> (https://github.com/jordanschalm) | |
+/// @author Axiom Zen, Dieter Shirley <[email protected]> (https://github.com/dete), Fabiano P. Soriani <[email protected]> (https://github.com/flockonus), Jordan Schalm <[email protected]> (https://github.com/jordanschalm), Abhishek Chadha <[email protected]> (https://github.com/achadha235) | |
contract GeneScience { | |
bool public isGeneScience = true; | |
uint256 internal constant maskLast8Bits = uint256(0xff); | |
uint256 internal constant maskFirst248Bits = uint256(~0xff); | |
- function GeneScience() public {} | |
+ // This is the privileged birther address. If this is set to 0, privileged birthing is disabled | |
+ address internal _privilegedBirther; | |
+ // Privileged window size for birthers, set to 5 blocks. | |
+ uint256 public privilegedBirtherWindowSize = 5; | |
+ KittyCoreInterface _kittyCore; | |
+ | |
+ function GeneScience(address _privilegedBirtherAddress, address _kittyCoreAddress) public { | |
+ require(_kittyCoreAddress != address(0)); | |
+ _kittyCore = KittyCoreInterface(_kittyCoreAddress); | |
+ _privilegedBirther = _privilegedBirtherAddress; | |
+ } | |
+ | |
+ /// @dev set the privileged birther address | |
+ /// @param _birtherAddress the new birther address | |
+ function setPrivilegedBirther(address _birtherAddress) public { | |
+ require(msg.sender == _kittyCore.cooAddress()); | |
+ _privilegedBirther = _birtherAddress; | |
+ } | |
/// @dev given a characteristic and 2 genes (unsorted) - returns > 0 if the genes ascended, that's the value | |
/// @param trait1 any trait of that characteristic | |
@@ -99,7 +118,14 @@ contract GeneScience { | |
/// @dev the function as defined in the breeding contract - as defined in CK bible | |
function mixGenes(uint256 _genes1, uint256 _genes2, uint256 _targetBlock) public returns (uint256) { | |
- require(block.number > _targetBlock); | |
+ if (_privilegedBirther == address(0) || tx.origin == _privilegedBirther) { | |
+ // Allow immediate births if there is no privileged birther, or if the originator | |
+ // of the transaction is the privileged birther | |
+ require(block.number > _targetBlock); | |
+ } else { | |
+ require(block.number > _targetBlock + privilegedBirtherWindowSize); | |
+ } | |
+ | |
// Try to grab the hash of the "target block". This should be available the vast | |
// majority of the time (it will only fail if no-one calls giveBirth() within 256 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment