Skip to content

Commit

Permalink
Merge branch 'stellar:master' into 4907/limit-flag-claimable-balance
Browse files Browse the repository at this point in the history
  • Loading branch information
urvisavla authored Sep 14, 2023
2 parents f78515f + 86d1e0d commit c4890ec
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 34 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/horizon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:
env:
HORIZON_INTEGRATION_TESTS_ENABLED: true
HORIZON_INTEGRATION_TESTS_CORE_MAX_SUPPORTED_PROTOCOL: ${{ matrix.protocol-version }}
PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 19.13.1-1469.76fed6ead.focal~soroban
PROTOCOL_20_CORE_DOCKER_IMG: stellar/unsafe-stellar-core-next:19.13.1-1469.76fed6ead.focal-soroban
PROTOCOL_20_SOROBAN_RPC_DOCKER_IMG: stellar/soroban-rpc:0.9.4-fix-fees-31
PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 19.13.1-1481.3acf6dd26.focal
PROTOCOL_20_CORE_DOCKER_IMG: stellar/stellar-core:19.13.1-1481.3acf6dd26.focal
PROTOCOL_20_SOROBAN_RPC_DOCKER_IMG: stellar/soroban-rpc:20.0.0-rc1-35
PROTOCOL_19_CORE_DEBIAN_PKG_VERSION: 19.12.0-1378.2109a168a.focal
PROTOCOL_19_CORE_DOCKER_IMG: stellar/stellar-core:19.12.0-1378.2109a168a.focal
PGHOST: localhost
Expand Down
12 changes: 7 additions & 5 deletions exp/services/recoverysigner/internal/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,14 @@ func getHandlerDeps(opts Options) (handlerDeps, error) {
}

allowedSourceAccounts := []*keypair.FromAddress{}
for _, addressStr := range strings.Split(opts.AllowedSourceAccounts, ",") {
accountAddress, err := keypair.ParseAddress(addressStr)
if err != nil {
return handlerDeps{}, errors.Wrap(err, "parsing allowed source accounts")
if opts.AllowedSourceAccounts != "" {
for _, addressStr := range strings.Split(opts.AllowedSourceAccounts, ",") {
accountAddress, err := keypair.ParseAddress(addressStr)
if err != nil {
return handlerDeps{}, errors.Wrap(err, "parsing allowed source accounts")
}
allowedSourceAccounts = append(allowedSourceAccounts, accountAddress)
}
allowedSourceAccounts = append(allowedSourceAccounts, accountAddress)
}

deps := handlerDeps{
Expand Down
35 changes: 35 additions & 0 deletions exp/services/recoverysigner/internal/serve/serve_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package serve

import (
"encoding/json"
"testing"

"github.com/stellar/go/keypair"
supportlog "github.com/stellar/go/support/log"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/square/go-jose.v2"
)

func TestGetHandlerDeps(t *testing.T) {
signingKey := "SBWLXUTJR2CGVPGCZDIGGLQDPX7ZGGBHBFXBJ555MNIQ2PZCCLM643Z3"
signingKeyFull := keypair.MustParseFull(signingKey)

opts := Options{
Logger: supportlog.DefaultLogger,
SigningKeys: signingKey,
SEP10JWKS: `{"keys":[{"kty":"EC","crv":"P-256","alg":"ES256","x":"i8chX_7Slm4VQ_Y6XBWVBnxIO5-XSWH1GJsXWNkal3E","y":"G22r0OgrcQnkfCAqsS6wvtHgR0SbfvXNJy6-jJfvc94"}]}`,
}

sep10JWKS := jose.JSONWebKeySet{}
err := json.Unmarshal([]byte(opts.SEP10JWKS), &sep10JWKS)
require.NoError(t, err)

got, err := getHandlerDeps(opts)
assert.NoError(t, err)

assert.Equal(t, []*keypair.Full{signingKeyFull}, got.SigningKeys)
assert.Equal(t, []*keypair.FromAddress{signingKeyFull.FromAddress()}, got.SigningAddresses)
assert.Equal(t, sep10JWKS, got.SEP10JWKS)
assert.Equal(t, []*keypair.FromAddress{}, got.AllowedSourceAccounts)
}
3 changes: 3 additions & 0 deletions ingest/ledgerbackend/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ type captiveCoreTomlValues struct {
UnsafeQuorum bool `toml:"UNSAFE_QUORUM,omitempty"`
RunStandalone bool `toml:"RUN_STANDALONE,omitempty"`
ArtificiallyAccelerateTimeForTesting bool `toml:"ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING,omitempty"`
PreferredPeers []string `toml:"PREFERRED_PEERS,omitempty"`
PreferredPeerKeys []string `toml:"PREFERRED_PEER_KEYS,omitempty"`
PreferredPeersOnly bool `toml:"PREFERRED_PEERS_ONLY,omitempty"`
HomeDomains []HomeDomain `toml:"HOME_DOMAINS,omitempty"`
Validators []Validator `toml:"VALIDATORS,omitempty"`
HistoryEntries map[string]History `toml:"-"`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING=true

[[VALIDATORS]]
NAME="local_core"
HOME_DOMAIN="core.local"
# From "SACJC372QBSSKJYTV5A7LWT4NXWHTQO6GHG4QDAVC2XDPX6CNNXFZ4JK"
PUBLIC_KEY="GD5KD2KEZJIGTC63IGW6UMUSMVUVG5IHG64HUTFWCHVZH2N2IBOQN7PS"
ADDRESS="localhost"
QUALITY="MEDIUM"
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING=true
TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE=true

[[VALIDATORS]]
NAME="local_core"
Expand Down
4 changes: 2 additions & 2 deletions services/horizon/internal/integration/contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ codegen-units = 1
lto = true

[workspace.dependencies.soroban-sdk]
version = "0.9.1"
version = "20.0.0-rc1"
git = "https://github.com/stellar/rs-soroban-sdk"
rev = "ee44e420b9badeb16cab870ed25bef397c058f64"
rev = "f743d6f9e49caa08924318907cd0588b60d7f187"
13 changes: 11 additions & 2 deletions services/horizon/internal/integration/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/stellar/go/clients/horizonclient"
"github.com/stellar/go/historyarchive"
"github.com/stellar/go/ingest/ledgerbackend"
"github.com/stellar/go/keypair"
horizoncmd "github.com/stellar/go/services/horizon/cmd"
horizon "github.com/stellar/go/services/horizon/internal"
Expand Down Expand Up @@ -526,7 +527,7 @@ func TestReingestDB(t *testing.T) {

horizonConfig.CaptiveCoreConfigPath = filepath.Join(
filepath.Dir(horizonConfig.CaptiveCoreConfigPath),
"captive-core-reingest-range-integration-tests.cfg",
getCoreConfigFile(itest),
)

horizoncmd.RootCmd.SetArgs(command(t, horizonConfig, "db",
Expand All @@ -541,6 +542,14 @@ func TestReingestDB(t *testing.T) {
tt.NoError(horizoncmd.RootCmd.Execute(), "Repeat the same reingest range against db, should not have errors.")
}

func getCoreConfigFile(itest *integration.Test) string {
coreConfigFile := "captive-core-reingest-range-classic-integration-tests.cfg"
if itest.Config().ProtocolVersion >= ledgerbackend.MinimalSorobanProtocolSupport {
coreConfigFile = "captive-core-reingest-range-integration-tests.cfg"
}
return coreConfigFile
}

func command(t *testing.T, horizonConfig horizon.Config, args ...string) []string {
return append([]string{
"--stellar-core-url",
Expand Down Expand Up @@ -679,7 +688,7 @@ func TestFillGaps(t *testing.T) {

horizonConfig.CaptiveCoreConfigPath = filepath.Join(
filepath.Dir(horizonConfig.CaptiveCoreConfigPath),
"captive-core-reingest-range-integration-tests.cfg",
getCoreConfigFile(itest),
)
horizoncmd.RootCmd.SetArgs(command(t, horizonConfig, "db", "fill-gaps", "--parallel-workers=1"))
tt.NoError(horizoncmd.RootCmd.Execute())
Expand Down
9 changes: 5 additions & 4 deletions services/horizon/internal/integration/sac_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,10 @@ func TestContractBurnFromAccount(t *testing.T) {
)

fx := getTxEffects(itest, burnTx, asset)
assert.Len(t, fx, 1)
burnEffect := assertContainsEffect(t, fx,
effects.EffectAccountDebited)[0].(effects.AccountDebited)
require.Len(t, fx, 1)
assetEffects := assertContainsEffect(t, fx, effects.EffectAccountDebited)
require.GreaterOrEqual(t, len(assetEffects), 1)
burnEffect := assetEffects[0].(effects.AccountDebited)

assert.Equal(t, issuer, burnEffect.Asset.Issuer)
assert.Equal(t, code, burnEffect.Asset.Code)
Expand Down Expand Up @@ -833,7 +834,7 @@ func assertEventPayments(itest *integration.Test, txHash string, asset xdr.Asset

invokeHostFn := ops.Embedded.Records[0].(operations.InvokeHostFunction)
assert.Equal(itest.CurrentTest(), invokeHostFn.Function, "HostFunctionTypeHostFunctionTypeInvokeContract")
assert.Equal(itest.CurrentTest(), 1, len(invokeHostFn.AssetBalanceChanges))
require.Equal(itest.CurrentTest(), 1, len(invokeHostFn.AssetBalanceChanges))
assetBalanceChange := invokeHostFn.AssetBalanceChanges[0]
assert.Equal(itest.CurrentTest(), assetBalanceChange.Amount, amount)
assert.Equal(itest.CurrentTest(), assetBalanceChange.From, from)
Expand Down
5 changes: 5 additions & 0 deletions services/horizon/internal/test/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,11 @@ func (i *Test) WaitForHorizon() {
i.t.Fatal("Horizon not ingesting...")
}

// Config returns the testing configuration for the current integration test run.
func (i *Test) Config() Config {
return i.config
}

// CoreClient returns a stellar core client connected to the Stellar Core instance.
func (i *Test) CoreClient() *stellarcore.Client {
return i.coreClient
Expand Down
4 changes: 2 additions & 2 deletions support/contractevents/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func parseCanonicalAsset(assetStr string) (*xdr.Asset, error) {
Ed25519: issuerKey.Ed25519,
})

if len(rawCode) == 4 {
if len(rawCode) <= 4 {
code := [4]byte{}
copy(code[:], rawCode[:])

Expand All @@ -182,7 +182,7 @@ func parseCanonicalAsset(assetStr string) (*xdr.Asset, error) {
AssetCode: xdr.AssetCode4(code),
Issuer: accountId,
}
} else if len(rawCode) == 12 {
} else if len(rawCode) <= 12 {
code := [12]byte{}
copy(code[:], rawCode[:])

Expand Down
18 changes: 2 additions & 16 deletions support/contractevents/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,8 @@ func makeAsset(asset xdr.Asset) xdr.ScVal {
panic(err)
}

case xdr.AssetTypeAssetTypeCreditAlphanum4:
_, err := xdr.Marshal(buffer, asset.AlphaNum4.AssetCode)
if err != nil {
panic(err)
}
buffer.WriteString(":")
buffer.WriteString(asset.AlphaNum4.Issuer.Address())

case xdr.AssetTypeAssetTypeCreditAlphanum12:
_, err := xdr.Marshal(buffer, asset.AlphaNum12.AssetCode)
if err != nil {
panic(err)
}
buffer.WriteString(":")
buffer.WriteString(asset.AlphaNum12.Issuer.Address())

case xdr.AssetTypeAssetTypeCreditAlphanum4, xdr.AssetTypeAssetTypeCreditAlphanum12:
buffer.WriteString(asset.GetCode() + ":" + asset.GetIssuer())
default:
panic("unexpected asset type")
}
Expand Down

0 comments on commit c4890ec

Please sign in to comment.