From 9cac594c3edcab405f05c5b73dc204d7223f8892 Mon Sep 17 00:00:00 2001 From: Silas Lenihan Date: Wed, 11 Dec 2024 16:58:25 -0500 Subject: [PATCH] merged with develop --- gotest.log | 92 +++++++++++++++++++++++++++++++++ pkg/solana/txm/txm.go | 22 ++++---- pkg/solana/txm/txm_unit_test.go | 17 +++--- pkg/solana/utils/utils.go | 2 + 4 files changed, 114 insertions(+), 19 deletions(-) create mode 100644 gotest.log diff --git a/gotest.log b/gotest.log new file mode 100644 index 000000000..41b099eb4 --- /dev/null +++ b/gotest.log @@ -0,0 +1,92 @@ +📦 github.com/smartcontractkit/chainlink-solana/pkg/solana/chainwriter +exit status 1 + ❌ TestLookupTables (30.04s) + ports.go:37: found open port: 41544 + ports.go:37: found open port: 39418 + utils.go:215: API server not ready yet (attempt 1) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 2) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 3) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 4) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 5) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 6) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 7) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 8) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 9) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 10) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 11) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 12) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 13) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 14) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 15) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 16) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 17) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 18) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 19) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 20) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 21) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 22) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 23) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 24) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 25) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 26) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 27) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 28) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 29) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: API server not ready yet (attempt 30) + utils.go:215: Error from API server: rpc call getHealth() on http://127.0.0.1:41544: Post "http://127.0.0.1:41544": dial tcp 127.0.0.1:41544: connect: connection refused + utils.go:215: Cmd output: Error: program file does not exist: /Users/silaslenihan/Desktop/repos/chainlink-solana/contracts/target/deploy/contract-reader-interface.so + + Cmd error: + utils.go:215: + Error Trace: /Users/silaslenihan/Desktop/repos/chainlink-solana/pkg/solana/client/test_helpers.go:78 + /Users/silaslenihan/Desktop/repos/chainlink-solana/pkg/solana/utils/utils.go:215 + /Users/silaslenihan/Desktop/repos/chainlink-solana/pkg/solana/chainwriter/lookups_test.go:279 + Error: Should be true + Test: TestLookupTables + test_helpers.go:55: + Error Trace: /Users/silaslenihan/Desktop/repos/chainlink-solana/pkg/solana/client/test_helpers.go:55 + /Users/silaslenihan/.asdf/installs/golang/1.23.3/go/src/testing/testing.go:1176 + /Users/silaslenihan/.asdf/installs/golang/1.23.3/go/src/testing/testing.go:1354 + /Users/silaslenihan/.asdf/installs/golang/1.23.3/go/src/testing/testing.go:1684 + /Users/silaslenihan/.asdf/installs/golang/1.23.3/go/src/runtime/panic.go:629 + /Users/silaslenihan/.asdf/installs/golang/1.23.3/go/src/testing/testing.go:1006 + /Users/silaslenihan/Desktop/repos/chainlink-solana/pkg/solana/client/test_helpers.go:78 + /Users/silaslenihan/Desktop/repos/chainlink-solana/pkg/solana/utils/utils.go:215 + /Users/silaslenihan/Desktop/repos/chainlink-solana/pkg/solana/chainwriter/lookups_test.go:279 + Error: "exit status 1" does not contain "signal: killed" + Test: TestLookupTables + Messages: exit status 1 + test_helpers.go:56: solana-test-validator + stdout: Error: program file does not exist: /Users/silaslenihan/Desktop/repos/chainlink-solana/contracts/target/deploy/contract-reader-interface.so + + stderr: + diff --git a/pkg/solana/txm/txm.go b/pkg/solana/txm/txm.go index f5d3d8705..0688b25fb 100644 --- a/pkg/solana/txm/txm.go +++ b/pkg/solana/txm/txm.go @@ -740,7 +740,7 @@ func (txm *Txm) simulateTx(ctx context.Context, tx *solanaGo.Transaction) (res * } // processError parses and handles relevant errors found in simulation results -func (txm *Txm) ProcessError(sig solanaGo.Signature, resErr interface{}, simulation bool) (txState TxState, errType TxErrType) { +func (txm *Txm) ProcessError(sig solanaGo.Signature, resErr interface{}, simulation bool) (txState txmutils.TxState, errType TxErrType) { if resErr != nil { // handle various errors // https://github.com/solana-labs/solana/blob/master/sdk/src/transaction/error.rs @@ -766,7 +766,7 @@ func (txm *Txm) ProcessError(sig solanaGo.Signature, resErr interface{}, simulat if simulation { return txState, NoFailure } - return Errored, errType + return txmutils.Errored, errType // transaction is already processed in the chain case strings.Contains(errStr, "AlreadyProcessed"): txm.lggr.Debugw("AlreadyProcessed", logValues...) @@ -775,39 +775,39 @@ func (txm *Txm) ProcessError(sig solanaGo.Signature, resErr interface{}, simulat if simulation { return txState, NoFailure } - return Errored, errType + return txmutils.Errored, errType // transaction will encounter execution error/revert case strings.Contains(errStr, "InstructionError"): txm.lggr.Debugw("InstructionError", logValues...) - return FatallyErrored, errType + return txmutils.FatallyErrored, errType // transaction contains an invalid account reference case strings.Contains(errStr, "InvalidAccountIndex"): txm.lggr.Debugw("InvalidAccountIndex", logValues...) - return FatallyErrored, errType + return txmutils.FatallyErrored, errType // transaction loads a writable account that cannot be written case strings.Contains(errStr, "InvalidWritableAccount"): txm.lggr.Debugw("InvalidWritableAccount", logValues...) - return FatallyErrored, errType + return txmutils.FatallyErrored, errType // address lookup table not found case strings.Contains(errStr, "AddressLookupTableNotFound"): txm.lggr.Debugw("AddressLookupTableNotFound", logValues...) - return FatallyErrored, errType + return txmutils.FatallyErrored, errType // attempted to lookup addresses from an invalid account case strings.Contains(errStr, "InvalidAddressLookupTableData"): txm.lggr.Debugw("InvalidAddressLookupTableData", logValues...) - return FatallyErrored, errType + return txmutils.FatallyErrored, errType // address table lookup uses an invalid index case strings.Contains(errStr, "InvalidAddressLookupTableIndex"): txm.lggr.Debugw("InvalidAddressLookupTableIndex", logValues...) - return FatallyErrored, errType + return txmutils.FatallyErrored, errType // attempt to debit an account but found no record of a prior credit. case strings.Contains(errStr, "AccountNotFound"): txm.lggr.Debugw("AccountNotFound", logValues...) - return FatallyErrored, errType + return txmutils.FatallyErrored, errType // attempt to load a program that does not exist case strings.Contains(errStr, "ProgramAccountNotFound"): txm.lggr.Debugw("ProgramAccountNotFound", logValues...) - return FatallyErrored, errType + return txmutils.FatallyErrored, errType // unrecognized errors (indicates more concerning failures) default: // if simulating, return TxFailSimOther if error unknown diff --git a/pkg/solana/txm/txm_unit_test.go b/pkg/solana/txm/txm_unit_test.go index 7dfec6c57..e8dfcb584 100644 --- a/pkg/solana/txm/txm_unit_test.go +++ b/pkg/solana/txm/txm_unit_test.go @@ -18,6 +18,7 @@ import ( "github.com/smartcontractkit/chainlink-solana/pkg/solana/fees" solanatxm "github.com/smartcontractkit/chainlink-solana/pkg/solana/txm" keyMocks "github.com/smartcontractkit/chainlink-solana/pkg/solana/txm/mocks" + txmutils "github.com/smartcontractkit/chainlink-solana/pkg/solana/txm/utils" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/utils" @@ -174,12 +175,12 @@ func TestTxm_ProcessError(t *testing.T) { // returns no failure if BlockhashNotFound encountered during simulation txState, errType := txm.ProcessError(solana.Signature{}, err, true) require.Equal(t, solanatxm.NoFailure, errType) - require.Equal(t, solanatxm.NotFound, txState) // default enum value + require.Equal(t, txmutils.NotFound, txState) // default enum value // returns error if BlockhashNotFound encountered during normal processing txState, errType = txm.ProcessError(solana.Signature{}, err, false) require.Equal(t, solanatxm.TxFailRevert, errType) - require.Equal(t, solanatxm.Errored, txState) // default enum value + require.Equal(t, txmutils.Errored, txState) // default enum value }) t.Run("process AlreadyProcessed error", func(t *testing.T) { t.Parallel() @@ -191,12 +192,12 @@ func TestTxm_ProcessError(t *testing.T) { // returns no failure if AlreadyProcessed encountered during simulation txState, errType := txm.ProcessError(solana.Signature{}, err, true) require.Equal(t, solanatxm.NoFailure, errType) - require.Equal(t, solanatxm.NotFound, txState) // default enum value + require.Equal(t, txmutils.NotFound, txState) // default enum value // returns error if AlreadyProcessed encountered during normal processing txState, errType = txm.ProcessError(solana.Signature{}, err, false) require.Equal(t, solanatxm.TxFailRevert, errType) - require.Equal(t, solanatxm.Errored, txState) // default enum value + require.Equal(t, txmutils.Errored, txState) // default enum value }) t.Run("process fatal error cases", func(t *testing.T) { t.Parallel() @@ -212,12 +213,12 @@ func TestTxm_ProcessError(t *testing.T) { // returns fatal error if InstructionError encountered during simulation txState, errType := txm.ProcessError(solana.Signature{}, err, true) require.Equal(t, solanatxm.TxFailSimRevert, errType) - require.Equal(t, solanatxm.FatallyErrored, txState) // default enum value + require.Equal(t, txmutils.FatallyErrored, txState) // default enum value // returns fatal error if InstructionError encountered during normal processing txState, errType = txm.ProcessError(solana.Signature{}, err, false) require.Equal(t, solanatxm.TxFailRevert, errType) - require.Equal(t, solanatxm.FatallyErrored, txState) // default enum value + require.Equal(t, txmutils.FatallyErrored, txState) // default enum value }) } }) @@ -231,12 +232,12 @@ func TestTxm_ProcessError(t *testing.T) { // returns fatal error if InstructionError encountered during simulation txState, errType := txm.ProcessError(solana.Signature{}, err, true) require.Equal(t, solanatxm.TxFailSimOther, errType) - require.Equal(t, solanatxm.Errored, txState) // default enum value + require.Equal(t, txmutils.Errored, txState) // default enum value // returns fatal error if InstructionError encountered during normal processing txState, errType = txm.ProcessError(solana.Signature{}, err, false) require.Equal(t, solanatxm.TxFailRevert, errType) - require.Equal(t, solanatxm.Errored, txState) // default enum value + require.Equal(t, txmutils.Errored, txState) // default enum value }) } diff --git a/pkg/solana/utils/utils.go b/pkg/solana/utils/utils.go index 3353d40b3..974ca6813 100644 --- a/pkg/solana/utils/utils.go +++ b/pkg/solana/utils/utils.go @@ -7,6 +7,7 @@ import ( "os" "path/filepath" "runtime" + "strings" "testing" "time" @@ -210,6 +211,7 @@ func SetupTestValidatorWithAnchorPrograms(t *testing.T, pathToAnchorConfig strin flags := []string{} for k, v := range anchorData.Programs.Localnet { + k = strings.Replace(k, "-", "_", -1) flags = append(flags, "--upgradeable-program", v, filepath.Join(ContractsDir, k+".so"), upgradeAuthority) } url, _ := client.SetupLocalSolNodeWithFlags(t, flags...)