From d91d1b820e36d57649c7d4b97bac32fc997d9313 Mon Sep 17 00:00:00 2001 From: Augustus Chang Date: Mon, 18 Sep 2023 12:18:11 +0800 Subject: [PATCH] confirm tx once get receipt does not error --- integration-tests/go.mod | 2 ++ integration-tests/go.sum | 4 ++-- monitoring/go.mod | 4 +++- monitoring/go.sum | 4 ++-- ops/go.mod | 2 ++ ops/go.sum | 4 ++-- relayer/go.mod | 2 ++ relayer/go.sum | 4 ++-- relayer/pkg/chainlink/txm/txm.go | 13 ++++++------- relayer/pkg/chainlink/txm/txm_test.go | 11 ++++++++++- 10 files changed, 33 insertions(+), 17 deletions(-) diff --git a/integration-tests/go.mod b/integration-tests/go.mod index c46c63bd7..846d94a66 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -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 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 453ac0854..6908b7cd7 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -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= @@ -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= diff --git a/monitoring/go.mod b/monitoring/go.mod index 9735be612..523723854 100644 --- a/monitoring/go.mod +++ b/monitoring/go.mod @@ -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 @@ -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 diff --git a/monitoring/go.sum b/monitoring/go.sum index ecfa59ecf..07d895eff 100644 --- a/monitoring/go.sum +++ b/monitoring/go.sum @@ -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= diff --git a/ops/go.mod b/ops/go.mod index e742433c8..b6d6f09c8 100644 --- a/ops/go.mod +++ b/ops/go.mod @@ -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 diff --git a/ops/go.sum b/ops/go.sum index 1a2d852b2..eed6befda 100644 --- a/ops/go.sum +++ b/ops/go.sum @@ -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= @@ -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= diff --git a/relayer/go.mod b/relayer/go.mod index 7e4d1ca12..1d9f8e27c 100644 --- a/relayer/go.mod +++ b/relayer/go.mod @@ -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 diff --git a/relayer/go.sum b/relayer/go.sum index ff10c9d3e..e4600d58f 100644 --- a/relayer/go.sum +++ b/relayer/go.sum @@ -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= diff --git a/relayer/pkg/chainlink/txm/txm.go b/relayer/pkg/chainlink/txm/txm.go index a4172b5f1..a19da2297 100644 --- a/relayer/pkg/chainlink/txm/txm.go +++ b/relayer/pkg/chainlink/txm/txm.go @@ -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" @@ -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) @@ -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) } } } diff --git a/relayer/pkg/chainlink/txm/txm_test.go b/relayer/pkg/chainlink/txm/txm_test.go index a0788c4ab..67f8975ce 100644 --- a/relayer/pkg/chainlink/txm/txm_test.go +++ b/relayer/pkg/chainlink/txm/txm_test.go @@ -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" @@ -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 + */