diff --git a/cmd/puppeth/wizard_genesis.go b/cmd/puppeth/wizard_genesis.go index edb4a3c1bb..5b2706f6d6 100644 --- a/cmd/puppeth/wizard_genesis.go +++ b/cmd/puppeth/wizard_genesis.go @@ -170,7 +170,8 @@ func (w *wizard) makeGenesis() { fmt.Println() fmt.Println("How many blocks per checkpoint? (default = 990)") - genesis.Config.Clique.RewardCheckpoint = uint64(w.readDefaultInt(990)) + epochNumber := w.readDefaultInt(990) + genesis.Config.Clique.RewardCheckpoint = uint64(epochNumber) // Validator Smart Contract Code pKey, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") @@ -201,7 +202,7 @@ func (w *wizard) makeGenesis() { } // Block Signers Smart Contract - blockSignerAddress, _, err := blockSignerContract.DeployBlockSigner(transactOpts, contractBackend) + blockSignerAddress, _, err := blockSignerContract.DeployBlockSigner(transactOpts, contractBackend, big.NewInt(int64(epochNumber))) if err != nil { fmt.Println("Can't deploy root registry") } diff --git a/contracts/blocksigner/blocksigner.go b/contracts/blocksigner/blocksigner.go index d7fe0970cb..6ad512dfba 100644 --- a/contracts/blocksigner/blocksigner.go +++ b/contracts/blocksigner/blocksigner.go @@ -42,8 +42,8 @@ func NewBlockSigner(transactOpts *bind.TransactOpts, contractAddr common.Address }, nil } -func DeployBlockSigner(transactOpts *bind.TransactOpts, contractBackend bind.ContractBackend) (common.Address, *BlockSigner, error) { - blockSignerAddr, _, _, err := contract.DeployBlockSigner(transactOpts, contractBackend, big.NewInt(99)) +func DeployBlockSigner(transactOpts *bind.TransactOpts, contractBackend bind.ContractBackend, epochNumber *big.Int) (common.Address, *BlockSigner, error) { + blockSignerAddr, _, _, err := contract.DeployBlockSigner(transactOpts, contractBackend, epochNumber) if err != nil { return blockSignerAddr, nil, err } diff --git a/contracts/blocksigner/blocksigner_test.go b/contracts/blocksigner/blocksigner_test.go index 0759964ed4..c18d8b53ba 100644 --- a/contracts/blocksigner/blocksigner_test.go +++ b/contracts/blocksigner/blocksigner_test.go @@ -38,7 +38,7 @@ func TestBlockSigner(t *testing.T) { contractBackend := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}}) transactOpts := bind.NewKeyedTransactor(key) - blockSignerAddress, blockSigner, err := DeployBlockSigner(transactOpts, contractBackend) + blockSignerAddress, blockSigner, err := DeployBlockSigner(transactOpts, contractBackend, big.NewInt(99)) if err != nil { t.Fatalf("can't deploy root registry: %v", err) } diff --git a/contracts/blocksigner/contract/BlockSigner.sol b/contracts/blocksigner/contract/BlockSigner.sol index 82dcdb4c63..3fc80b6cb1 100644 --- a/contracts/blocksigner/contract/BlockSigner.sol +++ b/contracts/blocksigner/contract/BlockSigner.sol @@ -17,8 +17,8 @@ contract BlockSigner { function sign(uint256 _blockNumber, bytes32 _blockHash) external { // consensus should validate all senders are validators, gas = 0 - //require(block.number >= _blockNumber); - //require(block.number <= _blockNumber.add(epochNumber * 2)); + require(block.number >= _blockNumber); + require(block.number <= _blockNumber.add(epochNumber * 2)); blocks[_blockNumber].push(_blockHash); blockSigners[_blockHash].push(msg.sender);