mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
return a different error code for each potential failure step
This commit is contained in:
parent
ac3f406ead
commit
4273efec1f
2 changed files with 12 additions and 5 deletions
|
|
@ -19,7 +19,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"os"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/stateless"
|
||||
|
|
@ -95,7 +97,8 @@ func getInput() []byte {
|
|||
|
||||
encoded, err := rlp.EncodeToBytes(payload)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
fmt.Fprintf(os.Stderr, "failed to encode payload: %v\n", err)
|
||||
os.Exit(20)
|
||||
}
|
||||
return encoded
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/stateless"
|
||||
|
|
@ -32,7 +33,7 @@ type Payload struct {
|
|||
}
|
||||
|
||||
func main() {
|
||||
input := getPayload()
|
||||
input := getInput()
|
||||
var payload Payload
|
||||
rlp.DecodeBytes(input, &payload)
|
||||
|
||||
|
|
@ -41,12 +42,15 @@ func main() {
|
|||
|
||||
crossStateRoot, crossReceiptRoot, err := core.ExecuteStateless(chainConfig, vmConfig, payload.Block, payload.Witness)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("stateless self-validation failed: %v", err))
|
||||
fmt.Fprintf(os.Stderr, "stateless self-validation failed: %v\n", err)
|
||||
os.Exit(10)
|
||||
}
|
||||
if crossStateRoot != payload.Block.Root() {
|
||||
panic(fmt.Errorf("stateless self-validation root mismatch (cross: %x local: %x)", crossStateRoot, payload.Block.Root()))
|
||||
fmt.Fprintf(os.Stderr, "stateless self-validation root mismatch (cross: %x local: %x)\n", crossStateRoot, payload.Block.Root())
|
||||
os.Exit(11)
|
||||
}
|
||||
if crossReceiptRoot != payload.Block.ReceiptHash() {
|
||||
panic(fmt.Errorf("stateless self-validation receipt root mismatch (cross: %x local: %x)", crossReceiptRoot, payload.Block.ReceiptHash()))
|
||||
fmt.Fprintf(os.Stderr, "stateless self-validation receipt root mismatch (cross: %x local: %x)\n", crossReceiptRoot, payload.Block.ReceiptHash())
|
||||
os.Exit(12)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue