Skip to content

Commit

Permalink
confirm tx once get receipt does not error
Browse files Browse the repository at this point in the history
  • Loading branch information
augustbleeds committed Sep 18, 2023
1 parent 5c692ac commit d91d1b8
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 17 deletions.
2 changes: 2 additions & 0 deletions integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ require (
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/NethermindEth/starknet.go => github.com/augustbleeds/starknet.go v0.4.2-0.20230912155424-048179bee72e

replace (
// Fix go mod tidy issue for ambiguous imports from go-ethereum
// See https://github.com/ugorji/go/issues/279
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYr
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/NethermindEth/juno v0.3.1 h1:AW72LiAm9gqUeCVJWvepnZcTnpU4Vkl0KzPMxS+42FA=
github.com/NethermindEth/juno v0.3.1/go.mod h1:SGbTpgGaCsxhFsKOid7Ylnz//WZ8swtILk+NbHGsk/Q=
github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3 h1:SAE7oDXo82lT+arBtg6sozPMt9bNSkXY1A2TxlCGRw4=
github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3/go.mod h1:4fchLnLzJuwl1bnNUR+iBjKYN11afzJCdBcGZKIuFeU=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/OneOfOne/xxhash v1.2.5 h1:zl/OfRA6nftbBK9qTohYBJ5xvw6C/oNKizR7cZGl3cI=
Expand All @@ -117,6 +115,8 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV
github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/augustbleeds/starknet.go v0.4.2-0.20230912155424-048179bee72e h1:MDgZ7KPzwKRSzwSHqiifOXdyavuapggpXfYR7bPqW7c=
github.com/augustbleeds/starknet.go v0.4.2-0.20230912155424-048179bee72e/go.mod h1:jYturIQWt6EvmiALjvNgHNzNtACuS+Rb7MngXLaPHeI=
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
github.com/avast/retry-go/v4 v4.3.4 h1:pHLkL7jvCvP317I8Ge+Km2Yhntv3SdkJm7uekkqbKhM=
Expand Down
4 changes: 3 additions & 1 deletion monitoring/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/NethermindEth/juno v0.3.1
github.com/NethermindEth/starknet.go v0.4.2-0.20230804102546-d30334cf21f3
github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3
github.com/prometheus/client_golang v1.15.0
github.com/smartcontractkit/chainlink-relay v0.1.7-0.20230808141159-4e20b0757f3a
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.0-20230508053614-9f2fd5fd4ff1
Expand Down Expand Up @@ -86,6 +86,8 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/NethermindEth/starknet.go => github.com/augustbleeds/starknet.go v0.4.2-0.20230912155424-048179bee72e

replace (
// Fix go mod tidy issue for ambiguous imports from go-ethereum
// See https://github.com/ugorji/go/issues/279
Expand Down
4 changes: 2 additions & 2 deletions monitoring/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8=
github.com/NethermindEth/juno v0.3.1 h1:AW72LiAm9gqUeCVJWvepnZcTnpU4Vkl0KzPMxS+42FA=
github.com/NethermindEth/juno v0.3.1/go.mod h1:SGbTpgGaCsxhFsKOid7Ylnz//WZ8swtILk+NbHGsk/Q=
github.com/NethermindEth/starknet.go v0.4.2-0.20230804102546-d30334cf21f3 h1:hjY72ob267YRlORRxi0kO85h2emR6EYn0BlUpM0+avY=
github.com/NethermindEth/starknet.go v0.4.2-0.20230804102546-d30334cf21f3/go.mod h1:4fchLnLzJuwl1bnNUR+iBjKYN11afzJCdBcGZKIuFeU=
github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o=
github.com/actgardner/gogen-avro/v10 v10.1.0/go.mod h1:o+ybmVjEa27AAr35FRqU98DJu1fXES56uXniYFv4yDA=
github.com/actgardner/gogen-avro/v10 v10.2.1/go.mod h1:QUhjeHPchheYmMDni/Nx7VB0RsT/ee8YIgGY/xpEQgQ=
github.com/actgardner/gogen-avro/v9 v9.1.0/go.mod h1:nyTj6wPqDJoxM3qdnjcLv+EnMDSDFqE0qDpva2QRmKc=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/augustbleeds/starknet.go v0.4.2-0.20230912155424-048179bee72e h1:MDgZ7KPzwKRSzwSHqiifOXdyavuapggpXfYR7bPqW7c=
github.com/augustbleeds/starknet.go v0.4.2-0.20230912155424-048179bee72e/go.mod h1:jYturIQWt6EvmiALjvNgHNzNtACuS+Rb7MngXLaPHeI=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down
2 changes: 2 additions & 0 deletions ops/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ require (
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/NethermindEth/starknet.go => github.com/augustbleeds/starknet.go v0.4.2-0.20230912155424-048179bee72e

replace (
// Fix go mod tidy issue for ambiguous imports from go-ethereum
// See https://github.com/ugorji/go/issues/279
Expand Down
4 changes: 2 additions & 2 deletions ops/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/NethermindEth/juno v0.3.1 h1:AW72LiAm9gqUeCVJWvepnZcTnpU4Vkl0KzPMxS+42FA=
github.com/NethermindEth/juno v0.3.1/go.mod h1:SGbTpgGaCsxhFsKOid7Ylnz//WZ8swtILk+NbHGsk/Q=
github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3 h1:SAE7oDXo82lT+arBtg6sozPMt9bNSkXY1A2TxlCGRw4=
github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3/go.mod h1:4fchLnLzJuwl1bnNUR+iBjKYN11afzJCdBcGZKIuFeU=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/VictoriaMetrics/fastcache v1.10.0 h1:5hDJnLsKLpnUEToub7ETuRu8RCkb40woBZAUiKonXzY=
github.com/VictoriaMetrics/fastcache v1.10.0/go.mod h1:tjiYeEfYXCqacuvYw/7UoDIeJaNxq6132xHICNP77w8=
Expand All @@ -56,6 +54,8 @@ github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8V
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/augustbleeds/starknet.go v0.4.2-0.20230912155424-048179bee72e h1:MDgZ7KPzwKRSzwSHqiifOXdyavuapggpXfYR7bPqW7c=
github.com/augustbleeds/starknet.go v0.4.2-0.20230912155424-048179bee72e/go.mod h1:jYturIQWt6EvmiALjvNgHNzNtACuS+Rb7MngXLaPHeI=
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
github.com/aws/constructs-go/constructs/v10 v10.1.255 h1:5hARfEmhBqHSTQf/C3QLA3sWOxO2Dfja0iA1W7ZcI7g=
Expand Down
2 changes: 2 additions & 0 deletions relayer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/NethermindEth/starknet.go => github.com/augustbleeds/starknet.go v0.4.2-0.20230912155424-048179bee72e

replace (
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

Expand Down
4 changes: 2 additions & 2 deletions relayer/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8=
github.com/NethermindEth/juno v0.3.1 h1:AW72LiAm9gqUeCVJWvepnZcTnpU4Vkl0KzPMxS+42FA=
github.com/NethermindEth/juno v0.3.1/go.mod h1:SGbTpgGaCsxhFsKOid7Ylnz//WZ8swtILk+NbHGsk/Q=
github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3 h1:SAE7oDXo82lT+arBtg6sozPMt9bNSkXY1A2TxlCGRw4=
github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3/go.mod h1:4fchLnLzJuwl1bnNUR+iBjKYN11afzJCdBcGZKIuFeU=
github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o=
github.com/augustbleeds/starknet.go v0.4.2-0.20230912155424-048179bee72e h1:MDgZ7KPzwKRSzwSHqiifOXdyavuapggpXfYR7bPqW7c=
github.com/augustbleeds/starknet.go v0.4.2-0.20230912155424-048179bee72e/go.mod h1:jYturIQWt6EvmiALjvNgHNzNtACuS+Rb7MngXLaPHeI=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down
13 changes: 6 additions & 7 deletions relayer/pkg/chainlink/txm/txm.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

"github.com/NethermindEth/juno/core/felt"
"github.com/NethermindEth/starknet.go"
starknetgo "github.com/NethermindEth/starknet.go"
starknetrpc "github.com/NethermindEth/starknet.go/rpc"
starknettypes "github.com/NethermindEth/starknet.go/types"
starknetutils "github.com/NethermindEth/starknet.go/utils"
Expand Down Expand Up @@ -218,6 +218,7 @@ func (txm *starktxm) confirmLoop() {
txm.lggr.Errorw("invalid felt value", "hash", hash)
continue
}
// according to v0.4 rpc changes, if no error, then tx is confirmed
response, err := client.Provider.TransactionReceipt(ctx, f)
if err != nil {
txm.lggr.Errorw("failed to fetch transaction status", "hash", hash, "error", err)
Expand All @@ -229,13 +230,11 @@ func (txm *starktxm) confirmLoop() {
continue
}

status := receipt.Status
status := receipt.FinalityStatus

if status == starknetrpc.TransactionAcceptedOnL1 || status == starknetrpc.TransactionAcceptedOnL2 || status == starknetrpc.TransactionRejected {
txm.lggr.Debugw(fmt.Sprintf("tx confirmed: %s", status), "hash", hash, "status", status)
if err := txm.txStore.Confirm(addr, hash); err != nil {
txm.lggr.Errorw("failed to confirm tx in TxStore", "hash", hash, "sender", addr, "error", err)
}
txm.lggr.Debugw(fmt.Sprintf("tx confirmed: %s", status), "hash", hash, "finality status", status)
if err := txm.txStore.Confirm(addr, hash); err != nil {
txm.lggr.Errorw("failed to confirm tx in TxStore", "hash", hash, "sender", addr, "error", err)
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion relayer/pkg/chainlink/txm/txm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"
"time"

"github.com/NethermindEth/starknet.go"
starknetgo "github.com/NethermindEth/starknet.go"
starknetgw "github.com/NethermindEth/starknet.go/gateway"
"github.com/NethermindEth/starknet.go/test"
starknettypes "github.com/NethermindEth/starknet.go/types"
Expand Down Expand Up @@ -163,3 +163,12 @@ func (lk *LooppKeystore) Sign(ctx context.Context, id string, hash []byte) ([]by
func (lk *LooppKeystore) Accounts(ctx context.Context) ([]string, error) {
return nil, fmt.Errorf("unimplemented")
}

/*
*
* Todo: once signatures are fixed on starknet.go, add a test to verify nonce behavior for following scenarios
*
* Test cases:
* 1. tx is accepted but it fails during run => reverted and increments nonce
* 2. tx is accepted and succeeds during run => succeeded and increments nonce
*/

0 comments on commit d91d1b8

Please sign in to comment.