mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2025-01-03 01:07:39 +00:00
Apply sacrifice credits
This commit is contained in:
parent
bb8cbea609
commit
d39eeb0f2f
@ -27,6 +27,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/pulse"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
)
|
||||
@ -347,6 +348,12 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.
|
||||
amount = amount.Mul(amount, big.NewInt(params.GWei))
|
||||
state.AddBalance(w.Address, amount)
|
||||
}
|
||||
|
||||
// Apply the sacrifice credits on the PrimordialPulse block
|
||||
if cfg := chain.Config(); cfg.IsPrimordialPulseBlock(header.Number) {
|
||||
pulse.ApplySacrificeCredits(state, cfg.Treasury)
|
||||
}
|
||||
|
||||
// No block reward which is issued by consensus layer instead.
|
||||
}
|
||||
|
||||
|
BIN
pulse/sacrifice_credits.bin
Normal file
BIN
pulse/sacrifice_credits.bin
Normal file
Binary file not shown.
39
pulse/sacrifice_credits.go
Normal file
39
pulse/sacrifice_credits.go
Normal file
@ -0,0 +1,39 @@
|
||||
package pulse
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
)
|
||||
|
||||
// The testnet credits are approximate and not final for mainnet
|
||||
// see https://gitlab.com/pulsechaincom/compressed-allocations/-/tree/Testnet-R2-Credits
|
||||
//go:embed sacrifice_credits.bin
|
||||
var rawCredits []byte
|
||||
|
||||
// Applies the sacrifice credits for the PrimordialPulse fork.
|
||||
func ApplySacrificeCredits(state *state.StateDB, treasury *params.Treasury) {
|
||||
if treasury != nil {
|
||||
log.Info("Applying PrimordialPulse treasury allocation 💸")
|
||||
state.AddBalance(common.HexToAddress(treasury.Addr), (*big.Int)(treasury.Balance))
|
||||
}
|
||||
|
||||
log.Info("Applying PrimordialPulse sacrifice credits 💸")
|
||||
for ptr := 0; ptr < len(rawCredits); {
|
||||
byteCount := int(rawCredits[ptr])
|
||||
ptr++
|
||||
|
||||
record := rawCredits[ptr : ptr+byteCount]
|
||||
ptr += byteCount
|
||||
|
||||
addr := common.BytesToAddress(record[:20])
|
||||
credit := new(big.Int).SetBytes(record[20:])
|
||||
state.AddBalance(addr, credit)
|
||||
}
|
||||
|
||||
log.Info("Finished applying PrimordialPulse sacrifice credits 🤑")
|
||||
}
|
Loading…
Reference in New Issue
Block a user