Skip to content

Commit

Permalink
feat: ignore the first tx (connect oracle extension tx)
Browse files Browse the repository at this point in the history
  • Loading branch information
rustcandy committed Nov 28, 2024
1 parent f171805 commit 1f306b0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
14 changes: 8 additions & 6 deletions node/remote/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ import (

// Details represents a node details for a remote node
type Details struct {
RPC *RPCConfig `yaml:"rpc"`
GRPC *GRPCConfig `yaml:"grpc"`
RPC *RPCConfig `yaml:"rpc"`
GRPC *GRPCConfig `yaml:"grpc"`
IgnoreConnectVoteExtensionTx bool `yaml:"ignore_connect_vote_extension_tx"` // ignore tx[0] for the chains that are using Skip Oracle
}

func NewDetails(rpc *RPCConfig, grpc *GRPCConfig) *Details {
func NewDetails(rpc *RPCConfig, grpc *GRPCConfig, ignoreConnectVoteExtensionTx bool) *Details {
return &Details{
RPC: rpc,
GRPC: grpc,
RPC: rpc,
GRPC: grpc,
IgnoreConnectVoteExtensionTx: ignoreConnectVoteExtensionTx,
}
}

func DefaultDetails() *Details {
return NewDetails(DefaultRPCConfig(), DefaultGrpcConfig())
return NewDetails(DefaultRPCConfig(), DefaultGrpcConfig(), false)
}

// Validate implements node.Details
Expand Down
19 changes: 13 additions & 6 deletions node/remote/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ type Node struct {

computeTxHash types.TxHashCalculator

client *httpclient.HTTP
txServiceClient tx.ServiceClient
client *httpclient.HTTP
txServiceClient tx.ServiceClient
ignoreConnectVoteExtensionTx bool
}

// NewNode allows to build a new Node instance
Expand Down Expand Up @@ -74,8 +75,9 @@ func NewNode(

computeTxHash: txHashCalculator,

client: rpcClient,
txServiceClient: tx.NewServiceClient(grpcConnection),
client: rpcClient,
txServiceClient: tx.NewServiceClient(grpcConnection),
ignoreConnectVoteExtensionTx: cfg.IgnoreConnectVoteExtensionTx,
}, nil
}

Expand Down Expand Up @@ -269,9 +271,14 @@ func (cp *Node) Tx(hash string) (*types.Tx, error) {
}

// Txs implements node.Node

func (cp *Node) Txs(block *tmctypes.ResultBlock) ([]*types.Tx, error) {
txResponses := make([]*types.Tx, len(block.Block.Txs))
for i, tmTx := range block.Block.Txs {
txs := block.Block.Txs
if cp.ignoreConnectVoteExtensionTx && len(block.Block.Txs) > 0 {
txs = block.Block.Txs[1:]
}
txResponses := make([]*types.Tx, len(txs))
for i, tmTx := range txs {
txResponse, err := cp.Tx(fmt.Sprintf("%X", cp.computeTxHash(tmTx)))
if err != nil {
return nil, err
Expand Down

0 comments on commit 1f306b0

Please sign in to comment.