Skip to content

Commit

Permalink
[action] use SenderAddress() to replace SrcPubkey().Address() (#3446)
Browse files Browse the repository at this point in the history
Co-authored-by: Haaai <[email protected]>
  • Loading branch information
saitofun and Liuhaai authored Jun 13, 2022
1 parent 744dde9 commit fbd9bc4
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion action/protocol/generic_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (v *GenericValidator) Validate(_ context.Context, selp action.SealedEnvelop
if err := selp.VerifySignature(); err != nil {
return err
}
caller := selp.SrcPubkey().Address()
caller := selp.SenderAddress()
if caller == nil {
return errors.New("failed to get address")
}
Expand Down
10 changes: 5 additions & 5 deletions action/protocol/poll/governance_protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ func TestHandle(t *testing.T) {
selp2, err := action.Sign(elp, senderKey)
require.NoError(err)
require.NotNil(selp2)
caller := selp2.SrcPubkey().Address()
caller := selp2.SenderAddress()
require.NotNil(caller)
ctx2 = protocol.WithBlockCtx(
ctx2,
Expand Down Expand Up @@ -442,7 +442,7 @@ func TestHandle(t *testing.T) {
selp2, err := action.Sign(elp, senderKey)
require.NoError(err)
require.NotNil(selp2)
caller := selp2.SrcPubkey().Address()
caller := selp2.SenderAddress()
require.NotNil(caller)
ctx2 = protocol.WithBlockCtx(
ctx2,
Expand Down Expand Up @@ -477,7 +477,7 @@ func TestHandle(t *testing.T) {
selp3, err := action.Sign(elp, senderKey)
require.NoError(err)
require.NotNil(selp3)
caller := selp3.SrcPubkey().Address()
caller := selp3.SenderAddress()
require.NotNil(caller)
ctx3 = protocol.WithBlockCtx(
ctx3,
Expand Down Expand Up @@ -511,7 +511,7 @@ func TestHandle(t *testing.T) {
selp4, err := action.Sign(elp4, senderKey)
require.NoError(err)
require.NotNil(selp4)
caller := selp4.SrcPubkey().Address()
caller := selp4.SenderAddress()
require.NotNil(caller)
ctx4 = protocol.WithBlockCtx(
ctx4,
Expand Down Expand Up @@ -545,7 +545,7 @@ func TestHandle(t *testing.T) {
selp5, err := action.Sign(elp5, senderKey)
require.NoError(err)
require.NotNil(selp5)
caller := selp5.SrcPubkey().Address()
caller := selp5.SenderAddress()
require.NotNil(caller)
ctx5 = protocol.WithBlockCtx(
ctx5,
Expand Down
8 changes: 4 additions & 4 deletions action/protocol/poll/staking_committee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func TestHandle_StakingCommittee(t *testing.T) {
selp2, err := action.Sign(elp, senderKey)
require.NoError(err)
require.NotNil(selp2)
caller := selp2.SrcPubkey().Address()
caller := selp2.SenderAddress()
require.NotNil(caller)
ctx2 = protocol.WithBlockCtx(
ctx2,
Expand Down Expand Up @@ -298,7 +298,7 @@ func TestHandle_StakingCommittee(t *testing.T) {
selp3, err := action.Sign(elp, senderKey)
require.NoError(err)
require.NotNil(selp3)
caller := selp3.SrcPubkey().Address()
caller := selp3.SenderAddress()
require.NotNil(caller)
ctx3 = protocol.WithBlockCtx(
ctx3,
Expand Down Expand Up @@ -334,7 +334,7 @@ func TestHandle_StakingCommittee(t *testing.T) {
selp4, err := action.Sign(elp4, senderKey)
require.NoError(err)
require.NotNil(selp4)
caller := selp4.SrcPubkey().Address()
caller := selp4.SenderAddress()
require.NotNil(caller)
ctx4 = protocol.WithBlockCtx(
ctx4,
Expand Down Expand Up @@ -370,7 +370,7 @@ func TestHandle_StakingCommittee(t *testing.T) {
selp5, err := action.Sign(elp5, senderKey)
require.NoError(err)
require.NotNil(selp5)
caller := selp5.SrcPubkey().Address()
caller := selp5.SenderAddress()
require.NotNil(caller)
ctx5 = protocol.WithBlockCtx(
ctx5,
Expand Down
4 changes: 2 additions & 2 deletions actpool/actpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (ap *actPool) Add(ctx context.Context, act action.SealedEnvelope) error {
return err
}

caller := act.SrcPubkey().Address()
caller := act.SenderAddress()
if caller == nil {
return action.ErrAddress
}
Expand Down Expand Up @@ -331,7 +331,7 @@ func (ap *actPool) validate(ctx context.Context, selp action.SealedEnvelope) err
span.AddEvent("actPool.validate")
defer span.End()

caller := selp.SrcPubkey().Address()
caller := selp.SenderAddress()
if caller == nil {
return errors.New("failed to get address")
}
Expand Down
8 changes: 4 additions & 4 deletions api/coreservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ func (core *coreService) EstimateGasForAction(ctx context.Context, in *iotextype
}
return gas, nil
}
callerAddr := selp.SrcPubkey().Address()
callerAddr := selp.SenderAddress()
if callerAddr == nil {
return 0, status.Error(codes.Internal, "failed to get address")
}
Expand Down Expand Up @@ -1166,7 +1166,7 @@ func (core *coreService) committedAction(selp action.SealedEnvelope, blkHash has
if err != nil {
return nil, err
}
sender := selp.SrcPubkey().Address()
sender := selp.SenderAddress()
receipt, err := core.dao.GetReceiptByActionHash(actHash, blkHeight)
if err != nil {
return nil, err
Expand All @@ -1190,7 +1190,7 @@ func (core *coreService) pendingAction(selp action.SealedEnvelope) (*iotexapi.Ac
if err != nil {
return nil, err
}
sender := selp.SrcPubkey().Address()
sender := selp.SenderAddress()
return &iotexapi.ActionInfo{
Action: selp.Proto(),
ActHash: hex.EncodeToString(actHash[:]),
Expand Down Expand Up @@ -1242,7 +1242,7 @@ func (core *coreService) reverseActionsInBlock(blk *block.Block, reverseStart, c
continue
}
gas := new(big.Int).Mul(selp.GasPrice(), big.NewInt(int64(receipt.GasConsumed)))
sender := selp.SrcPubkey().Address()
sender := selp.SenderAddress()
res = append([]*iotexapi.ActionInfo{{
Action: selp.Proto(),
ActHash: hex.EncodeToString(actHash[:]),
Expand Down
4 changes: 2 additions & 2 deletions api/grpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func actionsInBlock(blk *block.Block, receipts []*action.Receipt, start, count u
continue
}
gas := new(big.Int).Mul(selp.GasPrice(), big.NewInt(int64(receipt.GasConsumed)))
sender := selp.SrcPubkey().Address()
sender := selp.SenderAddress()
res = append(res, &iotexapi.ActionInfo{
Action: selp.Proto(),
ActHash: hex.EncodeToString(actHash[:]),
Expand Down Expand Up @@ -647,7 +647,7 @@ func (svr *GRPCServer) TraceTransactionStructLogs(ctx context.Context, in *iotex
NoBaseFee: true,
})

_, _, err = svr.coreService.SimulateExecution(ctx, act.SrcPubkey().Address(), sc)
_, _, err = svr.coreService.SimulateExecution(ctx, act.SenderAddress(), sc)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion api/web3server.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ func (svr *web3Handler) getTransactionReceipt(in *gjson.Result) (interface{}, er

return &getReceiptResult{
blockHash: blockHash,
from: selp.SrcPubkey().Address(),
from: selp.SenderAddress(),
to: to,
contractAddress: contractAddr,
logsBloom: blkMeta.LogsBloom,
Expand Down
6 changes: 3 additions & 3 deletions state/factory/workingset.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (ws *workingSet) runActions(
func withActionCtx(ctx context.Context, selp action.SealedEnvelope) (context.Context, error) {
var actionCtx protocol.ActionCtx
var err error
caller := selp.SrcPubkey().Address()
caller := selp.SenderAddress()
if caller == nil {
return nil, errors.New("failed to get address")
}
Expand Down Expand Up @@ -326,7 +326,7 @@ func (ws *workingSet) CreateGenesisStates(ctx context.Context) error {
func (ws *workingSet) validateNonce(blk *block.Block) error {
accountNonceMap := make(map[string][]uint64)
for _, selp := range blk.Actions {
caller := selp.SrcPubkey().Address()
caller := selp.SenderAddress()
if caller == nil {
return errors.New("failed to get address")
}
Expand Down Expand Up @@ -445,7 +445,7 @@ func (ws *workingSet) pickAndRunActions(
}
}
if err != nil {
caller := nextAction.SrcPubkey().Address()
caller := nextAction.SenderAddress()
if caller == nil {
return nil, errors.New("failed to get address")
}
Expand Down

0 comments on commit fbd9bc4

Please sign in to comment.