mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-31 17:13:57 +00:00
verbose precompile logging
This commit is contained in:
parent
0b880fa0ad
commit
205a1b31d6
1 changed files with 9 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/common/math"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
)
|
||||
|
||||
|
|
@ -84,6 +85,7 @@ const whitelistCreate2Addr = "0x07e77fdc3DF92E58c9230eEFaABdBd92a8D0c2Af"
|
|||
func (c *mint) Run(input []byte, ctx *precompileContext) ([]byte, error) {
|
||||
|
||||
if ctx.caller != common.HexToAddress(whitelistCreate2Addr) {
|
||||
log.Error("Error parsing transfer: caller not whitelisted")
|
||||
return nil, fmt.Errorf("Error parsing transfer: caller not whitelisted")
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +94,8 @@ func (c *mint) Run(input []byte, ctx *precompileContext) ([]byte, error) {
|
|||
var parsed bool
|
||||
value, parsed := math.ParseBig256(hexutil.Encode(input[32:64]))
|
||||
if !parsed {
|
||||
return nil, fmt.Errorf("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[64:96]))
|
||||
log.Error("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[32:64]))
|
||||
return nil, fmt.Errorf("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[32:64]))
|
||||
}
|
||||
|
||||
// Create native token out of thin air
|
||||
|
|
@ -112,6 +115,7 @@ func (c *burn) RequiredGas(input []byte) uint64 {
|
|||
func (c *burn) Run(input []byte, ctx *precompileContext) ([]byte, error) {
|
||||
|
||||
if ctx.caller != common.HexToAddress(whitelistCreate2Addr) {
|
||||
log.Error("Error parsing transfer: caller not whitelisted")
|
||||
return nil, fmt.Errorf("Error parsing transfer: caller not whitelisted")
|
||||
}
|
||||
|
||||
|
|
@ -120,10 +124,13 @@ func (c *burn) Run(input []byte, ctx *precompileContext) ([]byte, error) {
|
|||
var parsed bool
|
||||
value, parsed := math.ParseBig256(hexutil.Encode(input[32:64]))
|
||||
if !parsed {
|
||||
return nil, fmt.Errorf("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[64:96]))
|
||||
log.Error("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[32:64]))
|
||||
return nil, fmt.Errorf("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[32:64]))
|
||||
}
|
||||
|
||||
if !ctx.CanTransfer(ctx.evm.StateDB, burnFrom, value) {
|
||||
log.Error("Error parsing transfer, address: " + burnFrom.Hex() + " has insufficient balance. " +
|
||||
value.String() + " needed " + ctx.evm.StateDB.GetBalance(burnFrom).String() + " available")
|
||||
return nil, ErrInsufficientBalance
|
||||
}
|
||||
ctx.evm.StateDB.SubBalance(burnFrom, value)
|
||||
|
|
|
|||
Loading…
Reference in a new issue