mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
update block signer with epochNumber
This commit is contained in:
parent
2cfae3e48a
commit
908385b31d
4 changed files with 8 additions and 7 deletions
|
|
@ -170,7 +170,8 @@ func (w *wizard) makeGenesis() {
|
||||||
|
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println("How many blocks per checkpoint? (default = 990)")
|
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
|
// Validator Smart Contract Code
|
||||||
pKey, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
pKey, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||||
|
|
@ -201,7 +202,7 @@ func (w *wizard) makeGenesis() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block Signers Smart Contract
|
// Block Signers Smart Contract
|
||||||
blockSignerAddress, _, err := blockSignerContract.DeployBlockSigner(transactOpts, contractBackend)
|
blockSignerAddress, _, err := blockSignerContract.DeployBlockSigner(transactOpts, contractBackend, big.NewInt(int64(epochNumber)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Can't deploy root registry")
|
fmt.Println("Can't deploy root registry")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ func NewBlockSigner(transactOpts *bind.TransactOpts, contractAddr common.Address
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeployBlockSigner(transactOpts *bind.TransactOpts, contractBackend bind.ContractBackend) (common.Address, *BlockSigner, error) {
|
func DeployBlockSigner(transactOpts *bind.TransactOpts, contractBackend bind.ContractBackend, epochNumber *big.Int) (common.Address, *BlockSigner, error) {
|
||||||
blockSignerAddr, _, _, err := contract.DeployBlockSigner(transactOpts, contractBackend, big.NewInt(99))
|
blockSignerAddr, _, _, err := contract.DeployBlockSigner(transactOpts, contractBackend, epochNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return blockSignerAddr, nil, err
|
return blockSignerAddr, nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ func TestBlockSigner(t *testing.T) {
|
||||||
contractBackend := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}})
|
contractBackend := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}})
|
||||||
transactOpts := bind.NewKeyedTransactor(key)
|
transactOpts := bind.NewKeyedTransactor(key)
|
||||||
|
|
||||||
blockSignerAddress, blockSigner, err := DeployBlockSigner(transactOpts, contractBackend)
|
blockSignerAddress, blockSigner, err := DeployBlockSigner(transactOpts, contractBackend, big.NewInt(99))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't deploy root registry: %v", err)
|
t.Fatalf("can't deploy root registry: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ contract BlockSigner {
|
||||||
|
|
||||||
function sign(uint256 _blockNumber, bytes32 _blockHash) external {
|
function sign(uint256 _blockNumber, bytes32 _blockHash) external {
|
||||||
// consensus should validate all senders are validators, gas = 0
|
// consensus should validate all senders are validators, gas = 0
|
||||||
//require(block.number >= _blockNumber);
|
require(block.number >= _blockNumber);
|
||||||
//require(block.number <= _blockNumber.add(epochNumber * 2));
|
require(block.number <= _blockNumber.add(epochNumber * 2));
|
||||||
blocks[_blockNumber].push(_blockHash);
|
blocks[_blockNumber].push(_blockHash);
|
||||||
blockSigners[_blockHash].push(msg.sender);
|
blockSigners[_blockHash].push(msg.sender);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue