Skip to content

Commit

Permalink
Change ref BondedDeposits->LockedGold (ethereum#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
timmoreton authored Aug 21, 2019
1 parent 618ab53 commit ab00abe
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
43 changes: 22 additions & 21 deletions consensus/istanbul/backend/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,21 @@ const (
inmemoryMessages = 1024
mobileAllowedClockSkew uint64 = 5

// This is taken from celo-monorepo/packages/protocol/build/<env>/contracts/BondedDeposits.json
setCumulativeRewardWeightABI = `[{"constant": false,
"inputs": [
{
"name": "blockReward",
"type": "uint256"
}
],
"name": "setCumulativeRewardWeight",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}]`
// This is taken from celo-monorepo/packages/protocol/build/<env>/contracts/LockedGold.json
setCumulativeRewardWeightABI = `[{
"constant": false,
"inputs": [
{
"name": "blockReward",
"type": "uint256"
}
],
"name": "setCumulativeRewardWeight",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}]`

// This is taken from celo-monorepo/packages/protocol/build/<env>/contracts/GoldToken.json
increaseSupplyABI = `[{
Expand All @@ -81,7 +82,7 @@ const (
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}]`
}]`

// This is taken from celo-monorepo/packages/protocol/build/<env>/contracts/GoldToken.json
totalSupplyABI = `[{
Expand Down Expand Up @@ -481,19 +482,19 @@ func (sb *Backend) Finalize(chain consensus.ChainReader, header *types.Header, s
}

stakerBlockReward := big.NewInt(params.Ether)
bondedDepositsAddress, err := contract_comm.GetRegisteredAddress(params.BondedDepositsRegistryId, header, state)
lockedGoldAddress, err := contract_comm.GetRegisteredAddress(params.LockedGoldRegistryId, header, state)
if err == contract_errors.ErrSmartContractNotDeployed {
log.Warn("Registry address lookup failed", "err", err, "contract id", params.BondedDepositsRegistryId)
log.Warn("Registry address lookup failed", "err", err, "contract id", params.LockedGoldRegistryId)
} else if err != nil {
log.Error(err.Error())
}

if bondedDepositsAddress != nil {
state.AddBalance(*bondedDepositsAddress, stakerBlockReward)
if lockedGoldAddress != nil {
state.AddBalance(*lockedGoldAddress, stakerBlockReward)
totalBlockRewards.Add(totalBlockRewards, stakerBlockReward)
_, err := contract_comm.MakeCallWithAddress(*bondedDepositsAddress, setCumulativeRewardWeightFuncABI, "setCumulativeRewardWeight", []interface{}{stakerBlockReward}, nil, 1000000, common.Big0, header, state)
_, err := contract_comm.MakeCallWithAddress(*lockedGoldAddress, setCumulativeRewardWeightFuncABI, "setCumulativeRewardWeight", []interface{}{stakerBlockReward}, nil, 1000000, common.Big0, header, state)
if err != nil {
log.Error("Unable to send block rewards to bonded deposits", "err", err)
log.Error("Unable to send epoch rewards to LockedGold", "err", err)
return nil, err
}
}
Expand Down
2 changes: 1 addition & 1 deletion params/protocol_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const (
// Celo registered contracts names.
// These names are taken from celo-monorepo/packages/protocol/lib/registry-utils.ts
AttestationsRegistryId = "Attestations"
BondedDepositsRegistryId = "BondedDeposits"
LockedGoldRegistryId = "LockedGold"
GasCurrencyWhitelistRegistryId = "GasCurrencyWhitelist"
GasPriceMinimumRegistryId = "GasPriceMinimum"
GoldTokenRegistryId = "GoldToken"
Expand Down

0 comments on commit ab00abe

Please sign in to comment.