forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
6,544 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package core | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/core/types" | ||
"github.com/ethereum/go-ethereum/params" | ||
"github.com/ethereum/go-ethereum/trie" | ||
) | ||
|
||
func (v *BlockValidator) validateGoatBlock(block *types.Block) error { | ||
if v.config.Goat == nil { | ||
return nil | ||
} | ||
|
||
extra := block.Header().Extra | ||
if len(extra) != params.GoatHeaderExtraLengthV0 { | ||
return fmt.Errorf("no goat tx root found (block %x)", block.Number()) | ||
} | ||
|
||
txLen, txRoot := int(extra[0]), common.BytesToHash(extra[1:]) | ||
if l := block.Transactions().Len(); l < txLen { | ||
return fmt.Errorf("txs length(%d) is less than goat tx length %d", l, txLen) | ||
} | ||
if hash := types.DeriveSha(block.Transactions()[:txLen], trie.NewStackTrie(nil)); hash != txRoot { | ||
return fmt.Errorf("goat tx root hash mismatch (header value %x, calculated %x)", txRoot, hash) | ||
} | ||
if len(block.Withdrawals()) > 0 { | ||
return errors.New("withdrawals not allowed for goat-geth") | ||
} | ||
|
||
for i, tx := range block.Transactions() { | ||
if i < txLen { | ||
if !tx.IsGoatTx() { | ||
return fmt.Errorf("transaction %d should be goat tx", i) | ||
} | ||
if tx.To() == nil { | ||
return fmt.Errorf("goat tx %d should have a to address", i) | ||
} | ||
} else { | ||
if tx.IsGoatTx() { | ||
return fmt.Errorf("transaction %d should not be goat tx", i) | ||
} | ||
if tx.Type() == types.BlobTxType { | ||
return fmt.Errorf("blob transaction %d is not allowed", i) | ||
} | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package core | ||
|
||
import ( | ||
"embed" | ||
"encoding/json" | ||
"math/big" | ||
|
||
_ "embed" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/core/types" | ||
"github.com/ethereum/go-ethereum/params" | ||
) | ||
|
||
//go:embed goat | ||
var goatGenesis embed.FS | ||
|
||
var goatEmptyExtra = common.Hex2Bytes("0056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") | ||
|
||
// DefaultGoatTestnet3GenesisBlock returns the Goat Testnet3 genesis block. | ||
func DefaultGoatTestnet3GenesisBlock() *Genesis { | ||
raw, err := goatGenesis.ReadFile("goat/testnet3.json") | ||
if err != nil { | ||
panic(err) | ||
} | ||
var alloc types.GenesisAlloc | ||
if err := json.Unmarshal(raw, &alloc); err != nil { | ||
panic(err) | ||
} | ||
return &Genesis{ | ||
Config: params.GoatTestnet3ChainConfig, | ||
Nonce: 0, | ||
Timestamp: 0x67345ba0, | ||
ExtraData: goatEmptyExtra, | ||
GasLimit: params.GoatTxGasLimit, | ||
Difficulty: common.Big0, | ||
Alloc: alloc, | ||
BaseFee: big.NewInt(2028449), | ||
} | ||
} | ||
|
||
// DefaultGoatMainnetGenesisBlock returns the Goat Mainnet genesis block. | ||
func DefaultGoatMainnetGenesisBlock() *Genesis { | ||
raw, err := goatGenesis.ReadFile("goat/mainnet.json") | ||
if err != nil { | ||
panic(err) | ||
} | ||
var alloc types.GenesisAlloc | ||
if err := json.Unmarshal(raw, &alloc); err != nil { | ||
panic(err) | ||
} | ||
return &Genesis{ | ||
Config: params.GoatMainnetChainConfig, | ||
Nonce: 0, | ||
Timestamp: 0x674d6b3a, | ||
ExtraData: goatEmptyExtra, | ||
GasLimit: params.GoatTxGasLimit, | ||
Difficulty: common.Big0, | ||
Alloc: alloc, | ||
BaseFee: big.NewInt(2028449), | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.