mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
syscoin rebase
This commit is contained in:
parent
65e5ca7d81
commit
ca46bd5d83
52 changed files with 1387 additions and 155 deletions
|
|
@ -379,7 +379,8 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
|
||||||
execRs.CurrentExcessBlobGas = (*math.HexOrDecimal64)(&excessBlobGas)
|
execRs.CurrentExcessBlobGas = (*math.HexOrDecimal64)(&excessBlobGas)
|
||||||
execRs.CurrentBlobGasUsed = (*math.HexOrDecimal64)(&blobGasUsed)
|
execRs.CurrentBlobGasUsed = (*math.HexOrDecimal64)(&blobGasUsed)
|
||||||
}
|
}
|
||||||
if chainConfig.IsPrague(vmContext.BlockNumber, vmContext.Time) {
|
// SYSCOIN
|
||||||
|
if !chainConfig.IsSyscoin(vmContext.BlockNumber) && chainConfig.IsPrague(vmContext.BlockNumber, vmContext.Time) {
|
||||||
// Parse the requests from the logs
|
// Parse the requests from the logs
|
||||||
var allLogs []*types.Log
|
var allLogs []*types.Log
|
||||||
for _, receipt := range receipts {
|
for _, receipt := range receipts {
|
||||||
|
|
|
||||||
|
|
@ -229,11 +229,12 @@ func applyLondonChecks(env *stEnv, chainConfig *params.ChainConfig) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyShanghaiChecks(env *stEnv, chainConfig *params.ChainConfig) error {
|
func applyShanghaiChecks(env *stEnv, chainConfig *params.ChainConfig) error {
|
||||||
if !chainConfig.IsShanghai(big.NewInt(int64(env.Number)), env.Timestamp) {
|
// SYSCOIN
|
||||||
|
if !chainConfig.IsSyscoin(big.NewInt(int64(env.Number))) || !chainConfig.IsShanghai(big.NewInt(int64(env.Number)), env.Timestamp) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if env.Withdrawals == nil {
|
if env.Withdrawals == nil {
|
||||||
return NewError(ErrorConfig, errors.New("Shanghai config but missing 'withdrawals' in env section"))
|
return NewError(ErrorConfig, errors.New("shanghai config but missing 'withdrawals' in env section"))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -273,7 +274,8 @@ func applyMergeChecks(env *stEnv, chainConfig *params.ChainConfig) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyCancunChecks(env *stEnv, chainConfig *params.ChainConfig) error {
|
func applyCancunChecks(env *stEnv, chainConfig *params.ChainConfig) error {
|
||||||
if !chainConfig.IsCancun(big.NewInt(int64(env.Number)), env.Timestamp) {
|
// SYSCOIN
|
||||||
|
if chainConfig.IsSyscoin(big.NewInt(int64(env.Number))) || !chainConfig.IsCancun(big.NewInt(int64(env.Number)), env.Timestamp) {
|
||||||
env.ParentBeaconBlockRoot = nil // un-set it if it has been set too early
|
env.ParentBeaconBlockRoot = nil // un-set it if it has been set too early
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,8 @@ var (
|
||||||
utils.MinerRecommitIntervalFlag,
|
utils.MinerRecommitIntervalFlag,
|
||||||
utils.MinerPendingFeeRecipientFlag,
|
utils.MinerPendingFeeRecipientFlag,
|
||||||
utils.MinerNewPayloadTimeoutFlag, // deprecated
|
utils.MinerNewPayloadTimeoutFlag, // deprecated
|
||||||
|
// SYSCOIN
|
||||||
|
utils.NEVMPubFlag,
|
||||||
utils.NATFlag,
|
utils.NATFlag,
|
||||||
utils.NoDiscoverFlag,
|
utils.NoDiscoverFlag,
|
||||||
utils.DiscoveryV4Flag,
|
utils.DiscoveryV4Flag,
|
||||||
|
|
@ -288,6 +290,9 @@ func main() {
|
||||||
func prepare(ctx *cli.Context) {
|
func prepare(ctx *cli.Context) {
|
||||||
// If we're running a known preset, log it for convenience.
|
// If we're running a known preset, log it for convenience.
|
||||||
switch {
|
switch {
|
||||||
|
// SYSCOIN
|
||||||
|
case ctx.IsSet(utils.TanenbaumFlag.Name):
|
||||||
|
log.Info("Starting Geth on Tanenbaum testnet...")
|
||||||
case ctx.IsSet(utils.SepoliaFlag.Name):
|
case ctx.IsSet(utils.SepoliaFlag.Name):
|
||||||
log.Info("Starting Geth on Sepolia testnet...")
|
log.Info("Starting Geth on Sepolia testnet...")
|
||||||
|
|
||||||
|
|
@ -313,13 +318,16 @@ func prepare(ctx *cli.Context) {
|
||||||
`)
|
`)
|
||||||
|
|
||||||
case !ctx.IsSet(utils.NetworkIdFlag.Name):
|
case !ctx.IsSet(utils.NetworkIdFlag.Name):
|
||||||
log.Info("Starting Geth on Ethereum mainnet...")
|
// SYSCOIN
|
||||||
|
log.Info("Starting Geth on Syscoin mainnet...")
|
||||||
}
|
}
|
||||||
// If we're a full node on mainnet without --cache specified, bump default cache allowance
|
// If we're a full node on mainnet without --cache specified, bump default cache allowance
|
||||||
if !ctx.IsSet(utils.CacheFlag.Name) && !ctx.IsSet(utils.NetworkIdFlag.Name) {
|
if !ctx.IsSet(utils.CacheFlag.Name) && !ctx.IsSet(utils.NetworkIdFlag.Name) {
|
||||||
// Make sure we're not on any supported preconfigured testnet either
|
// Make sure we're not on any supported preconfigured testnet either
|
||||||
if !ctx.IsSet(utils.HoleskyFlag.Name) &&
|
if !ctx.IsSet(utils.HoleskyFlag.Name) &&
|
||||||
!ctx.IsSet(utils.SepoliaFlag.Name) &&
|
!ctx.IsSet(utils.SepoliaFlag.Name) &&
|
||||||
|
// SYSCOIN
|
||||||
|
!ctx.IsSet(utils.TanenbaumFlag.Name) &&
|
||||||
!ctx.IsSet(utils.DeveloperFlag.Name) {
|
!ctx.IsSet(utils.DeveloperFlag.Name) {
|
||||||
// Nope, we're really on mainnet. Bump that cache up!
|
// Nope, we're really on mainnet. Bump that cache up!
|
||||||
log.Info("Bumping default cache on mainnet", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 4096)
|
log.Info("Bumping default cache on mainnet", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 4096)
|
||||||
|
|
|
||||||
|
|
@ -140,9 +140,19 @@ var (
|
||||||
}
|
}
|
||||||
MainnetFlag = &cli.BoolFlag{
|
MainnetFlag = &cli.BoolFlag{
|
||||||
Name: "mainnet",
|
Name: "mainnet",
|
||||||
Usage: "Ethereum mainnet",
|
// SYSCOIN
|
||||||
|
Usage: "Syscoin mainnet",
|
||||||
Category: flags.EthCategory,
|
Category: flags.EthCategory,
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
NEVMPubFlag = &cli.StringFlag{
|
||||||
|
Name: "nevmpub",
|
||||||
|
Usage: "NEVM ZMQ REP Endpoint",
|
||||||
|
}
|
||||||
|
TanenbaumFlag = &cli.BoolFlag{
|
||||||
|
Name: "tanenbaum",
|
||||||
|
Usage: "Tanenbaum network: pre-configured NEVM-based Tanenbaum test network.",
|
||||||
|
}
|
||||||
SepoliaFlag = &cli.BoolFlag{
|
SepoliaFlag = &cli.BoolFlag{
|
||||||
Name: "sepolia",
|
Name: "sepolia",
|
||||||
Usage: "Sepolia network: pre-configured proof-of-work test network",
|
Usage: "Sepolia network: pre-configured proof-of-work test network",
|
||||||
|
|
@ -981,6 +991,10 @@ func MakeDataDir(ctx *cli.Context) string {
|
||||||
if ctx.Bool(SepoliaFlag.Name) {
|
if ctx.Bool(SepoliaFlag.Name) {
|
||||||
return filepath.Join(path, "sepolia")
|
return filepath.Join(path, "sepolia")
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
if ctx.Bool(TanenbaumFlag.Name) {
|
||||||
|
return filepath.Join(path, "tanenbaum")
|
||||||
|
}
|
||||||
if ctx.Bool(HoleskyFlag.Name) {
|
if ctx.Bool(HoleskyFlag.Name) {
|
||||||
return filepath.Join(path, "holesky")
|
return filepath.Join(path, "holesky")
|
||||||
}
|
}
|
||||||
|
|
@ -1042,6 +1056,9 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
|
||||||
switch {
|
switch {
|
||||||
case ctx.Bool(HoleskyFlag.Name):
|
case ctx.Bool(HoleskyFlag.Name):
|
||||||
urls = params.HoleskyBootnodes
|
urls = params.HoleskyBootnodes
|
||||||
|
// SYSCOIN
|
||||||
|
case ctx.Bool(TanenbaumFlag.Name):
|
||||||
|
urls = params.TanenbaumBootnodes
|
||||||
case ctx.Bool(SepoliaFlag.Name):
|
case ctx.Bool(SepoliaFlag.Name):
|
||||||
urls = params.SepoliaBootnodes
|
urls = params.SepoliaBootnodes
|
||||||
}
|
}
|
||||||
|
|
@ -1306,9 +1323,12 @@ func MakeAddress(ks *keystore.KeyStore, account string) (accounts.Account, error
|
||||||
// setEtherbase retrieves the etherbase from the directly specified command line flags.
|
// setEtherbase retrieves the etherbase from the directly specified command line flags.
|
||||||
func setEtherbase(ctx *cli.Context, cfg *ethconfig.Config) {
|
func setEtherbase(ctx *cli.Context, cfg *ethconfig.Config) {
|
||||||
if ctx.IsSet(MinerEtherbaseFlag.Name) {
|
if ctx.IsSet(MinerEtherbaseFlag.Name) {
|
||||||
log.Warn("Option --miner.etherbase is deprecated as the etherbase is set by the consensus client post-merge")
|
// SYSCOIN
|
||||||
|
log.Warn("Option --miner.etherbase is deprecated")
|
||||||
}
|
}
|
||||||
if !ctx.IsSet(MinerPendingFeeRecipientFlag.Name) {
|
if !ctx.IsSet(MinerPendingFeeRecipientFlag.Name) {
|
||||||
|
// SYSCOIN
|
||||||
|
log.Warn("Option --miner.pending.feeRecipient is missing")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
addr := ctx.String(MinerPendingFeeRecipientFlag.Name)
|
addr := ctx.String(MinerPendingFeeRecipientFlag.Name)
|
||||||
|
|
@ -1468,6 +1488,9 @@ func SetDataDir(ctx *cli.Context, cfg *node.Config) {
|
||||||
cfg.DataDir = ctx.String(DataDirFlag.Name)
|
cfg.DataDir = ctx.String(DataDirFlag.Name)
|
||||||
case ctx.Bool(DeveloperFlag.Name):
|
case ctx.Bool(DeveloperFlag.Name):
|
||||||
cfg.DataDir = "" // unless explicitly requested, use memory databases
|
cfg.DataDir = "" // unless explicitly requested, use memory databases
|
||||||
|
// SYSCOIN
|
||||||
|
case ctx.Bool(TanenbaumFlag.Name) && cfg.DataDir == node.DefaultDataDir():
|
||||||
|
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "tanenbaum")
|
||||||
case ctx.Bool(SepoliaFlag.Name) && cfg.DataDir == node.DefaultDataDir():
|
case ctx.Bool(SepoliaFlag.Name) && cfg.DataDir == node.DefaultDataDir():
|
||||||
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "sepolia")
|
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "sepolia")
|
||||||
case ctx.Bool(HoleskyFlag.Name) && cfg.DataDir == node.DefaultDataDir():
|
case ctx.Bool(HoleskyFlag.Name) && cfg.DataDir == node.DefaultDataDir():
|
||||||
|
|
@ -1670,7 +1693,10 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
||||||
|
|
||||||
log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc))
|
log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc))
|
||||||
godebug.SetGCPercent(int(gogc))
|
godebug.SetGCPercent(int(gogc))
|
||||||
|
// SYSCOIN
|
||||||
|
if ctx.IsSet(NEVMPubFlag.Name) {
|
||||||
|
cfg.NEVMPubEP = ctx.String(NEVMPubFlag.Name)
|
||||||
|
}
|
||||||
if ctx.IsSet(SyncTargetFlag.Name) {
|
if ctx.IsSet(SyncTargetFlag.Name) {
|
||||||
cfg.SyncMode = downloader.FullSync // dev sync target forces full sync
|
cfg.SyncMode = downloader.FullSync // dev sync target forces full sync
|
||||||
} else if ctx.IsSet(SyncModeFlag.Name) {
|
} else if ctx.IsSet(SyncModeFlag.Name) {
|
||||||
|
|
@ -1790,7 +1816,8 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
||||||
switch {
|
switch {
|
||||||
case ctx.Bool(MainnetFlag.Name):
|
case ctx.Bool(MainnetFlag.Name):
|
||||||
if !ctx.IsSet(NetworkIdFlag.Name) {
|
if !ctx.IsSet(NetworkIdFlag.Name) {
|
||||||
cfg.NetworkId = 1
|
// SYSCOIN
|
||||||
|
cfg.NetworkId = 57
|
||||||
}
|
}
|
||||||
cfg.Genesis = core.DefaultGenesisBlock()
|
cfg.Genesis = core.DefaultGenesisBlock()
|
||||||
SetDNSDiscoveryDefaults(cfg, params.MainnetGenesisHash)
|
SetDNSDiscoveryDefaults(cfg, params.MainnetGenesisHash)
|
||||||
|
|
@ -1806,6 +1833,13 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
||||||
}
|
}
|
||||||
cfg.Genesis = core.DefaultSepoliaGenesisBlock()
|
cfg.Genesis = core.DefaultSepoliaGenesisBlock()
|
||||||
SetDNSDiscoveryDefaults(cfg, params.SepoliaGenesisHash)
|
SetDNSDiscoveryDefaults(cfg, params.SepoliaGenesisHash)
|
||||||
|
// SYSCOIN
|
||||||
|
case ctx.Bool(TanenbaumFlag.Name):
|
||||||
|
if !ctx.IsSet(NetworkIdFlag.Name) {
|
||||||
|
cfg.NetworkId = 5700
|
||||||
|
}
|
||||||
|
cfg.Genesis = core.DefaultTanenbaumGenesisBlock()
|
||||||
|
SetDNSDiscoveryDefaults(cfg, params.TanenbaumGenesisHash)
|
||||||
case ctx.Bool(DeveloperFlag.Name):
|
case ctx.Bool(DeveloperFlag.Name):
|
||||||
if !ctx.IsSet(NetworkIdFlag.Name) {
|
if !ctx.IsSet(NetworkIdFlag.Name) {
|
||||||
cfg.NetworkId = 1337
|
cfg.NetworkId = 1337
|
||||||
|
|
@ -2125,6 +2159,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
|
||||||
genesis = core.DefaultHoleskyGenesisBlock()
|
genesis = core.DefaultHoleskyGenesisBlock()
|
||||||
case ctx.Bool(SepoliaFlag.Name):
|
case ctx.Bool(SepoliaFlag.Name):
|
||||||
genesis = core.DefaultSepoliaGenesisBlock()
|
genesis = core.DefaultSepoliaGenesisBlock()
|
||||||
|
case ctx.Bool(TanenbaumFlag.Name):
|
||||||
|
genesis = core.DefaultTanenbaumGenesisBlock()
|
||||||
case ctx.Bool(DeveloperFlag.Name):
|
case ctx.Bool(DeveloperFlag.Name):
|
||||||
Fatalf("Developer chains are ephemeral")
|
Fatalf("Developer chains are ephemeral")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
// SYSCOIN
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/consensus"
|
"github.com/ethereum/go-ethereum/consensus"
|
||||||
|
|
@ -36,8 +38,12 @@ import (
|
||||||
|
|
||||||
// Proof-of-stake protocol constants.
|
// Proof-of-stake protocol constants.
|
||||||
var (
|
var (
|
||||||
beaconDifficulty = common.Big0 // The default block difficulty in the beacon consensus
|
beaconDifficulty = common.Big1 // The default block difficulty in the beacon consensus
|
||||||
beaconNonce = types.EncodeNonce(0) // The default block nonce in the beacon consensus
|
beaconNonce = types.EncodeNonce(0) // The default block nonce in the beacon consensus
|
||||||
|
// SYSCOIN
|
||||||
|
SyscoinBlockReward, _ = new(big.Int).SetString("10550000000000000000", 10) // 10.55 Block reward for successfully mining a block upward from Syscoin
|
||||||
|
allowedFutureBlockTimeSeconds = int64(150) // Max seconds from current time allowed for blocks, before they're considered future blocks
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Various error messages to mark blocks invalid. These should be private to
|
// Various error messages to mark blocks invalid. These should be private to
|
||||||
|
|
@ -94,8 +100,8 @@ func (beacon *Beacon) VerifyHeader(chain consensus.ChainHeaderReader, header *ty
|
||||||
if parent == nil {
|
if parent == nil {
|
||||||
return consensus.ErrUnknownAncestor
|
return consensus.ErrUnknownAncestor
|
||||||
}
|
}
|
||||||
// Sanity checks passed, do a proper verification
|
// SYSCOIN Sanity checks passed, do a proper verification
|
||||||
return beacon.verifyHeader(chain, header, parent)
|
return beacon.verifyHeader(chain, header, parent, time.Now().Unix())
|
||||||
}
|
}
|
||||||
|
|
||||||
// errOut constructs an error channel with prefilled errors inside.
|
// errOut constructs an error channel with prefilled errors inside.
|
||||||
|
|
@ -227,7 +233,8 @@ func (beacon *Beacon) VerifyUncles(chain consensus.ChainReader, block *types.Blo
|
||||||
//
|
//
|
||||||
// (b) we don't verify if a block is in the future anymore
|
// (b) we don't verify if a block is in the future anymore
|
||||||
// (c) the extradata is limited to 32 bytes
|
// (c) the extradata is limited to 32 bytes
|
||||||
func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, parent *types.Header) error {
|
// SYSCOIN
|
||||||
|
func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, parent *types.Header, unixNow int64) error {
|
||||||
// Ensure that the header's extra-data section is of a reasonable size
|
// Ensure that the header's extra-data section is of a reasonable size
|
||||||
if len(header.Extra) > int(params.MaximumExtraDataSize) {
|
if len(header.Extra) > int(params.MaximumExtraDataSize) {
|
||||||
return fmt.Errorf("extra-data longer than 32 bytes (%d)", len(header.Extra))
|
return fmt.Errorf("extra-data longer than 32 bytes (%d)", len(header.Extra))
|
||||||
|
|
@ -239,6 +246,16 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
|
||||||
if header.UncleHash != types.EmptyUncleHash {
|
if header.UncleHash != types.EmptyUncleHash {
|
||||||
return errInvalidUncleHash
|
return errInvalidUncleHash
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
syscoin := chain.Config().IsSyscoin(header.Number)
|
||||||
|
if syscoin {
|
||||||
|
if header.Time > uint64(unixNow+allowedFutureBlockTimeSeconds) {
|
||||||
|
return consensus.ErrFutureBlock
|
||||||
|
}
|
||||||
|
if !chain.HasNEVMMapping(header.Hash()) {
|
||||||
|
return errors.New("Block not found in NEVM mapping")
|
||||||
|
}
|
||||||
|
}
|
||||||
// Verify the timestamp
|
// Verify the timestamp
|
||||||
if header.Time <= parent.Time {
|
if header.Time <= parent.Time {
|
||||||
return errInvalidTimestamp
|
return errInvalidTimestamp
|
||||||
|
|
@ -263,17 +280,17 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
|
||||||
if err := eip1559.VerifyEIP1559Header(chain.Config(), parent, header); err != nil {
|
if err := eip1559.VerifyEIP1559Header(chain.Config(), parent, header); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Verify existence / non-existence of withdrawalsHash.
|
// SYSCOIN Verify existence / non-existence of withdrawalsHash.
|
||||||
shanghai := chain.Config().IsShanghai(header.Number, header.Time)
|
shanghai := chain.Config().IsShanghai(header.Number, header.Time)
|
||||||
if shanghai && header.WithdrawalsHash == nil {
|
if (!syscoin && shanghai) && header.WithdrawalsHash == nil {
|
||||||
return errors.New("missing withdrawalsHash")
|
return errors.New("missing withdrawalsHash")
|
||||||
}
|
}
|
||||||
if !shanghai && header.WithdrawalsHash != nil {
|
if (syscoin || !shanghai) && header.WithdrawalsHash != nil {
|
||||||
return fmt.Errorf("invalid withdrawalsHash: have %x, expected nil", header.WithdrawalsHash)
|
return fmt.Errorf("invalid withdrawalsHash: have %x, expected nil", header.WithdrawalsHash)
|
||||||
}
|
}
|
||||||
// Verify the existence / non-existence of cancun-specific header fields
|
// Verify the existence / non-existence of cancun-specific header fields
|
||||||
cancun := chain.Config().IsCancun(header.Number, header.Time)
|
cancun := chain.Config().IsCancun(header.Number, header.Time)
|
||||||
if !cancun {
|
if !cancun || syscoin {
|
||||||
switch {
|
switch {
|
||||||
case header.ExcessBlobGas != nil:
|
case header.ExcessBlobGas != nil:
|
||||||
return fmt.Errorf("invalid excessBlobGas: have %d, expected nil", header.ExcessBlobGas)
|
return fmt.Errorf("invalid excessBlobGas: have %d, expected nil", header.ExcessBlobGas)
|
||||||
|
|
@ -301,6 +318,8 @@ func (beacon *Beacon) verifyHeaders(chain consensus.ChainHeaderReader, headers [
|
||||||
var (
|
var (
|
||||||
abort = make(chan struct{})
|
abort = make(chan struct{})
|
||||||
results = make(chan error, len(headers))
|
results = make(chan error, len(headers))
|
||||||
|
// SYSCOIN
|
||||||
|
unixNow = time.Now().Unix()
|
||||||
)
|
)
|
||||||
go func() {
|
go func() {
|
||||||
for i, header := range headers {
|
for i, header := range headers {
|
||||||
|
|
@ -322,7 +341,8 @@ func (beacon *Beacon) verifyHeaders(chain consensus.ChainHeaderReader, headers [
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
err := beacon.verifyHeader(chain, header, parent)
|
// SYSCOIN
|
||||||
|
err := beacon.verifyHeader(chain, header, parent, unixNow)
|
||||||
select {
|
select {
|
||||||
case <-abort:
|
case <-abort:
|
||||||
return
|
return
|
||||||
|
|
@ -348,6 +368,13 @@ func (beacon *Beacon) Prepare(chain consensus.ChainHeaderReader, header *types.H
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// accumulateRewards credits the coinbase of the given block with the mining
|
||||||
|
// reward. The total reward consists of the static block reward and rewards for
|
||||||
|
// included uncles. The coinbase of each uncle block is also rewarded.
|
||||||
|
func accumulateRewards(config *params.ChainConfig, stateDB *state.StateDB, header *types.Header) {
|
||||||
|
stateDB.AddBalance(header.Coinbase, uint256.MustFromBig(SyscoinBlockReward), tracing.BalanceIncreaseRewardMineBlock)
|
||||||
|
}
|
||||||
|
|
||||||
// Finalize implements consensus.Engine and processes withdrawals on top.
|
// Finalize implements consensus.Engine and processes withdrawals on top.
|
||||||
func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body) {
|
func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body) {
|
||||||
if !beacon.IsPoSHeader(header) {
|
if !beacon.IsPoSHeader(header) {
|
||||||
|
|
@ -361,7 +388,10 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.
|
||||||
amount = amount.Mul(amount, uint256.NewInt(params.GWei))
|
amount = amount.Mul(amount, uint256.NewInt(params.GWei))
|
||||||
state.AddBalance(w.Address, amount, tracing.BalanceIncreaseWithdrawal)
|
state.AddBalance(w.Address, amount, tracing.BalanceIncreaseWithdrawal)
|
||||||
}
|
}
|
||||||
// No block reward which is issued by consensus layer instead.
|
// SYSCOIN Accumulate any block
|
||||||
|
if(chain.Config().IsSyscoin(header.Number)) {
|
||||||
|
accumulateRewards(chain.Config(), state, header)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FinalizeAndAssemble implements consensus.Engine, setting the final state and
|
// FinalizeAndAssemble implements consensus.Engine, setting the final state and
|
||||||
|
|
@ -370,15 +400,17 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea
|
||||||
if !beacon.IsPoSHeader(header) {
|
if !beacon.IsPoSHeader(header) {
|
||||||
return beacon.ethone.FinalizeAndAssemble(chain, header, state, body, receipts)
|
return beacon.ethone.FinalizeAndAssemble(chain, header, state, body, receipts)
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
syscoin := chain.Config().IsSyscoin(header.Number)
|
||||||
shanghai := chain.Config().IsShanghai(header.Number, header.Time)
|
shanghai := chain.Config().IsShanghai(header.Number, header.Time)
|
||||||
if shanghai {
|
if shanghai && !syscoin {
|
||||||
// All blocks after Shanghai must include a withdrawals root.
|
// All blocks after Shanghai must include a withdrawals root.
|
||||||
if body.Withdrawals == nil {
|
if body.Withdrawals == nil {
|
||||||
body.Withdrawals = make([]*types.Withdrawal, 0)
|
body.Withdrawals = make([]*types.Withdrawal, 0)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(body.Withdrawals) > 0 {
|
if len(body.Withdrawals) > 0 {
|
||||||
return nil, errors.New("withdrawals set before Shanghai activation")
|
return nil, errors.New("withdrawals set")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Finalize and assemble the block.
|
// Finalize and assemble the block.
|
||||||
|
|
@ -471,7 +503,8 @@ func (beacon *Beacon) IsPoSHeader(header *types.Header) bool {
|
||||||
if header.Difficulty == nil {
|
if header.Difficulty == nil {
|
||||||
panic("IsPoSHeader called with invalid difficulty")
|
panic("IsPoSHeader called with invalid difficulty")
|
||||||
}
|
}
|
||||||
return header.Difficulty.Cmp(beaconDifficulty) == 0
|
// SYSCOIN
|
||||||
|
return header.Difficulty.Cmp(beaconDifficulty) <= 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// InnerEngine returns the embedded eth1 consensus engine.
|
// InnerEngine returns the embedded eth1 consensus engine.
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,9 @@ type ChainHeaderReader interface {
|
||||||
// GetHeaderByHash retrieves a block header from the database by its hash.
|
// GetHeaderByHash retrieves a block header from the database by its hash.
|
||||||
GetHeaderByHash(hash common.Hash) *types.Header
|
GetHeaderByHash(hash common.Hash) *types.Header
|
||||||
|
|
||||||
|
// SYSCOIN check to see if an NEVM mapping exists for a specific block hash
|
||||||
|
HasNEVMMapping(hash common.Hash) bool
|
||||||
|
|
||||||
// GetTd retrieves the total difficulty from the database by hash and number.
|
// GetTd retrieves the total difficulty from the database by hash and number.
|
||||||
GetTd(hash common.Hash, number uint64) *big.Int
|
GetTd(hash common.Hash, number uint64) *big.Int
|
||||||
}
|
}
|
||||||
|
|
|
||||||
40
consensus/misc/nexus.go
Normal file
40
consensus/misc/nexus.go
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
// Copyright 2016 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package misc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
|
"github.com/ethereum/go-ethereum/params"
|
||||||
|
"github.com/ethereum/go-ethereum/core/tracing"
|
||||||
|
"github.com/holiman/uint256"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
// ApplyNexusHardFork modifies the state database according to the Nexus hard-fork
|
||||||
|
// rules, transferring SYS balance from previous VaultManager to new one
|
||||||
|
func ApplyNexusHardFork(statedb *state.StateDB) {
|
||||||
|
// Create the new contract account if it doesn't already exist
|
||||||
|
if !statedb.Exist(params.VaultManager) {
|
||||||
|
statedb.CreateAccount(params.VaultManager)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transfer the balance from the old contract to the new contract
|
||||||
|
oldBalance := statedb.GetBalance(params.VaultManagerOld)
|
||||||
|
statedb.AddBalance(params.VaultManager, oldBalance, tracing.BalanceIncreaseVaultManagerContract)
|
||||||
|
statedb.SetBalance(params.VaultManagerOld, new(uint256.Int), tracing.BalanceDecreaseVaultManagerAccount)// Reset the old contract's balance
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -258,6 +258,8 @@ type BlockChain struct {
|
||||||
prefetcher Prefetcher
|
prefetcher Prefetcher
|
||||||
processor Processor // Block transaction processor interface
|
processor Processor // Block transaction processor interface
|
||||||
vmConfig vm.Config
|
vmConfig vm.Config
|
||||||
|
// SYSCOIN
|
||||||
|
NevmBlockConnect *types.NEVMBlockConnect
|
||||||
logger *tracing.Hooks
|
logger *tracing.Hooks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1433,9 +1435,9 @@ func (bc *BlockChain) writeBlockWithoutState(block *types.Block, td *big.Int) (e
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// writeKnownBlock updates the head block flag with a known block
|
// SYSCOIN WriteKnownBlock updates the head block flag with a known block
|
||||||
// and introduces chain reorg if necessary.
|
// and introduces chain reorg if necessary.
|
||||||
func (bc *BlockChain) writeKnownBlock(block *types.Block) error {
|
func (bc *BlockChain) WriteKnownBlock(block *types.Block) error {
|
||||||
current := bc.CurrentBlock()
|
current := bc.CurrentBlock()
|
||||||
if block.ParentHash() != current.Hash() {
|
if block.ParentHash() != current.Hash() {
|
||||||
if err := bc.reorg(current, block); err != nil {
|
if err := bc.reorg(current, block); err != nil {
|
||||||
|
|
@ -1466,6 +1468,32 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
|
||||||
rawdb.WriteBlock(blockBatch, block)
|
rawdb.WriteBlock(blockBatch, block)
|
||||||
rawdb.WriteReceipts(blockBatch, block.Hash(), block.NumberU64(), receipts)
|
rawdb.WriteReceipts(blockBatch, block.Hash(), block.NumberU64(), receipts)
|
||||||
rawdb.WritePreimages(blockBatch, statedb.Preimages())
|
rawdb.WritePreimages(blockBatch, statedb.Preimages())
|
||||||
|
// SYSCOIN
|
||||||
|
nevmBlockConnect := bc.NevmBlockConnect
|
||||||
|
if nevmBlockConnect != nil {
|
||||||
|
// Update the NEVM address mappings based on the block's diff
|
||||||
|
hasDiff := nevmBlockConnect.HasDiff()
|
||||||
|
if hasDiff {
|
||||||
|
// Retrieve the current NEVM address mappings from the database
|
||||||
|
mapping := bc.ReadNEVMAddressMapping()
|
||||||
|
for _, entry := range nevmBlockConnect.Diff.AddedMNNEVM {
|
||||||
|
mapping.AddNEVMAddress(common.BytesToAddress(entry.Address), entry.CollateralHeight)
|
||||||
|
}
|
||||||
|
for _, entry := range nevmBlockConnect.Diff.UpdatedMNNEVM {
|
||||||
|
mapping.UpdateNEVMAddress(common.BytesToAddress(entry.OldAddress), common.BytesToAddress(entry.NewAddress))
|
||||||
|
}
|
||||||
|
for _, entry := range nevmBlockConnect.Diff.RemovedMNNEVM {
|
||||||
|
mapping.RemoveNEVMAddress(common.BytesToAddress(entry.Address))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Persist the updated NEVM address mappings to the database
|
||||||
|
bc.WriteNEVMAddressMapping(blockBatch, mapping)
|
||||||
|
}
|
||||||
|
proposedBlockNumber := nevmBlockConnect.Block.NumberU64()
|
||||||
|
bc.WriteNEVMMapping(blockBatch, nevmBlockConnect.Block.Hash())
|
||||||
|
bc.WriteDataHashes(blockBatch, proposedBlockNumber, nevmBlockConnect.VersionHashes)
|
||||||
|
bc.WriteSYSHash(blockBatch, nevmBlockConnect.Sysblockhash, proposedBlockNumber)
|
||||||
|
}
|
||||||
if err := blockBatch.Write(); err != nil {
|
if err := blockBatch.Write(); err != nil {
|
||||||
log.Crit("Failed to write block into disk", "err", err)
|
log.Crit("Failed to write block into disk", "err", err)
|
||||||
}
|
}
|
||||||
|
|
@ -1669,7 +1697,8 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool, makeWitness
|
||||||
// head full block(new pivot point).
|
// head full block(new pivot point).
|
||||||
for block != nil && bc.skipBlock(err, it) {
|
for block != nil && bc.skipBlock(err, it) {
|
||||||
log.Debug("Writing previously known block", "number", block.Number(), "hash", block.Hash())
|
log.Debug("Writing previously known block", "number", block.Number(), "hash", block.Hash())
|
||||||
if err := bc.writeKnownBlock(block); err != nil {
|
// SYSCOIN
|
||||||
|
if err := bc.WriteKnownBlock(block); err != nil {
|
||||||
return nil, it.index, err
|
return nil, it.index, err
|
||||||
}
|
}
|
||||||
lastCanon = block
|
lastCanon = block
|
||||||
|
|
@ -1749,7 +1778,8 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool, makeWitness
|
||||||
log.Error("Please file an issue, skip known block execution without receipt",
|
log.Error("Please file an issue, skip known block execution without receipt",
|
||||||
"hash", block.Hash(), "number", block.NumberU64())
|
"hash", block.Hash(), "number", block.NumberU64())
|
||||||
}
|
}
|
||||||
if err := bc.writeKnownBlock(block); err != nil {
|
// SYSCOIN
|
||||||
|
if err := bc.WriteKnownBlock(block); err != nil {
|
||||||
return nil, it.index, err
|
return nil, it.index, err
|
||||||
}
|
}
|
||||||
stats.processed++
|
stats.processed++
|
||||||
|
|
@ -2537,3 +2567,7 @@ func (bc *BlockChain) SetTrieFlushInterval(interval time.Duration) {
|
||||||
func (bc *BlockChain) GetTrieFlushInterval() time.Duration {
|
func (bc *BlockChain) GetTrieFlushInterval() time.Duration {
|
||||||
return time.Duration(bc.flushInterval.Load())
|
return time.Duration(bc.flushInterval.Load())
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
func (bc *BlockChain) GetChainConfig() *params.ChainConfig {
|
||||||
|
return bc.chainConfig
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/triedb"
|
"github.com/ethereum/go-ethereum/triedb"
|
||||||
|
"github.com/ethereum/go-ethereum/ethdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CurrentHeader retrieves the current head header of the canonical chain. The
|
// CurrentHeader retrieves the current head header of the canonical chain. The
|
||||||
|
|
@ -445,3 +446,48 @@ func (bc *BlockChain) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscript
|
||||||
func (bc *BlockChain) SubscribeBlockProcessingEvent(ch chan<- bool) event.Subscription {
|
func (bc *BlockChain) SubscribeBlockProcessingEvent(ch chan<- bool) event.Subscription {
|
||||||
return bc.scope.Track(bc.blockProcFeed.Subscribe(ch))
|
return bc.scope.Track(bc.blockProcFeed.Subscribe(ch))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SYSCOIN
|
||||||
|
func (bc *BlockChain) ReadSYSHash(n uint64) []byte {
|
||||||
|
return bc.hc.ReadSYSHash(n)
|
||||||
|
}
|
||||||
|
func (bc *BlockChain) GetNEVMAddress(address common.Address) []byte {
|
||||||
|
return bc.hc.GetNEVMAddress(address)
|
||||||
|
}
|
||||||
|
func (bc *BlockChain) WriteNEVMAddressMapping(db ethdb.KeyValueWriter, mapping *rawdb.NEVMAddressMapping) {
|
||||||
|
bc.hc.WriteNEVMAddressMapping(db, mapping)
|
||||||
|
}
|
||||||
|
func (bc *BlockChain) ReadNEVMAddressMapping() *rawdb.NEVMAddressMapping {
|
||||||
|
return bc.hc.ReadNEVMAddressMapping()
|
||||||
|
}
|
||||||
|
func (bc *BlockChain) ReadDataHash(hash common.Hash) []byte {
|
||||||
|
return bc.hc.ReadDataHash(hash)
|
||||||
|
}
|
||||||
|
func (bc *BlockChain) WriteSYSHash(db ethdb.KeyValueWriter, sysBlockhash string, n uint64) {
|
||||||
|
bc.hc.WriteSYSHash(db, sysBlockhash, n)
|
||||||
|
}
|
||||||
|
func (bc *BlockChain) WriteDataHashes(db ethdb.KeyValueWriter, n uint64, dataHashes []*common.Hash) {
|
||||||
|
bc.hc.WriteDataHashes(db, n, dataHashes)
|
||||||
|
}
|
||||||
|
func (bc *BlockChain) DeleteDataHashes(db ethdb.KeyValueWriter, n uint64) {
|
||||||
|
bc.hc.DeleteDataHashes(db, n)
|
||||||
|
}
|
||||||
|
func (bc *BlockChain) DeleteSYSHash(db ethdb.KeyValueWriter, n uint64) {
|
||||||
|
bc.hc.DeleteSYSHash(db, n)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasNEVMMapping checks if a NEVM block is present in the database or not, caching
|
||||||
|
// it if present.
|
||||||
|
func (bc *BlockChain) HasNEVMMapping(hash common.Hash) bool {
|
||||||
|
if(bc.NevmBlockConnect != nil) {
|
||||||
|
return (bc.NevmBlockConnect.Block.Hash() == hash)
|
||||||
|
}
|
||||||
|
return bc.hc.HasNEVMMapping(hash)
|
||||||
|
}
|
||||||
|
func (bc *BlockChain) DeleteNEVMMapping(db ethdb.KeyValueWriter, hash common.Hash) {
|
||||||
|
bc.hc.DeleteNEVMMapping(db, hash)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (bc *BlockChain) WriteNEVMMapping(db ethdb.KeyValueWriter, hash common.Hash) {
|
||||||
|
bc.hc.WriteNEVMMapping(db, hash)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -341,13 +341,17 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
|
||||||
if config.DAOForkSupport && config.DAOForkBlock != nil && config.DAOForkBlock.Cmp(b.header.Number) == 0 {
|
if config.DAOForkSupport && config.DAOForkBlock != nil && config.DAOForkBlock.Cmp(b.header.Number) == 0 {
|
||||||
misc.ApplyDAOHardFork(statedb)
|
misc.ApplyDAOHardFork(statedb)
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
if config.NexusBlock != nil && config.NexusBlock.Cmp(b.header.Number) == 0 {
|
||||||
|
misc.ApplyNexusHardFork(statedb)
|
||||||
|
}
|
||||||
// Execute any user modifications to the block
|
// Execute any user modifications to the block
|
||||||
if gen != nil {
|
if gen != nil {
|
||||||
gen(i, b)
|
gen(i, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
var requests types.Requests
|
var requests types.Requests
|
||||||
if config.IsPrague(b.header.Number, b.header.Time) {
|
if !config.IsSyscoin(b.header.Number) && config.IsPrague(b.header.Number, b.header.Time) {
|
||||||
for _, r := range b.receipts {
|
for _, r := range b.receipts {
|
||||||
d, err := ParseDepositLogs(r.Logs, config)
|
d, err := ParseDepositLogs(r.Logs, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -554,7 +558,8 @@ func (cm *chainMaker) makeHeader(parent *types.Block, state *state.StateDB, engi
|
||||||
header.GasLimit = CalcGasLimit(parentGasLimit, parentGasLimit)
|
header.GasLimit = CalcGasLimit(parentGasLimit, parentGasLimit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if cm.config.IsCancun(header.Number, header.Time) {
|
// SYSCOIN
|
||||||
|
if !cm.config.IsSyscoin(header.Number) && cm.config.IsCancun(header.Number, header.Time) {
|
||||||
var (
|
var (
|
||||||
parentExcessBlobGas uint64
|
parentExcessBlobGas uint64
|
||||||
parentBlobGasUsed uint64
|
parentBlobGasUsed uint64
|
||||||
|
|
@ -690,3 +695,14 @@ func (cm *chainMaker) GetBlock(hash common.Hash, number uint64) *types.Block {
|
||||||
func (cm *chainMaker) GetTd(hash common.Hash, number uint64) *big.Int {
|
func (cm *chainMaker) GetTd(hash common.Hash, number uint64) *big.Int {
|
||||||
return nil // not supported
|
return nil // not supported
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
func (cm *chainMaker) HasNEVMMapping(hash common.Hash) bool { return false }
|
||||||
|
func (cm *chainMaker) ReadSYSHash(uint64) []byte {
|
||||||
|
return []byte{}
|
||||||
|
}
|
||||||
|
func (cm *chainMaker) ReadDataHash(common.Hash) []byte {
|
||||||
|
return []byte{}
|
||||||
|
}
|
||||||
|
func (cm *chainMaker) GetNEVMAddress(common.Address) []byte {
|
||||||
|
return []byte{}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,10 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common
|
||||||
CanTransfer: CanTransfer,
|
CanTransfer: CanTransfer,
|
||||||
Transfer: Transfer,
|
Transfer: Transfer,
|
||||||
GetHash: GetHashFn(header, chain),
|
GetHash: GetHashFn(header, chain),
|
||||||
|
// SYSCOIN
|
||||||
|
ReadSYSHash: ReadSYSHashFn(chain),
|
||||||
|
ReadDataHash: ReadDataHashFn(chain),
|
||||||
|
GetNEVMAddress: GetNEVMAddressFn(chain),
|
||||||
Coinbase: beneficiary,
|
Coinbase: beneficiary,
|
||||||
BlockNumber: new(big.Int).Set(header.Number),
|
BlockNumber: new(big.Int).Set(header.Number),
|
||||||
Time: header.Time,
|
Time: header.Time,
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,9 @@ func getGenesisState(db ethdb.Database, blockhash common.Hash) (alloc types.Gene
|
||||||
genesis = DefaultSepoliaGenesisBlock()
|
genesis = DefaultSepoliaGenesisBlock()
|
||||||
case params.HoleskyGenesisHash:
|
case params.HoleskyGenesisHash:
|
||||||
genesis = DefaultHoleskyGenesisBlock()
|
genesis = DefaultHoleskyGenesisBlock()
|
||||||
|
// SYSCOIN
|
||||||
|
case params.TanenbaumGenesisHash:
|
||||||
|
genesis = DefaultTanenbaumGenesisBlock()
|
||||||
}
|
}
|
||||||
if genesis != nil {
|
if genesis != nil {
|
||||||
return genesis.Alloc, nil
|
return genesis.Alloc, nil
|
||||||
|
|
@ -398,6 +401,9 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
|
||||||
return params.HoleskyChainConfig
|
return params.HoleskyChainConfig
|
||||||
case ghash == params.SepoliaGenesisHash:
|
case ghash == params.SepoliaGenesisHash:
|
||||||
return params.SepoliaChainConfig
|
return params.SepoliaChainConfig
|
||||||
|
// SYSCOIN
|
||||||
|
case ghash == params.TanenbaumGenesisHash:
|
||||||
|
return params.TanenbaumChainConfig
|
||||||
default:
|
default:
|
||||||
return params.AllEthashProtocolChanges
|
return params.AllEthashProtocolChanges
|
||||||
}
|
}
|
||||||
|
|
@ -453,11 +459,13 @@ func (g *Genesis) toBlockWithRoot(root common.Hash) *types.Block {
|
||||||
)
|
)
|
||||||
if conf := g.Config; conf != nil {
|
if conf := g.Config; conf != nil {
|
||||||
num := big.NewInt(int64(g.Number))
|
num := big.NewInt(int64(g.Number))
|
||||||
if conf.IsShanghai(num, g.Timestamp) {
|
// SYSCOIN
|
||||||
|
if !conf.IsSyscoin(num) && conf.IsShanghai(num, g.Timestamp) {
|
||||||
head.WithdrawalsHash = &types.EmptyWithdrawalsHash
|
head.WithdrawalsHash = &types.EmptyWithdrawalsHash
|
||||||
withdrawals = make([]*types.Withdrawal, 0)
|
withdrawals = make([]*types.Withdrawal, 0)
|
||||||
}
|
}
|
||||||
if conf.IsCancun(num, g.Timestamp) {
|
// SYSCOIN
|
||||||
|
if !conf.IsSyscoin(num) && conf.IsCancun(num, g.Timestamp) {
|
||||||
// EIP-4788: The parentBeaconBlockRoot of the genesis block is always
|
// EIP-4788: The parentBeaconBlockRoot of the genesis block is always
|
||||||
// the zero hash. This is because the genesis block does not have a parent
|
// the zero hash. This is because the genesis block does not have a parent
|
||||||
// by definition.
|
// by definition.
|
||||||
|
|
@ -472,7 +480,8 @@ func (g *Genesis) toBlockWithRoot(root common.Hash) *types.Block {
|
||||||
head.BlobGasUsed = new(uint64)
|
head.BlobGasUsed = new(uint64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if conf.IsPrague(num, g.Timestamp) {
|
// SYSCOIN
|
||||||
|
if !conf.IsSyscoin(num) && conf.IsPrague(num, g.Timestamp) {
|
||||||
head.RequestsHash = &types.EmptyRequestsHash
|
head.RequestsHash = &types.EmptyRequestsHash
|
||||||
requests = make(types.Requests, 0)
|
requests = make(types.Requests, 0)
|
||||||
}
|
}
|
||||||
|
|
@ -534,14 +543,25 @@ func (g *Genesis) MustCommit(db ethdb.Database, triedb *triedb.Database) *types.
|
||||||
func DefaultGenesisBlock() *Genesis {
|
func DefaultGenesisBlock() *Genesis {
|
||||||
return &Genesis{
|
return &Genesis{
|
||||||
Config: params.MainnetChainConfig,
|
Config: params.MainnetChainConfig,
|
||||||
Nonce: 66,
|
// SYSCOIN
|
||||||
ExtraData: hexutil.MustDecode("0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa"),
|
Timestamp: 0x60d7aef6,
|
||||||
GasLimit: 5000,
|
ExtraData: hexutil.MustDecode("0x00"),
|
||||||
Difficulty: big.NewInt(17179869184),
|
GasLimit: 0x7A1200,
|
||||||
Alloc: decodePrealloc(mainnetAllocData),
|
Difficulty: big.NewInt(1),
|
||||||
|
Alloc: decodePrealloc(syscoinAllocData),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
func DefaultTanenbaumGenesisBlock() *Genesis {
|
||||||
|
return &Genesis{
|
||||||
|
Config: params.TanenbaumChainConfig,
|
||||||
|
Timestamp: 0x60d6aef5,
|
||||||
|
ExtraData: hexutil.MustDecode("0x00"),
|
||||||
|
GasLimit: 0x7A1200,
|
||||||
|
Difficulty: big.NewInt(1),
|
||||||
|
Alloc: decodePrealloc(syscoinAllocData),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultSepoliaGenesisBlock returns the Sepolia network genesis block.
|
// DefaultSepoliaGenesisBlock returns the Sepolia network genesis block.
|
||||||
func DefaultSepoliaGenesisBlock() *Genesis {
|
func DefaultSepoliaGenesisBlock() *Genesis {
|
||||||
return &Genesis{
|
return &Genesis{
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -67,7 +67,11 @@ type HeaderChain struct {
|
||||||
headerCache *lru.Cache[common.Hash, *types.Header]
|
headerCache *lru.Cache[common.Hash, *types.Header]
|
||||||
tdCache *lru.Cache[common.Hash, *big.Int] // most recent total difficulties
|
tdCache *lru.Cache[common.Hash, *big.Int] // most recent total difficulties
|
||||||
numberCache *lru.Cache[common.Hash, uint64] // most recent block numbers
|
numberCache *lru.Cache[common.Hash, uint64] // most recent block numbers
|
||||||
|
// SYSCOIN
|
||||||
|
NEVMCache *lru.Cache[common.Hash, []byte] // Cache for NEVM blocks existing
|
||||||
|
SYSHashCache *lru.Cache[uint64, []byte] // Cache for SYS hash
|
||||||
|
DataHashCache *lru.Cache[common.Hash, []byte] // Cache for Data availability
|
||||||
|
NEVMAddressCache *rawdb.NEVMAddressMapping
|
||||||
procInterrupt func() bool
|
procInterrupt func() bool
|
||||||
engine consensus.Engine
|
engine consensus.Engine
|
||||||
}
|
}
|
||||||
|
|
@ -497,6 +501,97 @@ func (hc *HeaderChain) GetCanonicalHash(number uint64) common.Hash {
|
||||||
return rawdb.ReadCanonicalHash(hc.chainDb, number)
|
return rawdb.ReadCanonicalHash(hc.chainDb, number)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (hc *HeaderChain) WriteNEVMAddressMapping(db ethdb.KeyValueWriter, mapping *rawdb.NEVMAddressMapping) {
|
||||||
|
rawdb.WriteNEVMAddressMapping(db, mapping)
|
||||||
|
hc.NEVMAddressCache = mapping
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadNEVMAddressMapping retrieves the NEVM address mapping from the database
|
||||||
|
func (hc *HeaderChain) ReadNEVMAddressMapping() *rawdb.NEVMAddressMapping {
|
||||||
|
if hc.NEVMAddressCache != nil {
|
||||||
|
return hc.NEVMAddressCache
|
||||||
|
}
|
||||||
|
// sanity in case it doesn't exist in cache
|
||||||
|
addressMapping := rawdb.ReadNEVMAddressMapping(hc.chainDb)
|
||||||
|
if len(addressMapping.AddressMappings) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
hc.NEVMAddressCache = addressMapping
|
||||||
|
return addressMapping
|
||||||
|
}
|
||||||
|
|
||||||
|
func (hc *HeaderChain) GetNEVMAddress(address common.Address) []byte {
|
||||||
|
mapping := hc.ReadNEVMAddressMapping()
|
||||||
|
return mapping.GetNEVMAddress(address)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (hc *HeaderChain) ReadSYSHash(n uint64) []byte {
|
||||||
|
// Should exist in cache because we store in LRU upon creating block and delete upon disconnecting we should only store latest 50k blocks (limits to querying in opcode)
|
||||||
|
if sysBlockhash, ok := hc.SYSHashCache.Get(n); ok {
|
||||||
|
return sysBlockhash
|
||||||
|
}
|
||||||
|
// sanity in case it doesn't exist in LRU cache
|
||||||
|
sysBlockhash := rawdb.ReadSYSHash(hc.chainDb, n)
|
||||||
|
if len(sysBlockhash) == 0 {
|
||||||
|
return []byte{}
|
||||||
|
}
|
||||||
|
hc.SYSHashCache.Add(n, sysBlockhash)
|
||||||
|
return sysBlockhash
|
||||||
|
}
|
||||||
|
func (hc *HeaderChain) ReadDataHash(hash common.Hash) []byte {
|
||||||
|
// Should exist in cache because we store in LRU upon creating block and delete upon disconnecting we should only store latest 50k blocks (limits to querying in opcode)
|
||||||
|
if hc.DataHashCache.Contains(hash) {
|
||||||
|
return hash.Bytes()
|
||||||
|
}
|
||||||
|
// sanity in case it doesn't exist in LRU cache
|
||||||
|
dataHash := rawdb.ReadDataHash(hc.chainDb, hash)
|
||||||
|
if len(dataHash) == 0 {
|
||||||
|
return []byte{}
|
||||||
|
}
|
||||||
|
hc.DataHashCache.Add(hash, []byte{0})
|
||||||
|
return hash.Bytes()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (hc *HeaderChain) WriteSYSHash(db ethdb.KeyValueWriter, sysBlockhash string, n uint64) {
|
||||||
|
rawdb.WriteSYSHash(db, sysBlockhash, n)
|
||||||
|
hc.SYSHashCache.Add(n, []byte(sysBlockhash))
|
||||||
|
}
|
||||||
|
func (hc *HeaderChain) WriteDataHashes(db ethdb.KeyValueWriter, n uint64, dataHashes []*common.Hash) {
|
||||||
|
rawdb.WriteDataHashes(db, hc.chainDb, n, dataHashes)
|
||||||
|
for _, dataHash := range dataHashes {
|
||||||
|
hc.DataHashCache.Add(*dataHash, []byte{0})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (hc *HeaderChain) DeleteDataHashes(db ethdb.KeyValueWriter, n uint64) {
|
||||||
|
dataHashes := rawdb.DeleteDataHashes(db, hc.chainDb, n)
|
||||||
|
for _, dataHash := range dataHashes {
|
||||||
|
hc.DataHashCache.Remove(*dataHash)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (hc *HeaderChain) DeleteSYSHash(db ethdb.KeyValueWriter, n uint64) {
|
||||||
|
rawdb.DeleteSYSHash(db, n)
|
||||||
|
hc.SYSHashCache.Remove(n)
|
||||||
|
}
|
||||||
|
func (hc *HeaderChain) HasNEVMMapping(hash common.Hash) bool {
|
||||||
|
if hc.NEVMCache.Contains(hash) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
hasMapping := rawdb.HasNEVMMapping(hc.chainDb, hash)
|
||||||
|
if hasMapping {
|
||||||
|
hc.NEVMCache.Add(hash, []byte{0})
|
||||||
|
}
|
||||||
|
return hasMapping
|
||||||
|
}
|
||||||
|
func (hc *HeaderChain) DeleteNEVMMapping(db ethdb.KeyValueWriter, hash common.Hash) {
|
||||||
|
rawdb.DeleteNEVMMapping(db, hash)
|
||||||
|
hc.NEVMCache.Remove(hash)
|
||||||
|
}
|
||||||
|
func (hc *HeaderChain) WriteNEVMMapping(db ethdb.KeyValueWriter, hash common.Hash) {
|
||||||
|
rawdb.WriteNEVMMapping(db, hash)
|
||||||
|
hc.NEVMCache.Add(hash, []byte{0})
|
||||||
|
}
|
||||||
|
|
||||||
// CurrentHeader retrieves the current head header of the canonical chain. The
|
// CurrentHeader retrieves the current head header of the canonical chain. The
|
||||||
// header is retrieved from the HeaderChain's internal cache.
|
// header is retrieved from the HeaderChain's internal cache.
|
||||||
func (hc *HeaderChain) CurrentHeader() *types.Header {
|
func (hc *HeaderChain) CurrentHeader() *types.Header {
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,10 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
)
|
)
|
||||||
|
const (
|
||||||
|
// SYSCOIN
|
||||||
|
DataBlockLimit = 50001
|
||||||
|
)
|
||||||
// ReadCanonicalHash retrieves the hash assigned to a canonical block number.
|
// ReadCanonicalHash retrieves the hash assigned to a canonical block number.
|
||||||
func ReadCanonicalHash(db ethdb.Reader, number uint64) common.Hash {
|
func ReadCanonicalHash(db ethdb.Reader, number uint64) common.Hash {
|
||||||
var data []byte
|
var data []byte
|
||||||
|
|
@ -785,6 +788,132 @@ func writeAncientBlock(op ethdb.AncientWriteOp, block *types.Block, header *type
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SYSCOIN
|
||||||
|
// WriteNEVMAddressMapping stores the NEVM address mapping into the database
|
||||||
|
func WriteNEVMAddressMapping(db ethdb.KeyValueWriter, mapping *NEVMAddressMapping) {
|
||||||
|
data, err := rlp.EncodeToBytes(mapping.AddressMappings)
|
||||||
|
if err != nil {
|
||||||
|
log.Crit("Failed to RLP encode NEVM address mappings", "err", err)
|
||||||
|
}
|
||||||
|
if err := db.Put(nevmAddressKey(), data); err != nil {
|
||||||
|
log.Crit("Failed to store NEVM address mappings", "err", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadNEVMAddressMapping retrieves the NEVM address mapping from the database
|
||||||
|
func ReadNEVMAddressMapping(db ethdb.Reader) *NEVMAddressMapping {
|
||||||
|
data, err := db.Get(nevmAddressKey())
|
||||||
|
if err != nil || len(data) == 0 {
|
||||||
|
return NewNEVMAddressMapping()
|
||||||
|
}
|
||||||
|
var mappings map[common.Address]uint32
|
||||||
|
if err := rlp.DecodeBytes(data, &mappings); err != nil {
|
||||||
|
log.Crit("Failed to decode NEVM address mappings", "err", err)
|
||||||
|
}
|
||||||
|
return &NEVMAddressMapping{AddressMappings: mappings}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func WriteSYSHash(db ethdb.KeyValueWriter, sysBlockhash string, n uint64) {
|
||||||
|
if err := db.Put(blockNumToSysKey(n), []byte(sysBlockhash)); err != nil {
|
||||||
|
log.Crit("Failed to store blockNumToSysKey", "err", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func DeleteSYSHash(db ethdb.KeyValueWriter, n uint64) {
|
||||||
|
if err := db.Delete(blockNumToSysKey(n)); err != nil {
|
||||||
|
log.Crit("Failed to delete blockNumToSysKey", "err", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func ReadDataHashesRLP(db ethdb.Reader, number uint64) rlp.RawValue {
|
||||||
|
var data []byte
|
||||||
|
data, _ = db.Get(dataHashesKey(number))
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadRawDataHashes retrieves all the data hashes belonging to a block.
|
||||||
|
func ReadRawDataHashes(db ethdb.Reader, number uint64) []*common.Hash {
|
||||||
|
// Retrieve the flattened datahash slice
|
||||||
|
data := ReadDataHashesRLP(db, number)
|
||||||
|
if len(data) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
dataHashes := []*common.Hash{}
|
||||||
|
if err := rlp.DecodeBytes(data, &dataHashes); err != nil {
|
||||||
|
log.Error("Invalid datahash array RLP", "number", number, "err", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return dataHashes
|
||||||
|
}
|
||||||
|
|
||||||
|
func WriteDataHashes(dbw ethdb.KeyValueWriter, dbr ethdb.Reader, n uint64, dataHashes []*common.Hash) {
|
||||||
|
// prune older data hashes after a safe amount of blocks
|
||||||
|
if n > DataBlockLimit {
|
||||||
|
DeleteDataHashes(dbw, dbr, n-DataBlockLimit)
|
||||||
|
}
|
||||||
|
if len(dataHashes) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
bytes, err := rlp.EncodeToBytes(dataHashes)
|
||||||
|
if err != nil {
|
||||||
|
log.Crit("Failed to encode block dataHashes", "err", err)
|
||||||
|
}
|
||||||
|
// Store the flattened datahash slice
|
||||||
|
if err := dbw.Put(dataHashesKey(n), bytes); err != nil {
|
||||||
|
log.Crit("Failed to store block dataHashes", "err", err)
|
||||||
|
}
|
||||||
|
for _, dataHash := range dataHashes {
|
||||||
|
if err := dbw.Put(dataHashKey(*dataHash), []byte{0}); err != nil {
|
||||||
|
log.Crit("Failed to write dataHash", "err", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func DeleteDataHashes(dbw ethdb.KeyValueWriter, dbr ethdb.Reader, n uint64) []*common.Hash {
|
||||||
|
dataHashes := ReadRawDataHashes(dbr, n)
|
||||||
|
if dataHashes == nil || len(dataHashes) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
for _, dataHash := range dataHashes {
|
||||||
|
if err := dbw.Delete(dataHashKey(*dataHash)); err != nil {
|
||||||
|
log.Crit("Failed to delete dataHashKey", "err", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := dbw.Delete(dataHashesKey(n)); err != nil {
|
||||||
|
log.Crit("Failed to delete dataHashesKey", "err", err)
|
||||||
|
}
|
||||||
|
return dataHashes
|
||||||
|
}
|
||||||
|
func ReadSYSHash(db ethdb.Reader, n uint64) []byte {
|
||||||
|
data, err := db.Get(blockNumToSysKey(n))
|
||||||
|
if data == nil || err != nil {
|
||||||
|
return []byte{}
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
func ReadDataHash(db ethdb.Reader, hash common.Hash) []byte {
|
||||||
|
data, err := db.Get(dataHashKey(hash))
|
||||||
|
if data == nil || err != nil {
|
||||||
|
return []byte{}
|
||||||
|
}
|
||||||
|
return hash.Bytes()
|
||||||
|
}
|
||||||
|
|
||||||
|
// SYSCOIN HasNEVMMapping verifies the existence of a NEVM block corresponding to the hash.
|
||||||
|
func HasNEVMMapping(db ethdb.Reader, hash common.Hash) bool {
|
||||||
|
if has, err := db.Has(nevmToSysKey(hash)); !has || err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
func WriteNEVMMapping(db ethdb.KeyValueWriter, hash common.Hash) {
|
||||||
|
if err := db.Put(nevmToSysKey(hash), []byte{0}); err != nil {
|
||||||
|
log.Crit("Failed to store nevmToSysKey", "err", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func DeleteNEVMMapping(db ethdb.KeyValueWriter, hash common.Hash) {
|
||||||
|
if err := db.Delete(nevmToSysKey(hash)); err != nil {
|
||||||
|
log.Crit("Failed to delete nevmToSysKey", "err", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
// DeleteBlock removes all block data associated with a hash.
|
// DeleteBlock removes all block data associated with a hash.
|
||||||
func DeleteBlock(db ethdb.KeyValueWriter, hash common.Hash, number uint64) {
|
func DeleteBlock(db ethdb.KeyValueWriter, hash common.Hash, number uint64) {
|
||||||
DeleteReceipts(db, hash, number)
|
DeleteReceipts(db, hash, number)
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,12 @@ var (
|
||||||
CodePrefix = []byte("c") // CodePrefix + code hash -> account code
|
CodePrefix = []byte("c") // CodePrefix + code hash -> account code
|
||||||
skeletonHeaderPrefix = []byte("S") // skeletonHeaderPrefix + num (uint64 big endian) -> header
|
skeletonHeaderPrefix = []byte("S") // skeletonHeaderPrefix + num (uint64 big endian) -> header
|
||||||
|
|
||||||
|
// SYSCOIN
|
||||||
|
nevmToSysPrefix = []byte("x") // nevmToSysPrefix + nevm block hash -> nevmBlock
|
||||||
|
blockNumToSysKeyPrefix = []byte("z") // blockNumToSysKeyPrefix + block number -> SYS block hash
|
||||||
|
dataHashesKeyPrefix = []byte("y") // dataHashesKeyPrefix + block number -> versioned hashes
|
||||||
|
dataHashKeyPrefix = []byte("w") // dataHashKeyPrefix + versioned hash -> versioned hash
|
||||||
|
|
||||||
// Path-based storage scheme of merkle patricia trie.
|
// Path-based storage scheme of merkle patricia trie.
|
||||||
TrieNodeAccountPrefix = []byte("A") // TrieNodeAccountPrefix + hexPath -> trie node
|
TrieNodeAccountPrefix = []byte("A") // TrieNodeAccountPrefix + hexPath -> trie node
|
||||||
TrieNodeStoragePrefix = []byte("O") // TrieNodeStoragePrefix + accountHash + hexPath -> trie node
|
TrieNodeStoragePrefix = []byte("O") // TrieNodeStoragePrefix + accountHash + hexPath -> trie node
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,8 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
||||||
}
|
}
|
||||||
// Read requests if Prague is enabled.
|
// Read requests if Prague is enabled.
|
||||||
var requests types.Requests
|
var requests types.Requests
|
||||||
if p.config.IsPrague(block.Number(), block.Time()) {
|
// SYSCOIN
|
||||||
|
if !p.config.IsSyscoin(block.Number()) && p.config.IsPrague(block.Number(), block.Time()) {
|
||||||
requests, err = ParseDepositLogs(allLogs, p.config)
|
requests, err = ParseDepositLogs(allLogs, p.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -385,7 +385,8 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr
|
||||||
if config.IsLondon(header.Number) {
|
if config.IsLondon(header.Number) {
|
||||||
header.BaseFee = eip1559.CalcBaseFee(config, parent.Header())
|
header.BaseFee = eip1559.CalcBaseFee(config, parent.Header())
|
||||||
}
|
}
|
||||||
if config.IsShanghai(header.Number, header.Time) {
|
// SYSCOIN
|
||||||
|
if !config.IsSyscoin(header.Number) && config.IsShanghai(header.Number, header.Time) {
|
||||||
header.WithdrawalsHash = &types.EmptyWithdrawalsHash
|
header.WithdrawalsHash = &types.EmptyWithdrawalsHash
|
||||||
}
|
}
|
||||||
var receipts []*types.Receipt
|
var receipts []*types.Receipt
|
||||||
|
|
@ -406,7 +407,8 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr
|
||||||
nBlobs += len(tx.BlobHashes())
|
nBlobs += len(tx.BlobHashes())
|
||||||
}
|
}
|
||||||
header.Root = common.BytesToHash(hasher.Sum(nil))
|
header.Root = common.BytesToHash(hasher.Sum(nil))
|
||||||
if config.IsCancun(header.Number, header.Time) {
|
// SYSCOIN
|
||||||
|
if !config.IsSyscoin(header.Number) && config.IsCancun(header.Number, header.Time) {
|
||||||
var pExcess, pUsed = uint64(0), uint64(0)
|
var pExcess, pUsed = uint64(0), uint64(0)
|
||||||
if parent.ExcessBlobGas() != nil {
|
if parent.ExcessBlobGas() != nil {
|
||||||
pExcess = *parent.ExcessBlobGas()
|
pExcess = *parent.ExcessBlobGas()
|
||||||
|
|
|
||||||
|
|
@ -246,8 +246,8 @@ func (st *StateTransition) buyGas() error {
|
||||||
balanceCheck = balanceCheck.Mul(balanceCheck, st.msg.GasFeeCap)
|
balanceCheck = balanceCheck.Mul(balanceCheck, st.msg.GasFeeCap)
|
||||||
}
|
}
|
||||||
balanceCheck.Add(balanceCheck, st.msg.Value)
|
balanceCheck.Add(balanceCheck, st.msg.Value)
|
||||||
|
// SYSCOIN
|
||||||
if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) {
|
if !st.evm.ChainConfig().IsSyscoin(st.evm.Context.BlockNumber) && st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) {
|
||||||
if blobGas := st.blobGasUsed(); blobGas > 0 {
|
if blobGas := st.blobGasUsed(); blobGas > 0 {
|
||||||
// Check that the user has enough funds to cover blobGasUsed * tx.BlobGasFeeCap
|
// Check that the user has enough funds to cover blobGasUsed * tx.BlobGasFeeCap
|
||||||
blobBalanceCheck := new(big.Int).SetUint64(blobGas)
|
blobBalanceCheck := new(big.Int).SetUint64(blobGas)
|
||||||
|
|
@ -348,8 +348,8 @@ func (st *StateTransition) preCheck() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check that the user is paying at least the current blob fee
|
// SYSCOIN Check that the user is paying at least the current blob fee
|
||||||
if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) {
|
if !st.evm.ChainConfig().IsSyscoin(st.evm.Context.BlockNumber) && st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) {
|
||||||
if st.blobGasUsed() > 0 {
|
if st.blobGasUsed() > 0 {
|
||||||
// Skip the checks if gas fields are zero and blobBaseFee was explicitly disabled (eth_call)
|
// Skip the checks if gas fields are zero and blobBaseFee was explicitly disabled (eth_call)
|
||||||
skipCheck := st.evm.Config.NoBaseFee && msg.BlobGasFeeCap.BitLen() == 0
|
skipCheck := st.evm.Config.NoBaseFee && msg.BlobGasFeeCap.BitLen() == 0
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,10 @@ const (
|
||||||
// account within the same tx (captured at end of tx).
|
// account within the same tx (captured at end of tx).
|
||||||
// Note it doesn't account for a self-destruct which appoints itself as recipient.
|
// Note it doesn't account for a self-destruct which appoints itself as recipient.
|
||||||
BalanceDecreaseSelfdestructBurn BalanceChangeReason = 14
|
BalanceDecreaseSelfdestructBurn BalanceChangeReason = 14
|
||||||
|
|
||||||
|
// SYSCOIN
|
||||||
|
BalanceIncreaseVaultManagerContract BalanceChangeReason = 100
|
||||||
|
BalanceDecreaseVaultManagerAccount BalanceChangeReason = 101
|
||||||
)
|
)
|
||||||
|
|
||||||
// GasChangeReason is used to indicate the reason for a gas change, useful
|
// GasChangeReason is used to indicate the reason for a gas change, useful
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,8 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
|
||||||
if !opts.Config.IsLondon(head.Number) && tx.Type() == types.DynamicFeeTxType {
|
if !opts.Config.IsLondon(head.Number) && tx.Type() == types.DynamicFeeTxType {
|
||||||
return fmt.Errorf("%w: type %d rejected, pool not yet in London", core.ErrTxTypeNotSupported, tx.Type())
|
return fmt.Errorf("%w: type %d rejected, pool not yet in London", core.ErrTxTypeNotSupported, tx.Type())
|
||||||
}
|
}
|
||||||
if !opts.Config.IsCancun(head.Number, head.Time) && tx.Type() == types.BlobTxType {
|
// SYSCOIN
|
||||||
|
if (!opts.Config.IsSyscoin(head.Number) || !opts.Config.IsCancun(head.Number, head.Time)) && tx.Type() == types.BlobTxType {
|
||||||
return fmt.Errorf("%w: type %d rejected, pool not yet in Cancun", core.ErrTxTypeNotSupported, tx.Type())
|
return fmt.Errorf("%w: type %d rejected, pool not yet in Cancun", core.ErrTxTypeNotSupported, tx.Type())
|
||||||
}
|
}
|
||||||
// Check whether the init code size has been exceeded
|
// Check whether the init code size has been exceeded
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,17 @@ import (
|
||||||
"slices"
|
"slices"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
// SYSCOIN
|
||||||
|
"bytes"
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-verkle"
|
"github.com/ethereum/go-verkle"
|
||||||
|
// SYSCOIN
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
"github.com/syscoin/btcd/wire"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A BlockNonce is a 64-bit hash which proves (combined with the
|
// A BlockNonce is a 64-bit hash which proves (combined with the
|
||||||
|
|
@ -234,7 +240,124 @@ type extblock struct {
|
||||||
Withdrawals []*Withdrawal `rlp:"optional"`
|
Withdrawals []*Withdrawal `rlp:"optional"`
|
||||||
Requests []*Request `rlp:"optional"`
|
Requests []*Request `rlp:"optional"`
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
type NEVMBlockDisconnect struct {
|
||||||
|
Sysblockhash string
|
||||||
|
Diff *wire.NEVMAddressDiff
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *NEVMBlockDisconnect) Deserialize(bytesIn []byte) error {
|
||||||
|
var NEVMBlockWire wire.NEVMDisconnectBlockWire
|
||||||
|
r := bytes.NewReader(bytesIn)
|
||||||
|
err := NEVMBlockWire.Deserialize(r)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("NEVMBlockDisconnect: could not deserialize", "err", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign deserialized fields to NEVMDisconnectBlock fields
|
||||||
|
n.Sysblockhash = string(NEVMBlockWire.SYSBlockHash)
|
||||||
|
|
||||||
|
// Deserialize and handle the Diff field
|
||||||
|
n.Diff = &NEVMBlockWire.Diff
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
type NEVMBlockConnect struct {
|
||||||
|
Blockhash common.Hash
|
||||||
|
Sysblockhash string
|
||||||
|
Block *Block
|
||||||
|
VersionHashes []*common.Hash
|
||||||
|
Diff *wire.NEVMAddressDiff
|
||||||
|
}
|
||||||
|
func (n *NEVMBlockConnect) HasDiff() bool {
|
||||||
|
return len(n.Diff.AddedMNNEVM) > 0 || len(n.Diff.RemovedMNNEVM) > 0 || len(n.Diff.UpdatedMNNEVM) > 0
|
||||||
|
}
|
||||||
|
func (n *NEVMBlockDisconnect) HasDiff() bool {
|
||||||
|
return len(n.Diff.AddedMNNEVM) > 0 || len(n.Diff.RemovedMNNEVM) > 0 || len(n.Diff.UpdatedMNNEVM) > 0
|
||||||
|
}
|
||||||
|
func (n *NEVMBlockConnect) Deserialize(bytesIn []byte) error {
|
||||||
|
var NEVMBlockWire wire.NEVMBlockWire
|
||||||
|
r := bytes.NewReader(bytesIn)
|
||||||
|
err := NEVMBlockWire.Deserialize(r)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("NEVMBlockConnect: could not deserialize", "err", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign deserialized fields to NEVMBlockConnect fields
|
||||||
|
n.Blockhash = common.BytesToHash(NEVMBlockWire.NEVMBlockHash)
|
||||||
|
n.Sysblockhash = string(NEVMBlockWire.SYSBlockHash)
|
||||||
|
|
||||||
|
if len(NEVMBlockWire.NEVMBlockData) == 0 {
|
||||||
|
return errors.New("empty block data")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode the raw block inside of NEVM data
|
||||||
|
var block Block
|
||||||
|
err = rlp.DecodeBytes(NEVMBlockWire.NEVMBlockData, &block)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("NEVMBlockConnect: could not decode NEVMBlockData", "err", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create NEVMBlockConnect object from deserialized block and NEVM wire data
|
||||||
|
n.Block = &block
|
||||||
|
|
||||||
|
// Validate that tx root and receipt root is correct based on the block
|
||||||
|
txRootHash := common.BytesToHash(NEVMBlockWire.TxRoot)
|
||||||
|
if txRootHash != block.TxHash() {
|
||||||
|
return errors.New("transaction Root mismatch")
|
||||||
|
}
|
||||||
|
|
||||||
|
receiptRootHash := common.BytesToHash(NEVMBlockWire.ReceiptRoot)
|
||||||
|
if receiptRootHash != block.ReceiptHash() {
|
||||||
|
return errors.New("receipt Root mismatch")
|
||||||
|
}
|
||||||
|
|
||||||
|
if n.Blockhash != block.Hash() {
|
||||||
|
return errors.New("blockhash mismatch")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process VersionHashes
|
||||||
|
numVH := len(NEVMBlockWire.VersionHashes)
|
||||||
|
n.VersionHashes = make([]*common.Hash, numVH)
|
||||||
|
for i := 0; i < numVH; i++ {
|
||||||
|
vh := common.BytesToHash(NEVMBlockWire.VersionHashes[i])
|
||||||
|
n.VersionHashes[i] = &vh
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deserialize and handle the Diff field
|
||||||
|
n.Diff = &NEVMBlockWire.Diff
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *NEVMBlockConnect) Serialize(block *Block) ([]byte, error) {
|
||||||
|
var NEVMBlockWire wire.NEVMBlockWire
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// Encode block to RLP
|
||||||
|
NEVMBlockWire.NEVMBlockData, err = rlp.EncodeToBytes(block)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set block hashes
|
||||||
|
NEVMBlockWire.NEVMBlockHash = block.Hash().Bytes()
|
||||||
|
NEVMBlockWire.TxRoot = block.TxHash().Bytes()
|
||||||
|
NEVMBlockWire.ReceiptRoot = block.ReceiptHash().Bytes()
|
||||||
|
|
||||||
|
// Serialize the NEVMBlockWire structure to bytes
|
||||||
|
var buffer bytes.Buffer
|
||||||
|
err = NEVMBlockWire.Serialize(&buffer)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("NEVMBlockConnect: could not serialize", "err", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer.Bytes(), nil
|
||||||
|
}
|
||||||
// NewBlock creates a new block. The input data is copied, changes to header and to the
|
// NewBlock creates a new block. The input data is copied, changes to header and to the
|
||||||
// field values will not affect the block.
|
// field values will not affect the block.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@ import (
|
||||||
// contract.
|
// contract.
|
||||||
type PrecompiledContract interface {
|
type PrecompiledContract interface {
|
||||||
RequiredGas(input []byte) uint64 // RequiredPrice calculates the contract gas use
|
RequiredGas(input []byte) uint64 // RequiredPrice calculates the contract gas use
|
||||||
Run(input []byte) ([]byte, error) // Run runs the precompiled contract
|
// SYSCOIN
|
||||||
|
Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) // Run runs the precompiled contract
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrecompiledContracts contains the precompiled contracts supported at the given fork.
|
// PrecompiledContracts contains the precompiled contracts supported at the given fork.
|
||||||
|
|
@ -138,6 +139,43 @@ var PrecompiledContractsPrague = PrecompiledContracts{
|
||||||
common.BytesToAddress([]byte{0x12}): &bls12381MapG1{},
|
common.BytesToAddress([]byte{0x12}): &bls12381MapG1{},
|
||||||
common.BytesToAddress([]byte{0x13}): &bls12381MapG2{},
|
common.BytesToAddress([]byte{0x13}): &bls12381MapG2{},
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
var PrecompiledContractsRollux = PrecompiledContracts{
|
||||||
|
common.BytesToAddress([]byte{0x1}): &ecrecover{},
|
||||||
|
common.BytesToAddress([]byte{0x2}): &sha256hash{},
|
||||||
|
common.BytesToAddress([]byte{0x3}): &ripemd160hash{},
|
||||||
|
common.BytesToAddress([]byte{0x4}): &dataCopy{},
|
||||||
|
common.BytesToAddress([]byte{0x5}): &bigModExp{eip2565: true},
|
||||||
|
common.BytesToAddress([]byte{0x6}): &bn256AddIstanbul{},
|
||||||
|
common.BytesToAddress([]byte{0x7}): &bn256ScalarMulIstanbul{},
|
||||||
|
common.BytesToAddress([]byte{0x8}): &bn256PairingIstanbul{},
|
||||||
|
common.BytesToAddress([]byte{0x9}): &blake2F{},
|
||||||
|
common.BytesToAddress([]byte{0x63}): &datahash{},
|
||||||
|
}
|
||||||
|
var PrecompiledContractsNexus = PrecompiledContracts{
|
||||||
|
common.BytesToAddress([]byte{0x01}): &ecrecover{},
|
||||||
|
common.BytesToAddress([]byte{0x02}): &sha256hash{},
|
||||||
|
common.BytesToAddress([]byte{0x03}): &ripemd160hash{},
|
||||||
|
common.BytesToAddress([]byte{0x04}): &dataCopy{},
|
||||||
|
common.BytesToAddress([]byte{0x05}): &bigModExp{eip2565: true},
|
||||||
|
common.BytesToAddress([]byte{0x06}): &bn256AddIstanbul{},
|
||||||
|
common.BytesToAddress([]byte{0x07}): &bn256ScalarMulIstanbul{},
|
||||||
|
common.BytesToAddress([]byte{0x08}): &bn256PairingIstanbul{},
|
||||||
|
common.BytesToAddress([]byte{0x09}): &blake2F{},
|
||||||
|
common.BytesToAddress([]byte{0x0a}): &kzgPointEvaluation{},
|
||||||
|
common.BytesToAddress([]byte{0x0b}): &bls12381G1Add{},
|
||||||
|
common.BytesToAddress([]byte{0x0c}): &bls12381G1Mul{},
|
||||||
|
common.BytesToAddress([]byte{0x0d}): &bls12381G1MultiExp{},
|
||||||
|
common.BytesToAddress([]byte{0x0e}): &bls12381G2Add{},
|
||||||
|
common.BytesToAddress([]byte{0x0f}): &bls12381G2Mul{},
|
||||||
|
common.BytesToAddress([]byte{0x10}): &bls12381G2MultiExp{},
|
||||||
|
common.BytesToAddress([]byte{0x11}): &bls12381Pairing{},
|
||||||
|
common.BytesToAddress([]byte{0x12}): &bls12381MapG1{},
|
||||||
|
common.BytesToAddress([]byte{0x13}): &bls12381MapG2{},
|
||||||
|
common.BytesToAddress([]byte{0x61}): &sysblockhash{},
|
||||||
|
common.BytesToAddress([]byte{0x62}): &nevmaddress{},
|
||||||
|
common.BytesToAddress([]byte{0x63}): &datahash{},
|
||||||
|
}
|
||||||
|
|
||||||
var PrecompiledContractsBLS = PrecompiledContractsPrague
|
var PrecompiledContractsBLS = PrecompiledContractsPrague
|
||||||
|
|
||||||
|
|
@ -150,6 +188,10 @@ var (
|
||||||
PrecompiledAddressesIstanbul []common.Address
|
PrecompiledAddressesIstanbul []common.Address
|
||||||
PrecompiledAddressesByzantium []common.Address
|
PrecompiledAddressesByzantium []common.Address
|
||||||
PrecompiledAddressesHomestead []common.Address
|
PrecompiledAddressesHomestead []common.Address
|
||||||
|
// SYSCOIN
|
||||||
|
PrecompiledAddressesSyscoin []common.Address
|
||||||
|
PrecompiledAddressesRollux []common.Address
|
||||||
|
PrecompiledAddressesNexus []common.Address
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -171,14 +213,22 @@ func init() {
|
||||||
for k := range PrecompiledContractsPrague {
|
for k := range PrecompiledContractsPrague {
|
||||||
PrecompiledAddressesPrague = append(PrecompiledAddressesPrague, k)
|
PrecompiledAddressesPrague = append(PrecompiledAddressesPrague, k)
|
||||||
}
|
}
|
||||||
|
for k := range PrecompiledContractsNexus {
|
||||||
|
PrecompiledAddressesNexus = append(PrecompiledAddressesNexus, k)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func activePrecompiledContracts(rules params.Rules) PrecompiledContracts {
|
func activePrecompiledContracts(rules params.Rules) PrecompiledContracts {
|
||||||
switch {
|
switch {
|
||||||
|
// SYSCOIN
|
||||||
|
case rules.IsNexus:
|
||||||
|
return PrecompiledContractsNexus
|
||||||
case rules.IsVerkle:
|
case rules.IsVerkle:
|
||||||
return PrecompiledContractsVerkle
|
return PrecompiledContractsVerkle
|
||||||
case rules.IsPrague:
|
case rules.IsPrague:
|
||||||
return PrecompiledContractsPrague
|
return PrecompiledContractsPrague
|
||||||
|
case rules.IsRollux:
|
||||||
|
return PrecompiledContractsRollux
|
||||||
case rules.IsCancun:
|
case rules.IsCancun:
|
||||||
return PrecompiledContractsCancun
|
return PrecompiledContractsCancun
|
||||||
case rules.IsBerlin:
|
case rules.IsBerlin:
|
||||||
|
|
@ -200,8 +250,13 @@ func ActivePrecompiledContracts(rules params.Rules) PrecompiledContracts {
|
||||||
// ActivePrecompiles returns the precompile addresses enabled with the current configuration.
|
// ActivePrecompiles returns the precompile addresses enabled with the current configuration.
|
||||||
func ActivePrecompiles(rules params.Rules) []common.Address {
|
func ActivePrecompiles(rules params.Rules) []common.Address {
|
||||||
switch {
|
switch {
|
||||||
|
// SYSCOIN
|
||||||
|
case rules.IsNexus:
|
||||||
|
return PrecompiledAddressesNexus
|
||||||
case rules.IsPrague:
|
case rules.IsPrague:
|
||||||
return PrecompiledAddressesPrague
|
return PrecompiledAddressesPrague
|
||||||
|
case rules.IsRollux:
|
||||||
|
return PrecompiledAddressesRollux
|
||||||
case rules.IsCancun:
|
case rules.IsCancun:
|
||||||
return PrecompiledAddressesCancun
|
return PrecompiledAddressesCancun
|
||||||
case rules.IsBerlin:
|
case rules.IsBerlin:
|
||||||
|
|
@ -215,12 +270,12 @@ func ActivePrecompiles(rules params.Rules) []common.Address {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunPrecompiledContract runs and evaluates the output of a precompiled contract.
|
// SYSCOIN RunPrecompiledContract runs and evaluates the output of a precompiled contract.
|
||||||
// It returns
|
// It returns
|
||||||
// - the returned bytes,
|
// - the returned bytes,
|
||||||
// - the _remaining_ gas,
|
// - the _remaining_ gas,
|
||||||
// - any error that occurred
|
// - any error that occurred
|
||||||
func RunPrecompiledContract(p PrecompiledContract, input []byte, suppliedGas uint64, logger *tracing.Hooks) (ret []byte, remainingGas uint64, err error) {
|
func RunPrecompiledContract(p PrecompiledContract, input []byte, suppliedGas uint64, logger *tracing.Hooks, interpreter *EVMInterpreter) (ret []byte, remainingGas uint64, err error) {
|
||||||
gasCost := p.RequiredGas(input)
|
gasCost := p.RequiredGas(input)
|
||||||
if suppliedGas < gasCost {
|
if suppliedGas < gasCost {
|
||||||
return nil, 0, ErrOutOfGas
|
return nil, 0, ErrOutOfGas
|
||||||
|
|
@ -229,7 +284,8 @@ func RunPrecompiledContract(p PrecompiledContract, input []byte, suppliedGas uin
|
||||||
logger.OnGasChange(suppliedGas, suppliedGas-gasCost, tracing.GasChangeCallPrecompiledContract)
|
logger.OnGasChange(suppliedGas, suppliedGas-gasCost, tracing.GasChangeCallPrecompiledContract)
|
||||||
}
|
}
|
||||||
suppliedGas -= gasCost
|
suppliedGas -= gasCost
|
||||||
output, err := p.Run(input)
|
// SYSCOIN
|
||||||
|
output, err := p.Run(input, interpreter)
|
||||||
return output, suppliedGas, err
|
return output, suppliedGas, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -239,8 +295,8 @@ type ecrecover struct{}
|
||||||
func (c *ecrecover) RequiredGas(input []byte) uint64 {
|
func (c *ecrecover) RequiredGas(input []byte) uint64 {
|
||||||
return params.EcrecoverGas
|
return params.EcrecoverGas
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *ecrecover) Run(input []byte) ([]byte, error) {
|
func (c *ecrecover) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
const ecRecoverInputLength = 128
|
const ecRecoverInputLength = 128
|
||||||
|
|
||||||
input = common.RightPadBytes(input, ecRecoverInputLength)
|
input = common.RightPadBytes(input, ecRecoverInputLength)
|
||||||
|
|
@ -281,7 +337,8 @@ type sha256hash struct{}
|
||||||
func (c *sha256hash) RequiredGas(input []byte) uint64 {
|
func (c *sha256hash) RequiredGas(input []byte) uint64 {
|
||||||
return uint64(len(input)+31)/32*params.Sha256PerWordGas + params.Sha256BaseGas
|
return uint64(len(input)+31)/32*params.Sha256PerWordGas + params.Sha256BaseGas
|
||||||
}
|
}
|
||||||
func (c *sha256hash) Run(input []byte) ([]byte, error) {
|
// SYSCOIN
|
||||||
|
func (c *sha256hash) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
h := sha256.Sum256(input)
|
h := sha256.Sum256(input)
|
||||||
return h[:], nil
|
return h[:], nil
|
||||||
}
|
}
|
||||||
|
|
@ -296,7 +353,8 @@ type ripemd160hash struct{}
|
||||||
func (c *ripemd160hash) RequiredGas(input []byte) uint64 {
|
func (c *ripemd160hash) RequiredGas(input []byte) uint64 {
|
||||||
return uint64(len(input)+31)/32*params.Ripemd160PerWordGas + params.Ripemd160BaseGas
|
return uint64(len(input)+31)/32*params.Ripemd160PerWordGas + params.Ripemd160BaseGas
|
||||||
}
|
}
|
||||||
func (c *ripemd160hash) Run(input []byte) ([]byte, error) {
|
// SYSCOIN
|
||||||
|
func (c *ripemd160hash) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
ripemd := ripemd160.New()
|
ripemd := ripemd160.New()
|
||||||
ripemd.Write(input)
|
ripemd.Write(input)
|
||||||
return common.LeftPadBytes(ripemd.Sum(nil), 32), nil
|
return common.LeftPadBytes(ripemd.Sum(nil), 32), nil
|
||||||
|
|
@ -312,7 +370,8 @@ type dataCopy struct{}
|
||||||
func (c *dataCopy) RequiredGas(input []byte) uint64 {
|
func (c *dataCopy) RequiredGas(input []byte) uint64 {
|
||||||
return uint64(len(input)+31)/32*params.IdentityPerWordGas + params.IdentityBaseGas
|
return uint64(len(input)+31)/32*params.IdentityPerWordGas + params.IdentityBaseGas
|
||||||
}
|
}
|
||||||
func (c *dataCopy) Run(in []byte) ([]byte, error) {
|
// SYSCOIN
|
||||||
|
func (c *dataCopy) Run(in []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
return common.CopyBytes(in), nil
|
return common.CopyBytes(in), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -433,8 +492,8 @@ func (c *bigModExp) RequiredGas(input []byte) uint64 {
|
||||||
}
|
}
|
||||||
return gas.Uint64()
|
return gas.Uint64()
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *bigModExp) Run(input []byte) ([]byte, error) {
|
func (c *bigModExp) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
baseLen = new(big.Int).SetBytes(getData(input, 0, 32)).Uint64()
|
baseLen = new(big.Int).SetBytes(getData(input, 0, 32)).Uint64()
|
||||||
expLen = new(big.Int).SetBytes(getData(input, 32, 32)).Uint64()
|
expLen = new(big.Int).SetBytes(getData(input, 32, 32)).Uint64()
|
||||||
|
|
@ -513,8 +572,8 @@ type bn256AddIstanbul struct{}
|
||||||
func (c *bn256AddIstanbul) RequiredGas(input []byte) uint64 {
|
func (c *bn256AddIstanbul) RequiredGas(input []byte) uint64 {
|
||||||
return params.Bn256AddGasIstanbul
|
return params.Bn256AddGasIstanbul
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *bn256AddIstanbul) Run(input []byte) ([]byte, error) {
|
func (c *bn256AddIstanbul) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
return runBn256Add(input)
|
return runBn256Add(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -526,8 +585,8 @@ type bn256AddByzantium struct{}
|
||||||
func (c *bn256AddByzantium) RequiredGas(input []byte) uint64 {
|
func (c *bn256AddByzantium) RequiredGas(input []byte) uint64 {
|
||||||
return params.Bn256AddGasByzantium
|
return params.Bn256AddGasByzantium
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *bn256AddByzantium) Run(input []byte) ([]byte, error) {
|
func (c *bn256AddByzantium) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
return runBn256Add(input)
|
return runBn256Add(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -551,8 +610,8 @@ type bn256ScalarMulIstanbul struct{}
|
||||||
func (c *bn256ScalarMulIstanbul) RequiredGas(input []byte) uint64 {
|
func (c *bn256ScalarMulIstanbul) RequiredGas(input []byte) uint64 {
|
||||||
return params.Bn256ScalarMulGasIstanbul
|
return params.Bn256ScalarMulGasIstanbul
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *bn256ScalarMulIstanbul) Run(input []byte) ([]byte, error) {
|
func (c *bn256ScalarMulIstanbul) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
return runBn256ScalarMul(input)
|
return runBn256ScalarMul(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -564,8 +623,8 @@ type bn256ScalarMulByzantium struct{}
|
||||||
func (c *bn256ScalarMulByzantium) RequiredGas(input []byte) uint64 {
|
func (c *bn256ScalarMulByzantium) RequiredGas(input []byte) uint64 {
|
||||||
return params.Bn256ScalarMulGasByzantium
|
return params.Bn256ScalarMulGasByzantium
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *bn256ScalarMulByzantium) Run(input []byte) ([]byte, error) {
|
func (c *bn256ScalarMulByzantium) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
return runBn256ScalarMul(input)
|
return runBn256ScalarMul(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -619,8 +678,8 @@ type bn256PairingIstanbul struct{}
|
||||||
func (c *bn256PairingIstanbul) RequiredGas(input []byte) uint64 {
|
func (c *bn256PairingIstanbul) RequiredGas(input []byte) uint64 {
|
||||||
return params.Bn256PairingBaseGasIstanbul + uint64(len(input)/192)*params.Bn256PairingPerPointGasIstanbul
|
return params.Bn256PairingBaseGasIstanbul + uint64(len(input)/192)*params.Bn256PairingPerPointGasIstanbul
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *bn256PairingIstanbul) Run(input []byte) ([]byte, error) {
|
func (c *bn256PairingIstanbul) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
return runBn256Pairing(input)
|
return runBn256Pairing(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -632,8 +691,8 @@ type bn256PairingByzantium struct{}
|
||||||
func (c *bn256PairingByzantium) RequiredGas(input []byte) uint64 {
|
func (c *bn256PairingByzantium) RequiredGas(input []byte) uint64 {
|
||||||
return params.Bn256PairingBaseGasByzantium + uint64(len(input)/192)*params.Bn256PairingPerPointGasByzantium
|
return params.Bn256PairingBaseGasByzantium + uint64(len(input)/192)*params.Bn256PairingPerPointGasByzantium
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *bn256PairingByzantium) Run(input []byte) ([]byte, error) {
|
func (c *bn256PairingByzantium) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
return runBn256Pairing(input)
|
return runBn256Pairing(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -658,8 +717,8 @@ var (
|
||||||
errBlake2FInvalidInputLength = errors.New("invalid input length")
|
errBlake2FInvalidInputLength = errors.New("invalid input length")
|
||||||
errBlake2FInvalidFinalFlag = errors.New("invalid final flag")
|
errBlake2FInvalidFinalFlag = errors.New("invalid final flag")
|
||||||
)
|
)
|
||||||
|
// SYSCOIN
|
||||||
func (c *blake2F) Run(input []byte) ([]byte, error) {
|
func (c *blake2F) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
// Make sure the input is valid (correct length and final flag)
|
// Make sure the input is valid (correct length and final flag)
|
||||||
if len(input) != blake2FInputLength {
|
if len(input) != blake2FInputLength {
|
||||||
return nil, errBlake2FInvalidInputLength
|
return nil, errBlake2FInvalidInputLength
|
||||||
|
|
@ -712,8 +771,8 @@ type bls12381G1Add struct{}
|
||||||
func (c *bls12381G1Add) RequiredGas(input []byte) uint64 {
|
func (c *bls12381G1Add) RequiredGas(input []byte) uint64 {
|
||||||
return params.Bls12381G1AddGas
|
return params.Bls12381G1AddGas
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *bls12381G1Add) Run(input []byte) ([]byte, error) {
|
func (c *bls12381G1Add) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
// Implements EIP-2537 G1Add precompile.
|
// Implements EIP-2537 G1Add precompile.
|
||||||
// > G1 addition call expects `256` bytes as an input that is interpreted as byte concatenation of two G1 points (`128` bytes each).
|
// > G1 addition call expects `256` bytes as an input that is interpreted as byte concatenation of two G1 points (`128` bytes each).
|
||||||
// > Output is an encoding of addition operation result - single G1 point (`128` bytes).
|
// > Output is an encoding of addition operation result - single G1 point (`128` bytes).
|
||||||
|
|
@ -748,8 +807,8 @@ type bls12381G1Mul struct{}
|
||||||
func (c *bls12381G1Mul) RequiredGas(input []byte) uint64 {
|
func (c *bls12381G1Mul) RequiredGas(input []byte) uint64 {
|
||||||
return params.Bls12381G1MulGas
|
return params.Bls12381G1MulGas
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *bls12381G1Mul) Run(input []byte) ([]byte, error) {
|
func (c *bls12381G1Mul) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
// Implements EIP-2537 G1Mul precompile.
|
// Implements EIP-2537 G1Mul precompile.
|
||||||
// > G1 multiplication call expects `160` bytes as an input that is interpreted as byte concatenation of encoding of G1 point (`128` bytes) and encoding of a scalar value (`32` bytes).
|
// > G1 multiplication call expects `160` bytes as an input that is interpreted as byte concatenation of encoding of G1 point (`128` bytes) and encoding of a scalar value (`32` bytes).
|
||||||
// > Output is an encoding of multiplication operation result - single G1 point (`128` bytes).
|
// > Output is an encoding of multiplication operation result - single G1 point (`128` bytes).
|
||||||
|
|
@ -800,8 +859,8 @@ func (c *bls12381G1MultiExp) RequiredGas(input []byte) uint64 {
|
||||||
// Calculate gas and return the result
|
// Calculate gas and return the result
|
||||||
return (uint64(k) * params.Bls12381G1MulGas * discount) / 1000
|
return (uint64(k) * params.Bls12381G1MulGas * discount) / 1000
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *bls12381G1MultiExp) Run(input []byte) ([]byte, error) {
|
func (c *bls12381G1MultiExp) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
// Implements EIP-2537 G1MultiExp precompile.
|
// Implements EIP-2537 G1MultiExp precompile.
|
||||||
// G1 multiplication call expects `160*k` bytes as an input that is interpreted as byte concatenation of `k` slices each of them being a byte concatenation of encoding of G1 point (`128` bytes) and encoding of a scalar value (`32` bytes).
|
// G1 multiplication call expects `160*k` bytes as an input that is interpreted as byte concatenation of `k` slices each of them being a byte concatenation of encoding of G1 point (`128` bytes) and encoding of a scalar value (`32` bytes).
|
||||||
// Output is an encoding of multiexponentiation operation result - single G1 point (`128` bytes).
|
// Output is an encoding of multiexponentiation operation result - single G1 point (`128` bytes).
|
||||||
|
|
@ -846,8 +905,8 @@ type bls12381G2Add struct{}
|
||||||
func (c *bls12381G2Add) RequiredGas(input []byte) uint64 {
|
func (c *bls12381G2Add) RequiredGas(input []byte) uint64 {
|
||||||
return params.Bls12381G2AddGas
|
return params.Bls12381G2AddGas
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *bls12381G2Add) Run(input []byte) ([]byte, error) {
|
func (c *bls12381G2Add) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
// Implements EIP-2537 G2Add precompile.
|
// Implements EIP-2537 G2Add precompile.
|
||||||
// > G2 addition call expects `512` bytes as an input that is interpreted as byte concatenation of two G2 points (`256` bytes each).
|
// > G2 addition call expects `512` bytes as an input that is interpreted as byte concatenation of two G2 points (`256` bytes each).
|
||||||
// > Output is an encoding of addition operation result - single G2 point (`256` bytes).
|
// > Output is an encoding of addition operation result - single G2 point (`256` bytes).
|
||||||
|
|
@ -883,8 +942,8 @@ type bls12381G2Mul struct{}
|
||||||
func (c *bls12381G2Mul) RequiredGas(input []byte) uint64 {
|
func (c *bls12381G2Mul) RequiredGas(input []byte) uint64 {
|
||||||
return params.Bls12381G2MulGas
|
return params.Bls12381G2MulGas
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *bls12381G2Mul) Run(input []byte) ([]byte, error) {
|
func (c *bls12381G2Mul) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
// Implements EIP-2537 G2MUL precompile logic.
|
// Implements EIP-2537 G2MUL precompile logic.
|
||||||
// > G2 multiplication call expects `288` bytes as an input that is interpreted as byte concatenation of encoding of G2 point (`256` bytes) and encoding of a scalar value (`32` bytes).
|
// > G2 multiplication call expects `288` bytes as an input that is interpreted as byte concatenation of encoding of G2 point (`256` bytes) and encoding of a scalar value (`32` bytes).
|
||||||
// > Output is an encoding of multiplication operation result - single G2 point (`256` bytes).
|
// > Output is an encoding of multiplication operation result - single G2 point (`256` bytes).
|
||||||
|
|
@ -935,8 +994,8 @@ func (c *bls12381G2MultiExp) RequiredGas(input []byte) uint64 {
|
||||||
// Calculate gas and return the result
|
// Calculate gas and return the result
|
||||||
return (uint64(k) * params.Bls12381G2MulGas * discount) / 1000
|
return (uint64(k) * params.Bls12381G2MulGas * discount) / 1000
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *bls12381G2MultiExp) Run(input []byte) ([]byte, error) {
|
func (c *bls12381G2MultiExp) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
// Implements EIP-2537 G2MultiExp precompile logic
|
// Implements EIP-2537 G2MultiExp precompile logic
|
||||||
// > G2 multiplication call expects `288*k` bytes as an input that is interpreted as byte concatenation of `k` slices each of them being a byte concatenation of encoding of G2 point (`256` bytes) and encoding of a scalar value (`32` bytes).
|
// > G2 multiplication call expects `288*k` bytes as an input that is interpreted as byte concatenation of `k` slices each of them being a byte concatenation of encoding of G2 point (`256` bytes) and encoding of a scalar value (`32` bytes).
|
||||||
// > Output is an encoding of multiexponentiation operation result - single G2 point (`256` bytes).
|
// > Output is an encoding of multiexponentiation operation result - single G2 point (`256` bytes).
|
||||||
|
|
@ -981,8 +1040,8 @@ type bls12381Pairing struct{}
|
||||||
func (c *bls12381Pairing) RequiredGas(input []byte) uint64 {
|
func (c *bls12381Pairing) RequiredGas(input []byte) uint64 {
|
||||||
return params.Bls12381PairingBaseGas + uint64(len(input)/384)*params.Bls12381PairingPerPairGas
|
return params.Bls12381PairingBaseGas + uint64(len(input)/384)*params.Bls12381PairingPerPairGas
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *bls12381Pairing) Run(input []byte) ([]byte, error) {
|
func (c *bls12381Pairing) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
// Implements EIP-2537 Pairing precompile logic.
|
// Implements EIP-2537 Pairing precompile logic.
|
||||||
// > Pairing call expects `384*k` bytes as an inputs that is interpreted as byte concatenation of `k` slices. Each slice has the following structure:
|
// > Pairing call expects `384*k` bytes as an inputs that is interpreted as byte concatenation of `k` slices. Each slice has the following structure:
|
||||||
// > - `128` bytes of G1 point encoding
|
// > - `128` bytes of G1 point encoding
|
||||||
|
|
@ -1133,8 +1192,8 @@ type bls12381MapG1 struct{}
|
||||||
func (c *bls12381MapG1) RequiredGas(input []byte) uint64 {
|
func (c *bls12381MapG1) RequiredGas(input []byte) uint64 {
|
||||||
return params.Bls12381MapG1Gas
|
return params.Bls12381MapG1Gas
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *bls12381MapG1) Run(input []byte) ([]byte, error) {
|
func (c *bls12381MapG1) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
// Implements EIP-2537 Map_To_G1 precompile.
|
// Implements EIP-2537 Map_To_G1 precompile.
|
||||||
// > Field-to-curve call expects an `64` bytes input that is interpreted as an element of the base field.
|
// > Field-to-curve call expects an `64` bytes input that is interpreted as an element of the base field.
|
||||||
// > Output of this call is `128` bytes and is G1 point following respective encoding rules.
|
// > Output of this call is `128` bytes and is G1 point following respective encoding rules.
|
||||||
|
|
@ -1162,8 +1221,8 @@ type bls12381MapG2 struct{}
|
||||||
func (c *bls12381MapG2) RequiredGas(input []byte) uint64 {
|
func (c *bls12381MapG2) RequiredGas(input []byte) uint64 {
|
||||||
return params.Bls12381MapG2Gas
|
return params.Bls12381MapG2Gas
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
func (c *bls12381MapG2) Run(input []byte) ([]byte, error) {
|
func (c *bls12381MapG2) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
// Implements EIP-2537 Map_FP2_TO_G2 precompile logic.
|
// Implements EIP-2537 Map_FP2_TO_G2 precompile logic.
|
||||||
// > Field-to-curve call expects an `128` bytes input that is interpreted as an element of the quadratic extension field.
|
// > Field-to-curve call expects an `128` bytes input that is interpreted as an element of the quadratic extension field.
|
||||||
// > Output of this call is `256` bytes and is G2 point following respective encoding rules.
|
// > Output of this call is `256` bytes and is G2 point following respective encoding rules.
|
||||||
|
|
@ -1188,6 +1247,64 @@ func (c *bls12381MapG2) Run(input []byte) ([]byte, error) {
|
||||||
return encodePointG2(&r), nil
|
return encodePointG2(&r), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SYSCOIN datahash implements DA precompile.
|
||||||
|
type datahash struct{}
|
||||||
|
|
||||||
|
// RequiredGas returns the gas required to execute the pre-compiled contract.
|
||||||
|
func (c *datahash) RequiredGas(input []byte) uint64 {
|
||||||
|
return params.SYSDataHashGas
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *datahash) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
|
if len(input) != 32 {
|
||||||
|
return nil, errDataHashInvalidInputLength
|
||||||
|
}
|
||||||
|
|
||||||
|
return interpreter.evm.Context.ReadDataHash(common.BytesToHash(input)), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type sysblockhash struct{}
|
||||||
|
|
||||||
|
// RequiredGas returns the gas required to execute the pre-compiled contract.
|
||||||
|
func (c *sysblockhash) RequiredGas(input []byte) uint64 {
|
||||||
|
return params.SYSBlockHashGas
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *sysblockhash) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
|
if len(input) != 8 {
|
||||||
|
return nil, errReadSYSHashInvalidInputLength
|
||||||
|
}
|
||||||
|
inputUint64 := binary.BigEndian.Uint64(input)
|
||||||
|
var upper, lower uint64
|
||||||
|
upper = interpreter.evm.Context.BlockNumber.Uint64()
|
||||||
|
if upper < 50001 {
|
||||||
|
lower = 0
|
||||||
|
} else {
|
||||||
|
lower = upper - 50000
|
||||||
|
}
|
||||||
|
if inputUint64 >= lower && inputUint64 < upper {
|
||||||
|
return interpreter.evm.Context.ReadSYSHash(inputUint64), nil
|
||||||
|
} else {
|
||||||
|
return []byte{}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type nevmaddress struct{}
|
||||||
|
|
||||||
|
// RequiredGas returns the gas required to execute the pre-compiled contract.
|
||||||
|
func (c *nevmaddress) RequiredGas(input []byte) uint64 {
|
||||||
|
return params.NEVMAddressGas
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *nevmaddress) Run(input []byte, interpreter *EVMInterpreter) ([]byte, error) {
|
||||||
|
if len(input) != 20 {
|
||||||
|
return nil, errNEVMAddressInvalidInputLength
|
||||||
|
}
|
||||||
|
|
||||||
|
return interpreter.evm.Context.GetNEVMAddress(common.BytesToAddress(input)), nil
|
||||||
|
}
|
||||||
|
|
||||||
// kzgPointEvaluation implements the EIP-4844 point evaluation precompile.
|
// kzgPointEvaluation implements the EIP-4844 point evaluation precompile.
|
||||||
type kzgPointEvaluation struct{}
|
type kzgPointEvaluation struct{}
|
||||||
|
|
||||||
|
|
@ -1207,7 +1324,7 @@ var (
|
||||||
errBlobVerifyMismatchedVersion = errors.New("mismatched versioned hash")
|
errBlobVerifyMismatchedVersion = errors.New("mismatched versioned hash")
|
||||||
errBlobVerifyKZGProof = errors.New("error verifying kzg proof")
|
errBlobVerifyKZGProof = errors.New("error verifying kzg proof")
|
||||||
)
|
)
|
||||||
|
// SYSCOIN
|
||||||
// Run executes the point evaluation precompile.
|
// Run executes the point evaluation precompile.
|
||||||
func (b *kzgPointEvaluation) Run(input []byte) ([]byte, error) {
|
func (b *kzgPointEvaluation) Run(input []byte) ([]byte, error) {
|
||||||
if len(input) != blobVerifyInputLength {
|
if len(input) != blobVerifyInputLength {
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,8 @@ func FuzzPrecompiledContracts(f *testing.F) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
inWant := string(input)
|
inWant := string(input)
|
||||||
RunPrecompiledContract(p, input, gas, nil)
|
// SYSCOIN
|
||||||
|
RunPrecompiledContract(p, input, gas, nil, nil)
|
||||||
if inHave := string(input); inWant != inHave {
|
if inHave := string(input); inWant != inHave {
|
||||||
t.Errorf("Precompiled %v modified input data", a)
|
t.Errorf("Precompiled %v modified input data", a)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,8 @@ func testPrecompiled(addr string, test precompiledTest, t *testing.T) {
|
||||||
in := common.Hex2Bytes(test.Input)
|
in := common.Hex2Bytes(test.Input)
|
||||||
gas := p.RequiredGas(in)
|
gas := p.RequiredGas(in)
|
||||||
t.Run(fmt.Sprintf("%s-Gas=%d", test.Name, gas), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%s-Gas=%d", test.Name, gas), func(t *testing.T) {
|
||||||
if res, _, err := RunPrecompiledContract(p, in, gas, nil); err != nil {
|
// SYSCOIN
|
||||||
|
if res, _, err := RunPrecompiledContract(p, in, gas, nil, nil); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
} else if common.Bytes2Hex(res) != test.Expected {
|
} else if common.Bytes2Hex(res) != test.Expected {
|
||||||
t.Errorf("Expected %v, got %v", test.Expected, common.Bytes2Hex(res))
|
t.Errorf("Expected %v, got %v", test.Expected, common.Bytes2Hex(res))
|
||||||
|
|
@ -120,7 +121,8 @@ func testPrecompiledOOG(addr string, test precompiledTest, t *testing.T) {
|
||||||
gas := p.RequiredGas(in) - 1
|
gas := p.RequiredGas(in) - 1
|
||||||
|
|
||||||
t.Run(fmt.Sprintf("%s-Gas=%d", test.Name, gas), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%s-Gas=%d", test.Name, gas), func(t *testing.T) {
|
||||||
_, _, err := RunPrecompiledContract(p, in, gas, nil)
|
// SYSCOIN
|
||||||
|
_, _, err := RunPrecompiledContract(p, in, gas, nil, nil)
|
||||||
if err.Error() != "out of gas" {
|
if err.Error() != "out of gas" {
|
||||||
t.Errorf("Expected error [out of gas], got [%v]", err)
|
t.Errorf("Expected error [out of gas], got [%v]", err)
|
||||||
}
|
}
|
||||||
|
|
@ -137,7 +139,8 @@ func testPrecompiledFailure(addr string, test precompiledFailureTest, t *testing
|
||||||
in := common.Hex2Bytes(test.Input)
|
in := common.Hex2Bytes(test.Input)
|
||||||
gas := p.RequiredGas(in)
|
gas := p.RequiredGas(in)
|
||||||
t.Run(test.Name, func(t *testing.T) {
|
t.Run(test.Name, func(t *testing.T) {
|
||||||
_, _, err := RunPrecompiledContract(p, in, gas, nil)
|
// SYSCOIN
|
||||||
|
_, _, err := RunPrecompiledContract(p, in, gas, nil, nil)
|
||||||
if err.Error() != test.ExpectedError {
|
if err.Error() != test.ExpectedError {
|
||||||
t.Errorf("Expected error [%v], got [%v]", test.ExpectedError, err)
|
t.Errorf("Expected error [%v], got [%v]", test.ExpectedError, err)
|
||||||
}
|
}
|
||||||
|
|
@ -169,7 +172,8 @@ func benchmarkPrecompiled(addr string, test precompiledTest, bench *testing.B) {
|
||||||
bench.ResetTimer()
|
bench.ResetTimer()
|
||||||
for i := 0; i < bench.N; i++ {
|
for i := 0; i < bench.N; i++ {
|
||||||
copy(data, in)
|
copy(data, in)
|
||||||
res, _, err = RunPrecompiledContract(p, data, reqGas, nil)
|
// SYSCOIN
|
||||||
|
res, _, err = RunPrecompiledContract(p, data, reqGas, nil, nil)
|
||||||
}
|
}
|
||||||
bench.StopTimer()
|
bench.StopTimer()
|
||||||
elapsed := uint64(time.Since(start))
|
elapsed := uint64(time.Since(start))
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,8 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
|
||||||
evm.Context.Transfer(evm.StateDB, caller.Address(), addr, value)
|
evm.Context.Transfer(evm.StateDB, caller.Address(), addr, value)
|
||||||
|
|
||||||
if isPrecompile {
|
if isPrecompile {
|
||||||
ret, gas, err = RunPrecompiledContract(p, input, gas, evm.Config.Tracer)
|
// SYSCOIN
|
||||||
|
ret, gas, err = RunPrecompiledContract(p, input, gas, evm.Config.Tracer, evm.interpreter)
|
||||||
} else {
|
} else {
|
||||||
// Initialise a new contract and set the code that is to be used by the EVM.
|
// Initialise a new contract and set the code that is to be used by the EVM.
|
||||||
// The contract is a scoped environment for this execution context only.
|
// The contract is a scoped environment for this execution context only.
|
||||||
|
|
@ -277,7 +278,8 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
|
||||||
|
|
||||||
// It is allowed to call precompiles, even via delegatecall
|
// It is allowed to call precompiles, even via delegatecall
|
||||||
if p, isPrecompile := evm.precompile(addr); isPrecompile {
|
if p, isPrecompile := evm.precompile(addr); isPrecompile {
|
||||||
ret, gas, err = RunPrecompiledContract(p, input, gas, evm.Config.Tracer)
|
// SYSCOIN
|
||||||
|
ret, gas, err = RunPrecompiledContract(p, input, gas, evm.Config.Tracer, evm.interpreter)
|
||||||
} else {
|
} else {
|
||||||
addrCopy := addr
|
addrCopy := addr
|
||||||
// Initialise a new contract and set the code that is to be used by the EVM.
|
// Initialise a new contract and set the code that is to be used by the EVM.
|
||||||
|
|
@ -328,7 +330,8 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
|
||||||
|
|
||||||
// It is allowed to call precompiles, even via delegatecall
|
// It is allowed to call precompiles, even via delegatecall
|
||||||
if p, isPrecompile := evm.precompile(addr); isPrecompile {
|
if p, isPrecompile := evm.precompile(addr); isPrecompile {
|
||||||
ret, gas, err = RunPrecompiledContract(p, input, gas, evm.Config.Tracer)
|
// SYSCOIN
|
||||||
|
ret, gas, err = RunPrecompiledContract(p, input, gas, evm.Config.Tracer, evm.interpreter)
|
||||||
} else {
|
} else {
|
||||||
addrCopy := addr
|
addrCopy := addr
|
||||||
// Initialise a new contract and make initialise the delegate values
|
// Initialise a new contract and make initialise the delegate values
|
||||||
|
|
@ -382,7 +385,8 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
|
||||||
evm.StateDB.AddBalance(addr, new(uint256.Int), tracing.BalanceChangeTouchAccount)
|
evm.StateDB.AddBalance(addr, new(uint256.Int), tracing.BalanceChangeTouchAccount)
|
||||||
|
|
||||||
if p, isPrecompile := evm.precompile(addr); isPrecompile {
|
if p, isPrecompile := evm.precompile(addr); isPrecompile {
|
||||||
ret, gas, err = RunPrecompiledContract(p, input, gas, evm.Config.Tracer)
|
// SYSCOIN
|
||||||
|
ret, gas, err = RunPrecompiledContract(p, input, gas, evm.Config.Tracer, evm.interpreter)
|
||||||
} else {
|
} else {
|
||||||
// At this point, we use a copy of address. If we don't, the go compiler will
|
// At this point, we use a copy of address. If we don't, the go compiler will
|
||||||
// leak the 'contract' to the outer scope, and make allocation for 'contract'
|
// leak the 'contract' to the outer scope, and make allocation for 'contract'
|
||||||
|
|
|
||||||
|
|
@ -499,6 +499,29 @@ func opPop(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte
|
||||||
scope.Stack.pop()
|
scope.Stack.pop()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
func opSYSBlockhash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
||||||
|
num := scope.Stack.peek()
|
||||||
|
num64, overflow := num.Uint64WithOverflow()
|
||||||
|
if overflow {
|
||||||
|
num.Clear()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
var upper, lower uint64
|
||||||
|
upper = interpreter.evm.Context.BlockNumber.Uint64()
|
||||||
|
if upper < 50001 {
|
||||||
|
lower = 0
|
||||||
|
} else {
|
||||||
|
lower = upper - 50000
|
||||||
|
}
|
||||||
|
if num64 >= lower && num64 < upper {
|
||||||
|
num.SetBytes(interpreter.evm.Context.ReadSYSHash(num64))
|
||||||
|
} else {
|
||||||
|
num.Clear()
|
||||||
|
}
|
||||||
|
scope.Stack.pop()
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
func opMload(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opMload(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
||||||
v := scope.Stack.peek()
|
v := scope.Stack.peek()
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,10 @@ func setDefaults(cfg *Config) {
|
||||||
MuirGlacierBlock: new(big.Int),
|
MuirGlacierBlock: new(big.Int),
|
||||||
BerlinBlock: new(big.Int),
|
BerlinBlock: new(big.Int),
|
||||||
LondonBlock: new(big.Int),
|
LondonBlock: new(big.Int),
|
||||||
|
// SYSCOIN
|
||||||
|
SyscoinBlock: new(big.Int),
|
||||||
|
RolluxBlock: new(big.Int),
|
||||||
|
NexusBlock: new(big.Int),
|
||||||
ArrowGlacierBlock: nil,
|
ArrowGlacierBlock: nil,
|
||||||
GrayGlacierBlock: nil,
|
GrayGlacierBlock: nil,
|
||||||
TerminalTotalDifficulty: big.NewInt(0),
|
TerminalTotalDifficulty: big.NewInt(0),
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,16 @@ func TestDefaults(t *testing.T) {
|
||||||
if cfg.GetHashFn == nil {
|
if cfg.GetHashFn == nil {
|
||||||
t.Error("expected time to be non nil")
|
t.Error("expected time to be non nil")
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
if cfg.ReadSYSHashFn == nil {
|
||||||
|
t.Error("expected time to be non nil")
|
||||||
|
}
|
||||||
|
if cfg.ReadDataHashFn == nil {
|
||||||
|
t.Error("expected time to be non nil")
|
||||||
|
}
|
||||||
|
if cfg.GetNEVMAddressFn == nil {
|
||||||
|
t.Error("expected time to be non nil")
|
||||||
|
}
|
||||||
if cfg.BlockNumber == nil {
|
if cfg.BlockNumber == nil {
|
||||||
t.Error("expected block number to be non nil")
|
t.Error("expected block number to be non nil")
|
||||||
}
|
}
|
||||||
|
|
@ -80,6 +90,8 @@ func TestEVM(t *testing.T) {
|
||||||
byte(vm.PUSH1),
|
byte(vm.PUSH1),
|
||||||
byte(vm.ORIGIN),
|
byte(vm.ORIGIN),
|
||||||
byte(vm.BLOCKHASH),
|
byte(vm.BLOCKHASH),
|
||||||
|
// SYSCOIN
|
||||||
|
byte(vm.SYSBLOCKHASH),
|
||||||
byte(vm.COINBASE),
|
byte(vm.COINBASE),
|
||||||
}, nil, nil)
|
}, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
@ -312,6 +324,17 @@ func (d *dummyChain) GetHeader(h common.Hash, n uint64) *types.Header {
|
||||||
return fakeHeader(n, parentHash)
|
return fakeHeader(n, parentHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SYSCOIN
|
||||||
|
func (d *dummyChain) ReadSYSHash(uint64) []byte {
|
||||||
|
return []byte{}
|
||||||
|
}
|
||||||
|
func (d *dummyChain) ReadDataHash(common.Hash) []byte {
|
||||||
|
return []byte{}
|
||||||
|
}
|
||||||
|
func (d *dummyChain) GetNEVMAddress(common.Address) []byte {
|
||||||
|
return []byte{}
|
||||||
|
}
|
||||||
|
|
||||||
// TestBlockhash tests the blockhash operation. It's a bit special, since it internally
|
// TestBlockhash tests the blockhash operation. It's a bit special, since it internally
|
||||||
// requires access to a chain reader.
|
// requires access to a chain reader.
|
||||||
func TestBlockhash(t *testing.T) {
|
func TestBlockhash(t *testing.T) {
|
||||||
|
|
@ -362,6 +385,10 @@ func TestBlockhash(t *testing.T) {
|
||||||
ret, _, err := Execute(data, input, &Config{
|
ret, _, err := Execute(data, input, &Config{
|
||||||
GetHashFn: core.GetHashFn(header, chain),
|
GetHashFn: core.GetHashFn(header, chain),
|
||||||
BlockNumber: new(big.Int).Set(header.Number),
|
BlockNumber: new(big.Int).Set(header.Number),
|
||||||
|
// SYSCOIN
|
||||||
|
ReadSYSHashFn: core.ReadSYSHashFn(chain),
|
||||||
|
ReadDataHashFn: core.ReadDataHashFn(chain),
|
||||||
|
GetNEVMAddressFn: core.GetNEVMAddressFn(chain),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("expected no error, got %v", err)
|
t.Fatalf("expected no error, got %v", err)
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,16 @@ func (b *EthAPIBackend) SetHead(number uint64) {
|
||||||
b.eth.handler.downloader.Cancel()
|
b.eth.handler.downloader.Cancel()
|
||||||
b.eth.blockchain.SetHead(number)
|
b.eth.blockchain.SetHead(number)
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
func (b *EthAPIBackend) ReadSYSHash(ctx context.Context, number rpc.BlockNumber) ([]byte, error) {
|
||||||
|
return b.eth.blockchain.ReadSYSHash(uint64(number)), nil
|
||||||
|
}
|
||||||
|
func (b *EthAPIBackend) ReadDataHash(ctx context.Context, hash common.Hash) ([]byte, error) {
|
||||||
|
return b.eth.blockchain.ReadDataHash(hash), nil
|
||||||
|
}
|
||||||
|
func (b *EthAPIBackend) GetNEVMAddress(ctx context.Context, address common.Address) ([]byte, error) {
|
||||||
|
return b.eth.blockchain.GetNEVMAddress(address), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (b *EthAPIBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) {
|
func (b *EthAPIBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) {
|
||||||
// Pending block is only known by the miner
|
// Pending block is only known by the miner
|
||||||
|
|
|
||||||
200
eth/backend.go
200
eth/backend.go
|
|
@ -23,6 +23,9 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
|
// SYSCOIN
|
||||||
|
"errors"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
@ -56,12 +59,24 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
// SYSCOIN
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config contains the configuration options of the ETH protocol.
|
// Config contains the configuration options of the ETH protocol.
|
||||||
// Deprecated: use ethconfig.Config instead.
|
// Deprecated: use ethconfig.Config instead.
|
||||||
type Config = ethconfig.Config
|
type Config = ethconfig.Config
|
||||||
|
// SYSCOIN
|
||||||
|
type NEVMCreateBlockFn func(*Ethereum) *types.Block
|
||||||
|
type NEVMAddBlockFn func(*types.NEVMBlockConnect, *Ethereum) error
|
||||||
|
type NEVMDeleteBlockFn func(*types.NEVMBlockDisconnect, *Ethereum) error
|
||||||
|
|
||||||
|
type NEVMIndex struct {
|
||||||
|
// Callbacks
|
||||||
|
CreateBlock NEVMCreateBlockFn // Mines a block locally
|
||||||
|
AddBlock NEVMAddBlockFn // Connects a new NEVM block
|
||||||
|
DeleteBlock NEVMDeleteBlockFn // Disconnects NEVM tip
|
||||||
|
}
|
||||||
// Ethereum implements the Ethereum full node service.
|
// Ethereum implements the Ethereum full node service.
|
||||||
type Ethereum struct {
|
type Ethereum struct {
|
||||||
// core protocol objects
|
// core protocol objects
|
||||||
|
|
@ -96,6 +111,11 @@ type Ethereum struct {
|
||||||
lock sync.RWMutex // Protects the variadic fields (e.g. gas price and etherbase)
|
lock sync.RWMutex // Protects the variadic fields (e.g. gas price and etherbase)
|
||||||
|
|
||||||
shutdownTracker *shutdowncheck.ShutdownTracker // Tracks if and when the node has shutdown ungracefully
|
shutdownTracker *shutdowncheck.ShutdownTracker // Tracks if and when the node has shutdown ungracefully
|
||||||
|
// SYSCOIN
|
||||||
|
wgNEVM sync.WaitGroup
|
||||||
|
zmqRep *ZMQRep
|
||||||
|
node *node.Node
|
||||||
|
timeLastBlock int64
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new Ethereum object (including the initialisation of the common Ethereum object),
|
// New creates a new Ethereum object (including the initialisation of the common Ethereum object),
|
||||||
|
|
@ -270,7 +290,167 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||||
|
|
||||||
// Successful startup; push a marker and check previous unclean shutdowns.
|
// Successful startup; push a marker and check previous unclean shutdowns.
|
||||||
eth.shutdownTracker.MarkStartup()
|
eth.shutdownTracker.MarkStartup()
|
||||||
|
// SYSCOIN
|
||||||
|
eth.node = stack
|
||||||
|
createBlock := func(eth *Ethereum) *types.Block {
|
||||||
|
eth.wgNEVM.Add(1)
|
||||||
|
defer eth.wgNEVM.Done()
|
||||||
|
return eth.miner.GenerateWorkSyscoin(eth.blockchain.CurrentBlock().Hash(), eth.config.Miner.PendingFeeRecipient, crypto.Keccak256Hash([]byte{byte(123)}))
|
||||||
|
}
|
||||||
|
addBlock := func(nevmBlockConnect *types.NEVMBlockConnect, eth *Ethereum) error {
|
||||||
|
if nevmBlockConnect == nil {
|
||||||
|
return errors.New("addBlock: Empty block")
|
||||||
|
}
|
||||||
|
proposedBlockNumber := nevmBlockConnect.Block.NumberU64()
|
||||||
|
proposedBlockHash := nevmBlockConnect.Block.Hash()
|
||||||
|
proposedBlockParentHash := nevmBlockConnect.Block.ParentHash()
|
||||||
|
currentHash := common.Hash{}
|
||||||
|
currentNumber := uint64(0)
|
||||||
|
if nevmBlockConnect.Block == nil {
|
||||||
|
return errors.New("addBlock: empty block")
|
||||||
|
}
|
||||||
|
// because we set canonical head only after sync we can check for continuity via saved block connects
|
||||||
|
if eth.blockchain.NevmBlockConnect != nil {
|
||||||
|
currentBlock := eth.blockchain.NevmBlockConnect.Block
|
||||||
|
if currentBlock == nil {
|
||||||
|
return errors.New("addBlock: Current block is nil")
|
||||||
|
}
|
||||||
|
currentNumber = currentBlock.NumberU64()
|
||||||
|
currentHash = currentBlock.Hash()
|
||||||
|
} else {
|
||||||
|
currentBlock := eth.blockchain.CurrentBlock()
|
||||||
|
if currentBlock == nil {
|
||||||
|
return errors.New("addBlock: Current block is nil")
|
||||||
|
}
|
||||||
|
currentNumber = currentBlock.Number.Uint64()
|
||||||
|
currentHash = currentBlock.Hash()
|
||||||
|
}
|
||||||
|
if (proposedBlockNumber != (currentNumber + 1)) || (proposedBlockParentHash != currentHash) {
|
||||||
|
log.Error("Non contiguous block insert", "number", proposedBlockNumber, "hash", proposedBlockHash,
|
||||||
|
"parent", proposedBlockParentHash, "prevnumber", currentNumber, "prevhash", currentHash)
|
||||||
|
return errors.New("addBlock: Non contiguous block insert")
|
||||||
|
}
|
||||||
|
eth.blockchain.NevmBlockConnect = nevmBlockConnect
|
||||||
|
// special case where miner process includes validating block in pre-packaging stage on SYS node
|
||||||
|
// the validation of this hash is done in ConnectNEVMCommitment() in Syscoin using fJustCheck
|
||||||
|
sysBlockHash := common.BytesToHash([]byte(nevmBlockConnect.Sysblockhash))
|
||||||
|
if sysBlockHash == (common.Hash{}) {
|
||||||
|
err := eth.engine.VerifyHeader(eth.blockchain, nevmBlockConnect.Block.Header())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := eth.blockchain.InsertBlockWithoutSetHead(nevmBlockConnect.Block, false); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !eth.handler.inited {
|
||||||
|
eth.lock.Lock()
|
||||||
|
eth.timeLastBlock = time.Now().Unix()
|
||||||
|
eth.lock.Unlock()
|
||||||
|
if (nevmBlockConnect.Block.NumberU64() % 100) == 0 {
|
||||||
|
if _, err := eth.blockchain.SetCanonical(nevmBlockConnect.Block); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if _, err := eth.blockchain.SetCanonical(nevmBlockConnect.Block); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// start networking sync once we start inserting chain meaning we are likely finished with IBD
|
||||||
|
go func(eth *Ethereum) {
|
||||||
|
sub := eth.eventMux.Subscribe(downloader.StartNetworkEvent{})
|
||||||
|
defer sub.Unsubscribe()
|
||||||
|
for {
|
||||||
|
event := <-sub.Chan()
|
||||||
|
if event == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
switch event.Data.(type) {
|
||||||
|
case downloader.StartNetworkEvent:
|
||||||
|
eth.lock.Lock()
|
||||||
|
eth.timeLastBlock = time.Now().Unix()
|
||||||
|
eth.lock.Unlock()
|
||||||
|
log.Info("Attempt to start networking/peering...")
|
||||||
|
for {
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
eth.lock.Lock()
|
||||||
|
if eth.handler.inited && eth.handler.peers.closed {
|
||||||
|
log.Info("Networking stopped, return without starting peering...")
|
||||||
|
eth.lock.Unlock()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// ensure 5 seconds has passed between blocks before we start peering so we are sure sync has finished
|
||||||
|
if time.Now().Unix()-eth.timeLastBlock >= 5 {
|
||||||
|
log.Info("Networking and peering start...")
|
||||||
|
eth.handler.Start(eth.handler.maxPeers)
|
||||||
|
eth.handler.peers.open()
|
||||||
|
eth.Downloader().Peers().Open()
|
||||||
|
eth.p2pServer.Start()
|
||||||
|
eth.Downloader().DoneEvent()
|
||||||
|
eth.handler.synced.Store(true)
|
||||||
|
eth.lock.Unlock()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
eth.lock.Unlock()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}(eth)
|
||||||
|
|
||||||
|
deleteBlock := func(nevmBlockDisconnect *types.NEVMBlockDisconnect, eth *Ethereum) error {
|
||||||
|
current := eth.blockchain.CurrentBlock()
|
||||||
|
if current == nil {
|
||||||
|
return errors.New("deleteBlock: Current block is nil")
|
||||||
|
}
|
||||||
|
currentNumber := current.Number.Uint64()
|
||||||
|
if current.Number.Uint64() == 0 {
|
||||||
|
log.Warn("Trying to disconnect block 0")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
parent := eth.blockchain.GetBlock(current.ParentHash, currentNumber-1)
|
||||||
|
if parent == nil {
|
||||||
|
return errors.New("deleteBlock: NEVM tip parent block not found")
|
||||||
|
}
|
||||||
|
err := eth.blockchain.WriteKnownBlock(parent)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if eth.blockchain.CurrentBlock().Number.Uint64() != (currentNumber - 1) {
|
||||||
|
return errors.New("deleteBlock: Block number post-write does not match")
|
||||||
|
}
|
||||||
|
batch := eth.ChainDb().NewBatch()
|
||||||
|
// Update the NEVM address mappings based on the block's diff
|
||||||
|
hasDiff := nevmBlockDisconnect.HasDiff()
|
||||||
|
if hasDiff {
|
||||||
|
// Retrieve the current NEVM address mappings from the database
|
||||||
|
mapping := eth.blockchain.ReadNEVMAddressMapping()
|
||||||
|
for _, entry := range nevmBlockDisconnect.Diff.AddedMNNEVM {
|
||||||
|
mapping.AddNEVMAddress(common.BytesToAddress(entry.Address), entry.CollateralHeight)
|
||||||
|
}
|
||||||
|
for _, entry := range nevmBlockDisconnect.Diff.UpdatedMNNEVM {
|
||||||
|
mapping.UpdateNEVMAddress(common.BytesToAddress(entry.OldAddress), common.BytesToAddress(entry.NewAddress))
|
||||||
|
}
|
||||||
|
for _, entry := range nevmBlockDisconnect.Diff.RemovedMNNEVM {
|
||||||
|
mapping.RemoveNEVMAddress(common.BytesToAddress(entry.Address))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Persist the updated NEVM address mappings to the database
|
||||||
|
eth.blockchain.WriteNEVMAddressMapping(batch, mapping)
|
||||||
|
}
|
||||||
|
|
||||||
|
eth.blockchain.DeleteNEVMMapping(batch, current.Hash())
|
||||||
|
eth.blockchain.DeleteSYSHash(batch, currentNumber)
|
||||||
|
eth.blockchain.DeleteDataHashes(batch, currentNumber)
|
||||||
|
if err := batch.Write(); err != nil {
|
||||||
|
log.Crit("Failed to delete NEVM index data", "err", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if eth.blockchain.GetChainConfig().SyscoinBlock != nil {
|
||||||
|
eth.zmqRep = NewZMQRep(stack, eth, config.NEVMPubEP, NEVMIndex{createBlock, addBlock, deleteBlock})
|
||||||
|
}
|
||||||
return eth, nil
|
return eth, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -360,8 +540,18 @@ func (s *Ethereum) Start() error {
|
||||||
// Regularly update shutdown marker
|
// Regularly update shutdown marker
|
||||||
s.shutdownTracker.Start()
|
s.shutdownTracker.Start()
|
||||||
|
|
||||||
// Start the networking layer
|
// SYSCOIN
|
||||||
s.handler.Start(s.p2pServer.MaxPeers)
|
if s.blockchain.GetChainConfig().SyscoinBlock != nil {
|
||||||
|
log.Info("Skip networking and peering...")
|
||||||
|
s.handler.maxPeers = s.p2pServer.MaxPeers
|
||||||
|
s.handler.peers.close()
|
||||||
|
s.p2pServer.Stop()
|
||||||
|
} else {
|
||||||
|
// Start the networking layer
|
||||||
|
s.handler.Start(s.p2pServer.MaxPeers)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -416,7 +606,11 @@ func (s *Ethereum) Stop() error {
|
||||||
|
|
||||||
s.chainDb.Close()
|
s.chainDb.Close()
|
||||||
s.eventMux.Stop()
|
s.eventMux.Stop()
|
||||||
|
// SYSCOIN
|
||||||
|
s.wgNEVM.Wait()
|
||||||
|
if s.zmqRep != nil {
|
||||||
|
s.zmqRep.Close()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -379,7 +379,15 @@ func (d *Downloader) synchronise(mode SyncMode, beaconPing chan struct{}) error
|
||||||
func (d *Downloader) getMode() SyncMode {
|
func (d *Downloader) getMode() SyncMode {
|
||||||
return SyncMode(d.mode.Load())
|
return SyncMode(d.mode.Load())
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
func (s *Downloader) Peers() *peerSet { return s.peers }
|
||||||
|
func (d *Downloader) DoneEvent() {
|
||||||
|
latest := d.blockchain.CurrentHeader()
|
||||||
|
d.mux.Post(DoneEvent{latest})
|
||||||
|
}
|
||||||
|
func (d *Downloader) StartNetworkEvent() {
|
||||||
|
d.mux.Post(StartNetworkEvent{})
|
||||||
|
}
|
||||||
// syncToHead starts a block synchronization based on the hash chain from
|
// syncToHead starts a block synchronization based on the hash chain from
|
||||||
// the specified head hash.
|
// the specified head hash.
|
||||||
func (d *Downloader) syncToHead() (err error) {
|
func (d *Downloader) syncToHead() (err error) {
|
||||||
|
|
|
||||||
|
|
@ -23,3 +23,6 @@ type DoneEvent struct {
|
||||||
}
|
}
|
||||||
type StartEvent struct{}
|
type StartEvent struct{}
|
||||||
type FailedEvent struct{ Err error }
|
type FailedEvent struct{ Err error }
|
||||||
|
|
||||||
|
// SYSCOIN
|
||||||
|
type StartNetworkEvent struct{}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ const (
|
||||||
var (
|
var (
|
||||||
errAlreadyRegistered = errors.New("peer is already registered")
|
errAlreadyRegistered = errors.New("peer is already registered")
|
||||||
errNotRegistered = errors.New("peer is not registered")
|
errNotRegistered = errors.New("peer is not registered")
|
||||||
|
// SYSCOIN
|
||||||
|
errPeerSetClosed = errors.New("peerset closed")
|
||||||
)
|
)
|
||||||
|
|
||||||
// peerConnection represents an active peer from which hashes and blocks are retrieved.
|
// peerConnection represents an active peer from which hashes and blocks are retrieved.
|
||||||
|
|
@ -173,6 +175,8 @@ type peerSet struct {
|
||||||
events event.Feed // Feed to publish peer lifecycle events on
|
events event.Feed // Feed to publish peer lifecycle events on
|
||||||
|
|
||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
|
// SYSCOIN
|
||||||
|
closed bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// newPeerSet creates a new peer set top track the active download sources.
|
// newPeerSet creates a new peer set top track the active download sources.
|
||||||
|
|
@ -223,7 +227,19 @@ func (ps *peerSet) Register(p *peerConnection) error {
|
||||||
ps.events.Send(&peeringEvent{peer: p, join: true})
|
ps.events.Send(&peeringEvent{peer: p, join: true})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
func (ps *peerSet) Close() {
|
||||||
|
ps.lock.Lock()
|
||||||
|
defer ps.lock.Unlock()
|
||||||
|
|
||||||
|
ps.closed = true
|
||||||
|
}
|
||||||
|
func (ps *peerSet) Open() {
|
||||||
|
ps.lock.Lock()
|
||||||
|
defer ps.lock.Unlock()
|
||||||
|
|
||||||
|
ps.closed = false
|
||||||
|
}
|
||||||
// Unregister removes a remote peer from the active set, disabling any further
|
// Unregister removes a remote peer from the active set, disabling any further
|
||||||
// actions to/from that particular entity.
|
// actions to/from that particular entity.
|
||||||
func (ps *peerSet) Unregister(id string) error {
|
func (ps *peerSet) Unregister(id string) error {
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,9 @@ type Config struct {
|
||||||
// send-transaction variants. The unit is ether.
|
// send-transaction variants. The unit is ether.
|
||||||
RPCTxFeeCap float64
|
RPCTxFeeCap float64
|
||||||
|
|
||||||
|
// SYSCOIN
|
||||||
|
NEVMPubEP string `toml:",omitempty"`
|
||||||
|
|
||||||
// OverrideCancun (TODO: remove after the fork)
|
// OverrideCancun (TODO: remove after the fork)
|
||||||
OverrideCancun *uint64 `toml:",omitempty"`
|
OverrideCancun *uint64 `toml:",omitempty"`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,8 @@ func Estimate(ctx context.Context, call *core.Message, opts *Options, gasCap uin
|
||||||
}
|
}
|
||||||
available.Sub(available, call.Value)
|
available.Sub(available, call.Value)
|
||||||
}
|
}
|
||||||
if opts.Config.IsCancun(opts.Header.Number, opts.Header.Time) && len(call.BlobHashes) > 0 {
|
// SYSCOIN
|
||||||
|
if !opts.Config.IsSyscoin(opts.Header.Number) && opts.Config.IsCancun(opts.Header.Number, opts.Header.Time) && len(call.BlobHashes) > 0 {
|
||||||
blobGasPerBlob := new(big.Int).SetInt64(params.BlobTxBlobGasPerBlob)
|
blobGasPerBlob := new(big.Int).SetInt64(params.BlobTxBlobGasPerBlob)
|
||||||
blobBalanceUsage := new(big.Int).SetInt64(int64(len(call.BlobHashes)))
|
blobBalanceUsage := new(big.Int).SetInt64(int64(len(call.BlobHashes)))
|
||||||
blobBalanceUsage.Mul(blobBalanceUsage, blobGasPerBlob)
|
blobBalanceUsage.Mul(blobBalanceUsage, blobGasPerBlob)
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,8 @@ type handler struct {
|
||||||
|
|
||||||
// channels for fetcher, syncer, txsyncLoop
|
// channels for fetcher, syncer, txsyncLoop
|
||||||
quitSync chan struct{}
|
quitSync chan struct{}
|
||||||
|
// SYSCOIN
|
||||||
|
inited bool
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
|
||||||
handlerStartCh chan struct{}
|
handlerStartCh chan struct{}
|
||||||
|
|
@ -179,8 +180,10 @@ func newHandler(config *handlerConfig) (*handler, error) {
|
||||||
if h.snapSync.Load() && config.Chain.Snapshots() == nil {
|
if h.snapSync.Load() && config.Chain.Snapshots() == nil {
|
||||||
return nil, errors.New("snap sync not supported with snapshots disabled")
|
return nil, errors.New("snap sync not supported with snapshots disabled")
|
||||||
}
|
}
|
||||||
// Construct the downloader (long sync)
|
// SYSCOIN Construct the downloader (long sync)
|
||||||
h.downloader = downloader.New(config.Database, h.eventMux, h.chain, h.removePeer, h.enableSyncedFeatures)
|
if h.chain.GetChainConfig().SyscoinBlock == nil {
|
||||||
|
h.downloader = downloader.New(config.Database, h.eventMux, h.chain, h.removePeer, h.enableSyncedFeatures)
|
||||||
|
}
|
||||||
|
|
||||||
fetchTx := func(peer string, hashes []common.Hash) error {
|
fetchTx := func(peer string, hashes []common.Hash) error {
|
||||||
p := h.peers.peer(peer)
|
p := h.peers.peer(peer)
|
||||||
|
|
@ -192,6 +195,8 @@ func newHandler(config *handlerConfig) (*handler, error) {
|
||||||
addTxs := func(txs []*types.Transaction) []error {
|
addTxs := func(txs []*types.Transaction) []error {
|
||||||
return h.txpool.Add(txs, false, false)
|
return h.txpool.Add(txs, false, false)
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
h.inited = false
|
||||||
h.txFetcher = fetcher.NewTxFetcher(h.txpool.Has, addTxs, fetchTx, h.removePeer)
|
h.txFetcher = fetcher.NewTxFetcher(h.txpool.Has, addTxs, fetchTx, h.removePeer)
|
||||||
return h, nil
|
return h, nil
|
||||||
}
|
}
|
||||||
|
|
@ -427,7 +432,8 @@ func (h *handler) Start(maxPeers int) {
|
||||||
h.txsCh = make(chan core.NewTxsEvent, txChanSize)
|
h.txsCh = make(chan core.NewTxsEvent, txChanSize)
|
||||||
h.txsSub = h.txpool.SubscribeTransactions(h.txsCh, false)
|
h.txsSub = h.txpool.SubscribeTransactions(h.txsCh, false)
|
||||||
go h.txBroadcastLoop()
|
go h.txBroadcastLoop()
|
||||||
|
// SYSCOIN
|
||||||
|
h.inited = true
|
||||||
// start sync handlers
|
// start sync handlers
|
||||||
h.txFetcher.Start()
|
h.txFetcher.Start()
|
||||||
|
|
||||||
|
|
@ -437,6 +443,10 @@ func (h *handler) Start(maxPeers int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *handler) Stop() {
|
func (h *handler) Stop() {
|
||||||
|
// SYSCOIN
|
||||||
|
if !h.inited {
|
||||||
|
return
|
||||||
|
}
|
||||||
h.txsSub.Unsubscribe() // quits txBroadcastLoop
|
h.txsSub.Unsubscribe() // quits txBroadcastLoop
|
||||||
h.txFetcher.Stop()
|
h.txFetcher.Stop()
|
||||||
h.downloader.Terminate()
|
h.downloader.Terminate()
|
||||||
|
|
|
||||||
|
|
@ -237,3 +237,11 @@ func (ps *peerSet) close() {
|
||||||
}
|
}
|
||||||
ps.closed = true
|
ps.closed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SYSCOIN
|
||||||
|
func (ps *peerSet) open() {
|
||||||
|
ps.lock.Lock()
|
||||||
|
defer ps.lock.Unlock()
|
||||||
|
|
||||||
|
ps.closed = false
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,10 @@ type Backend interface {
|
||||||
ChainDb() ethdb.Database
|
ChainDb() ethdb.Database
|
||||||
StateAtBlock(ctx context.Context, block *types.Block, reexec uint64, base *state.StateDB, readOnly bool, preferDisk bool) (*state.StateDB, StateReleaseFunc, error)
|
StateAtBlock(ctx context.Context, block *types.Block, reexec uint64, base *state.StateDB, readOnly bool, preferDisk bool) (*state.StateDB, StateReleaseFunc, error)
|
||||||
StateAtTransaction(ctx context.Context, block *types.Block, txIndex int, reexec uint64) (*types.Transaction, vm.BlockContext, *state.StateDB, StateReleaseFunc, error)
|
StateAtTransaction(ctx context.Context, block *types.Block, txIndex int, reexec uint64) (*types.Transaction, vm.BlockContext, *state.StateDB, StateReleaseFunc, error)
|
||||||
|
// SYSCOIN
|
||||||
|
ReadSYSHash(ctx context.Context, number rpc.BlockNumber) ([]byte, error)
|
||||||
|
ReadDataHash(ctx context.Context, hash common.Hash) ([]byte, error)
|
||||||
|
GetNEVMAddress(ctx context.Context, address common.Address) ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// API is the collection of tracing APIs exposed over the private debugging endpoint.
|
// API is the collection of tracing APIs exposed over the private debugging endpoint.
|
||||||
|
|
@ -105,7 +109,28 @@ func NewAPI(backend Backend) *API {
|
||||||
func (api *API) chainContext(ctx context.Context) core.ChainContext {
|
func (api *API) chainContext(ctx context.Context) core.ChainContext {
|
||||||
return ethapi.NewChainContext(ctx, api.backend)
|
return ethapi.NewChainContext(ctx, api.backend)
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
func (api *API) ReadSYSHash(ctx context.Context, number rpc.BlockNumber) ([]byte, error) {
|
||||||
|
sysBlockHash, err := api.backend.ReadSYSHash(ctx, number)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return sysBlockHash, nil
|
||||||
|
}
|
||||||
|
func (api *API) ReadDataHash(ctx context.Context, hash common.Hash) ([]byte, error) {
|
||||||
|
dataHash, err := api.backend.ReadDataHash(ctx, hash)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return dataHash, nil
|
||||||
|
}
|
||||||
|
func (api *API) GetNEVMAddress(ctx context.Context, address common.Address) ([]byte, error) {
|
||||||
|
collateralHeight, err := api.backend.GetNEVMAddress(ctx, address)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return collateralHeight, nil
|
||||||
|
}
|
||||||
// blockByNumber is the wrapper of the chain access function offered by the backend.
|
// blockByNumber is the wrapper of the chain access function offered by the backend.
|
||||||
// It will return an error if the block is not found.
|
// It will return an error if the block is not found.
|
||||||
func (api *API) blockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) {
|
func (api *API) blockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) {
|
||||||
|
|
|
||||||
5
go.mod
5
go.mod
|
|
@ -70,7 +70,7 @@ require (
|
||||||
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
|
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
|
||||||
golang.org/x/sync v0.7.0
|
golang.org/x/sync v0.7.0
|
||||||
golang.org/x/sys v0.22.0
|
golang.org/x/sys v0.22.0
|
||||||
golang.org/x/text v0.14.0
|
golang.org/x/text v0.15.0
|
||||||
golang.org/x/time v0.5.0
|
golang.org/x/time v0.5.0
|
||||||
golang.org/x/tools v0.20.0
|
golang.org/x/tools v0.20.0
|
||||||
google.golang.org/protobuf v1.34.2
|
google.golang.org/protobuf v1.34.2
|
||||||
|
|
@ -109,6 +109,8 @@ require (
|
||||||
github.com/getsentry/sentry-go v0.27.0 // indirect
|
github.com/getsentry/sentry-go v0.27.0 // indirect
|
||||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||||
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
|
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
|
||||||
|
github.com/go-zeromq/goczmq/v4 v4.2.2 // indirect
|
||||||
|
github.com/go-zeromq/zmq4 v0.17.0 // indirect
|
||||||
github.com/goccy/go-json v0.10.2 // indirect
|
github.com/goccy/go-json v0.10.2 // indirect
|
||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
github.com/golang/protobuf v1.5.4 // indirect
|
github.com/golang/protobuf v1.5.4 // indirect
|
||||||
|
|
@ -139,6 +141,7 @@ require (
|
||||||
github.com/rivo/uniseg v0.2.0 // indirect
|
github.com/rivo/uniseg v0.2.0 // indirect
|
||||||
github.com/rogpeppe/go-internal v1.9.0 // indirect
|
github.com/rogpeppe/go-internal v1.9.0 // indirect
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
|
github.com/syscoin/btcd v0.0.0-20240828024112-dde8b967d0f8 // indirect
|
||||||
github.com/tklauser/go-sysconf v0.3.12 // indirect
|
github.com/tklauser/go-sysconf v0.3.12 // indirect
|
||||||
github.com/tklauser/numcpus v0.6.1 // indirect
|
github.com/tklauser/numcpus v0.6.1 // indirect
|
||||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||||
|
|
|
||||||
22
go.sum
22
go.sum
|
|
@ -53,6 +53,7 @@ github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDO
|
||||||
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
|
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
|
||||||
github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI=
|
github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI=
|
||||||
github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI=
|
github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI=
|
||||||
|
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
|
|
@ -96,6 +97,12 @@ github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurT
|
||||||
github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
|
github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
|
||||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
|
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
|
||||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
|
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
|
||||||
|
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
||||||
|
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
|
||||||
|
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY=
|
||||||
|
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
|
||||||
|
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
|
||||||
|
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
|
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
|
||||||
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
|
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
|
||||||
|
|
@ -140,6 +147,7 @@ github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDF
|
||||||
github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc=
|
github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc=
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
|
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
|
||||||
|
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
|
@ -210,6 +218,10 @@ github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh
|
||||||
github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
|
github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
|
||||||
github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
|
github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
|
github.com/go-zeromq/goczmq/v4 v4.2.2 h1:HAJN+i+3NW55ijMJJhk7oWxHKXgAuSBkoFfvr8bYj4U=
|
||||||
|
github.com/go-zeromq/goczmq/v4 v4.2.2/go.mod h1:Sm/lxrfxP/Oxqs0tnHD6WAhwkWrx+S+1MRrKzcxoaYE=
|
||||||
|
github.com/go-zeromq/zmq4 v0.17.0 h1:r12/XdqPeRbuaF4C3QZJeWCt7a5vpJbslDH1rTXF+Kc=
|
||||||
|
github.com/go-zeromq/zmq4 v0.17.0/go.mod h1:EQxjJD92qKnrsVMzAnx62giD6uJIPi1dMGZ781iCDtY=
|
||||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||||
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
|
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
|
||||||
|
|
@ -327,11 +339,13 @@ github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7Bd
|
||||||
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
|
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
|
||||||
github.com/jedisct1/go-minisign v0.0.0-20230811132847-661be99b8267 h1:TMtDYDHKYY15rFihtRfck/bfFqNfvcabqvXAFQfAUpY=
|
github.com/jedisct1/go-minisign v0.0.0-20230811132847-661be99b8267 h1:TMtDYDHKYY15rFihtRfck/bfFqNfvcabqvXAFQfAUpY=
|
||||||
github.com/jedisct1/go-minisign v0.0.0-20230811132847-661be99b8267/go.mod h1:h1nSAbGFqGVzn6Jyl1R/iCcBUHN4g+gW1u9CoBTrb9E=
|
github.com/jedisct1/go-minisign v0.0.0-20230811132847-661be99b8267/go.mod h1:h1nSAbGFqGVzn6Jyl1R/iCcBUHN4g+gW1u9CoBTrb9E=
|
||||||
|
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
||||||
|
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
|
||||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
|
|
@ -346,6 +360,7 @@ github.com/kilic/bls12-381 v0.1.0 h1:encrdjqKMEvabVQ7qYOKu1OvhqpK4s47wDYtNiPtlp4
|
||||||
github.com/kilic/bls12-381 v0.1.0/go.mod h1:vDTTHJONJ6G+P2R74EhnyotQDTliQDnFEwhdmfzw1ig=
|
github.com/kilic/bls12-381 v0.1.0/go.mod h1:vDTTHJONJ6G+P2R74EhnyotQDTliQDnFEwhdmfzw1ig=
|
||||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
|
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
|
||||||
github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4=
|
github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4=
|
||||||
github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
||||||
github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
|
|
@ -371,6 +386,8 @@ github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7
|
||||||
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
|
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
|
||||||
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
|
github.com/martinboehm/btcutil v0.0.0-20180706230648-ab6388e0c60a h1:J1QHZEr4MPI0uiftE6P7XQ3TLUoMabkArrJHAAv7boU=
|
||||||
|
github.com/martinboehm/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:NIviPmxe43yBgIB4HGB4w4kv9/s5kaDa/pi+wZAAxQo=
|
||||||
github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ=
|
github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ=
|
||||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||||
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||||
|
|
@ -499,6 +516,8 @@ github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKt
|
||||||
github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
|
github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
|
||||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
|
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
|
||||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
|
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
|
||||||
|
github.com/syscoin/btcd v0.0.0-20240828024112-dde8b967d0f8 h1:rXuV+f1ch5lFqu4D95NPye3lkAl9IeeHuZbRKcIvfiM=
|
||||||
|
github.com/syscoin/btcd v0.0.0-20240828024112-dde8b967d0f8/go.mod h1:xr4h8KaM4ibpFGPLDJLRhjZtKZet/Q14YgPk3T0F9FE=
|
||||||
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
|
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
|
||||||
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
|
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
|
||||||
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
|
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
|
||||||
|
|
@ -524,6 +543,7 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||||
go.uber.org/automaxprocs v1.5.2 h1:2LxUOGiR3O6tw8ui5sZa2LAaHnsviZdVOUZw4fvbnME=
|
go.uber.org/automaxprocs v1.5.2 h1:2LxUOGiR3O6tw8ui5sZa2LAaHnsviZdVOUZw4fvbnME=
|
||||||
go.uber.org/automaxprocs v1.5.2/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
|
go.uber.org/automaxprocs v1.5.2/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
|
||||||
|
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
|
@ -705,6 +725,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
|
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
||||||
|
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
|
|
|
||||||
|
|
@ -1159,6 +1159,29 @@ func (context *ChainContext) GetHeader(hash common.Hash, number uint64) *types.H
|
||||||
return header
|
return header
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SYSCOIN
|
||||||
|
func (context *ChainContext) ReadSYSHash(n uint64) []byte {
|
||||||
|
sysBlockHash, err := context.b.ReadSYSHash(context.ctx, rpc.BlockNumber(n))
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return sysBlockHash
|
||||||
|
}
|
||||||
|
func (context *ChainContext) ReadDataHash(hash common.Hash) []byte {
|
||||||
|
dataHash, err := context.b.ReadDataHash(context.ctx, hash)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return dataHash
|
||||||
|
}
|
||||||
|
func (context *ChainContext) GetNEVMAddress(address common.Address) []byte {
|
||||||
|
collateralHeight, err := context.b.GetNEVMAddress(context.ctx, address)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return collateralHeight
|
||||||
|
}
|
||||||
|
|
||||||
func doCall(ctx context.Context, b Backend, args TransactionArgs, state *state.StateDB, header *types.Header, overrides *StateOverride, blockOverrides *BlockOverrides, timeout time.Duration, globalGasCap uint64) (*core.ExecutionResult, error) {
|
func doCall(ctx context.Context, b Backend, args TransactionArgs, state *state.StateDB, header *types.Header, overrides *StateOverride, blockOverrides *BlockOverrides, timeout time.Duration, globalGasCap uint64) (*core.ExecutionResult, error) {
|
||||||
blockCtx := core.NewEVMBlockContext(header, NewChainContext(ctx, b), nil)
|
blockCtx := core.NewEVMBlockContext(header, NewChainContext(ctx, b), nil)
|
||||||
if blockOverrides != nil {
|
if blockOverrides != nil {
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,10 @@ type Backend interface {
|
||||||
|
|
||||||
ChainConfig() *params.ChainConfig
|
ChainConfig() *params.ChainConfig
|
||||||
Engine() consensus.Engine
|
Engine() consensus.Engine
|
||||||
|
// SYSCOIN
|
||||||
|
ReadSYSHash(ctx context.Context, number rpc.BlockNumber) ([]byte, error)
|
||||||
|
ReadDataHash(ctx context.Context, hash common.Hash) ([]byte, error)
|
||||||
|
GetNEVMAddress(ctx context.Context, address common.Address) ([]byte, error)
|
||||||
// This is copied from filters.Backend
|
// This is copied from filters.Backend
|
||||||
// eth/filters needs to be initialized from this backend type, so methods needed by
|
// eth/filters needs to be initialized from this backend type, so methods needed by
|
||||||
// it must also be included here.
|
// it must also be included here.
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,8 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if sim.chainConfig.IsCancun(header.Number, header.Time) {
|
// SYSCOIN
|
||||||
|
if !sim.chainConfig.IsSyscoin(header.Number) && sim.chainConfig.IsCancun(header.Number, header.Time) {
|
||||||
var excess uint64
|
var excess uint64
|
||||||
if sim.chainConfig.IsCancun(parent.Number, parent.Time) {
|
if sim.chainConfig.IsCancun(parent.Number, parent.Time) {
|
||||||
excess = eip4844.CalcExcessBlobGas(*parent.ExcessBlobGas, *parent.BlobGasUsed)
|
excess = eip4844.CalcExcessBlobGas(*parent.ExcessBlobGas, *parent.BlobGasUsed)
|
||||||
|
|
@ -239,11 +240,13 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
|
||||||
}
|
}
|
||||||
header.Root = sim.state.IntermediateRoot(true)
|
header.Root = sim.state.IntermediateRoot(true)
|
||||||
header.GasUsed = gasUsed
|
header.GasUsed = gasUsed
|
||||||
if sim.chainConfig.IsCancun(header.Number, header.Time) {
|
// SYSCOIN
|
||||||
|
if !sim.chainConfig.IsSyscoin(header.Number) && sim.chainConfig.IsCancun(header.Number, header.Time) {
|
||||||
header.BlobGasUsed = &blobGasUsed
|
header.BlobGasUsed = &blobGasUsed
|
||||||
}
|
}
|
||||||
var withdrawals types.Withdrawals
|
var withdrawals types.Withdrawals
|
||||||
if sim.chainConfig.IsShanghai(header.Number, header.Time) {
|
// SYSCOIN
|
||||||
|
if !sim.chainConfig.IsSyscoin(header.Number) && sim.chainConfig.IsShanghai(header.Number, header.Time) {
|
||||||
withdrawals = make([]*types.Withdrawal, 0)
|
withdrawals = make([]*types.Withdrawal, 0)
|
||||||
}
|
}
|
||||||
b := types.NewBlock(header, &types.Body{Transactions: txes, Withdrawals: withdrawals}, receipts, trie.NewStackTrie(nil))
|
b := types.NewBlock(header, &types.Body{Transactions: txes, Withdrawals: withdrawals}, receipts, trie.NewStackTrie(nil))
|
||||||
|
|
@ -361,11 +364,13 @@ func (sim *simulator) makeHeaders(blocks []simBlock) ([]*types.Header, error) {
|
||||||
overrides := block.BlockOverrides
|
overrides := block.BlockOverrides
|
||||||
|
|
||||||
var withdrawalsHash *common.Hash
|
var withdrawalsHash *common.Hash
|
||||||
if sim.chainConfig.IsShanghai(overrides.Number.ToInt(), (uint64)(*overrides.Time)) {
|
// SYSCOIN
|
||||||
|
if !sim.chainConfig.IsSyscoin(overrides.Number.ToInt()) && sim.chainConfig.IsShanghai(overrides.Number.ToInt(), (uint64)(*overrides.Time)) {
|
||||||
withdrawalsHash = &types.EmptyWithdrawalsHash
|
withdrawalsHash = &types.EmptyWithdrawalsHash
|
||||||
}
|
}
|
||||||
var parentBeaconRoot *common.Hash
|
var parentBeaconRoot *common.Hash
|
||||||
if sim.chainConfig.IsCancun(overrides.Number.ToInt(), (uint64)(*overrides.Time)) {
|
// SYSCOIN
|
||||||
|
if !sim.chainConfig.IsSyscoin(overrides.Number.ToInt()) && sim.chainConfig.IsCancun(overrides.Number.ToInt(), (uint64)(*overrides.Time)) {
|
||||||
parentBeaconRoot = &common.Hash{}
|
parentBeaconRoot = &common.Hash{}
|
||||||
}
|
}
|
||||||
header = overrides.MakeHeader(&types.Header{
|
header = overrides.MakeHeader(&types.Header{
|
||||||
|
|
@ -413,3 +418,13 @@ func (b *simBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumber)
|
||||||
}
|
}
|
||||||
return nil, errors.New("header not found")
|
return nil, errors.New("header not found")
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
func (b *simBackend) ReadSYSHash(ctx context.Context, number rpc.BlockNumber) ([]byte, error) {
|
||||||
|
return []byte{}, nil
|
||||||
|
}
|
||||||
|
func (b *simBackend) ReadDataHash(ctx context.Context, hash common.Hash) ([]byte, error) {
|
||||||
|
return []byte{}, nil
|
||||||
|
}
|
||||||
|
func (b *simBackend) GetNEVMAddress(ctx context.Context, address common.Address) ([]byte, error) {
|
||||||
|
return []byte{}, nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,9 @@ type Config struct {
|
||||||
|
|
||||||
// DefaultConfig contains default settings for miner.
|
// DefaultConfig contains default settings for miner.
|
||||||
var DefaultConfig = Config{
|
var DefaultConfig = Config{
|
||||||
GasCeil: 30_000_000,
|
// SYSCOIN
|
||||||
GasPrice: big.NewInt(params.GWei / 1000),
|
GasCeil: 8_000_000,
|
||||||
|
GasPrice: big.NewInt(100 * params.Wei),
|
||||||
|
|
||||||
// The default recommit time is chosen as two seconds since
|
// The default recommit time is chosen as two seconds since
|
||||||
// consensus-layer usually will wait a half slot of time(6s)
|
// consensus-layer usually will wait a half slot of time(6s)
|
||||||
|
|
@ -144,7 +145,8 @@ func (miner *Miner) getPending() *newPayloadResult {
|
||||||
timestamp = uint64(time.Now().Unix())
|
timestamp = uint64(time.Now().Unix())
|
||||||
withdrawal types.Withdrawals
|
withdrawal types.Withdrawals
|
||||||
)
|
)
|
||||||
if miner.chainConfig.IsShanghai(new(big.Int).Add(header.Number, big.NewInt(1)), timestamp) {
|
// SYSCOIN
|
||||||
|
if !miner.chainConfig.IsSyscoin(new(big.Int).Add(header.Number, big.NewInt(1))) && miner.chainConfig.IsShanghai(new(big.Int).Add(header.Number, big.NewInt(1)), timestamp) {
|
||||||
withdrawal = []*types.Withdrawal{}
|
withdrawal = []*types.Withdrawal{}
|
||||||
}
|
}
|
||||||
ret := miner.generateWork(&generateParams{
|
ret := miner.generateWork(&generateParams{
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,20 @@ type generateParams struct {
|
||||||
beaconRoot *common.Hash // The beacon root (cancun field).
|
beaconRoot *common.Hash // The beacon root (cancun field).
|
||||||
noTxs bool // Flag whether an empty block without any transaction is expected
|
noTxs bool // Flag whether an empty block without any transaction is expected
|
||||||
}
|
}
|
||||||
|
// SYSCOIN generates a sealing block based on the given parameters.
|
||||||
|
func (miner *Miner) GenerateWorkSyscoin(parentHash common.Hash, coinbase common.Address, random common.Hash) *types.Block {
|
||||||
|
result := miner.generateWork(&generateParams{
|
||||||
|
timestamp: uint64(time.Now().Unix()),
|
||||||
|
forceTime: true,
|
||||||
|
parentHash: parentHash,
|
||||||
|
coinbase: coinbase,
|
||||||
|
random: random,
|
||||||
|
withdrawals: nil,
|
||||||
|
beaconRoot: nil,
|
||||||
|
noTxs: false,
|
||||||
|
}, false)
|
||||||
|
return result.block
|
||||||
|
}
|
||||||
|
|
||||||
// generateWork generates a sealing block based on the given parameters.
|
// generateWork generates a sealing block based on the given parameters.
|
||||||
func (miner *Miner) generateWork(params *generateParams, witness bool) *newPayloadResult {
|
func (miner *Miner) generateWork(params *generateParams, witness bool) *newPayloadResult {
|
||||||
|
|
@ -115,8 +129,8 @@ func (miner *Miner) generateWork(params *generateParams, witness bool) *newPaylo
|
||||||
for _, r := range work.receipts {
|
for _, r := range work.receipts {
|
||||||
allLogs = append(allLogs, r.Logs...)
|
allLogs = append(allLogs, r.Logs...)
|
||||||
}
|
}
|
||||||
// Read requests if Prague is enabled.
|
// SYSCOIN Read requests if Prague is enabled.
|
||||||
if miner.chainConfig.IsPrague(work.header.Number, work.header.Time) {
|
if !miner.chainConfig.IsSyscoin(work.header.Number) && miner.chainConfig.IsPrague(work.header.Number, work.header.Time) {
|
||||||
requests, err := core.ParseDepositLogs(allLogs, miner.chainConfig)
|
requests, err := core.ParseDepositLogs(allLogs, miner.chainConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &newPayloadResult{err: err}
|
return &newPayloadResult{err: err}
|
||||||
|
|
@ -192,8 +206,8 @@ func (miner *Miner) prepareWork(genParams *generateParams, witness bool) (*envir
|
||||||
log.Error("Failed to prepare header for sealing", "err", err)
|
log.Error("Failed to prepare header for sealing", "err", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Apply EIP-4844, EIP-4788.
|
// SYSCOIN Apply EIP-4844, EIP-4788.
|
||||||
if miner.chainConfig.IsCancun(header.Number, header.Time) {
|
if !miner.chainConfig.IsSyscoin(header.Number) && miner.chainConfig.IsCancun(header.Number, header.Time) {
|
||||||
var excessBlobGas uint64
|
var excessBlobGas uint64
|
||||||
if miner.chainConfig.IsCancun(parent.Number, parent.Time) {
|
if miner.chainConfig.IsCancun(parent.Number, parent.Time) {
|
||||||
excessBlobGas = eip4844.CalcExcessBlobGas(*parent.ExcessBlobGas, *parent.BlobGasUsed)
|
excessBlobGas = eip4844.CalcExcessBlobGas(*parent.ExcessBlobGas, *parent.BlobGasUsed)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,10 @@ var MainnetBootnodes = []string{
|
||||||
"enode://2b252ab6a1d0f971d9722cb839a42cb81db019ba44c08754628ab4a823487071b5695317c8ccd085219c3a03af063495b2f1da8d18218da2d6a82981b45e6ffc@65.108.70.101:30303", // bootnode-hetzner-hel
|
"enode://2b252ab6a1d0f971d9722cb839a42cb81db019ba44c08754628ab4a823487071b5695317c8ccd085219c3a03af063495b2f1da8d18218da2d6a82981b45e6ffc@65.108.70.101:30303", // bootnode-hetzner-hel
|
||||||
"enode://4aeb4ab6c14b23e2c4cfdce879c04b0748a20d8e9b59e25ded2a08143e265c6c25936e74cbc8e641e3312ca288673d91f2f93f8e277de3cfa444ecdaaf982052@157.90.35.166:30303", // bootnode-hetzner-fsn
|
"enode://4aeb4ab6c14b23e2c4cfdce879c04b0748a20d8e9b59e25ded2a08143e265c6c25936e74cbc8e641e3312ca288673d91f2f93f8e277de3cfa444ecdaaf982052@157.90.35.166:30303", // bootnode-hetzner-fsn
|
||||||
}
|
}
|
||||||
|
// SYSCOIN
|
||||||
|
var TanenbaumBootnodes = []string{
|
||||||
|
"enode://f0e3e91d3d28b808734ce08b10855b5e6b6bde8eb9e4bedaf8aababc2ceaa8f4134cec309a996765f183361f1e67bce341326c05b743ed5932a8e705149364e4@44.238.217.166:30303",
|
||||||
|
}
|
||||||
// HoleskyBootnodes are the enode URLs of the P2P bootstrap nodes running on the
|
// HoleskyBootnodes are the enode URLs of the P2P bootstrap nodes running on the
|
||||||
// Holesky test network.
|
// Holesky test network.
|
||||||
var HoleskyBootnodes = []string{
|
var HoleskyBootnodes = []string{
|
||||||
|
|
@ -80,6 +83,8 @@ func KnownDNSNetwork(genesis common.Hash, protocol string) string {
|
||||||
switch genesis {
|
switch genesis {
|
||||||
case MainnetGenesisHash:
|
case MainnetGenesisHash:
|
||||||
net = "mainnet"
|
net = "mainnet"
|
||||||
|
case TanenbaumGenesisHash:
|
||||||
|
net = "tanenbaum"
|
||||||
case SepoliaGenesisHash:
|
case SepoliaGenesisHash:
|
||||||
net = "sepolia"
|
net = "sepolia"
|
||||||
case HoleskyGenesisHash:
|
case HoleskyGenesisHash:
|
||||||
|
|
|
||||||
105
params/config.go
105
params/config.go
|
|
@ -26,7 +26,9 @@ import (
|
||||||
|
|
||||||
// Genesis hashes to enforce below configs on.
|
// Genesis hashes to enforce below configs on.
|
||||||
var (
|
var (
|
||||||
MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")
|
// SYSCOIN
|
||||||
|
MainnetGenesisHash = common.HexToHash("0x2112327cad6deec6ada8bd7e5d33d263b57742a8495f3b641faa326b55b1c666")
|
||||||
|
TanenbaumGenesisHash = common.HexToHash("0x5fb22cd4425cea75d2ddaf5fbafb247bb682f407575c599d954b811214c3617c")
|
||||||
HoleskyGenesisHash = common.HexToHash("0xb5f7f912443c940f21fd611f12828d75b534364ed9e95ca4e307729a4661bde4")
|
HoleskyGenesisHash = common.HexToHash("0xb5f7f912443c940f21fd611f12828d75b534364ed9e95ca4e307729a4661bde4")
|
||||||
SepoliaGenesisHash = common.HexToHash("0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9")
|
SepoliaGenesisHash = common.HexToHash("0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9")
|
||||||
)
|
)
|
||||||
|
|
@ -34,33 +36,58 @@ var (
|
||||||
func newUint64(val uint64) *uint64 { return &val }
|
func newUint64(val uint64) *uint64 { return &val }
|
||||||
|
|
||||||
var (
|
var (
|
||||||
MainnetTerminalTotalDifficulty, _ = new(big.Int).SetString("58_750_000_000_000_000_000_000", 0)
|
// SYSCOIN
|
||||||
|
MainnetTerminalTotalDifficulty, _ = new(big.Int).SetString("0", 0)
|
||||||
|
|
||||||
// MainnetChainConfig is the chain parameters to run a node on the main network.
|
// MainnetChainConfig is the chain parameters to run a node on the main network.
|
||||||
MainnetChainConfig = &ChainConfig{
|
MainnetChainConfig = &ChainConfig{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: big.NewInt(57),
|
||||||
HomesteadBlock: big.NewInt(1_150_000),
|
HomesteadBlock: big.NewInt(0),
|
||||||
DAOForkBlock: big.NewInt(1_920_000),
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
EIP150Block: big.NewInt(2_463_000),
|
EIP150Block: big.NewInt(0),
|
||||||
EIP155Block: big.NewInt(2_675_000),
|
EIP155Block: big.NewInt(0),
|
||||||
EIP158Block: big.NewInt(2_675_000),
|
EIP158Block: big.NewInt(0),
|
||||||
ByzantiumBlock: big.NewInt(4_370_000),
|
ByzantiumBlock: big.NewInt(0),
|
||||||
ConstantinopleBlock: big.NewInt(7_280_000),
|
ConstantinopleBlock: big.NewInt(0),
|
||||||
PetersburgBlock: big.NewInt(7_280_000),
|
PetersburgBlock: big.NewInt(0),
|
||||||
IstanbulBlock: big.NewInt(9_069_000),
|
IstanbulBlock: big.NewInt(0),
|
||||||
MuirGlacierBlock: big.NewInt(9_200_000),
|
MuirGlacierBlock: big.NewInt(0),
|
||||||
BerlinBlock: big.NewInt(12_244_000),
|
BerlinBlock: big.NewInt(0),
|
||||||
LondonBlock: big.NewInt(12_965_000),
|
SyscoinBlock: big.NewInt(0),
|
||||||
ArrowGlacierBlock: big.NewInt(13_773_000),
|
RolluxBlock: big.NewInt(268500),
|
||||||
GrayGlacierBlock: big.NewInt(15_050_000),
|
NexusBlock: big.NewInt(600000),
|
||||||
TerminalTotalDifficulty: MainnetTerminalTotalDifficulty, // 58_750_000_000_000_000_000_000
|
LondonBlock: big.NewInt(1),
|
||||||
|
TerminalTotalDifficulty: MainnetTerminalTotalDifficulty,
|
||||||
TerminalTotalDifficultyPassed: true,
|
TerminalTotalDifficultyPassed: true,
|
||||||
ShanghaiTime: newUint64(1681338455),
|
ShanghaiTime: newUint64(1679618404),
|
||||||
CancunTime: newUint64(1710338135),
|
CancunTime: newUint64(1679618404),
|
||||||
DepositContractAddress: common.HexToAddress("0x00000000219ab540356cbb839cbe05303d7705fa"),
|
|
||||||
Ethash: new(EthashConfig),
|
Ethash: new(EthashConfig),
|
||||||
}
|
}
|
||||||
|
// SYSCOIN SyscoinChainConfig is the chain parameters to run a node on the syscoin network.
|
||||||
|
TanenbaumChainConfig = &ChainConfig{
|
||||||
|
ChainID: big.NewInt(5700),
|
||||||
|
HomesteadBlock: big.NewInt(0),
|
||||||
|
DAOForkBlock: nil,
|
||||||
|
DAOForkSupport: true,
|
||||||
|
EIP150Block: big.NewInt(0),
|
||||||
|
EIP155Block: big.NewInt(0),
|
||||||
|
EIP158Block: big.NewInt(0),
|
||||||
|
ByzantiumBlock: big.NewInt(0),
|
||||||
|
ConstantinopleBlock: big.NewInt(0),
|
||||||
|
PetersburgBlock: big.NewInt(0),
|
||||||
|
IstanbulBlock: big.NewInt(0),
|
||||||
|
MuirGlacierBlock: big.NewInt(0),
|
||||||
|
BerlinBlock: big.NewInt(0),
|
||||||
|
SyscoinBlock: big.NewInt(0),
|
||||||
|
RolluxBlock: big.NewInt(182500),
|
||||||
|
ShanghaiTime: newUint64(1675118284),
|
||||||
|
NexusBlock: big.NewInt(600000),
|
||||||
|
LondonBlock: big.NewInt(1),
|
||||||
|
CancunTime: newUint64(1675118284),
|
||||||
|
ArrowGlacierBlock: nil,
|
||||||
|
Ethash: new(EthashConfig),
|
||||||
|
}
|
||||||
// HoleskyChainConfig contains the chain parameters to run a node on the Holesky test network.
|
// HoleskyChainConfig contains the chain parameters to run a node on the Holesky test network.
|
||||||
HoleskyChainConfig = &ChainConfig{
|
HoleskyChainConfig = &ChainConfig{
|
||||||
ChainID: big.NewInt(17000),
|
ChainID: big.NewInt(17000),
|
||||||
|
|
@ -319,7 +346,10 @@ type ChainConfig struct {
|
||||||
ArrowGlacierBlock *big.Int `json:"arrowGlacierBlock,omitempty"` // Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated)
|
ArrowGlacierBlock *big.Int `json:"arrowGlacierBlock,omitempty"` // Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated)
|
||||||
GrayGlacierBlock *big.Int `json:"grayGlacierBlock,omitempty"` // Eip-5133 (bomb delay) switch block (nil = no fork, 0 = already activated)
|
GrayGlacierBlock *big.Int `json:"grayGlacierBlock,omitempty"` // Eip-5133 (bomb delay) switch block (nil = no fork, 0 = already activated)
|
||||||
MergeNetsplitBlock *big.Int `json:"mergeNetsplitBlock,omitempty"` // Virtual fork after The Merge to use as a network splitter
|
MergeNetsplitBlock *big.Int `json:"mergeNetsplitBlock,omitempty"` // Virtual fork after The Merge to use as a network splitter
|
||||||
|
// SYSCOIN
|
||||||
|
SyscoinBlock *big.Int `json:"syscoinBlock,omitempty"` // Syscoin switch block (nil = no fork, 0 = already on syscoin)
|
||||||
|
RolluxBlock *big.Int `json:"rolluxBlock,omitempty"` // Rollux switch block (nil = no fork, 0 = already on syscoin)
|
||||||
|
NexusBlock *big.Int `json:"nexusBlock,omitempty"` // Nexus switch block (nil = no fork, 0 = already on syscoin)
|
||||||
// Fork scheduling was switched from blocks to timestamps here
|
// Fork scheduling was switched from blocks to timestamps here
|
||||||
|
|
||||||
ShanghaiTime *uint64 `json:"shanghaiTime,omitempty"` // Shanghai switch time (nil = no fork, 0 = already on shanghai)
|
ShanghaiTime *uint64 `json:"shanghaiTime,omitempty"` // Shanghai switch time (nil = no fork, 0 = already on shanghai)
|
||||||
|
|
@ -535,7 +565,16 @@ func (c *ChainConfig) IsTerminalPoWBlock(parentTotalDiff *big.Int, totalDiff *bi
|
||||||
}
|
}
|
||||||
return parentTotalDiff.Cmp(c.TerminalTotalDifficulty) < 0 && totalDiff.Cmp(c.TerminalTotalDifficulty) >= 0
|
return parentTotalDiff.Cmp(c.TerminalTotalDifficulty) < 0 && totalDiff.Cmp(c.TerminalTotalDifficulty) >= 0
|
||||||
}
|
}
|
||||||
|
// SYSCOIN IsSyscoin returns whether num is either equal to the Syscoin fork block or greater.
|
||||||
|
func (c *ChainConfig) IsSyscoin(num *big.Int) bool {
|
||||||
|
return isBlockForked(c.SyscoinBlock, num)
|
||||||
|
}
|
||||||
|
func (c *ChainConfig) IsRollux(num *big.Int) bool {
|
||||||
|
return isBlockForked(c.RolluxBlock, num)
|
||||||
|
}
|
||||||
|
func (c *ChainConfig) IsNexus(num *big.Int) bool {
|
||||||
|
return isBlockForked(c.NexusBlock, num)
|
||||||
|
}
|
||||||
// IsShanghai returns whether time is either equal to the Shanghai fork time or greater.
|
// IsShanghai returns whether time is either equal to the Shanghai fork time or greater.
|
||||||
func (c *ChainConfig) IsShanghai(num *big.Int, time uint64) bool {
|
func (c *ChainConfig) IsShanghai(num *big.Int, time uint64) bool {
|
||||||
return c.IsLondon(num) && isTimestampForked(c.ShanghaiTime, time)
|
return c.IsLondon(num) && isTimestampForked(c.ShanghaiTime, time)
|
||||||
|
|
@ -710,6 +749,12 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int,
|
||||||
if isForkBlockIncompatible(c.MergeNetsplitBlock, newcfg.MergeNetsplitBlock, headNumber) {
|
if isForkBlockIncompatible(c.MergeNetsplitBlock, newcfg.MergeNetsplitBlock, headNumber) {
|
||||||
return newBlockCompatError("Merge netsplit fork block", c.MergeNetsplitBlock, newcfg.MergeNetsplitBlock)
|
return newBlockCompatError("Merge netsplit fork block", c.MergeNetsplitBlock, newcfg.MergeNetsplitBlock)
|
||||||
}
|
}
|
||||||
|
if isForkBlockIncompatible(c.RolluxBlock, newcfg.RolluxBlock, headNumber) {
|
||||||
|
return newBlockCompatError("Rollux fork block", c.RolluxBlock, newcfg.RolluxBlock)
|
||||||
|
}
|
||||||
|
if isForkBlockIncompatible(c.NexusBlock, newcfg.NexusBlock, headNumber) {
|
||||||
|
return newBlockCompatError("Nexus fork block", c.NexusBlock, newcfg.RolluxBlock)
|
||||||
|
}
|
||||||
if isForkTimestampIncompatible(c.ShanghaiTime, newcfg.ShanghaiTime, headTimestamp) {
|
if isForkTimestampIncompatible(c.ShanghaiTime, newcfg.ShanghaiTime, headTimestamp) {
|
||||||
return newTimestampCompatError("Shanghai fork timestamp", c.ShanghaiTime, newcfg.ShanghaiTime)
|
return newTimestampCompatError("Shanghai fork timestamp", c.ShanghaiTime, newcfg.ShanghaiTime)
|
||||||
}
|
}
|
||||||
|
|
@ -739,7 +784,10 @@ func (c *ChainConfig) ElasticityMultiplier() uint64 {
|
||||||
func (c *ChainConfig) LatestFork(time uint64) forks.Fork {
|
func (c *ChainConfig) LatestFork(time uint64) forks.Fork {
|
||||||
// Assume last non-time-based fork has passed.
|
// Assume last non-time-based fork has passed.
|
||||||
london := c.LondonBlock
|
london := c.LondonBlock
|
||||||
|
// SYSCOIN
|
||||||
|
if c.NexusBlock != nil {
|
||||||
|
london = c.NexusBlock
|
||||||
|
}
|
||||||
switch {
|
switch {
|
||||||
case c.IsPrague(london, time):
|
case c.IsPrague(london, time):
|
||||||
return forks.Prague
|
return forks.Prague
|
||||||
|
|
@ -891,7 +939,8 @@ type Rules struct {
|
||||||
IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool
|
IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool
|
||||||
IsEIP2929, IsEIP4762 bool
|
IsEIP2929, IsEIP4762 bool
|
||||||
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
|
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
|
||||||
IsBerlin, IsLondon bool
|
// SYSCOIN
|
||||||
|
IsBerlin, IsLondon, IsSyscoin, IsRollux, IsNexus bool
|
||||||
IsMerge, IsShanghai, IsCancun, IsPrague bool
|
IsMerge, IsShanghai, IsCancun, IsPrague bool
|
||||||
IsVerkle bool
|
IsVerkle bool
|
||||||
}
|
}
|
||||||
|
|
@ -924,5 +973,9 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
|
||||||
IsPrague: isMerge && c.IsPrague(num, timestamp),
|
IsPrague: isMerge && c.IsPrague(num, timestamp),
|
||||||
IsVerkle: isVerkle,
|
IsVerkle: isVerkle,
|
||||||
IsEIP4762: isVerkle,
|
IsEIP4762: isVerkle,
|
||||||
|
// SYSCOIN
|
||||||
|
IsSyscoin: c.IsSyscoin(num),
|
||||||
|
IsRollux: c.IsRollux(num),
|
||||||
|
IsNexus: c.IsNexus(num),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,4 +39,8 @@ const (
|
||||||
Shanghai
|
Shanghai
|
||||||
Cancun
|
Cancun
|
||||||
Prague
|
Prague
|
||||||
|
// SYSCOIN
|
||||||
|
Syscoin
|
||||||
|
Rollux
|
||||||
|
Nexus
|
||||||
)
|
)
|
||||||
|
|
|
||||||
23
params/nexus.go
Normal file
23
params/nexus.go
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
// Copyright 2016 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package params
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
)
|
||||||
|
var VaultManager = common.HexToAddress("0xA738a563F9ecb55e0b2245D1e9E380f0fE455ea1")
|
||||||
|
var VaultManagerOld = common.HexToAddress("0xA738a563F9ecb55e0b2245D1e9E380f0fE455ea1")
|
||||||
|
|
@ -21,9 +21,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VersionMajor = 1 // Major version component of the current release
|
// SYSCOIN
|
||||||
VersionMinor = 14 // Minor version component of the current release
|
VersionMajor = 4 // Major version component of the current release
|
||||||
VersionPatch = 12 // Patch version component of the current release
|
VersionMinor = 5 // Minor version component of the current release
|
||||||
|
VersionPatch = 1 // Patch version component of the current release
|
||||||
VersionMeta = "unstable" // Version metadata to append to the version string
|
VersionMeta = "unstable" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -290,7 +290,8 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh
|
||||||
context.Random = &rnd
|
context.Random = &rnd
|
||||||
context.Difficulty = big.NewInt(0)
|
context.Difficulty = big.NewInt(0)
|
||||||
}
|
}
|
||||||
if config.IsCancun(new(big.Int), block.Time()) && t.json.Env.ExcessBlobGas != nil {
|
// SYSCOIN
|
||||||
|
if !config.IsSyscoin(new(big.Int)) && config.IsCancun(new(big.Int), block.Time()) && t.json.Env.ExcessBlobGas != nil {
|
||||||
context.BlobBaseFee = eip4844.CalcBlobFee(*t.json.Env.ExcessBlobGas)
|
context.BlobBaseFee = eip4844.CalcBlobFee(*t.json.Env.ExcessBlobGas)
|
||||||
}
|
}
|
||||||
evm := vm.NewEVM(context, txContext, st.StateDB, config, vmconfig)
|
evm := vm.NewEVM(context, txContext, st.StateDB, config, vmconfig)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue