diff --git a/go.mod b/go.mod index b6b1e5485e..fc2df5cfcc 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,6 @@ require ( github.com/mattn/go-sqlite3 v1.14.10 github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/microcosm-cc/bluemonday v1.0.16 - github.com/miracl/conflate v1.2.1 // indirect github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect github.com/onsi/ginkgo v1.16.1 // indirect github.com/onsi/gomega v1.11.0 // indirect diff --git a/go.sum b/go.sum index 27b357f192..20377f06dc 100644 --- a/go.sum +++ b/go.sum @@ -810,8 +810,6 @@ github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3N github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= -github.com/miracl/conflate v1.2.1 h1:QlB+Hjh8vnPIjimCK2VKEvtLVxVGIVxNQ4K95JRpi90= -github.com/miracl/conflate v1.2.1/go.mod h1:F85f+vrE7SwfRoL31EpLZFa1sub0SDxzcwxDBxFvy7k= github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible/go.mod h1:8AuVvqP/mXw1px98n46wfvcGfQ4ci2FwoAjKYxuo3Z4= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= @@ -1085,13 +1083,8 @@ github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= -github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= -github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= @@ -1240,7 +1233,6 @@ golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191125084936-ffdde1057850/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= diff --git a/internal/blockchain/ethereum/config.go b/internal/blockchain/ethereum/config.go index f536862175..17f62ade77 100644 --- a/internal/blockchain/ethereum/config.go +++ b/internal/blockchain/ethereum/config.go @@ -37,7 +37,7 @@ const ( const ( // EthconnectConfigKey is a sub-key in the config to contain all the ethconnect specific config, EthconnectConfigKey = "ethconnect" - // EthconnectConfigInstancePath is the /contracts/0x12345 or /instances/0x12345 path of the REST API exposed by ethconnect for the contract + // EthconnectConfigInstancePath is the ethereum address of the contract EthconnectConfigInstancePath = "instance" // EthconnectConfigTopic is the websocket listen topic that the node should register on, which is important if there are multiple // nodes using a single ethconnect diff --git a/internal/config/config.go b/internal/config/config.go index adfd598a78..3a38724495 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -343,7 +343,7 @@ func Reset() { viper.SetDefault(string(CorsAllowedOrigins), []string{"*"}) viper.SetDefault(string(CorsEnabled), true) viper.SetDefault(string(CorsMaxAge), 600) - viper.SetDefault(string(DataexchangeType), "https") + viper.SetDefault(string(DataexchangeType), "ffdx") viper.SetDefault(string(DebugPort), -1) viper.SetDefault(string(DownloadWorkerCount), 10) viper.SetDefault(string(DownloadRetryMaxAttempts), 100) diff --git a/internal/dataexchange/dxfactory/factory.go b/internal/dataexchange/dxfactory/factory.go index 8914505066..2592bfdf46 100644 --- a/internal/dataexchange/dxfactory/factory.go +++ b/internal/dataexchange/dxfactory/factory.go @@ -25,19 +25,18 @@ import ( "github.com/hyperledger/firefly/pkg/dataexchange" ) +var ( + OldFFDXPluginName = "https" + NewFFDXPluginName = (*ffdx.FFDX)(nil).Name() +) + var pluginsByName = map[string]func() dataexchange.Plugin{ - (*ffdx.FFDX)(nil).Name(): func() dataexchange.Plugin { return &ffdx.FFDX{} }, + NewFFDXPluginName: func() dataexchange.Plugin { return &ffdx.FFDX{} }, } func InitPrefix(prefix config.Prefix) { for name, plugin := range pluginsByName { plugin().InitPrefix(prefix.SubPrefix(name)) - - // Migration path for old plugin name - // TODO: remove this - if name == "ffdx" { - plugin().InitPrefix(prefix.SubPrefix("https")) - } } } diff --git a/internal/orchestrator/orchestrator.go b/internal/orchestrator/orchestrator.go index 79ddc478cb..a6d1e89572 100644 --- a/internal/orchestrator/orchestrator.go +++ b/internal/orchestrator/orchestrator.go @@ -40,6 +40,7 @@ import ( "github.com/hyperledger/firefly/internal/networkmap" "github.com/hyperledger/firefly/internal/operations" "github.com/hyperledger/firefly/internal/privatemessaging" + "github.com/hyperledger/firefly/internal/restclient" "github.com/hyperledger/firefly/internal/shareddownload" "github.com/hyperledger/firefly/internal/sharedstorage/ssfactory" "github.com/hyperledger/firefly/internal/syncasync" @@ -337,12 +338,6 @@ func (or *orchestrator) initDataExchange(ctx context.Context) (err error) { dxPlugin := config.GetString(config.DataexchangeType) if or.dataexchange == nil { pluginName := dxPlugin - if pluginName == "https" { - // Migration path for old plugin name - // TODO: eventually make this fatal - log.L(ctx).Warnf("Your data exchange config uses the old plugin name 'https' - this plugin has been renamed to 'ffdx'") - pluginName = "ffdx" - } if or.dataexchange, err = dxfactory.GetPlugin(ctx, pluginName); err != nil { return err } @@ -361,7 +356,22 @@ func (or *orchestrator) initDataExchange(ctx context.Context) (err error) { nodeInfo[i] = node.Profile } - return or.dataexchange.Init(ctx, dataexchangeConfig.SubPrefix(dxPlugin), nodeInfo, &or.bc) + configPrefix := dataexchangeConfig.SubPrefix(dxPlugin) + // Migration for explicitly setting the old name .. + if dxPlugin == dxfactory.OldFFDXPluginName || + // .. or defaulting to the new name, but without setting the mandatory URL + (dxPlugin == dxfactory.NewFFDXPluginName && configPrefix.GetString(restclient.HTTPConfigURL) == "") { + // We need to initialize the migration prefix, and use that if it's set + migrationPrefix := dataexchangeConfig.SubPrefix(dxfactory.OldFFDXPluginName) + or.dataexchange.InitPrefix(migrationPrefix) + if migrationPrefix.GetString(restclient.HTTPConfigURL) != "" { + // TODO: eventually make this fatal + log.L(ctx).Warnf("The %s config key has been deprecated. Please use %s instead", config.OrgIdentityDeprecated, config.OrgKey) + configPrefix = migrationPrefix + } + } + + return or.dataexchange.Init(ctx, configPrefix, nodeInfo, &or.bc) } func (or *orchestrator) initPlugins(ctx context.Context) (err error) { diff --git a/internal/orchestrator/orchestrator_test.go b/internal/orchestrator/orchestrator_test.go index 4fb4e3c6cd..31e4d09708 100644 --- a/internal/orchestrator/orchestrator_test.go +++ b/internal/orchestrator/orchestrator_test.go @@ -47,6 +47,7 @@ import ( "github.com/hyperledger/firefly/mocks/txcommonmocks" "github.com/hyperledger/firefly/pkg/fftypes" "github.com/hyperledger/firefly/pkg/tokens" + "github.com/spf13/viper" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -301,6 +302,8 @@ func TestBadDataExchangePlugin(t *testing.T) { func TestBadDataExchangeInitFail(t *testing.T) { or := newTestOrchestrator() + dxfactory.InitPrefix(dataexchangeConfig) + viper.Set("dataexchange.ffdx.url", "https://test") or.mdi.On("GetConfigRecords", mock.Anything, mock.Anything, mock.Anything).Return([]*fftypes.ConfigRecord{}, nil, nil) or.mdi.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mbi.On("Init", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil) @@ -316,14 +319,14 @@ func TestBadDataExchangeInitFail(t *testing.T) { func TestDataExchangePluginOldName(t *testing.T) { or := newTestOrchestrator() dxfactory.InitPrefix(dataexchangeConfig) - config.Set(config.DataexchangeType, "https") - dataexchangeConfig.SubPrefix("https").Set(restclient.HTTPConfigURL, "http://test") + viper.Set("dataexchange.https.url", "https://test") or.dataexchange = nil or.mdi.On("GetConfigRecords", mock.Anything, mock.Anything, mock.Anything).Return([]*fftypes.ConfigRecord{}, nil, nil) or.mdi.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mbi.On("Init", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mii.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mps.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(nil) + or.mdx.On("InitPrefix", mock.Anything).Return() or.mdi.On("GetIdentities", mock.Anything, mock.Anything).Return([]*fftypes.Identity{}, nil, nil) or.mdi.On("GetNamespace", mock.Anything, mock.Anything).Return(nil, fmt.Errorf("pop")) ctx, cancelCtx := context.WithCancel(context.Background()) @@ -344,6 +347,7 @@ func TestBadTokensPlugin(t *testing.T) { or.mii.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mps.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mdi.On("GetIdentities", mock.Anything, mock.Anything).Return([]*fftypes.Identity{}, nil, nil) + or.mdx.On("InitPrefix", mock.Anything).Return() or.mdx.On("Init", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mdi.On("GetNamespace", mock.Anything, mock.Anything).Return(nil, nil) or.mdi.On("UpsertNamespace", mock.Anything, mock.Anything, true).Return(nil) @@ -366,6 +370,7 @@ func TestBadTokensPluginNoConnector(t *testing.T) { or.mbi.On("VerifyIdentitySyntax", mock.Anything, mock.Anything, mock.Anything).Return("", nil) or.mps.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mdi.On("GetIdentities", mock.Anything, mock.Anything).Return([]*fftypes.Identity{}, nil, nil) + or.mdx.On("InitPrefix", mock.Anything).Return() or.mdx.On("Init", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mdi.On("GetNamespace", mock.Anything, mock.Anything).Return(nil, nil) or.mdi.On("UpsertNamespace", mock.Anything, mock.Anything, true).Return(nil) @@ -387,6 +392,7 @@ func TestBadTokensPluginNoName(t *testing.T) { or.mii.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mps.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mdi.On("GetIdentities", mock.Anything, mock.Anything).Return([]*fftypes.Identity{}, nil, nil) + or.mdx.On("InitPrefix", mock.Anything).Return() or.mdx.On("Init", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mdi.On("GetNamespace", mock.Anything, mock.Anything).Return(nil, nil) or.mdi.On("UpsertNamespace", mock.Anything, mock.Anything, true).Return(nil) @@ -408,6 +414,7 @@ func TestBadTokensPluginInvalidName(t *testing.T) { or.mii.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mps.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mdi.On("GetIdentities", mock.Anything, mock.Anything).Return([]*fftypes.Identity{}, nil, nil) + or.mdx.On("InitPrefix", mock.Anything).Return() or.mdx.On("Init", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mdi.On("GetNamespace", mock.Anything, mock.Anything).Return(nil, nil) or.mdi.On("UpsertNamespace", mock.Anything, mock.Anything, true).Return(nil) @@ -430,6 +437,7 @@ func TestBadTokensPluginNoType(t *testing.T) { or.mbi.On("VerifyIdentitySyntax", mock.Anything, mock.Anything, mock.Anything).Return("", nil) or.mps.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mdi.On("GetIdentities", mock.Anything, mock.Anything).Return([]*fftypes.Identity{}, nil, nil) + or.mdx.On("InitPrefix", mock.Anything).Return() or.mdx.On("Init", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mdi.On("GetNamespace", mock.Anything, mock.Anything).Return(nil, nil) or.mdi.On("UpsertNamespace", mock.Anything, mock.Anything, true).Return(nil) @@ -453,6 +461,7 @@ func TestGoodTokensPlugin(t *testing.T) { or.mii.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mps.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mdi.On("GetIdentities", mock.Anything, mock.Anything).Return([]*fftypes.Identity{}, nil, nil) + or.mdx.On("InitPrefix", mock.Anything).Return() or.mdx.On("Init", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mdi.On("GetNamespace", mock.Anything, mock.Anything).Return(nil, nil) or.mdi.On("UpsertNamespace", mock.Anything, mock.Anything, true).Return(nil) @@ -684,6 +693,7 @@ func TestInitOK(t *testing.T) { or.mbi.On("Init", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mps.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mdi.On("GetIdentities", mock.Anything, mock.Anything).Return([]*fftypes.Identity{}, nil, nil) + or.mdx.On("InitPrefix", mock.Anything).Return() or.mdx.On("Init", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil) or.mdi.On("GetNamespace", mock.Anything, mock.Anything).Return(nil, nil) or.mdi.On("UpsertNamespace", mock.Anything, mock.Anything, true).Return(nil) @@ -721,6 +731,7 @@ func TestInitDataExchangeWithNodes(t *testing.T) { or := newTestOrchestrator() or.mdi.On("GetIdentities", mock.Anything, mock.Anything).Return([]*fftypes.Identity{{}}, nil, nil) + or.mdx.On("InitPrefix", mock.Anything).Return() or.mdx.On("Init", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil) err := or.initDataExchange(or.ctx)