Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix extrinsic failed event not throwing error #191

Merged
merged 5 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions chains/evm/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ func (e *Executor) watchExecution(ctx context.Context, cancelExecution context.C
case sigResult := <-sigChn:
{
cancelExecution()
if sigResult == nil {
continue
}

signatureData := sigResult.(*common.SignatureData)
hash, err := e.executeProposal(proposals, signatureData)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions chains/substrate/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ func (c *SubstrateClient) checkExtrinsicSuccess(extHash types.Hash, blockHash ty
if event.Name == events.ExtrinsicFailedEvent {
return fmt.Errorf("extrinsic failed")
}
if event.Name == events.FailedHandlerExecutionEvent {
return fmt.Errorf("extrinsic failed with failed handler execution")
}
if event.Name == events.ExtrinsicSuccessEvent {
return nil
}
Expand Down
11 changes: 6 additions & 5 deletions chains/substrate/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ type Retry struct {
}

const (
CodeUpdatedEvent = "System.CodeUpdated"
ExtrinsicFailedEvent = "System.ExtrinsicFailed"
ExtrinsicSuccessEvent = "System.ExtrinsicSuccess"
RetryEvent = "SygmaBridge.Retry"
DepositEvent = "SygmaBridge.Deposit"
CodeUpdatedEvent = "System.CodeUpdated"
ExtrinsicFailedEvent = "System.ExtrinsicFailed"
ExtrinsicSuccessEvent = "System.ExtrinsicSuccess"
RetryEvent = "SygmaBridge.Retry"
DepositEvent = "SygmaBridge.Deposit"
FailedHandlerExecutionEvent = "SygmaBridge.FailedHandlerExecution"
)
4 changes: 4 additions & 0 deletions chains/substrate/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func (e *Executor) Execute(msgs []*message.Message) error {
sigChn := make(chan interface{})
executionContext, cancelExecution := context.WithCancel(context.Background())
watchContext, cancelWatch := context.WithCancel(context.Background())

pool := pool.New().WithErrors()
pool.Go(func() error {
err := e.coordinator.Execute(executionContext, signing, sigChn)
Expand Down Expand Up @@ -152,6 +153,9 @@ func (e *Executor) watchExecution(ctx context.Context, cancelExecution context.C
case sigResult := <-sigChn:
{
cancelExecution()
if sigResult == nil {
continue
}

signatureData := sigResult.(*common.SignatureData)
hash, sub, err := e.executeProposal(proposals, signatureData)
Expand Down
4 changes: 2 additions & 2 deletions chains/substrate/pallet/pallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package pallet

import (
"math/big"
"strconv"

"github.com/ChainSafe/sygma-relayer/chains"
Expand Down Expand Up @@ -69,9 +68,10 @@ func (p *Pallet) IsProposalExecuted(prop *chains.Proposal) (bool, error) {
Str("resourceID", hexutil.Encode(prop.ResourceID[:])).
Msg("Getting is proposal executed")
var res bool
err := p.Conn.Call(res, "sygma_isProposalExecuted", big.NewInt(int64(prop.DepositNonce)), big.NewInt(int64(prop.OriginDomainID)))
err := p.Conn.Call(&res, "sygma_isProposalExecuted", prop.DepositNonce, prop.OriginDomainID)
if err != nil {
return false, err
}

return res, nil
}
2 changes: 2 additions & 0 deletions tss/signing/signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ func (s *Signing) processEndMessage(ctx context.Context, endChn chan tssCommon.S

if s.coordinator {
s.resultChn <- &sig
} else {
s.resultChn <- nil
}

return nil
Expand Down
8 changes: 6 additions & 2 deletions tss/signing/signing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ func (s *SigningTestSuite) Test_ValidSigningProcess() {
})
}

sig := <-resultChn
s.NotNil(sig)
sig1 := <-resultChn
sig2 := <-resultChn
s.NotEqual(sig1, sig2)
if sig1 == nil && sig2 == nil {
s.Fail("signature is nil")
}

time.Sleep(time.Millisecond * 100)
cancel()
Expand Down