Skip to content

Commit 53cf013

Browse files
authored
Merge pull request #3103 from algorand/rel/beta-3.1.2
go-algorand v3.1.2-beta
2 parents dbd0ec9 + 2eb56bb commit 53cf013

File tree

4 files changed

+107
-1
lines changed

4 files changed

+107
-1
lines changed

buildnumber.dat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1
1+
2

data/txHandler.go

+8
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,14 @@ func (handler *solicitedAsyncTxHandler) loop(ctx context.Context) {
534534
handler.txHandler.net.RequestConnectOutgoing(false, make(chan struct{}))
535535
transactionMessagesDroppedFromPool.Inc(nil)
536536
} else if allTransactionsIncluded {
537+
for _, txnGroup := range groups.txGroups {
538+
// We reencode here instead of using rawmsg.Data to avoid broadcasting non-canonical encodings
539+
err := handler.txHandler.net.Relay(ctx, protocol.TxnTag, reencode(txnGroup.Transactions), false, groups.networkPeer)
540+
if err != nil {
541+
logging.Base().Infof("solicitedAsyncTxHandler was unable to relay transaction message : %v")
542+
break
543+
}
544+
}
537545
select {
538546
case groups.ackCh <- groups.messageSeq:
539547
// all good, write was successful.

test/e2e-go/features/transactions/sendReceive_test.go

+59
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,62 @@ func TestAccountsCanSendMoneyAcrossTxSync(t *testing.T) {
208208
}
209209
}
210210
}
211+
212+
// this test checks that a relay would relay a transaction
213+
// received via the txnsync onto a node that doesn't support
214+
// transaction sync.
215+
func TestTransactionSyncRelayBridge(t *testing.T) {
216+
217+
partitiontest.PartitionTest(t)
218+
defer fixtures.ShutdownSynchronizedTest(t)
219+
220+
a := require.New(fixtures.SynchronizedTest(t))
221+
222+
var fixture fixtures.RestClientFixture
223+
fixture.SetupNoStart(t, filepath.Join("nettemplates", "ThreeNodesOneOnline.json"))
224+
defer fixture.Shutdown()
225+
226+
onlineNodeController, err := fixture.GetNodeController("OnlineNode")
227+
a.NoError(err)
228+
229+
cfg, err := config.LoadConfigFromDisk(onlineNodeController.GetDataDir())
230+
a.NoError(err)
231+
cfg.NetworkProtocolVersion = "2.1"
232+
cfg.SaveToDisk(onlineNodeController.GetDataDir())
233+
234+
offlineNodeController, err := fixture.GetNodeController("OfflineNode")
235+
a.NoError(err)
236+
237+
cfg, err = config.LoadConfigFromDisk(offlineNodeController.GetDataDir())
238+
a.NoError(err)
239+
cfg.NetworkProtocolVersion = "3.0"
240+
cfg.SaveToDisk(offlineNodeController.GetDataDir())
241+
242+
fixture.Start()
243+
244+
client := fixture.GetLibGoalClientFromNodeController(offlineNodeController)
245+
accounts, err := fixture.GetNodeWalletsSortedByBalance(client.DataDir())
246+
a.NoError(err)
247+
248+
a.Equal(1, len(accounts))
249+
250+
sendingAccount := accounts[0].Address
251+
252+
_, err = client.SendPaymentFromUnencryptedWallet(sendingAccount, sendingAccount, 1024*1024, 1024, nil)
253+
a.NoError(err)
254+
255+
startRoundStatus, err := client.Status()
256+
a.NoError(err)
257+
for {
258+
pendingTxns, err := client.GetPendingTransactions(2)
259+
a.NoError(err)
260+
if pendingTxns.TotalTxns == 0 {
261+
break
262+
}
263+
status, err := client.Status()
264+
a.NoError(err)
265+
_, err = client.WaitForRound(status.LastRound)
266+
a.NoError(err)
267+
a.Less(uint64(status.LastRound), uint64(startRoundStatus.LastRound+5), "transaction is still pending after 5 rounds, whereas it should have been confirmed within 2 rounds.")
268+
}
269+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"Genesis": {
3+
"NetworkName": "tbd",
4+
"Wallets": [
5+
{
6+
"Name": "Wallet1",
7+
"Stake": 50,
8+
"Online": true
9+
},
10+
{
11+
"Name": "Wallet2",
12+
"Stake": 50,
13+
"Online": false
14+
}
15+
]
16+
},
17+
"Nodes": [
18+
{
19+
"Name": "Primary",
20+
"IsRelay": true,
21+
"Wallets": [
22+
]
23+
},
24+
{
25+
"Name": "OnlineNode",
26+
"Wallets": [
27+
{ "Name": "Wallet1",
28+
"ParticipationOnly": true }
29+
]
30+
},
31+
{
32+
"Name": "OfflineNode",
33+
"Wallets": [
34+
{ "Name": "Wallet2",
35+
"ParticipationOnly": false }
36+
]
37+
}
38+
]
39+
}

0 commit comments

Comments
 (0)