additionla log messages for permissioning

This commit is contained in:
vsmk98 2018-07-31 01:42:51 +00:00
parent 8b31b8931d
commit 4e3c907531
5 changed files with 23 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
)
// SignerFn is a signer function callback when a contract requires a method to
@ -183,6 +184,7 @@ func (c *BoundContract) Transfer(opts *TransactOpts) (*types.Transaction, error)
// transact executes an actual transaction invocation, first deriving any missing
// authorization fields, and then scheduling the transaction for execution.
func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, input []byte) (*types.Transaction, error) {
log.Info("Inside transact")
var err error
// Ensure a valid value field and resolve the account nonce
@ -238,6 +240,7 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i
if err != nil {
return nil, err
}
log.Info("calling SendTransaction in side transact")
if err := c.transactor.SendTransaction(ensureContext(opts.Context), signedTx); err != nil {
return nil, err
}

View File

@ -81,7 +81,7 @@ var (
// ErrUnahorizedAccount is returned if the sender account is not authorized by the
// permissions module
ErrUnauthorizesAccount = errors.New("Account not authorized for this operation")
ErrUnAuthorizedAccount = errors.New("Account not authorized for this operation")
)
var (
@ -569,6 +569,7 @@ func (pool *TxPool) local() map[common.Address]types.Transactions {
// validateTx checks whether a transaction is valid according to the consensus
// rules and adheres to some heuristic limits of the local node (price and size).
func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
log.Info("Inside validateTx")
isQuorum := pool.chainconfig.IsQuorum
if isQuorum && tx.GasPrice().Cmp(common.Big0) != 0 {
@ -616,8 +617,9 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
// Check if the sender account is authorized to perform the transaction
if isQuorum {
log.Info("Inside if before checkAccount")
if err := checkAccount(); err != nil {
return ErrInvalidGasPrice
return ErrUnAuthorizedAccount
}
}
@ -633,6 +635,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
// whitelisted, preventing any associated transaction from being dropped out of
// the pool due to pricing constraints.
func (pool *TxPool) add(tx *types.Transaction, local bool) (bool, error) {
log.Info("Inside add")
// If the transaction is already known, discard it
hash := tx.Hash()
if pool.all[hash] != nil {
@ -784,6 +787,7 @@ func (pool *TxPool) promoteTx(addr common.Address, hash common.Hash, tx *types.T
// the sender as a local one in the mean time, ensuring it goes around the local
// pricing constraints.
func (pool *TxPool) AddLocal(tx *types.Transaction) error {
log.Info("inside AddLocal")
return pool.addTx(tx, !pool.config.NoLocals)
}
@ -810,6 +814,7 @@ func (pool *TxPool) AddRemotes(txs []*types.Transaction) []error {
// addTx enqueues a single transaction into the pool if it is valid.
func (pool *TxPool) addTx(tx *types.Transaction, local bool) error {
log.Info("inside addTx")
pool.mu.Lock()
defer pool.mu.Unlock()

View File

@ -35,6 +35,7 @@ import (
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/log"
)
// EthAPIBackend implements ethapi.Backend for full nodes
@ -172,6 +173,7 @@ func (b *EthAPIBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscri
}
func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error {
log.Info("inside SendTx")
return b.eth.txPool.AddLocal(signedTx)
}

View File

@ -30,6 +30,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/log"
)
// Client defines typed wrappers for the Ethereum RPC API.
@ -477,6 +478,7 @@ func (ec *Client) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64
// If the transaction was a contract creation use the TransactionReceipt method to get the
// contract address after the transaction has been mined.
func (ec *Client) SendTransaction(ctx context.Context, tx *types.Transaction) error {
log.Info("Inside SendTransaction")
data, err := rlp.EncodeToBytes(tx)
if err != nil {
return err

View File

@ -370,6 +370,7 @@ func (s *PrivateAccountAPI) signTransaction(ctx context.Context, args SendTxArgs
// tries to sign it with the key associated with args.To. If the given passwd isn't
// able to decrypt the key it fails.
func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error) {
log.Info("inside SendTransaction")
if args.Nonce == nil {
// Hold the addresse's mutex around signing to prevent concurrent assignment of
// the same nonce to multiple accounts.
@ -396,6 +397,7 @@ func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs
if err != nil {
return common.Hash{}, err
}
log.Info("Calling submitTransaction 1")
return submitTransaction(ctx, s.b, signed, isPrivate)
}
@ -1187,6 +1189,7 @@ func (args *SendTxArgs) setDefaults(ctx context.Context, b Backend) error {
}
func (args *SendTxArgs) toTransaction() *types.Transaction {
log.Info("inside toTransaction")
var input []byte
if args.Data != nil {
input = *args.Data
@ -1194,13 +1197,16 @@ func (args *SendTxArgs) toTransaction() *types.Transaction {
input = *args.Input
}
if args.To == nil {
log.Info("Contract creation call")
return types.NewContractCreation(uint64(*args.Nonce), (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input)
}
log.Info("New transaction callcreation call")
return types.NewTransaction(uint64(*args.Nonce), *args.To, (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input)
}
// submitTransaction is a helper function that submits tx to txPool and logs a message.
func submitTransaction(ctx context.Context, b Backend, tx *types.Transaction, isPrivate bool) (common.Hash, error) {
log.Info("inside submitTransaction")
if isPrivate {
tx.SetPrivate()
}
@ -1275,6 +1281,7 @@ func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args Sen
if err != nil {
return common.Hash{}, err
}
log.Info("Calling submitTransaction 2")
return submitTransaction(ctx, s.b, signed, isPrivate)
}
@ -1285,6 +1292,7 @@ func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encod
if err := rlp.DecodeBytes(encodedTx, tx); err != nil {
return common.Hash{}, err
}
log.Info("Calling submitTransaction 3")
return submitTransaction(ctx, s.b, tx, tx.IsPrivate())
}
@ -1614,6 +1622,7 @@ func (a *Async) save(ctx context.Context, s *PublicTransactionPoolAPI, args Send
return common.Hash{}, err
}
log.Info("Calling submitTransaction 4")
return submitTransaction(ctx, s.b, signed, args.PrivateFor != nil)
}