From 67bcde21115a1b29e42ff9753f8869068b9f1460 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Mon, 14 Feb 2022 19:36:15 +0200 Subject: [PATCH 01/43] indexer v1.2.6 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2d195cd2a03..93d4474531e 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.1.34 + github.com/ElrondNetwork/elastic-indexer-go v1.2.6 github.com/ElrondNetwork/elrond-go-core v1.1.11 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index 6473e74c6da..b0b5e20ae23 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.1.34 h1:oVYVGTfLnFKA0buh6oMbbl36fCy33PFQEPcj6RlkHo4= -github.com/ElrondNetwork/elastic-indexer-go v1.1.34/go.mod h1:2XJCGXNCOv9MIhbZeGNtXCiOAoZwTAjH16MVA+5Alj8= +github.com/ElrondNetwork/elastic-indexer-go v1.2.6 h1:E4sSIksxoUGy46rkJnCe6EDOmhgzfk7hQSu2bK+0Pxw= +github.com/ElrondNetwork/elastic-indexer-go v1.2.6/go.mod h1:2XJCGXNCOv9MIhbZeGNtXCiOAoZwTAjH16MVA+5Alj8= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From 1eda4929c5a7feb8abd4a064cf5f3ca4fea10133 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Mon, 14 Feb 2022 19:39:03 +0200 Subject: [PATCH 02/43] operations index --- cmd/node/config/external.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/node/config/external.toml b/cmd/node/config/external.toml index 337e885b47f..9fa578f3c92 100644 --- a/cmd/node/config/external.toml +++ b/cmd/node/config/external.toml @@ -12,7 +12,7 @@ Password = "" # EnabledIndexes represents a slice of indexes that will be enabled for indexing. Full list is: # ["tps", "rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators"] - EnabledIndexes = ["tps", "rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators"] + EnabledIndexes = ["tps", "rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations"] # EventNotifierConnector defines settings needed to configure and launch the event notifier component [EventNotifierConnector] From b386c3790d6621da0d32a9eee77a0f0f781a6a34 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Thu, 17 Feb 2022 12:05:51 +0200 Subject: [PATCH 03/43] indexer v1.2.7 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 93d4474531e..4da7977af13 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.6 + github.com/ElrondNetwork/elastic-indexer-go v1.2.7 github.com/ElrondNetwork/elrond-go-core v1.1.11 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index b0b5e20ae23..668f72db240 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.6 h1:E4sSIksxoUGy46rkJnCe6EDOmhgzfk7hQSu2bK+0Pxw= -github.com/ElrondNetwork/elastic-indexer-go v1.2.6/go.mod h1:2XJCGXNCOv9MIhbZeGNtXCiOAoZwTAjH16MVA+5Alj8= +github.com/ElrondNetwork/elastic-indexer-go v1.2.7 h1:qGmCPNLkak0X4KhsUbYQIrr1qgBTGqLI8uBBhplYLGk= +github.com/ElrondNetwork/elastic-indexer-go v1.2.7/go.mod h1:2XJCGXNCOv9MIhbZeGNtXCiOAoZwTAjH16MVA+5Alj8= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From b2c2c74174618953cff7853b2c38cd8a895c6c70 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Tue, 22 Feb 2022 10:59:36 +0200 Subject: [PATCH 04/43] indexer v1.2.8 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4da7977af13..5bce12e135f 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.7 + github.com/ElrondNetwork/elastic-indexer-go v1.2.8 github.com/ElrondNetwork/elrond-go-core v1.1.11 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index 668f72db240..0ac4d2ef006 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.7 h1:qGmCPNLkak0X4KhsUbYQIrr1qgBTGqLI8uBBhplYLGk= -github.com/ElrondNetwork/elastic-indexer-go v1.2.7/go.mod h1:2XJCGXNCOv9MIhbZeGNtXCiOAoZwTAjH16MVA+5Alj8= +github.com/ElrondNetwork/elastic-indexer-go v1.2.8 h1:THYuIGL4G4T9LM/gZf0J8yEur+1wMa1fNXltZKno6OA= +github.com/ElrondNetwork/elastic-indexer-go v1.2.8/go.mod h1:2XJCGXNCOv9MIhbZeGNtXCiOAoZwTAjH16MVA+5Alj8= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From 97ea47e4e003e76c5fa1edd196ed464ed2519d9b Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Wed, 23 Feb 2022 09:10:05 +0200 Subject: [PATCH 05/43] indexer 1.2.9 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 23176585fcd..663ebf52837 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.8 + github.com/ElrondNetwork/elastic-indexer-go v1.2.9 github.com/ElrondNetwork/elrond-go-core v1.1.11 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index 1715309efb5..fc9b0754f5b 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.8 h1:THYuIGL4G4T9LM/gZf0J8yEur+1wMa1fNXltZKno6OA= -github.com/ElrondNetwork/elastic-indexer-go v1.2.8/go.mod h1:2XJCGXNCOv9MIhbZeGNtXCiOAoZwTAjH16MVA+5Alj8= +github.com/ElrondNetwork/elastic-indexer-go v1.2.9 h1:xFK/0MUkSAmvaGbb8oXN7nXa00e+fZfmx8xVw8MRZBw= +github.com/ElrondNetwork/elastic-indexer-go v1.2.9/go.mod h1:2XJCGXNCOv9MIhbZeGNtXCiOAoZwTAjH16MVA+5Alj8= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From 6e53898d31e79058342674960583e546703e06c0 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Fri, 25 Feb 2022 09:19:36 +0200 Subject: [PATCH 06/43] indexer v1.2.10 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e3d9ec4eca3..5a07c6da0bf 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc2 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.9 + github.com/ElrondNetwork/elastic-indexer-go v1.2.10 github.com/ElrondNetwork/elrond-go-core v1.1.11 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index 9f37e9100cf..22ab985d5ca 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.9 h1:xFK/0MUkSAmvaGbb8oXN7nXa00e+fZfmx8xVw8MRZBw= -github.com/ElrondNetwork/elastic-indexer-go v1.2.9/go.mod h1:2XJCGXNCOv9MIhbZeGNtXCiOAoZwTAjH16MVA+5Alj8= +github.com/ElrondNetwork/elastic-indexer-go v1.2.10 h1:GIku+QWzkkuwcrUGweKkfRJk9uIIekdK7qa1I0eoIOI= +github.com/ElrondNetwork/elastic-indexer-go v1.2.10/go.mod h1:2XJCGXNCOv9MIhbZeGNtXCiOAoZwTAjH16MVA+5Alj8= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From ef604b6b5a8e90daaa06bd0024363924bc34b593 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Fri, 25 Feb 2022 18:44:11 +0200 Subject: [PATCH 07/43] indexer v1.2.11 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5a07c6da0bf..911026dbfda 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc2 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.10 + github.com/ElrondNetwork/elastic-indexer-go v1.2.11 github.com/ElrondNetwork/elrond-go-core v1.1.11 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index 22ab985d5ca..a4edf16c56f 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.10 h1:GIku+QWzkkuwcrUGweKkfRJk9uIIekdK7qa1I0eoIOI= -github.com/ElrondNetwork/elastic-indexer-go v1.2.10/go.mod h1:2XJCGXNCOv9MIhbZeGNtXCiOAoZwTAjH16MVA+5Alj8= +github.com/ElrondNetwork/elastic-indexer-go v1.2.11 h1:mQFU4fDkMhVNK3Rxd8cEaPHaHHti8Ucq/b3r1e72adM= +github.com/ElrondNetwork/elastic-indexer-go v1.2.11/go.mod h1:2XJCGXNCOv9MIhbZeGNtXCiOAoZwTAjH16MVA+5Alj8= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From 9d47074ed3a72f007269a0e53eebebe514776a2d Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Tue, 8 Mar 2022 11:20:37 +0200 Subject: [PATCH 08/43] latest indexer --- go.mod | 2 +- go.sum | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 19c29493897..0f8a945738b 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc6 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.1.37 + github.com/ElrondNetwork/elastic-indexer-go v1.2.14 github.com/ElrondNetwork/elrond-go-core v1.1.14 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index f0344ed0989..e3a722f203d 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.1.37 h1:nfAINYTM2jaFMYVobKA49Tu3ns/+e5W/82i3ti0Oeic= -github.com/ElrondNetwork/elastic-indexer-go v1.1.37/go.mod h1:zLa7vRvTJXjGXZuOy0BId3v+fvn5LSibOC2BeTsCqvs= +github.com/ElrondNetwork/elastic-indexer-go v1.2.14 h1:je3fo3RpoL9ipqy/YcedAMHdvBGM3Urj0JdmYKL2htU= +github.com/ElrondNetwork/elastic-indexer-go v1.2.14/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= @@ -1008,6 +1008,12 @@ github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpP github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965 h1:1oFLiOyVl+W7bnBzGhf7BbIv9loSFQcieWWYIjLqcAw= github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= +github.com/tidwall/gjson v1.14.0 h1:6aeJ0bzojgWLa82gDQHcx3S0Lr/O51I9bJ5nv6JFx5w= +github.com/tidwall/gjson v1.14.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tklauser/go-sysconf v0.3.4 h1:HT8SVixZd3IzLdfs/xlpq0jeSfTX57g1v6wB1EuzV7M= github.com/tklauser/go-sysconf v0.3.4/go.mod h1:Cl2c8ZRWfHD5IrfHo9VN+FX9kCFjIOyVklgXycLB6ek= github.com/tklauser/numcpus v0.2.1 h1:ct88eFm+Q7m2ZfXJdan1xYoXKlmwsfP+k88q05KvlZc= From 6821ffd093da18369b5737523f5856031cc41d5a Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Tue, 8 Mar 2022 11:36:16 +0200 Subject: [PATCH 09/43] fix tests --- integrationTests/mock/databaseWritterMock.go | 10 ++++++++++ integrationTests/vm/testIndexer.go | 3 +++ 2 files changed, 13 insertions(+) diff --git a/integrationTests/mock/databaseWritterMock.go b/integrationTests/mock/databaseWritterMock.go index 7dd22b555c2..d040b418fe2 100644 --- a/integrationTests/mock/databaseWritterMock.go +++ b/integrationTests/mock/databaseWritterMock.go @@ -14,6 +14,16 @@ type DatabaseWriterStub struct { DoMultiGetCalled func(ids []string, index string, withSource bool, res interface{}) error } +// DoScrollRequest - +func (dws *DatabaseWriterStub) DoScrollRequest(_ string, _ []byte, _ bool, _ func(responseBytes []byte) error) error { + return nil +} + +// DoCountRequest - +func (dws *DatabaseWriterStub) DoCountRequest(_ string, _ []byte) (uint64, error) { + return 0, nil +} + // DoRequest - func (dws *DatabaseWriterStub) DoRequest(req *esapi.IndexRequest) error { if dws.DoRequestCalled != nil { diff --git a/integrationTests/vm/testIndexer.go b/integrationTests/vm/testIndexer.go index 92e0970e750..f56996734c3 100644 --- a/integrationTests/vm/testIndexer.go +++ b/integrationTests/vm/testIndexer.go @@ -16,6 +16,7 @@ import ( blockProc "github.com/ElrondNetwork/elastic-indexer-go/process/block" "github.com/ElrondNetwork/elastic-indexer-go/process/logsevents" "github.com/ElrondNetwork/elastic-indexer-go/process/miniblocks" + "github.com/ElrondNetwork/elastic-indexer-go/process/operations" "github.com/ElrondNetwork/elastic-indexer-go/process/statistics" "github.com/ElrondNetwork/elastic-indexer-go/process/transactions" "github.com/ElrondNetwork/elastic-indexer-go/process/validators" @@ -125,6 +126,7 @@ func (ti *testIndexer) createElasticProcessor( mp, _ := miniblocks.NewMiniblocksProcessor(shardCoordinator.SelfId(), testHasher, testMarshalizer, false) sp := statistics.NewStatisticsProcessor() vp, _ := validators.NewValidatorsProcessor(pubkeyConv) + opp, _ := operations.NewOperationsProcessor(false, shardCoordinator) args := &logsevents.ArgsLogsAndEventsProcessor{ ShardCoordinator: shardCoordinator, PubKeyConverter: pubkeyConv, @@ -149,6 +151,7 @@ func (ti *testIndexer) createElasticProcessor( ValidatorsProc: vp, LogsAndEventsProc: lp, DBClient: databaseClient, + OperationsProc: opp, } esProcessor, _ := elasticProcessor.NewElasticProcessor(esIndexerArgs) From 185f44db692c018463936f9058513ed25c01388a Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Thu, 10 Mar 2022 17:09:12 +0200 Subject: [PATCH 10/43] operation in comment --- cmd/node/config/external.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/node/config/external.toml b/cmd/node/config/external.toml index 830acac336c..cd780783b38 100644 --- a/cmd/node/config/external.toml +++ b/cmd/node/config/external.toml @@ -11,7 +11,7 @@ Username = "" Password = "" # EnabledIndexes represents a slice of indexes that will be enabled for indexing. Full list is: - # ["tps", "rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators"] + # ["tps", "rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations"] EnabledIndexes = ["tps", "rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations"] # EventNotifierConnector defines settings needed to configure and launch the event notifier component From dbc71c20fe9a7e0ab6bd7d5066e8e1ce6487cea2 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Thu, 10 Mar 2022 17:09:51 +0200 Subject: [PATCH 11/43] remove tps --- cmd/node/config/external.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/node/config/external.toml b/cmd/node/config/external.toml index cd780783b38..aabae0e5e21 100644 --- a/cmd/node/config/external.toml +++ b/cmd/node/config/external.toml @@ -11,8 +11,8 @@ Username = "" Password = "" # EnabledIndexes represents a slice of indexes that will be enabled for indexing. Full list is: - # ["tps", "rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations"] - EnabledIndexes = ["tps", "rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations"] + # ["rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations"] + EnabledIndexes = ["rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations"] # EventNotifierConnector defines settings needed to configure and launch the event notifier component [EventNotifierConnector] From 360e17d19ae1a65f78602d72b645136341541285 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Fri, 11 Mar 2022 11:50:22 +0200 Subject: [PATCH 12/43] indexer v1.2.5 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2aaaaed2e3a..2af453f0321 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc7 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.14 + github.com/ElrondNetwork/elastic-indexer-go v1.2.15 github.com/ElrondNetwork/elrond-go-core v1.1.14 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index 8da5bcb9255..019860efc43 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.14 h1:je3fo3RpoL9ipqy/YcedAMHdvBGM3Urj0JdmYKL2htU= -github.com/ElrondNetwork/elastic-indexer-go v1.2.14/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= +github.com/ElrondNetwork/elastic-indexer-go v1.2.15 h1:beLJ0qx2PonDefYDG6pcEQYJTFDeMEiJ06GslKSOmnM= +github.com/ElrondNetwork/elastic-indexer-go v1.2.15/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From f438b861f5a273e09ace0cb1cc108439bb215947 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Thu, 17 Mar 2022 12:34:46 +0200 Subject: [PATCH 13/43] elrond-vm-common v1.2.13 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2af453f0321..45be76d07dc 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/ElrondNetwork/elrond-go-core v1.1.14 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 - github.com/ElrondNetwork/elrond-vm-common v1.2.12 + github.com/ElrondNetwork/elrond-vm-common v1.2.13 github.com/ElrondNetwork/notifier-go v1.0.3 github.com/beevik/ntp v0.3.0 github.com/btcsuite/btcd v0.22.0-beta diff --git a/go.sum b/go.sum index 019860efc43..279a45e966b 100644 --- a/go.sum +++ b/go.sum @@ -39,8 +39,8 @@ github.com/ElrondNetwork/elrond-go-logger v1.0.5 h1:tB/HBvV9IVeCaSrGakX+GLGu7K5U github.com/ElrondNetwork/elrond-go-logger v1.0.5/go.mod h1:cBfgx0ST/CJx8jrxJSC5aiSrvkGzcnF7sK06RD8mFxQ= github.com/ElrondNetwork/elrond-vm-common v1.1.0/go.mod h1:w3i6f8uiuRkE68Ie/gebRcLgTuHqvruJSYrFyZWuLrE= github.com/ElrondNetwork/elrond-vm-common v1.2.9/go.mod h1:B/Y8WiqHyDd7xsjNYsaYbVMp1jQgQ+z4jTJkFvj/EWI= -github.com/ElrondNetwork/elrond-vm-common v1.2.12 h1:MHsWE24BJbpmdm9v4apBQo6mz3jsHV+rKZLYllJ1M/E= -github.com/ElrondNetwork/elrond-vm-common v1.2.12/go.mod h1:B/Y8WiqHyDd7xsjNYsaYbVMp1jQgQ+z4jTJkFvj/EWI= +github.com/ElrondNetwork/elrond-vm-common v1.2.13 h1:7/czriJTBayEkVGo8Duf6GDJsUViTyEHQdQdD+W+oxI= +github.com/ElrondNetwork/elrond-vm-common v1.2.13/go.mod h1:B/Y8WiqHyDd7xsjNYsaYbVMp1jQgQ+z4jTJkFvj/EWI= github.com/ElrondNetwork/go-libp2p-pubsub v0.5.5-gamma h1:k3Ko5UI2HNZlrU9laVeWx13+jnm79Maame4wIhf6J7Y= github.com/ElrondNetwork/go-libp2p-pubsub v0.5.5-gamma/go.mod h1:gVOzwebXVdSMDQBTfH8ACO5EJ4SQrvsHqCmYsCZpD0E= github.com/ElrondNetwork/notifier-go v1.0.3 h1:LhecyXqKuc/Q4NtIOlb9rw4hfMSj6usmxvYQWvb7Pn4= From 0637c9f5a34ffaae06c4d272e4504c3fcf1ebfe6 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Mon, 21 Mar 2022 13:53:34 +0200 Subject: [PATCH 14/43] bulk size in external.toml --- cmd/node/config/external.toml | 15 ++++++++------- config/externalConfig.go | 15 ++++++++------- factory/statusComponents.go | 1 + go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/cmd/node/config/external.toml b/cmd/node/config/external.toml index aabae0e5e21..a334dbeab68 100644 --- a/cmd/node/config/external.toml +++ b/cmd/node/config/external.toml @@ -4,15 +4,16 @@ #the node might loose rating (even facing penalties) due to the fact that #the indexer is called synchronously and might block due to external causes. #Strongly suggested to activate this on a regular observer node. - Enabled = false - IndexerCacheSize = 0 - URL = "http://localhost:9200" - UseKibana = false - Username = "" - Password = "" + Enabled = false + IndexerCacheSize = 0 + BulkRequestMaxSize = 4000000 # 4MB + URL = "http://localhost:9200" + UseKibana = false + Username = "" + Password = "" # EnabledIndexes represents a slice of indexes that will be enabled for indexing. Full list is: # ["rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations"] - EnabledIndexes = ["rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations"] + EnabledIndexes = ["rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations"] # EventNotifierConnector defines settings needed to configure and launch the event notifier component [EventNotifierConnector] diff --git a/config/externalConfig.go b/config/externalConfig.go index c1b4ca7857b..893edc5036e 100644 --- a/config/externalConfig.go +++ b/config/externalConfig.go @@ -9,13 +9,14 @@ type ExternalConfig struct { // ElasticSearchConfig will hold the configuration for the elastic search type ElasticSearchConfig struct { - Enabled bool - IndexerCacheSize int - URL string - UseKibana bool - Username string - Password string - EnabledIndexes []string + Enabled bool + IndexerCacheSize int + BulkRequestMaxSize int + URL string + UseKibana bool + Username string + Password string + EnabledIndexes []string } // EventNotifierConfig will hold the configuration for the events notifier driver diff --git a/factory/statusComponents.go b/factory/statusComponents.go index c5505a2bca7..4c691ac48b5 100644 --- a/factory/statusComponents.go +++ b/factory/statusComponents.go @@ -222,6 +222,7 @@ func (scf *statusComponentsFactory) makeElasticIndexerArgs() *indexerFactory.Arg return &indexerFactory.ArgsIndexerFactory{ Enabled: elasticSearchConfig.Enabled, IndexerCacheSize: elasticSearchConfig.IndexerCacheSize, + BulkRequestMaxSize: elasticSearchConfig.BulkRequestMaxSize, ShardCoordinator: scf.shardCoordinator, Url: elasticSearchConfig.URL, UserName: elasticSearchConfig.Username, diff --git a/go.mod b/go.mod index 45be76d07dc..ecc96791c10 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc7 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.15 + github.com/ElrondNetwork/elastic-indexer-go v1.2.16-0.20220321113307-9b755f6fd873 github.com/ElrondNetwork/elrond-go-core v1.1.14 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index 279a45e966b..fc44527fd3f 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.15 h1:beLJ0qx2PonDefYDG6pcEQYJTFDeMEiJ06GslKSOmnM= -github.com/ElrondNetwork/elastic-indexer-go v1.2.15/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= +github.com/ElrondNetwork/elastic-indexer-go v1.2.16-0.20220321113307-9b755f6fd873 h1:K9TzesaROzEb1+mtyBPpPuF49Zs8LdOmBtm5fOJpIA8= +github.com/ElrondNetwork/elastic-indexer-go v1.2.16-0.20220321113307-9b755f6fd873/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From d7c0e5c733a1c658a520dd515391e4790224dc89 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Mon, 21 Mar 2022 14:49:10 +0200 Subject: [PATCH 15/43] fixes after review --- cmd/node/config/external.toml | 16 ++++++++-------- config/externalConfig.go | 16 ++++++++-------- factory/statusComponents.go | 2 +- integrationTests/vm/testIndexer.go | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cmd/node/config/external.toml b/cmd/node/config/external.toml index a334dbeab68..d361de87fa3 100644 --- a/cmd/node/config/external.toml +++ b/cmd/node/config/external.toml @@ -4,16 +4,16 @@ #the node might loose rating (even facing penalties) due to the fact that #the indexer is called synchronously and might block due to external causes. #Strongly suggested to activate this on a regular observer node. - Enabled = false - IndexerCacheSize = 0 - BulkRequestMaxSize = 4000000 # 4MB - URL = "http://localhost:9200" - UseKibana = false - Username = "" - Password = "" + Enabled = false + IndexerCacheSize = 0 + BulkRequestMaxSizeInBytes = 4194304 # 4MB + URL = "http://localhost:9200" + UseKibana = false + Username = "" + Password = "" # EnabledIndexes represents a slice of indexes that will be enabled for indexing. Full list is: # ["rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations"] - EnabledIndexes = ["rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations"] + EnabledIndexes = ["rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations"] # EventNotifierConnector defines settings needed to configure and launch the event notifier component [EventNotifierConnector] diff --git a/config/externalConfig.go b/config/externalConfig.go index 893edc5036e..d4a869bdf4c 100644 --- a/config/externalConfig.go +++ b/config/externalConfig.go @@ -9,14 +9,14 @@ type ExternalConfig struct { // ElasticSearchConfig will hold the configuration for the elastic search type ElasticSearchConfig struct { - Enabled bool - IndexerCacheSize int - BulkRequestMaxSize int - URL string - UseKibana bool - Username string - Password string - EnabledIndexes []string + Enabled bool + IndexerCacheSize int + BulkRequestMaxSizeInBytes int + URL string + UseKibana bool + Username string + Password string + EnabledIndexes []string } // EventNotifierConfig will hold the configuration for the events notifier driver diff --git a/factory/statusComponents.go b/factory/statusComponents.go index 4c691ac48b5..0aa18d70a3d 100644 --- a/factory/statusComponents.go +++ b/factory/statusComponents.go @@ -222,7 +222,7 @@ func (scf *statusComponentsFactory) makeElasticIndexerArgs() *indexerFactory.Arg return &indexerFactory.ArgsIndexerFactory{ Enabled: elasticSearchConfig.Enabled, IndexerCacheSize: elasticSearchConfig.IndexerCacheSize, - BulkRequestMaxSize: elasticSearchConfig.BulkRequestMaxSize, + BulkRequestMaxSize: elasticSearchConfig.BulkRequestMaxSizeInBytes, ShardCoordinator: scf.shardCoordinator, Url: elasticSearchConfig.URL, UserName: elasticSearchConfig.Username, diff --git a/integrationTests/vm/testIndexer.go b/integrationTests/vm/testIndexer.go index f56996734c3..8601504f971 100644 --- a/integrationTests/vm/testIndexer.go +++ b/integrationTests/vm/testIndexer.go @@ -125,7 +125,7 @@ func (ti *testIndexer) createElasticProcessor( bp, _ := blockProc.NewBlockProcessor(testHasher, testMarshalizer) mp, _ := miniblocks.NewMiniblocksProcessor(shardCoordinator.SelfId(), testHasher, testMarshalizer, false) sp := statistics.NewStatisticsProcessor() - vp, _ := validators.NewValidatorsProcessor(pubkeyConv) + vp, _ := validators.NewValidatorsProcessor(pubkeyConv, 0) opp, _ := operations.NewOperationsProcessor(false, shardCoordinator) args := &logsevents.ArgsLogsAndEventsProcessor{ ShardCoordinator: shardCoordinator, From 7891cefa4c3f80bd11ed7643ccb81745f6ed2443 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Mon, 21 Mar 2022 15:20:16 +0200 Subject: [PATCH 16/43] fix semi-integration tests --- integrationTests/vm/testIndexer.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/integrationTests/vm/testIndexer.go b/integrationTests/vm/testIndexer.go index 8601504f971..aa450f76dca 100644 --- a/integrationTests/vm/testIndexer.go +++ b/integrationTests/vm/testIndexer.go @@ -257,6 +257,7 @@ func (ti *testIndexer) createDatabaseClient(hasResults bool) elasticProcessor.Da ti.indexerData[index] = buff if !done { done = true + ti.saveDoneChan <- struct{}{} return nil } ti.saveDoneChan <- struct{}{} @@ -273,7 +274,7 @@ func (ti *testIndexer) createDatabaseClient(hasResults bool) elasticProcessor.Da // GetIndexerPreparedTransaction - func (ti *testIndexer) GetIndexerPreparedTransaction(t *testing.T) *indexerTypes.Transaction { ti.mutex.RLock() - txData, ok := ti.indexerData["transactions"] + txData, ok := ti.indexerData[""] ti.mutex.RUnlock() require.True(t, ok) @@ -303,7 +304,7 @@ func (ti *testIndexer) GetIndexerPreparedTransaction(t *testing.T) *indexerTypes func (ti *testIndexer) printReceipt() { ti.mutex.RLock() - receipts, ok := ti.indexerData["receipts"] + receipts, ok := ti.indexerData[""] ti.mutex.RUnlock() if !ok { @@ -322,7 +323,7 @@ func (ti *testIndexer) printReceipt() { func (ti *testIndexer) putSCRSInTx(tx *indexerTypes.Transaction) { ti.mutex.RLock() - scrData, ok := ti.indexerData["scresults"] + scrData, ok := ti.indexerData[""] ti.mutex.RUnlock() if !ok { @@ -333,6 +334,10 @@ func (ti *testIndexer) putSCRSInTx(tx *indexerTypes.Transaction) { require.True(ti.t, len(split) > 2) for idx := 1; idx < len(split); idx += 2 { + if !bytes.Contains(split[idx], []byte("scresults")) { + continue + } + newSCR := &indexerTypes.ScResult{} err := json.Unmarshal(split[idx], newSCR) require.Nil(ti.t, err) From c3463e9bf4999085e2d04d5597b158d2648d1fdf Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Tue, 22 Mar 2022 11:01:15 +0200 Subject: [PATCH 17/43] latest commit indexer --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ecc96791c10..5049e889081 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc7 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.16-0.20220321113307-9b755f6fd873 + github.com/ElrondNetwork/elastic-indexer-go v1.2.16-0.20220322085652-174d1edb1070 github.com/ElrondNetwork/elrond-go-core v1.1.14 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index fc44527fd3f..cbf2b4b3c5b 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.16-0.20220321113307-9b755f6fd873 h1:K9TzesaROzEb1+mtyBPpPuF49Zs8LdOmBtm5fOJpIA8= -github.com/ElrondNetwork/elastic-indexer-go v1.2.16-0.20220321113307-9b755f6fd873/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= +github.com/ElrondNetwork/elastic-indexer-go v1.2.16-0.20220322085652-174d1edb1070 h1:X1iUYqxjPcqzrIzUVIXjnfLz9fs2m++U+W6LX1vVzKI= +github.com/ElrondNetwork/elastic-indexer-go v1.2.16-0.20220322085652-174d1edb1070/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From 2b9b6112e0935f0d622a0205def2e3b7252926e6 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Thu, 24 Mar 2022 14:12:43 +0200 Subject: [PATCH 18/43] latest indexer v1.2.16 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5049e889081..dd7dbbe61f0 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc7 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.16-0.20220322085652-174d1edb1070 + github.com/ElrondNetwork/elastic-indexer-go v1.2.16 github.com/ElrondNetwork/elrond-go-core v1.1.14 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index cbf2b4b3c5b..3b59552ec04 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.16-0.20220322085652-174d1edb1070 h1:X1iUYqxjPcqzrIzUVIXjnfLz9fs2m++U+W6LX1vVzKI= -github.com/ElrondNetwork/elastic-indexer-go v1.2.16-0.20220322085652-174d1edb1070/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= +github.com/ElrondNetwork/elastic-indexer-go v1.2.16 h1:WkzwRe3ev0Q7yExTkBDjGbu6TBc3vQCpubivcRq0/Gs= +github.com/ElrondNetwork/elastic-indexer-go v1.2.16/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From 4ae922d201ce417efd31a582375925cc583dbb4c Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Mon, 4 Apr 2022 16:40:12 +0300 Subject: [PATCH 19/43] indexer v1.2.17 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index dd7dbbe61f0..240bfaa18b4 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc7 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.16 + github.com/ElrondNetwork/elastic-indexer-go v1.2.17 github.com/ElrondNetwork/elrond-go-core v1.1.14 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index 3b59552ec04..f5eaf4740a1 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.16 h1:WkzwRe3ev0Q7yExTkBDjGbu6TBc3vQCpubivcRq0/Gs= -github.com/ElrondNetwork/elastic-indexer-go v1.2.16/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= +github.com/ElrondNetwork/elastic-indexer-go v1.2.17 h1:50N4H0W5gZr71FxZjehNyNFWmbKHUitNExOPuWUz/i8= +github.com/ElrondNetwork/elastic-indexer-go v1.2.17/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From 503cf33226a9f07a53cb3687ceaee77361e7e4dd Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Mon, 4 Apr 2022 20:24:13 +0300 Subject: [PATCH 20/43] indexer with fixes --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 240bfaa18b4..5dfa2668649 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc7 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.17 + github.com/ElrondNetwork/elastic-indexer-go v1.2.18-0.20220404172109-49ad774679fe github.com/ElrondNetwork/elrond-go-core v1.1.14 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index f5eaf4740a1..9ff4f770d55 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.17 h1:50N4H0W5gZr71FxZjehNyNFWmbKHUitNExOPuWUz/i8= -github.com/ElrondNetwork/elastic-indexer-go v1.2.17/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= +github.com/ElrondNetwork/elastic-indexer-go v1.2.18-0.20220404172109-49ad774679fe h1:dQ7lExY106fD0hxD468Avk3eJwphSTvbJA1Be2Z5gpk= +github.com/ElrondNetwork/elastic-indexer-go v1.2.18-0.20220404172109-49ad774679fe/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From 3bc442e83eb42aa1ac17ae140fb233853c02be08 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Mon, 4 Apr 2022 20:59:29 +0300 Subject: [PATCH 21/43] fixes --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5dfa2668649..d76cf999090 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc7 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.18-0.20220404172109-49ad774679fe + github.com/ElrondNetwork/elastic-indexer-go v1.2.18-0.20220404175513-1a3c38bdc674 github.com/ElrondNetwork/elrond-go-core v1.1.14 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index 9ff4f770d55..f1eb8730f60 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.18-0.20220404172109-49ad774679fe h1:dQ7lExY106fD0hxD468Avk3eJwphSTvbJA1Be2Z5gpk= -github.com/ElrondNetwork/elastic-indexer-go v1.2.18-0.20220404172109-49ad774679fe/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= +github.com/ElrondNetwork/elastic-indexer-go v1.2.18-0.20220404175513-1a3c38bdc674 h1:bIOem2leok/3DZAsVF4yFVsAl1hVN+1G+PdgGqyU72M= +github.com/ElrondNetwork/elastic-indexer-go v1.2.18-0.20220404175513-1a3c38bdc674/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From a806b8ad9ead11a55269df92517ca9a016cb0233 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Mon, 4 Apr 2022 21:12:56 +0300 Subject: [PATCH 22/43] indexer v1.2.18 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d76cf999090..2d9a144fce8 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc7 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.18-0.20220404175513-1a3c38bdc674 + github.com/ElrondNetwork/elastic-indexer-go v1.2.18 github.com/ElrondNetwork/elrond-go-core v1.1.14 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index f1eb8730f60..d95eddd0060 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.18-0.20220404175513-1a3c38bdc674 h1:bIOem2leok/3DZAsVF4yFVsAl1hVN+1G+PdgGqyU72M= -github.com/ElrondNetwork/elastic-indexer-go v1.2.18-0.20220404175513-1a3c38bdc674/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= +github.com/ElrondNetwork/elastic-indexer-go v1.2.18 h1:XHE+bsV5iH1M8p70hw6dWEJvteFJEXMFPMC5NtUlCmU= +github.com/ElrondNetwork/elastic-indexer-go v1.2.18/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From 380bb39f8e3dc1b2b1144c7cee1b4f23fde5f1f1 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Wed, 6 Apr 2022 11:14:31 +0300 Subject: [PATCH 23/43] indexer v1.2.19 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2d9a144fce8..1da8a35e593 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc7 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.18 + github.com/ElrondNetwork/elastic-indexer-go v1.2.19 github.com/ElrondNetwork/elrond-go-core v1.1.14 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index d95eddd0060..02215abdd3c 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.18 h1:XHE+bsV5iH1M8p70hw6dWEJvteFJEXMFPMC5NtUlCmU= -github.com/ElrondNetwork/elastic-indexer-go v1.2.18/go.mod h1:jrzgNlt92qgq+GAW5p+ZgW2Rkzama+Ufr9sQ8KDgZfk= +github.com/ElrondNetwork/elastic-indexer-go v1.2.19 h1:mT96gDjdZk1f1TN5eoRCGPa+PZ4qpe5BSnIvqj1iLOk= +github.com/ElrondNetwork/elastic-indexer-go v1.2.19/go.mod h1:XkrkGcomheEZyMC1/OoANQ9KV0OCZF6+UP8lSPRrE9I= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From c38dec6b95bb9d08a7ab17ff9ae0ecd61381b305 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Thu, 7 Apr 2022 08:58:01 +0300 Subject: [PATCH 24/43] indexer v1.2.20 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1da8a35e593..648fa527601 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc7 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.19 + github.com/ElrondNetwork/elastic-indexer-go v1.2.20 github.com/ElrondNetwork/elrond-go-core v1.1.14 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 diff --git a/go.sum b/go.sum index 02215abdd3c..9620b071f5a 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.19 h1:mT96gDjdZk1f1TN5eoRCGPa+PZ4qpe5BSnIvqj1iLOk= -github.com/ElrondNetwork/elastic-indexer-go v1.2.19/go.mod h1:XkrkGcomheEZyMC1/OoANQ9KV0OCZF6+UP8lSPRrE9I= +github.com/ElrondNetwork/elastic-indexer-go v1.2.20 h1:+whAbb0pBEoiWJXXj+Iy9vt6xwqBKyQ9VwhvvOd4Nlc= +github.com/ElrondNetwork/elastic-indexer-go v1.2.20/go.mod h1:XkrkGcomheEZyMC1/OoANQ9KV0OCZF6+UP8lSPRrE9I= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From 3601b1f539cf93f83e675b4e7b6e54c3c394f721 Mon Sep 17 00:00:00 2001 From: Iulian Pascalau Date: Wed, 20 Apr 2022 23:09:22 +0300 Subject: [PATCH 25/43] - go mod tidy --- go.sum | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.sum b/go.sum index a029d1801ee..44e7c96b13f 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.20 h1:+whAbb0pBEoiWJXXj+Iy9vt6xwqBKyQ9VwhvvOd4Nlc= -github.com/ElrondNetwork/elastic-indexer-go v1.2.20/go.mod h1:XkrkGcomheEZyMC1/OoANQ9KV0OCZF6+UP8lSPRrE9I= +github.com/ElrondNetwork/elastic-indexer-go v1.2.22 h1:Vw5c9oUNuZ6tWuLuqwAwrOC1+cHpeU/MyseldgdGdUY= +github.com/ElrondNetwork/elastic-indexer-go v1.2.22/go.mod h1:XkrkGcomheEZyMC1/OoANQ9KV0OCZF6+UP8lSPRrE9I= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From 5cc4d74936f15ff82d003be905c59598e2ba761f Mon Sep 17 00:00:00 2001 From: robertsasu Date: Thu, 21 Apr 2022 22:11:02 +0300 Subject: [PATCH 26/43] integrated new flag --- cmd/node/config/enableEpochs.toml | 3 + config/epochConfig.go | 1 + factory/apiResolverFactory.go | 26 +-- factory/blockProcessorCreator.go | 23 +-- genesis/process/shardGenesisBlockCreator.go | 25 +-- go.mod | 2 +- go.sum | 4 +- integrationTests/vm/esdt/nft/esdtNft_test.go | 165 ++++++++++++++++++ node/nodeRunner.go | 1 + .../smartContract/builtInFunctions/factory.go | 26 +-- 10 files changed, 228 insertions(+), 48 deletions(-) diff --git a/cmd/node/config/enableEpochs.toml b/cmd/node/config/enableEpochs.toml index d0781c78ae3..050a6357ab4 100644 --- a/cmd/node/config/enableEpochs.toml +++ b/cmd/node/config/enableEpochs.toml @@ -190,6 +190,9 @@ # SCRSizeInvariantOnBuiltInResultEnableEpoch represents the epoch when scr size invariant on built in result is enabled SCRSizeInvariantOnBuiltInResultEnableEpoch = 1 + # CheckCorrectTokenIDForTransferRoleEnableEpoch represents the epoch when the correct token ID check is applied for transfer role verification + CheckCorrectTokenIDForTransferRoleEnableEpoch = 2 + # MaxNodesChangeEnableEpoch holds configuration for changing the maximum number of nodes and the enabling epoch MaxNodesChangeEnableEpoch = [ { EpochEnable = 0, MaxNumNodes = 36, NodesToShufflePerShard = 4 }, diff --git a/config/epochConfig.go b/config/epochConfig.go index 2857dc8c78d..1e62def39ce 100644 --- a/config/epochConfig.go +++ b/config/epochConfig.go @@ -76,6 +76,7 @@ type EnableEpochs struct { DoNotReturnOldBlockInBlockchainHookEnableEpoch uint32 AddFailedRelayedTxToInvalidMBsDisableEpoch uint32 SCRSizeInvariantOnBuiltInResultEnableEpoch uint32 + CheckCorrectTokenIDForTransferRoleEnableEpoch uint32 } // GasScheduleByEpochs represents a gas schedule toml entry that will be applied from the provided epoch diff --git a/factory/apiResolverFactory.go b/factory/apiResolverFactory.go index 7fd72accba9..57b1cd3c32e 100644 --- a/factory/apiResolverFactory.go +++ b/factory/apiResolverFactory.go @@ -111,6 +111,7 @@ func CreateApiResolver(args *ApiResolverArgs) (facade.ApiResolver, error) { args.Configs.EpochConfig.EnableEpochs.ESDTTransferRoleEnableEpoch, args.Configs.EpochConfig.EnableEpochs.BuiltInFunctionOnMetaEnableEpoch, args.Configs.EpochConfig.EnableEpochs.OptimizeNFTStoreEnableEpoch, + args.Configs.EpochConfig.EnableEpochs.CheckCorrectTokenIDForTransferRoleEnableEpoch, ) if err != nil { return nil, err @@ -249,6 +250,7 @@ func createScQueryElement( args.epochConfig.EnableEpochs.ESDTTransferRoleEnableEpoch, args.epochConfig.EnableEpochs.BuiltInFunctionOnMetaEnableEpoch, args.epochConfig.EnableEpochs.OptimizeNFTStoreEnableEpoch, + args.epochConfig.EnableEpochs.CheckCorrectTokenIDForTransferRoleEnableEpoch, ) if err != nil { return nil, err @@ -362,19 +364,21 @@ func createBuiltinFuncs( esdtTransferRoleEnableEpoch uint32, transferToMetaEnableEpoch uint32, optimizeNFTStoreEnableEpoch uint32, + checkCorrectTokenIDEnableEpoch uint32, ) (vmcommon.BuiltInFunctionContainer, vmcommon.SimpleESDTNFTStorageHandler, error) { argsBuiltIn := builtInFunctions.ArgsCreateBuiltInFunctionContainer{ - GasSchedule: gasScheduleNotifier, - MapDNSAddresses: make(map[string]struct{}), - Marshalizer: marshalizer, - Accounts: accnts, - ShardCoordinator: shardCoordinator, - EpochNotifier: epochNotifier, - ESDTMultiTransferEnableEpoch: esdtMultiTransferEnableEpoch, - ESDTTransferRoleEnableEpoch: esdtTransferRoleEnableEpoch, - GlobalMintBurnDisableEpoch: esdtGlobalMintBurnDisableEpoch, - ESDTTransferMetaEnableEpoch: transferToMetaEnableEpoch, - OptimizeNFTStoreEnableEpoch: optimizeNFTStoreEnableEpoch, + GasSchedule: gasScheduleNotifier, + MapDNSAddresses: make(map[string]struct{}), + Marshalizer: marshalizer, + Accounts: accnts, + ShardCoordinator: shardCoordinator, + EpochNotifier: epochNotifier, + ESDTMultiTransferEnableEpoch: esdtMultiTransferEnableEpoch, + ESDTTransferRoleEnableEpoch: esdtTransferRoleEnableEpoch, + GlobalMintBurnDisableEpoch: esdtGlobalMintBurnDisableEpoch, + ESDTTransferMetaEnableEpoch: transferToMetaEnableEpoch, + OptimizeNFTStoreEnableEpoch: optimizeNFTStoreEnableEpoch, + CheckCorrectTokenIDEnableEpoch: checkCorrectTokenIDEnableEpoch, } return builtInFunctions.CreateBuiltInFuncContainerAndNFTStorageHandler(argsBuiltIn) } diff --git a/factory/blockProcessorCreator.go b/factory/blockProcessorCreator.go index 7f6fe1e901c..ca12a36c1b4 100644 --- a/factory/blockProcessorCreator.go +++ b/factory/blockProcessorCreator.go @@ -1109,17 +1109,18 @@ func (pcf *processComponentsFactory) createBuiltInFunctionContainer( mapDNSAddresses map[string]struct{}, ) (vmcommon.BuiltInFunctionContainer, vmcommon.SimpleESDTNFTStorageHandler, error) { argsBuiltIn := builtInFunctions.ArgsCreateBuiltInFunctionContainer{ - GasSchedule: pcf.gasSchedule, - MapDNSAddresses: mapDNSAddresses, - Marshalizer: pcf.coreData.InternalMarshalizer(), - Accounts: accounts, - ShardCoordinator: pcf.bootstrapComponents.ShardCoordinator(), - EpochNotifier: pcf.epochNotifier, - ESDTMultiTransferEnableEpoch: pcf.epochConfig.EnableEpochs.ESDTMultiTransferEnableEpoch, - ESDTTransferRoleEnableEpoch: pcf.epochConfig.EnableEpochs.ESDTTransferRoleEnableEpoch, - GlobalMintBurnDisableEpoch: pcf.epochConfig.EnableEpochs.GlobalMintBurnDisableEpoch, - ESDTTransferMetaEnableEpoch: pcf.epochConfig.EnableEpochs.BuiltInFunctionOnMetaEnableEpoch, - OptimizeNFTStoreEnableEpoch: pcf.epochConfig.EnableEpochs.OptimizeNFTStoreEnableEpoch, + GasSchedule: pcf.gasSchedule, + MapDNSAddresses: mapDNSAddresses, + Marshalizer: pcf.coreData.InternalMarshalizer(), + Accounts: accounts, + ShardCoordinator: pcf.bootstrapComponents.ShardCoordinator(), + EpochNotifier: pcf.epochNotifier, + ESDTMultiTransferEnableEpoch: pcf.epochConfig.EnableEpochs.ESDTMultiTransferEnableEpoch, + ESDTTransferRoleEnableEpoch: pcf.epochConfig.EnableEpochs.ESDTTransferRoleEnableEpoch, + GlobalMintBurnDisableEpoch: pcf.epochConfig.EnableEpochs.GlobalMintBurnDisableEpoch, + ESDTTransferMetaEnableEpoch: pcf.epochConfig.EnableEpochs.BuiltInFunctionOnMetaEnableEpoch, + OptimizeNFTStoreEnableEpoch: pcf.epochConfig.EnableEpochs.OptimizeNFTStoreEnableEpoch, + CheckCorrectTokenIDEnableEpoch: pcf.epochConfig.EnableEpochs.CheckCorrectTokenIDForTransferRoleEnableEpoch, } return builtInFunctions.CreateBuiltInFuncContainerAndNFTStorageHandler(argsBuiltIn) diff --git a/genesis/process/shardGenesisBlockCreator.go b/genesis/process/shardGenesisBlockCreator.go index 90f6ea2c2d6..84f4f282e1c 100644 --- a/genesis/process/shardGenesisBlockCreator.go +++ b/genesis/process/shardGenesisBlockCreator.go @@ -115,6 +115,7 @@ func createGenesisConfig() config.EnableEpochs { ScheduledMiniBlocksEnableEpoch: unreachableEpoch, AddFailedRelayedTxToInvalidMBsDisableEpoch: unreachableEpoch, SCRSizeInvariantOnBuiltInResultEnableEpoch: unreachableEpoch, + CheckCorrectTokenIDForTransferRoleEnableEpoch: unreachableEpoch, } } @@ -349,17 +350,19 @@ func createProcessorsForShardGenesisBlock(arg ArgsGenesisBlockCreator, enableEpo epochNotifier := forking.NewGenericEpochNotifier() argsBuiltIn := builtInFunctions.ArgsCreateBuiltInFunctionContainer{ - GasSchedule: arg.GasSchedule, - MapDNSAddresses: make(map[string]struct{}), - EnableUserNameChange: false, - Marshalizer: arg.Core.InternalMarshalizer(), - Accounts: arg.Accounts, - ShardCoordinator: arg.ShardCoordinator, - EpochNotifier: epochNotifier, - ESDTMultiTransferEnableEpoch: enableEpochs.ESDTMultiTransferEnableEpoch, - ESDTTransferRoleEnableEpoch: enableEpochs.ESDTTransferRoleEnableEpoch, - GlobalMintBurnDisableEpoch: enableEpochs.GlobalMintBurnDisableEpoch, - ESDTTransferMetaEnableEpoch: enableEpochs.BuiltInFunctionOnMetaEnableEpoch, + GasSchedule: arg.GasSchedule, + MapDNSAddresses: make(map[string]struct{}), + EnableUserNameChange: false, + Marshalizer: arg.Core.InternalMarshalizer(), + Accounts: arg.Accounts, + ShardCoordinator: arg.ShardCoordinator, + EpochNotifier: epochNotifier, + ESDTMultiTransferEnableEpoch: enableEpochs.ESDTMultiTransferEnableEpoch, + ESDTTransferRoleEnableEpoch: enableEpochs.ESDTTransferRoleEnableEpoch, + GlobalMintBurnDisableEpoch: enableEpochs.GlobalMintBurnDisableEpoch, + ESDTTransferMetaEnableEpoch: enableEpochs.BuiltInFunctionOnMetaEnableEpoch, + OptimizeNFTStoreEnableEpoch: enableEpochs.OptimizeNFTStoreEnableEpoch, + CheckCorrectTokenIDEnableEpoch: enableEpochs.CheckCorrectTokenIDForTransferRoleEnableEpoch, } builtInFuncs, nftStorageHandler, err := builtInFunctions.CreateBuiltInFuncContainerAndNFTStorageHandler(argsBuiltIn) if err != nil { diff --git a/go.mod b/go.mod index f521c87a561..e55546cc912 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/ElrondNetwork/elrond-go-core v1.1.15 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 - github.com/ElrondNetwork/elrond-vm-common v1.2.12 + github.com/ElrondNetwork/elrond-vm-common v1.2.14-0.20220421185714-edf68ab67a9e github.com/ElrondNetwork/notifier-go v1.0.3 github.com/beevik/ntp v0.3.0 github.com/btcsuite/btcd v0.22.0-beta diff --git a/go.sum b/go.sum index 830339c992e..97265ebc4ee 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/ElrondNetwork/elrond-go-logger v1.0.5 h1:tB/HBvV9IVeCaSrGakX+GLGu7K5U github.com/ElrondNetwork/elrond-go-logger v1.0.5/go.mod h1:cBfgx0ST/CJx8jrxJSC5aiSrvkGzcnF7sK06RD8mFxQ= github.com/ElrondNetwork/elrond-vm-common v1.1.0/go.mod h1:w3i6f8uiuRkE68Ie/gebRcLgTuHqvruJSYrFyZWuLrE= github.com/ElrondNetwork/elrond-vm-common v1.2.9/go.mod h1:B/Y8WiqHyDd7xsjNYsaYbVMp1jQgQ+z4jTJkFvj/EWI= -github.com/ElrondNetwork/elrond-vm-common v1.2.12 h1:MHsWE24BJbpmdm9v4apBQo6mz3jsHV+rKZLYllJ1M/E= -github.com/ElrondNetwork/elrond-vm-common v1.2.12/go.mod h1:B/Y8WiqHyDd7xsjNYsaYbVMp1jQgQ+z4jTJkFvj/EWI= +github.com/ElrondNetwork/elrond-vm-common v1.2.14-0.20220421185714-edf68ab67a9e h1:9cTldeCNE+0oIHMIZEQXHfRdzi0sAoT1aFxNZARI6ho= +github.com/ElrondNetwork/elrond-vm-common v1.2.14-0.20220421185714-edf68ab67a9e/go.mod h1:B/Y8WiqHyDd7xsjNYsaYbVMp1jQgQ+z4jTJkFvj/EWI= github.com/ElrondNetwork/go-libp2p-pubsub v0.5.5-gamma h1:k3Ko5UI2HNZlrU9laVeWx13+jnm79Maame4wIhf6J7Y= github.com/ElrondNetwork/go-libp2p-pubsub v0.5.5-gamma/go.mod h1:gVOzwebXVdSMDQBTfH8ACO5EJ4SQrvsHqCmYsCZpD0E= github.com/ElrondNetwork/notifier-go v1.0.3 h1:LhecyXqKuc/Q4NtIOlb9rw4hfMSj6usmxvYQWvb7Pn4= diff --git a/integrationTests/vm/esdt/nft/esdtNft_test.go b/integrationTests/vm/esdt/nft/esdtNft_test.go index f68bb3218ca..6f215519b63 100644 --- a/integrationTests/vm/esdt/nft/esdtNft_test.go +++ b/integrationTests/vm/esdt/nft/esdtNft_test.go @@ -744,6 +744,171 @@ func TestESDTNFTSendCreateRoleInCrossShard(t *testing.T) { testNFTSendCreateRole(t, 2) } +func TestESDTSemiFungibleWithTransferRoleIntraShard(t *testing.T) { + if testing.Short() { + t.Skip("this is not a short test") + } + + testESDTSemiFungibleTokenTransferRole(t, 1) +} + +func TestESDTSemiFungibleWithTransferRoleCrossShard(t *testing.T) { + if testing.Short() { + t.Skip("this is not a short test") + } + + testESDTSemiFungibleTokenTransferRole(t, 2) +} + +func testESDTSemiFungibleTokenTransferRole(t *testing.T, numOfShards int) { + nodesPerShard := 2 + numMetachainNodes := 2 + + nodes := integrationTests.CreateNodes( + numOfShards, + nodesPerShard, + numMetachainNodes, + ) + + idxProposers := make([]int, numOfShards+1) + for i := 0; i < numOfShards; i++ { + idxProposers[i] = i * nodesPerShard + } + idxProposers[numOfShards] = numOfShards * nodesPerShard + + integrationTests.DisplayAndStartNodes(nodes) + + defer func() { + for _, n := range nodes { + _ = n.Messenger.Close() + } + }() + + initialVal := big.NewInt(10000000000) + integrationTests.MintAllNodes(nodes, initialVal) + + round := uint64(0) + nonce := uint64(0) + round = integrationTests.IncrementAndPrintRound(round) + nonce++ + + // get a node from a different shard + var nodeInDifferentShard = nodes[0] + for _, node := range nodes { + if node.ShardCoordinator.SelfId() != nodes[0].ShardCoordinator.SelfId() { + nodeInDifferentShard = node + break + } + } + + roles := [][]byte{ + []byte(core.ESDTRoleNFTCreate), + []byte(core.ESDTRoleNFTAddQuantity), + []byte(core.ESDTRoleNFTBurn), + []byte(core.ESDTRoleTransfer), + } + + initialQuantity := int64(5) + tokenIdentifier, nftMetaData := prepareNFTWithRoles( + t, + nodes, + idxProposers, + nodeInDifferentShard, + &round, + &nonce, + core.SemiFungibleESDT, + initialQuantity, + roles, + ) + + // increase quantity + nonceArg := hex.EncodeToString(big.NewInt(0).SetUint64(1).Bytes()) + quantityToAdd := int64(4) + quantityToAddArg := hex.EncodeToString(big.NewInt(quantityToAdd).Bytes()) + txData := []byte(core.BuiltInFunctionESDTNFTAddQuantity + "@" + hex.EncodeToString([]byte(tokenIdentifier)) + + "@" + nonceArg + "@" + quantityToAddArg) + integrationTests.CreateAndSendTransaction( + nodeInDifferentShard, + nodes, + big.NewInt(0), + nodeInDifferentShard.OwnAccount.Address, + string(txData), + integrationTests.AdditionalGasLimit, + ) + + time.Sleep(time.Second) + nrRoundsToPropagateMultiShard := 5 + nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) + time.Sleep(time.Second) + + nftMetaData.quantity += quantityToAdd + checkNftData( + t, + nodeInDifferentShard.OwnAccount.Address, + nodeInDifferentShard.OwnAccount.Address, + nodes, + []byte(tokenIdentifier), + nftMetaData, + 1, + ) + + time.Sleep(time.Second) + nrRoundsToPropagateMultiShard = 5 + nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) + time.Sleep(time.Second) + + checkNftData( + t, + nodeInDifferentShard.OwnAccount.Address, + nodeInDifferentShard.OwnAccount.Address, + nodes, + []byte(tokenIdentifier), + nftMetaData, + 1, + ) + + // transfer + quantityToTransfer := int64(4) + quantityToTransferArg := hex.EncodeToString(big.NewInt(quantityToTransfer).Bytes()) + txData = []byte(core.BuiltInFunctionESDTNFTTransfer + "@" + hex.EncodeToString([]byte(tokenIdentifier)) + + "@" + nonceArg + "@" + quantityToTransferArg + "@" + hex.EncodeToString(nodes[0].OwnAccount.Address)) + integrationTests.CreateAndSendTransaction( + nodeInDifferentShard, + nodes, + big.NewInt(0), + nodeInDifferentShard.OwnAccount.Address, + string(txData), + integrationTests.AdditionalGasLimit, + ) + + time.Sleep(time.Second) + nrRoundsToPropagateMultiShard = 11 + nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) + time.Sleep(time.Second) + + nftMetaData.quantity = initialQuantity + quantityToAdd - quantityToTransfer + checkNftData( + t, + nodeInDifferentShard.OwnAccount.Address, + nodeInDifferentShard.OwnAccount.Address, + nodes, + []byte(tokenIdentifier), + nftMetaData, + 1, + ) + + nftMetaData.quantity = quantityToTransfer + checkNftData( + t, + nodeInDifferentShard.OwnAccount.Address, + nodes[0].OwnAccount.Address, + nodes, + []byte(tokenIdentifier), + nftMetaData, + 1, + ) +} + func prepareNFTWithRoles( t *testing.T, nodes []*integrationTests.TestProcessorNode, diff --git a/node/nodeRunner.go b/node/nodeRunner.go index 410d3b305fb..ea945b3f960 100644 --- a/node/nodeRunner.go +++ b/node/nodeRunner.go @@ -175,6 +175,7 @@ func printEnableEpochs(configs *config.Configs) { log.Debug(readEpochFor("correct jailed not unstaked if empty queue"), "epoch", enableEpochs.CorrectJailedNotUnstakedEmptyQueueEpoch) log.Debug(readEpochFor("do not return old block in blockchain hook"), "epoch", enableEpochs.DoNotReturnOldBlockInBlockchainHookEnableEpoch) log.Debug(readEpochFor("scr size invariant check on built in"), "epoch", enableEpochs.SCRSizeInvariantOnBuiltInResultEnableEpoch) + log.Debug(readEpochFor("correct check on tokenID for transfer role"), "epoch", enableEpochs.CheckCorrectTokenIDForTransferRoleEnableEpoch) gasSchedule := configs.EpochConfig.GasSchedule diff --git a/process/smartContract/builtInFunctions/factory.go b/process/smartContract/builtInFunctions/factory.go index a1d2b593e26..70c84f8c1a4 100644 --- a/process/smartContract/builtInFunctions/factory.go +++ b/process/smartContract/builtInFunctions/factory.go @@ -13,18 +13,19 @@ import ( // ArgsCreateBuiltInFunctionContainer defines the argument structure to create new built in function container type ArgsCreateBuiltInFunctionContainer struct { - GasSchedule core.GasScheduleNotifier - MapDNSAddresses map[string]struct{} - EnableUserNameChange bool - Marshalizer marshal.Marshalizer - Accounts state.AccountsAdapter - ShardCoordinator sharding.Coordinator - EpochNotifier vmcommon.EpochNotifier - ESDTMultiTransferEnableEpoch uint32 - ESDTTransferRoleEnableEpoch uint32 - GlobalMintBurnDisableEpoch uint32 - ESDTTransferMetaEnableEpoch uint32 - OptimizeNFTStoreEnableEpoch uint32 + GasSchedule core.GasScheduleNotifier + MapDNSAddresses map[string]struct{} + EnableUserNameChange bool + Marshalizer marshal.Marshalizer + Accounts state.AccountsAdapter + ShardCoordinator sharding.Coordinator + EpochNotifier vmcommon.EpochNotifier + ESDTMultiTransferEnableEpoch uint32 + ESDTTransferRoleEnableEpoch uint32 + GlobalMintBurnDisableEpoch uint32 + ESDTTransferMetaEnableEpoch uint32 + OptimizeNFTStoreEnableEpoch uint32 + CheckCorrectTokenIDEnableEpoch uint32 } // CreateBuiltInFuncContainerAndNFTStorageHandler creates a container that will hold all the available built in functions @@ -66,6 +67,7 @@ func CreateBuiltInFuncContainerAndNFTStorageHandler(args ArgsCreateBuiltInFuncti ESDTTransferRoleEnableEpoch: args.ESDTTransferRoleEnableEpoch, GlobalMintBurnDisableEpoch: args.GlobalMintBurnDisableEpoch, SaveNFTToSystemAccountEnableEpoch: args.OptimizeNFTStoreEnableEpoch, + CheckCorrectTokenIDEnableEpoch: args.CheckCorrectTokenIDEnableEpoch, } bContainerFactory, err := vmcommonBuiltInFunctions.NewBuiltInFunctionsCreator(modifiedArgs) From 123951d3871da8e2781e095b36098ff405b697ed Mon Sep 17 00:00:00 2001 From: robertsasu Date: Fri, 22 Apr 2022 14:31:17 +0300 Subject: [PATCH 27/43] new vmcommon release --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e55546cc912..91fe9ba1a72 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/ElrondNetwork/elrond-go-core v1.1.15 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.5 - github.com/ElrondNetwork/elrond-vm-common v1.2.14-0.20220421185714-edf68ab67a9e + github.com/ElrondNetwork/elrond-vm-common v1.2.14 github.com/ElrondNetwork/notifier-go v1.0.3 github.com/beevik/ntp v0.3.0 github.com/btcsuite/btcd v0.22.0-beta diff --git a/go.sum b/go.sum index 97265ebc4ee..cbe430f2e71 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/ElrondNetwork/elrond-go-logger v1.0.5 h1:tB/HBvV9IVeCaSrGakX+GLGu7K5U github.com/ElrondNetwork/elrond-go-logger v1.0.5/go.mod h1:cBfgx0ST/CJx8jrxJSC5aiSrvkGzcnF7sK06RD8mFxQ= github.com/ElrondNetwork/elrond-vm-common v1.1.0/go.mod h1:w3i6f8uiuRkE68Ie/gebRcLgTuHqvruJSYrFyZWuLrE= github.com/ElrondNetwork/elrond-vm-common v1.2.9/go.mod h1:B/Y8WiqHyDd7xsjNYsaYbVMp1jQgQ+z4jTJkFvj/EWI= -github.com/ElrondNetwork/elrond-vm-common v1.2.14-0.20220421185714-edf68ab67a9e h1:9cTldeCNE+0oIHMIZEQXHfRdzi0sAoT1aFxNZARI6ho= -github.com/ElrondNetwork/elrond-vm-common v1.2.14-0.20220421185714-edf68ab67a9e/go.mod h1:B/Y8WiqHyDd7xsjNYsaYbVMp1jQgQ+z4jTJkFvj/EWI= +github.com/ElrondNetwork/elrond-vm-common v1.2.14 h1:wEXghtHU8dgnYpraI7PQENQpeDPP0g9ojdy0CzYYpDM= +github.com/ElrondNetwork/elrond-vm-common v1.2.14/go.mod h1:B/Y8WiqHyDd7xsjNYsaYbVMp1jQgQ+z4jTJkFvj/EWI= github.com/ElrondNetwork/go-libp2p-pubsub v0.5.5-gamma h1:k3Ko5UI2HNZlrU9laVeWx13+jnm79Maame4wIhf6J7Y= github.com/ElrondNetwork/go-libp2p-pubsub v0.5.5-gamma/go.mod h1:gVOzwebXVdSMDQBTfH8ACO5EJ4SQrvsHqCmYsCZpD0E= github.com/ElrondNetwork/notifier-go v1.0.3 h1:LhecyXqKuc/Q4NtIOlb9rw4hfMSj6usmxvYQWvb7Pn4= From f4a8ae6cd24d240e9b954bd5be610a16df161100 Mon Sep 17 00:00:00 2001 From: robertsasu Date: Tue, 26 Apr 2022 11:53:21 +0300 Subject: [PATCH 28/43] new vm release --- go.mod | 4 ++-- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 91fe9ba1a72..dc27de7385c 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.15 require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_2 v1.2.35 github.com/ElrondNetwork/arwen-wasm-vm/v1_3 v1.3.35 - github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc7 + github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc8 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 github.com/ElrondNetwork/elastic-indexer-go v1.1.41 @@ -56,6 +56,6 @@ replace github.com/ElrondNetwork/arwen-wasm-vm/v1_2 v1.2.35 => github.com/Elrond replace github.com/ElrondNetwork/arwen-wasm-vm/v1_3 v1.3.35 => github.com/ElrondNetwork/arwen-wasm-vm v1.3.35 -replace github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc7 => github.com/ElrondNetwork/arwen-wasm-vm v1.4.34-rc7 +replace github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc8 => github.com/ElrondNetwork/arwen-wasm-vm v1.4.34-rc8 replace github.com/libp2p/go-libp2p-pubsub v0.5.5 => github.com/ElrondNetwork/go-libp2p-pubsub v0.5.5-gamma diff --git a/go.sum b/go.sum index cbe430f2e71..945c3adc4bb 100644 --- a/go.sum +++ b/go.sum @@ -16,8 +16,8 @@ github.com/ElrondNetwork/arwen-wasm-vm v1.2.35 h1:dM8JnTFw9MuHKIuURLyflJzXX63JB9 github.com/ElrondNetwork/arwen-wasm-vm v1.2.35/go.mod h1:XLdb0Ng7k/BplIfq85MBvcVKpXMOOfn+IIJd6guigpw= github.com/ElrondNetwork/arwen-wasm-vm v1.3.35 h1:Wz+N0bVidKIi/inO1s55HwqrSqkfcPYpcyAIiBbnL+k= github.com/ElrondNetwork/arwen-wasm-vm v1.3.35/go.mod h1:hg3s6l5FbRfjWjzrXrt2kqyNNvDoerxWskLa5o3TYzs= -github.com/ElrondNetwork/arwen-wasm-vm v1.4.34-rc7 h1:b8dn0fz9YLOSsvGs1BQo9jwpwAussTze9C1BPCb5vv0= -github.com/ElrondNetwork/arwen-wasm-vm v1.4.34-rc7/go.mod h1:XdxG04hwtyD8jBFeblMR6r8bi7PxuOnuefzs7ptAYIM= +github.com/ElrondNetwork/arwen-wasm-vm v1.4.34-rc8 h1:b9Z7qpXVLue5U2FYSbrDIgk7fNcOG+KurPFJBWNwcxQ= +github.com/ElrondNetwork/arwen-wasm-vm v1.4.34-rc8/go.mod h1:XdxG04hwtyD8jBFeblMR6r8bi7PxuOnuefzs7ptAYIM= github.com/ElrondNetwork/big-int-util v0.1.0 h1:vTMoJ5azhVmr7jhpSD3JUjQdkdyXoEPVkOvhdw1RjV4= github.com/ElrondNetwork/big-int-util v0.1.0/go.mod h1:96viBvoTXLjZOhEvE0D+QnAwg1IJLPAK6GVHMbC7Aw4= github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04gd61sNYo04Zf0= From 6ba812df75d30efbba02fbee6bb50006dd28fbef Mon Sep 17 00:00:00 2001 From: robertsasu Date: Tue, 26 Apr 2022 15:03:24 +0300 Subject: [PATCH 29/43] new vm release --- go.mod | 4 ++-- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index dc27de7385c..f518815fda0 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.15 require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_2 v1.2.35 github.com/ElrondNetwork/arwen-wasm-vm/v1_3 v1.3.35 - github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc8 + github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc9 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 github.com/ElrondNetwork/elastic-indexer-go v1.1.41 @@ -56,6 +56,6 @@ replace github.com/ElrondNetwork/arwen-wasm-vm/v1_2 v1.2.35 => github.com/Elrond replace github.com/ElrondNetwork/arwen-wasm-vm/v1_3 v1.3.35 => github.com/ElrondNetwork/arwen-wasm-vm v1.3.35 -replace github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc8 => github.com/ElrondNetwork/arwen-wasm-vm v1.4.34-rc8 +replace github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc9 => github.com/ElrondNetwork/arwen-wasm-vm v1.4.34-rc9 replace github.com/libp2p/go-libp2p-pubsub v0.5.5 => github.com/ElrondNetwork/go-libp2p-pubsub v0.5.5-gamma diff --git a/go.sum b/go.sum index 945c3adc4bb..28b78d27070 100644 --- a/go.sum +++ b/go.sum @@ -16,8 +16,8 @@ github.com/ElrondNetwork/arwen-wasm-vm v1.2.35 h1:dM8JnTFw9MuHKIuURLyflJzXX63JB9 github.com/ElrondNetwork/arwen-wasm-vm v1.2.35/go.mod h1:XLdb0Ng7k/BplIfq85MBvcVKpXMOOfn+IIJd6guigpw= github.com/ElrondNetwork/arwen-wasm-vm v1.3.35 h1:Wz+N0bVidKIi/inO1s55HwqrSqkfcPYpcyAIiBbnL+k= github.com/ElrondNetwork/arwen-wasm-vm v1.3.35/go.mod h1:hg3s6l5FbRfjWjzrXrt2kqyNNvDoerxWskLa5o3TYzs= -github.com/ElrondNetwork/arwen-wasm-vm v1.4.34-rc8 h1:b9Z7qpXVLue5U2FYSbrDIgk7fNcOG+KurPFJBWNwcxQ= -github.com/ElrondNetwork/arwen-wasm-vm v1.4.34-rc8/go.mod h1:XdxG04hwtyD8jBFeblMR6r8bi7PxuOnuefzs7ptAYIM= +github.com/ElrondNetwork/arwen-wasm-vm v1.4.34-rc9 h1:4EcPQtxjgsIRN5mVw297LSUzhsfvN9r/FQilL8nxwrc= +github.com/ElrondNetwork/arwen-wasm-vm v1.4.34-rc9/go.mod h1:XdxG04hwtyD8jBFeblMR6r8bi7PxuOnuefzs7ptAYIM= github.com/ElrondNetwork/big-int-util v0.1.0 h1:vTMoJ5azhVmr7jhpSD3JUjQdkdyXoEPVkOvhdw1RjV4= github.com/ElrondNetwork/big-int-util v0.1.0/go.mod h1:96viBvoTXLjZOhEvE0D+QnAwg1IJLPAK6GVHMbC7Aw4= github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04gd61sNYo04Zf0= From 1809d98b4d6f171bd406d4cc3f23b6a93220fdb8 Mon Sep 17 00:00:00 2001 From: SebastianMarian Date: Wed, 27 Apr 2022 12:16:48 +0300 Subject: [PATCH 30/43] * Fixed Warn messages in block tracker pools cleanup mechanism --- process/block/baseProcess.go | 39 +++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/process/block/baseProcess.go b/process/block/baseProcess.go index 7d547886358..82d3787bb78 100644 --- a/process/block/baseProcess.go +++ b/process/block/baseProcess.go @@ -834,10 +834,10 @@ func (bp *baseProcessor) cleanupPoolsForCrossShard( ) { crossNotarizedHeader, _, err := bp.blockTracker.GetCrossNotarizedHeader(shardID, noncesToPrevFinal) if err != nil { - log.Warn("cleanupPoolsForCrossShard", - "shard", shardID, - "nonces to previous final", noncesToPrevFinal, - "error", err.Error()) + displayCleanupErrorMessage("cleanupPoolsForCrossShard", + shardID, + noncesToPrevFinal, + err) return } @@ -964,10 +964,10 @@ func (bp *baseProcessor) cleanupBlockTrackerPools(noncesToPrevFinal uint64) { func (bp *baseProcessor) cleanupBlockTrackerPoolsForShard(shardID uint32, noncesToPrevFinal uint64) { selfNotarizedHeader, _, errSelfNotarized := bp.blockTracker.GetSelfNotarizedHeader(shardID, noncesToPrevFinal) if errSelfNotarized != nil { - log.Warn("cleanupBlockTrackerPoolsForShard.GetSelfNotarizedHeader", - "shard", shardID, - "nonces to previous final", noncesToPrevFinal, - "error", errSelfNotarized.Error()) + displayCleanupErrorMessage("cleanupBlockTrackerPoolsForShard.GetSelfNotarizedHeader", + shardID, + noncesToPrevFinal, + errSelfNotarized) return } @@ -977,10 +977,10 @@ func (bp *baseProcessor) cleanupBlockTrackerPoolsForShard(shardID uint32, nonces if shardID != bp.shardCoordinator.SelfId() { crossNotarizedHeader, _, errCrossNotarized := bp.blockTracker.GetCrossNotarizedHeader(shardID, noncesToPrevFinal) if errCrossNotarized != nil { - log.Warn("cleanupBlockTrackerPoolsForShard.GetCrossNotarizedHeader", - "shard", shardID, - "nonces to previous final", noncesToPrevFinal, - "error", errCrossNotarized.Error()) + displayCleanupErrorMessage("cleanupBlockTrackerPoolsForShard.GetCrossNotarizedHeader", + shardID, + noncesToPrevFinal, + errCrossNotarized) return } @@ -1864,3 +1864,18 @@ func (bp *baseProcessor) EpochConfirmed(epoch uint32, _ uint64) { bp.flagScheduledMiniBlocks.SetValue(epoch >= bp.scheduledMiniBlocksEnableEpoch) log.Debug("baseProcessor: scheduled mini blocks", "enabled", bp.flagScheduledMiniBlocks.IsSet()) } + +func displayCleanupErrorMessage(message string, shardID uint32, noncesToPrevFinal uint64, err error) { + errMessage := fmt.Errorf("%w : for shard %d with %d nonces to previous final", + err, shardID, noncesToPrevFinal, + ) + + // 2 blocks on shard + 2 blocks on meta + 1 block to previous final + maxNoncesToPrevFinalWithoutWarn := uint64(process.BlockFinality+1)*2 + 1 + if noncesToPrevFinal <= maxNoncesToPrevFinalWithoutWarn { + log.Debug(message, "error", errMessage) + return + } + + log.Warn(message, "error", errMessage) +} From 8bded1fe2d989615fbf1411e3cdd43a769ca1692 Mon Sep 17 00:00:00 2001 From: Iulian Pascalau Date: Wed, 27 Apr 2022 12:24:17 +0300 Subject: [PATCH 31/43] - new logger version - minor code refactoring --- api/logs/logSender_test.go | 8 ++++---- api/mock/loggerStub.go | 36 ++++++++++++++++++++++-------------- cmd/logviewer/main.go | 12 ++++++------ go.mod | 2 +- go.sum | 3 ++- process/block/baseProcess.go | 13 ++++++------- testscommon/loggerStub.go | 28 +++++++++++++++++++--------- 7 files changed, 60 insertions(+), 42 deletions(-) diff --git a/api/logs/logSender_test.go b/api/logs/logSender_test.go index 630dbf1a9db..4f3eef61522 100644 --- a/api/logs/logSender_test.go +++ b/api/logs/logSender_test.go @@ -41,7 +41,7 @@ func createMockLogSender() (*logs.LogSender, *mock.WsConnStub, io.Writer) { return lsender, conn, ls.Writer() } -//------- NewLogSender +// ------- NewLogSender func TestNewLogSender_NilMarshalizerShouldErr(t *testing.T) { t.Parallel() @@ -82,7 +82,7 @@ func TestNewLogSender_ShouldWork(t *testing.T) { removeWriterFromLogSubsystem(ls.Writer()) } -//------- StartSendingBlocking +// ------- StartSendingBlocking func TestLogSender_StartSendingBlockingConnReadMessageErrShouldCloseConn(t *testing.T) { t.Parallel() @@ -144,7 +144,7 @@ func TestLogSender_StartSendingBlockingSendsMessage(t *testing.T) { }) go func() { - //watchdog function + // watchdog function time.Sleep(time.Millisecond * 10) _ = ls.Writer().Close() @@ -169,7 +169,7 @@ func TestLogSender_StartSendingBlockingSendsMessageAndStopsWhenReadClose(t *test }) go func() { - //watchdog function + // watchdog function time.Sleep(time.Millisecond * 10) conn.SetReadMessageHandler(func() (messageType int, p []byte, err error) { diff --git a/api/mock/loggerStub.go b/api/mock/loggerStub.go index 6e6aaf9a107..738af664fbb 100644 --- a/api/mock/loggerStub.go +++ b/api/mock/loggerStub.go @@ -4,56 +4,64 @@ import logger "github.com/ElrondNetwork/elrond-go-logger" // LoggerStub - type LoggerStub struct { - LogCalled func(level string, message string, args ...interface{}) + LogCalled func(level logger.LogLevel, message string, args ...interface{}) + LogLineCalled func(line *logger.LogLine) SetLevelCalled func(logLevel logger.LogLevel) } +// Log - +func (l *LoggerStub) Log(logLevel logger.LogLevel, message string, args ...interface{}) { + if l.LogCalled != nil { + l.LogCalled(logLevel, message, args...) + } +} + +// LogLine - +func (l *LoggerStub) LogLine(line *logger.LogLine) { + if l.LogLineCalled != nil { + l.LogLineCalled(line) + } +} + // Trace - func (l *LoggerStub) Trace(message string, args ...interface{}) { if l.LogCalled != nil { - l.LogCalled("TRACE", message, args...) + l.LogCalled(logger.LogTrace, message, args...) } } // Debug - func (l *LoggerStub) Debug(message string, args ...interface{}) { if l.LogCalled != nil { - l.LogCalled("DEBUG", message, args...) + l.LogCalled(logger.LogDebug, message, args...) } } // Info - func (l *LoggerStub) Info(message string, args ...interface{}) { if l.LogCalled != nil { - l.LogCalled("INFO", message, args...) + l.LogCalled(logger.LogInfo, message, args...) } } // Warn - func (l *LoggerStub) Warn(message string, args ...interface{}) { if l.LogCalled != nil { - l.LogCalled("WARN", message, args...) + l.LogCalled(logger.LogWarning, message, args...) } } // Error - func (l *LoggerStub) Error(message string, args ...interface{}) { if l.LogCalled != nil { - l.LogCalled("ERROR", message, args...) + l.LogCalled(logger.LogError, message, args...) } } // LogIfError - func (l *LoggerStub) LogIfError(err error, args ...interface{}) { if l.LogCalled != nil && err != nil { - l.LogCalled("ERROR", err.Error(), args...) - } -} - -// Log - -func (l *LoggerStub) Log(line *logger.LogLine) { - if l.LogCalled != nil { - l.LogCalled("Log", "line", line) + l.LogCalled(logger.LogError, err.Error(), args...) } } diff --git a/cmd/logviewer/main.go b/cmd/logviewer/main.go index 138c0f341ac..057aeef61ec 100644 --- a/cmd/logviewer/main.go +++ b/cmd/logviewer/main.go @@ -69,25 +69,25 @@ VERSION: Value: "*:" + logger.LogInfo.String(), Destination: &argsConfig.logLevel, } - //logFile is used when the log output needs to be logged in a file + // logFile is used when the log output needs to be logged in a file logSaveFile = cli.BoolFlag{ Name: "log-save", Usage: "Boolean option for enabling log saving. If set, it will automatically save all the logs into a file.", Destination: &argsConfig.logSave, } - //useWss is used when the user require connection through wss + // useWss is used when the user require connection through wss useWss = cli.BoolFlag{ Name: "use-wss", Usage: "Will use wss instead of ws when creating the web socket", Destination: &argsConfig.useWss, } - //logWithCorrelation is used to enable log correlation elements + // logWithCorrelation is used to enable log correlation elements logWithCorrelation = cli.BoolFlag{ Name: "log-correlation", Usage: "Boolean option for enabling log correlation elements.", Destination: &argsConfig.logWithCorrelation, } - //logWithLoggerName is used to enable log correlation elements + // logWithLoggerName is used to enable log correlation elements logWithLoggerName = cli.BoolFlag{ Name: "log-logger-name", Usage: "Boolean option for logger name in the logs.", @@ -209,7 +209,7 @@ func startLogViewer(ctx *cli.Context) error { } }() - //set this log's level to the lowest desired log level that matches received logs from elrond-go + // set this log's level to the lowest desired log level that matches received logs from elrond-go lowestLogLevel := getLowestLogLevel(logLevels) log.SetLevel(lowestLogLevel) @@ -337,5 +337,5 @@ func outputMessage(message []byte) { recoveredLogLine.Args[i] = str } - log.Log(recoveredLogLine) + log.LogLine(recoveredLogLine) } diff --git a/go.mod b/go.mod index 91fe9ba1a72..866df6ecb94 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/ElrondNetwork/elastic-indexer-go v1.1.41 github.com/ElrondNetwork/elrond-go-core v1.1.15 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 - github.com/ElrondNetwork/elrond-go-logger v1.0.5 + github.com/ElrondNetwork/elrond-go-logger v1.0.7 github.com/ElrondNetwork/elrond-vm-common v1.2.14 github.com/ElrondNetwork/notifier-go v1.0.3 github.com/beevik/ntp v0.3.0 diff --git a/go.sum b/go.sum index cbe430f2e71..3a031d494b4 100644 --- a/go.sum +++ b/go.sum @@ -36,8 +36,9 @@ github.com/ElrondNetwork/elrond-go-crypto v1.0.0/go.mod h1:DGiR7/j1xv729Xg8SsjYa github.com/ElrondNetwork/elrond-go-crypto v1.0.1 h1:xJUUshIZQ7h+rG7Art/9QHVyaPRV1wEjrxXYBdpmRlM= github.com/ElrondNetwork/elrond-go-crypto v1.0.1/go.mod h1:uunsvweBrrhVojL8uiQSaTPsl3YIQ9iBqtYGM6xs4s0= github.com/ElrondNetwork/elrond-go-logger v1.0.4/go.mod h1:e5D+c97lKUfFdAzFX7rrI2Igl/z4Y0RkKYKWyzprTGk= -github.com/ElrondNetwork/elrond-go-logger v1.0.5 h1:tB/HBvV9IVeCaSrGakX+GLGu7K5UPLv8gA0TNKPOTOU= github.com/ElrondNetwork/elrond-go-logger v1.0.5/go.mod h1:cBfgx0ST/CJx8jrxJSC5aiSrvkGzcnF7sK06RD8mFxQ= +github.com/ElrondNetwork/elrond-go-logger v1.0.7 h1:Ldl1rVS0RGKc1IsW8jIaGCb6Zwei04gsMvyjL05X6mE= +github.com/ElrondNetwork/elrond-go-logger v1.0.7/go.mod h1:cBfgx0ST/CJx8jrxJSC5aiSrvkGzcnF7sK06RD8mFxQ= github.com/ElrondNetwork/elrond-vm-common v1.1.0/go.mod h1:w3i6f8uiuRkE68Ie/gebRcLgTuHqvruJSYrFyZWuLrE= github.com/ElrondNetwork/elrond-vm-common v1.2.9/go.mod h1:B/Y8WiqHyDd7xsjNYsaYbVMp1jQgQ+z4jTJkFvj/EWI= github.com/ElrondNetwork/elrond-vm-common v1.2.14 h1:wEXghtHU8dgnYpraI7PQENQpeDPP0g9ojdy0CzYYpDM= diff --git a/process/block/baseProcess.go b/process/block/baseProcess.go index 82d3787bb78..2a02535fabe 100644 --- a/process/block/baseProcess.go +++ b/process/block/baseProcess.go @@ -1866,16 +1866,15 @@ func (bp *baseProcessor) EpochConfirmed(epoch uint32, _ uint64) { } func displayCleanupErrorMessage(message string, shardID uint32, noncesToPrevFinal uint64, err error) { - errMessage := fmt.Errorf("%w : for shard %d with %d nonces to previous final", - err, shardID, noncesToPrevFinal, - ) - // 2 blocks on shard + 2 blocks on meta + 1 block to previous final maxNoncesToPrevFinalWithoutWarn := uint64(process.BlockFinality+1)*2 + 1 + level := logger.LogWarning if noncesToPrevFinal <= maxNoncesToPrevFinalWithoutWarn { - log.Debug(message, "error", errMessage) - return + level = logger.LogDebug } - log.Warn(message, "error", errMessage) + log.Log(level, message, + "shard", shardID, + "nonces to previous final", noncesToPrevFinal, + "error", err.Error()) } diff --git a/testscommon/loggerStub.go b/testscommon/loggerStub.go index b7f0b9a42e5..40d7d0ab860 100644 --- a/testscommon/loggerStub.go +++ b/testscommon/loggerStub.go @@ -1,6 +1,8 @@ package testscommon -import logger "github.com/ElrondNetwork/elrond-go-logger" +import ( + logger "github.com/ElrondNetwork/elrond-go-logger" +) // LoggerStub - type LoggerStub struct { @@ -9,12 +11,27 @@ type LoggerStub struct { InfoCalled func(message string, args ...interface{}) WarnCalled func(message string, args ...interface{}) ErrorCalled func(message string, args ...interface{}) + LogCalled func(logLevel logger.LogLevel, message string, args ...interface{}) LogIfErrorCalled func(err error, args ...interface{}) - LogCalled func(line *logger.LogLine) + LogLineCalled func(line *logger.LogLine) SetLevelCalled func(logLevel logger.LogLevel) GetLevelCalled func() logger.LogLevel } +// Log - +func (stub *LoggerStub) Log(logLevel logger.LogLevel, message string, args ...interface{}) { + if stub.LogCalled != nil { + stub.LogCalled(logLevel, message, args...) + } +} + +// LogLine - +func (stub *LoggerStub) LogLine(line *logger.LogLine) { + if stub.LogLineCalled != nil { + stub.LogLineCalled(line) + } +} + // Trace - func (stub *LoggerStub) Trace(message string, args ...interface{}) { if stub.TraceCalled != nil { @@ -57,13 +74,6 @@ func (stub *LoggerStub) LogIfError(err error, args ...interface{}) { } } -// Log - -func (stub *LoggerStub) Log(line *logger.LogLine) { - if stub.LogCalled != nil { - stub.LogCalled(line) - } -} - // SetLevel - func (stub *LoggerStub) SetLevel(logLevel logger.LogLevel) { if stub.SetLevelCalled != nil { From b5d657cf27f7a328d3df19182b8af5bfbaefab33 Mon Sep 17 00:00:00 2001 From: SebastianMarian Date: Wed, 27 Apr 2022 14:26:06 +0300 Subject: [PATCH 32/43] * Changed log Warn to Debug --- process/block/preprocess/transactions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/block/preprocess/transactions.go b/process/block/preprocess/transactions.go index 7b2cf070982..f624c5de33c 100644 --- a/process/block/preprocess/transactions.go +++ b/process/block/preprocess/transactions.go @@ -780,7 +780,7 @@ func (txs *transactions) AddTxsFromMiniBlocks(miniBlocks block.MiniBlockSlice) { searchFirst, ) if err != nil { - log.Warn("transactions.AddTxsFromMiniBlocks: GetTransactionHandler", "tx hash", txHash, "error", err.Error()) + log.Debug("transactions.AddTxsFromMiniBlocks: GetTransactionHandler", "tx hash", txHash, "error", err.Error()) continue } From e8e2e564dfa9c57507be63ea53074d3e6232acb3 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Wed, 27 Apr 2022 15:45:19 +0300 Subject: [PATCH 33/43] fix logs order --- process/smartContract/process.go | 3 ++- process/smartContract/process_test.go | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/process/smartContract/process.go b/process/smartContract/process.go index be3e710cedf..b3cd2d4ade2 100644 --- a/process/smartContract/process.go +++ b/process/smartContract/process.go @@ -1055,7 +1055,8 @@ func mergeVMOutputLogs(newVMOutput *vmcommon.VMOutput, vmOutput *vmcommon.VMOutp if newVMOutput.Logs == nil { newVMOutput.Logs = make([]*vmcommon.LogEntry, 0, len(vmOutput.Logs)) } - newVMOutput.Logs = append(newVMOutput.Logs, vmOutput.Logs...) + + newVMOutput.Logs = append(vmOutput.Logs, newVMOutput.Logs...) } func (sc *scProcessor) processSCRForSenderAfterBuiltIn( diff --git a/process/smartContract/process_test.go b/process/smartContract/process_test.go index 12bb0790d11..8f246e6df85 100644 --- a/process/smartContract/process_test.go +++ b/process/smartContract/process_test.go @@ -4243,6 +4243,27 @@ func TestMergeVmOutputLogs(t *testing.T) { mergeVMOutputLogs(vmOutput1, vmOutput2) require.Len(t, vmOutput1.Logs, 2) + + vmOutput1 = &vmcommon.VMOutput{ + Logs: []*vmcommon.LogEntry{ + { + Identifier: []byte("identifier2"), + }, + }, + } + + vmOutput2 = &vmcommon.VMOutput{ + Logs: []*vmcommon.LogEntry{ + { + Identifier: []byte("identifier1"), + }, + }, + } + + mergeVMOutputLogs(vmOutput1, vmOutput2) + require.Len(t, vmOutput1.Logs, 2) + require.Equal(t, []byte("identifier1"), vmOutput1.Logs[0].Identifier) + require.Equal(t, []byte("identifier2"), vmOutput1.Logs[1].Identifier) } func TestScProcessor_TooMuchGasProvidedMessage(t *testing.T) { From 53b9f1938063cbbce998b74d8358530acdd957d1 Mon Sep 17 00:00:00 2001 From: Iulian Pascalau Date: Thu, 28 Apr 2022 12:30:44 +0300 Subject: [PATCH 34/43] - fixed unit and integration tests --- consensus/spos/scheduledProcessor_test.go | 4 +- .../stateTrieClose/stateTrieClose_test.go | 2 + .../esdtMultiTransferThroughForwarder_test.go | 69 ++-- ...esdtMultiTransferToVaultCrossShard_test.go | 11 + .../esdtMultiTransferToVaultSameShard_test.go | 11 + .../esdtMultiTransferToVault_test.go | 327 --------------- .../multi-transfer/multiTransferCommon.go | 389 ++++++++++++++++-- integrationTests/vm/esdt/nft/common.go | 122 ++++++ .../vm/esdt/nft/{ => esdtNFT}/esdtNft_test.go | 189 ++------- .../nft/{ => esdtNFTSCs}/esdtNFTSCs_test.go | 12 +- 10 files changed, 588 insertions(+), 548 deletions(-) rename integrationTests/vm/esdt/multi-transfer/{ => esdtMultiTransferThroughForwarder}/esdtMultiTransferThroughForwarder_test.go (75%) create mode 100644 integrationTests/vm/esdt/multi-transfer/esdtMultiTransferToVaultCrossShard/esdtMultiTransferToVaultCrossShard_test.go create mode 100644 integrationTests/vm/esdt/multi-transfer/esdtMultiTransferToVaultSameShard/esdtMultiTransferToVaultSameShard_test.go delete mode 100644 integrationTests/vm/esdt/multi-transfer/esdtMultiTransferToVault_test.go create mode 100644 integrationTests/vm/esdt/nft/common.go rename integrationTests/vm/esdt/nft/{ => esdtNFT}/esdtNft_test.go (82%) rename integrationTests/vm/esdt/nft/{ => esdtNFTSCs}/esdtNFTSCs_test.go (98%) diff --git a/consensus/spos/scheduledProcessor_test.go b/consensus/spos/scheduledProcessor_test.go index 87889c1f7a5..50bfc68ed0a 100644 --- a/consensus/spos/scheduledProcessor_test.go +++ b/consensus/spos/scheduledProcessor_test.go @@ -148,10 +148,10 @@ func TestScheduledProcessorWrapper_IsProcessedInProgressStartingInFuture(t *test sp.setStatus(inProgress) startTime := time.Now() - sp.startTime = startTime.Add(10 * time.Millisecond) + sp.startTime = startTime.Add(500 * time.Millisecond) require.False(t, sp.IsProcessedOKWithTimeout()) endTime := time.Now() - require.Less(t, endTime.Sub(startTime), time.Millisecond) + require.Less(t, endTime.Sub(startTime), time.Millisecond*100) } func TestScheduledProcessorWrapper_IsProcessedInProgressEarlyCompletion(t *testing.T) { diff --git a/integrationTests/state/stateTrieClose/stateTrieClose_test.go b/integrationTests/state/stateTrieClose/stateTrieClose_test.go index b7f8a994d41..e5a388debef 100644 --- a/integrationTests/state/stateTrieClose/stateTrieClose_test.go +++ b/integrationTests/state/stateTrieClose/stateTrieClose_test.go @@ -34,6 +34,7 @@ func TestPatriciaMerkleTrie_Close(t *testing.T) { idxInitial, _ := gc.Snapshot() rootHash, _ := tr.RootHash() leavesChannel1, _ := tr.GetAllLeavesOnChannel(rootHash) + time.Sleep(time.Second) // allow the go routine to start idx, _ := gc.Snapshot() diff := gc.DiffGoRoutines(idxInitial, idx) assert.Equal(t, 1, len(diff), fmt.Sprintf("%v", diff)) @@ -57,6 +58,7 @@ func TestPatriciaMerkleTrie_Close(t *testing.T) { rootHash, _ = tr.RootHash() leavesChannel2, _ := tr.GetAllLeavesOnChannel(rootHash) + time.Sleep(time.Second) // allow the go routine to start idx, _ = gc.Snapshot() diff = gc.DiffGoRoutines(idxInitial, idx) assert.Equal(t, 4, len(diff), fmt.Sprintf("%v", diff)) diff --git a/integrationTests/vm/esdt/multi-transfer/esdtMultiTransferThroughForwarder_test.go b/integrationTests/vm/esdt/multi-transfer/esdtMultiTransferThroughForwarder/esdtMultiTransferThroughForwarder_test.go similarity index 75% rename from integrationTests/vm/esdt/multi-transfer/esdtMultiTransferThroughForwarder_test.go rename to integrationTests/vm/esdt/multi-transfer/esdtMultiTransferThroughForwarder/esdtMultiTransferThroughForwarder_test.go index 9f207559228..6d971059fc3 100644 --- a/integrationTests/vm/esdt/multi-transfer/esdtMultiTransferThroughForwarder_test.go +++ b/integrationTests/vm/esdt/multi-transfer/esdtMultiTransferThroughForwarder/esdtMultiTransferThroughForwarder_test.go @@ -1,4 +1,4 @@ -package multitransfer +package esdtMultiTransferThroughForwarder import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/ElrondNetwork/elrond-go-core/core" "github.com/ElrondNetwork/elrond-go/integrationTests" "github.com/ElrondNetwork/elrond-go/integrationTests/vm/esdt" + multitransfer "github.com/ElrondNetwork/elrond-go/integrationTests/vm/esdt/multi-transfer" "github.com/ElrondNetwork/elrond-go/testscommon/txDataBuilder" ) @@ -24,17 +25,17 @@ func TestESDTMultiTransferThroughForwarder(t *testing.T) { senderNode := net.NodesSharded[0][0] owner := senderNode.OwnAccount - forwarder := net.DeployPayableSC(owner, "../testdata/forwarder.wasm") - vault := net.DeployNonpayableSC(owner, "../testdata/vaultV2.wasm") - vaultOtherShard := net.DeployNonpayableSC(net.NodesSharded[1][0].OwnAccount, "../testdata/vaultV2.wasm") + forwarder := net.DeployPayableSC(owner, "../../testdata/forwarder.wasm") + vault := net.DeployNonpayableSC(owner, "../../testdata/vaultV2.wasm") + vaultOtherShard := net.DeployNonpayableSC(net.NodesSharded[1][0].OwnAccount, "../../testdata/vaultV2.wasm") // Create the fungible token supply := int64(1000) - tokenID := issueFungibleToken(t, net, senderNode, "FUNG1", supply) + tokenID := multitransfer.IssueFungibleToken(t, net, senderNode, "FUNG1", supply) // Issue and create an SFT - sftID := issueNft(net, senderNode, "SFT1", true) - createSFT(t, net, senderNode, sftID, 1, supply) + sftID := multitransfer.IssueNft(net, senderNode, "SFT1", true) + multitransfer.CreateSFT(t, net, senderNode, sftID, 1, supply) // Send the tokens to the forwarder SC txData := txDataBuilder.NewBuilder() @@ -52,11 +53,11 @@ func TestESDTMultiTransferThroughForwarder(t *testing.T) { esdt.CheckAddressHasTokens(t, forwarder, net.Nodes, []byte(tokenID), 0, supply) // transfer to a user from another shard - transfers := []*esdtTransfer{ + transfers := []*multitransfer.EsdtTransfer{ { - tokenIdentifier: tokenID, - nonce: 0, - amount: 100, + TokenIdentifier: tokenID, + Nonce: 0, + Amount: 100, }} destAddress := net.NodesSharded[1][0].OwnAccount.Address multiTransferThroughForwarder( @@ -84,16 +85,16 @@ func TestESDTMultiTransferThroughForwarder(t *testing.T) { // transfer fungible and non-fungible // transfer to vault, same shard - transfers = []*esdtTransfer{ + transfers = []*multitransfer.EsdtTransfer{ { - tokenIdentifier: tokenID, - nonce: 0, - amount: 100, + TokenIdentifier: tokenID, + Nonce: 0, + Amount: 100, }, { - tokenIdentifier: sftID, - nonce: 1, - amount: 100, + TokenIdentifier: sftID, + Nonce: 1, + Amount: 100, }, } multiTransferThroughForwarder( @@ -112,16 +113,16 @@ func TestESDTMultiTransferThroughForwarder(t *testing.T) { // transfer fungible and non-fungible // transfer to vault, cross shard via transfer and execute - transfers = []*esdtTransfer{ + transfers = []*multitransfer.EsdtTransfer{ { - tokenIdentifier: tokenID, - nonce: 0, - amount: 100, + TokenIdentifier: tokenID, + Nonce: 0, + Amount: 100, }, { - tokenIdentifier: sftID, - nonce: 1, - amount: 100, + TokenIdentifier: sftID, + Nonce: 1, + Amount: 100, }, } multiTransferThroughForwarder( @@ -139,16 +140,16 @@ func TestESDTMultiTransferThroughForwarder(t *testing.T) { esdt.CheckAddressHasTokens(t, vaultOtherShard, net.Nodes, []byte(sftID), 1, 100) // transfer to vault, cross shard, via async call - transfers = []*esdtTransfer{ + transfers = []*multitransfer.EsdtTransfer{ { - tokenIdentifier: tokenID, - nonce: 0, - amount: 100, + TokenIdentifier: tokenID, + Nonce: 0, + Amount: 100, }, { - tokenIdentifier: sftID, - nonce: 1, - amount: 100, + TokenIdentifier: sftID, + Nonce: 1, + Amount: 100, }, } multiTransferThroughForwarder( @@ -171,14 +172,14 @@ func multiTransferThroughForwarder( ownerWallet *integrationTests.TestWalletAccount, forwarderAddress []byte, function string, - transfers []*esdtTransfer, + transfers []*multitransfer.EsdtTransfer, destAddress []byte) { txData := txDataBuilder.NewBuilder() txData.Func(function).Bytes(destAddress) for _, transfer := range transfers { - txData.Str(transfer.tokenIdentifier).Int64(transfer.nonce).Int64(transfer.amount) + txData.Str(transfer.TokenIdentifier).Int64(transfer.Nonce).Int64(transfer.Amount) } tx := net.CreateTxUint64(ownerWallet, forwarderAddress, 0, txData.ToBytes()) diff --git a/integrationTests/vm/esdt/multi-transfer/esdtMultiTransferToVaultCrossShard/esdtMultiTransferToVaultCrossShard_test.go b/integrationTests/vm/esdt/multi-transfer/esdtMultiTransferToVaultCrossShard/esdtMultiTransferToVaultCrossShard_test.go new file mode 100644 index 00000000000..e3647bc878f --- /dev/null +++ b/integrationTests/vm/esdt/multi-transfer/esdtMultiTransferToVaultCrossShard/esdtMultiTransferToVaultCrossShard_test.go @@ -0,0 +1,11 @@ +package esdtMultiTransferToVaultCrossShard + +import ( + "testing" + + multitransfer "github.com/ElrondNetwork/elrond-go/integrationTests/vm/esdt/multi-transfer" +) + +func TestESDTMultiTransferToVaultCrossShard(t *testing.T) { + multitransfer.EsdtMultiTransferToVault(t, true, "../../testdata/vaultV2.wasm") +} diff --git a/integrationTests/vm/esdt/multi-transfer/esdtMultiTransferToVaultSameShard/esdtMultiTransferToVaultSameShard_test.go b/integrationTests/vm/esdt/multi-transfer/esdtMultiTransferToVaultSameShard/esdtMultiTransferToVaultSameShard_test.go new file mode 100644 index 00000000000..aab16166338 --- /dev/null +++ b/integrationTests/vm/esdt/multi-transfer/esdtMultiTransferToVaultSameShard/esdtMultiTransferToVaultSameShard_test.go @@ -0,0 +1,11 @@ +package esdtMultiTransferToVaultSameShard + +import ( + "testing" + + multitransfer "github.com/ElrondNetwork/elrond-go/integrationTests/vm/esdt/multi-transfer" +) + +func TestESDTMultiTransferToVaultSameShard(t *testing.T) { + multitransfer.EsdtMultiTransferToVault(t, false, "../../testdata/vaultV2.wasm") +} diff --git a/integrationTests/vm/esdt/multi-transfer/esdtMultiTransferToVault_test.go b/integrationTests/vm/esdt/multi-transfer/esdtMultiTransferToVault_test.go deleted file mode 100644 index a32985add98..00000000000 --- a/integrationTests/vm/esdt/multi-transfer/esdtMultiTransferToVault_test.go +++ /dev/null @@ -1,327 +0,0 @@ -package multitransfer - -import ( - "testing" - - "github.com/ElrondNetwork/elrond-go/integrationTests" -) - -func TestESDTMultiTransferToVaultSameShard(t *testing.T) { - esdtMultiTransferToVault(t, false) -} - -func TestESDTMultiTransferToVaultCrossShard(t *testing.T) { - esdtMultiTransferToVault(t, true) -} - -func esdtMultiTransferToVault(t *testing.T, crossShard bool) { - if testing.Short() { - t.Skip("this is not a short test") - } - - // For cross shard, we use 2 nodes, with node[1] being the SC deployer, and node[0] being the caller - numShards := 1 - nrRoundsToWait := numRoundsSameShard - - if crossShard { - numShards = 2 - nrRoundsToWait = numRoundsCrossShard - } - - net := integrationTests.NewTestNetworkSized(t, numShards, 1, 1) - net.Start() - defer net.Close() - - net.MintNodeAccountsUint64(10000000000) - net.Step() - - senderNode := net.NodesSharded[0][0] - if crossShard { - senderNode = net.NodesSharded[1][0] - } - - expectedIssuerBalance := make(map[string]map[int64]int64) - expectedVaultBalance := make(map[string]map[int64]int64) - - // deploy vault SC - vaultScAddress := deployNonPayableSmartContract(t, net, net.NodesSharded[0][0], "../testdata/vaultV2.wasm") - - // issue two fungible tokens - fungibleTokenIdentifier1 := issueFungibleToken(t, net, senderNode, "FUNG1", 1000) - fungibleTokenIdentifier2 := issueFungibleToken(t, net, senderNode, "FUNG2", 1000) - - expectedIssuerBalance[fungibleTokenIdentifier1] = make(map[int64]int64) - expectedIssuerBalance[fungibleTokenIdentifier2] = make(map[int64]int64) - expectedVaultBalance[fungibleTokenIdentifier1] = make(map[int64]int64) - expectedVaultBalance[fungibleTokenIdentifier2] = make(map[int64]int64) - - expectedIssuerBalance[fungibleTokenIdentifier1][0] = 1000 - expectedIssuerBalance[fungibleTokenIdentifier2][0] = 1000 - - // issue two NFT, with multiple NFTCreate - nonFungibleTokenIdentifier1 := issueNft(net, senderNode, "NFT1", false) - nonFungibleTokenIdentifier2 := issueNft(net, senderNode, "NFT2", false) - - expectedIssuerBalance[nonFungibleTokenIdentifier1] = make(map[int64]int64) - expectedIssuerBalance[nonFungibleTokenIdentifier2] = make(map[int64]int64) - - expectedVaultBalance[nonFungibleTokenIdentifier1] = make(map[int64]int64) - expectedVaultBalance[nonFungibleTokenIdentifier2] = make(map[int64]int64) - - for i := int64(1); i <= 10; i++ { - createNFT(t, net, senderNode, nonFungibleTokenIdentifier1, i) - createNFT(t, net, senderNode, nonFungibleTokenIdentifier2, i) - - expectedIssuerBalance[nonFungibleTokenIdentifier1][i] = 1 - expectedIssuerBalance[nonFungibleTokenIdentifier2][i] = 1 - } - - // issue two SFTs, with two NFTCreate for each - semiFungibleTokenIdentifier1 := issueNft(net, senderNode, "SFT1", true) - semiFungibleTokenIdentifier2 := issueNft(net, senderNode, "SFT2", true) - - expectedIssuerBalance[semiFungibleTokenIdentifier1] = make(map[int64]int64) - expectedIssuerBalance[semiFungibleTokenIdentifier2] = make(map[int64]int64) - - expectedVaultBalance[semiFungibleTokenIdentifier1] = make(map[int64]int64) - expectedVaultBalance[semiFungibleTokenIdentifier2] = make(map[int64]int64) - - for i := int64(1); i <= 2; i++ { - createSFT(t, net, senderNode, semiFungibleTokenIdentifier1, i, 1000) - createSFT(t, net, senderNode, semiFungibleTokenIdentifier2, i, 1000) - - expectedIssuerBalance[semiFungibleTokenIdentifier1][i] = 1000 - expectedIssuerBalance[semiFungibleTokenIdentifier2][i] = 1000 - } - - // send a single ESDT with multi-transfer - transfers := []*esdtTransfer{ - { - tokenIdentifier: fungibleTokenIdentifier1, - nonce: 0, - amount: 100, - }} - multiTransferToVault(t, net, senderNode, - vaultScAddress, transfers, nrRoundsToWait, - expectedIssuerBalance, expectedVaultBalance, - ) - - // send two identical transfers with multi-transfer - transfers = []*esdtTransfer{ - { - tokenIdentifier: fungibleTokenIdentifier1, - nonce: 0, - amount: 50, - }, - { - tokenIdentifier: fungibleTokenIdentifier1, - nonce: 0, - amount: 50, - }} - multiTransferToVault(t, net, senderNode, - vaultScAddress, transfers, nrRoundsToWait, - expectedIssuerBalance, expectedVaultBalance, - ) - - // send two different transfers amounts, same token - transfers = []*esdtTransfer{ - { - tokenIdentifier: fungibleTokenIdentifier1, - nonce: 0, - amount: 50, - }, - { - tokenIdentifier: fungibleTokenIdentifier1, - nonce: 0, - amount: 100, - }} - multiTransferToVault(t, net, senderNode, - vaultScAddress, transfers, nrRoundsToWait, - expectedIssuerBalance, expectedVaultBalance, - ) - - // send two different tokens, same amount - transfers = []*esdtTransfer{ - { - tokenIdentifier: fungibleTokenIdentifier1, - nonce: 0, - amount: 100, - }, - { - tokenIdentifier: fungibleTokenIdentifier2, - nonce: 0, - amount: 100, - }} - multiTransferToVault(t, net, senderNode, - vaultScAddress, transfers, nrRoundsToWait, - expectedIssuerBalance, expectedVaultBalance, - ) - - // send single NFT - transfers = []*esdtTransfer{ - { - tokenIdentifier: nonFungibleTokenIdentifier1, - nonce: 1, - amount: 1, - }} - multiTransferToVault(t, net, senderNode, - vaultScAddress, transfers, nrRoundsToWait, - expectedIssuerBalance, expectedVaultBalance, - ) - - // send two NFTs, same token ID - transfers = []*esdtTransfer{ - { - tokenIdentifier: nonFungibleTokenIdentifier1, - nonce: 2, - amount: 1, - }, - { - tokenIdentifier: nonFungibleTokenIdentifier1, - nonce: 3, - amount: 1, - }} - multiTransferToVault(t, net, senderNode, - vaultScAddress, transfers, nrRoundsToWait, - expectedIssuerBalance, expectedVaultBalance, - ) - - // send two NFTs, different token ID - transfers = []*esdtTransfer{ - { - tokenIdentifier: nonFungibleTokenIdentifier1, - nonce: 4, - amount: 1, - }, - { - tokenIdentifier: nonFungibleTokenIdentifier2, - nonce: 1, - amount: 1, - }} - multiTransferToVault(t, net, senderNode, - vaultScAddress, transfers, nrRoundsToWait, - expectedIssuerBalance, expectedVaultBalance, - ) - - // send fours NFTs, two of each different token ID - transfers = []*esdtTransfer{ - { - tokenIdentifier: nonFungibleTokenIdentifier1, - nonce: 5, - amount: 1, - }, - { - tokenIdentifier: nonFungibleTokenIdentifier2, - nonce: 2, - amount: 1, - }, - { - tokenIdentifier: nonFungibleTokenIdentifier1, - nonce: 6, - amount: 1, - }, - { - tokenIdentifier: nonFungibleTokenIdentifier2, - nonce: 3, - amount: 1, - }} - multiTransferToVault(t, net, senderNode, - vaultScAddress, transfers, nrRoundsToWait, - expectedIssuerBalance, expectedVaultBalance, - ) - - // send single SFT - transfers = []*esdtTransfer{ - { - tokenIdentifier: semiFungibleTokenIdentifier1, - nonce: 1, - amount: 100, - }} - multiTransferToVault(t, net, senderNode, - vaultScAddress, transfers, nrRoundsToWait, - expectedIssuerBalance, expectedVaultBalance, - ) - - // send two SFTs, same token ID - transfers = []*esdtTransfer{ - { - tokenIdentifier: semiFungibleTokenIdentifier1, - nonce: 1, - amount: 100, - }, - { - tokenIdentifier: semiFungibleTokenIdentifier1, - nonce: 2, - amount: 100, - }} - multiTransferToVault(t, net, senderNode, - vaultScAddress, transfers, nrRoundsToWait, - expectedIssuerBalance, expectedVaultBalance, - ) - - // send two SFTs, different token ID - transfers = []*esdtTransfer{ - { - tokenIdentifier: semiFungibleTokenIdentifier1, - nonce: 1, - amount: 100, - }, - { - tokenIdentifier: semiFungibleTokenIdentifier2, - nonce: 1, - amount: 100, - }} - multiTransferToVault(t, net, senderNode, - vaultScAddress, transfers, nrRoundsToWait, - expectedIssuerBalance, expectedVaultBalance, - ) - - // send fours SFTs, two of each different token ID - transfers = []*esdtTransfer{ - { - tokenIdentifier: semiFungibleTokenIdentifier1, - nonce: 1, - amount: 100, - }, - { - tokenIdentifier: semiFungibleTokenIdentifier2, - nonce: 2, - amount: 100, - }, - { - tokenIdentifier: semiFungibleTokenIdentifier1, - nonce: 2, - amount: 50, - }, - { - tokenIdentifier: semiFungibleTokenIdentifier2, - nonce: 1, - amount: 200, - }} - multiTransferToVault(t, net, senderNode, - vaultScAddress, transfers, nrRoundsToWait, - expectedIssuerBalance, expectedVaultBalance, - ) - - // transfer all 3 types - transfers = []*esdtTransfer{ - { - tokenIdentifier: fungibleTokenIdentifier1, - nonce: 0, - amount: 100, - }, - { - tokenIdentifier: semiFungibleTokenIdentifier2, - nonce: 2, - amount: 100, - }, - { - tokenIdentifier: nonFungibleTokenIdentifier1, - nonce: 7, - amount: 1, - }} - multiTransferToVault(t, net, senderNode, - vaultScAddress, transfers, nrRoundsToWait, - expectedIssuerBalance, expectedVaultBalance, - ) -} diff --git a/integrationTests/vm/esdt/multi-transfer/multiTransferCommon.go b/integrationTests/vm/esdt/multi-transfer/multiTransferCommon.go index f3ca482752e..ca4d62f5419 100644 --- a/integrationTests/vm/esdt/multi-transfer/multiTransferCommon.go +++ b/integrationTests/vm/esdt/multi-transfer/multiTransferCommon.go @@ -20,13 +20,15 @@ import ( const numRoundsCrossShard = 15 const numRoundsSameShard = 1 -type esdtTransfer struct { - tokenIdentifier string - nonce int64 - amount int64 +// EsdtTransfer - +type EsdtTransfer struct { + TokenIdentifier string + Nonce int64 + Amount int64 } -func issueFungibleToken( +// IssueFungibleToken - +func IssueFungibleToken( t *testing.T, net *integrationTests.TestNetwork, issuerNode *integrationTests.TestProcessorNode, @@ -48,7 +50,7 @@ func issueFungibleToken( issuePrice, vm.ESDTSCAddress, txData.ToString(), core.MinMetaTxExtraGasCost) - waitForOperationCompletion(net, numRoundsCrossShard) + WaitForOperationCompletion(net, numRoundsCrossShard) tokenIdentifier := integrationTests.GetTokenIdentifier(net.Nodes, []byte(ticker)) @@ -58,7 +60,8 @@ func issueFungibleToken( return string(tokenIdentifier) } -func issueNft( +// IssueNft - +func IssueNft( net *integrationTests.TestNetwork, issuerNode *integrationTests.TestProcessorNode, ticker string, @@ -85,7 +88,7 @@ func issueNft( vm.ESDTSCAddress, txData.ToString(), core.MinMetaTxExtraGasCost) - waitForOperationCompletion(net, numRoundsCrossShard) + WaitForOperationCompletion(net, numRoundsCrossShard) issuerAddress := issuerNode.OwnAccount.Address tokenIdentifier := string(integrationTests.GetTokenIdentifier(net.Nodes, []byte(ticker))) @@ -97,12 +100,13 @@ func issueNft( roles = append(roles, []byte(core.ESDTRoleNFTAddQuantity)) } - setLocalRoles(net, issuerNode, issuerAddress, tokenIdentifier, roles) + SetLocalRoles(net, issuerNode, issuerAddress, tokenIdentifier, roles) return tokenIdentifier } -func setLocalRoles( +// SetLocalRoles - +func SetLocalRoles( net *integrationTests.TestNetwork, issuerNode *integrationTests.TestProcessorNode, addrForRole []byte, @@ -124,10 +128,11 @@ func setLocalRoles( vm.ESDTSCAddress, txData, core.MinMetaTxExtraGasCost) - waitForOperationCompletion(net, numRoundsCrossShard) + WaitForOperationCompletion(net, numRoundsCrossShard) } -func createSFT( +// CreateSFT - +func CreateSFT( t *testing.T, net *integrationTests.TestNetwork, issuerNode *integrationTests.TestProcessorNode, @@ -161,13 +166,14 @@ func createSFT( issuerAddress, txData.ToString(), integrationTests.AdditionalGasLimit) - waitForOperationCompletion(net, numRoundsSameShard) + WaitForOperationCompletion(net, numRoundsSameShard) esdt.CheckAddressHasTokens(t, issuerAddress, net.Nodes, []byte(tokenIdentifier), createdTokenNonce, initialSupply) } -func createNFT( +// CreateNFT - +func CreateNFT( t *testing.T, net *integrationTests.TestNetwork, issuerNode *integrationTests.TestProcessorNode, @@ -175,12 +181,13 @@ func createNFT( createdTokenNonce int64, ) { - createSFT(t, net, issuerNode, tokenIdentifier, createdTokenNonce, 1) + CreateSFT(t, net, issuerNode, tokenIdentifier, createdTokenNonce, 1) } -func buildEsdtMultiTransferTxData( +// BuildEsdtMultiTransferTxData - +func BuildEsdtMultiTransferTxData( receiverAddress []byte, - transfers []*esdtTransfer, + transfers []*EsdtTransfer, endpointName string, arguments ...[]byte, ) string { @@ -193,9 +200,9 @@ func buildEsdtMultiTransferTxData( txData.Int(nrTransfers) for _, transfer := range transfers { - txData.Str(transfer.tokenIdentifier) - txData.Int64(transfer.nonce) - txData.Int64(transfer.amount) + txData.Str(transfer.TokenIdentifier) + txData.Int64(transfer.Nonce) + txData.Int64(transfer.Amount) } if len(endpointName) > 0 { @@ -209,17 +216,19 @@ func buildEsdtMultiTransferTxData( return txData.ToString() } -func waitForOperationCompletion(net *integrationTests.TestNetwork, roundsToWait int) { +// WaitForOperationCompletion - +func WaitForOperationCompletion(net *integrationTests.TestNetwork, roundsToWait int) { time.Sleep(time.Second) net.Steps(roundsToWait) } -func multiTransferToVault( +// MultiTransferToVault - +func MultiTransferToVault( t *testing.T, net *integrationTests.TestNetwork, senderNode *integrationTests.TestProcessorNode, vaultScAddress []byte, - transfers []*esdtTransfer, + transfers []*EsdtTransfer, nrRoundsToWait int, userBalances map[string]map[int64]int64, scBalances map[string]map[int64]int64, @@ -228,7 +237,7 @@ func multiTransferToVault( acceptMultiTransferEndpointName := "accept_funds_multi_transfer" senderAddress := senderNode.OwnAccount.Address - txData := buildEsdtMultiTransferTxData(vaultScAddress, + txData := BuildEsdtMultiTransferTxData(vaultScAddress, transfers, acceptMultiTransferEndpointName, ) @@ -241,27 +250,28 @@ func multiTransferToVault( txData, integrationTests.AdditionalGasLimit, ) - waitForOperationCompletion(net, nrRoundsToWait) + WaitForOperationCompletion(net, nrRoundsToWait) // update expected balances after transfers for _, transfer := range transfers { - userBalances[transfer.tokenIdentifier][transfer.nonce] -= transfer.amount - scBalances[transfer.tokenIdentifier][transfer.nonce] += transfer.amount + userBalances[transfer.TokenIdentifier][transfer.Nonce] -= transfer.Amount + scBalances[transfer.TokenIdentifier][transfer.Nonce] += transfer.Amount } // check expected vs actual values for _, transfer := range transfers { - expectedUserBalance := userBalances[transfer.tokenIdentifier][transfer.nonce] - expectedScBalance := scBalances[transfer.tokenIdentifier][transfer.nonce] + expectedUserBalance := userBalances[transfer.TokenIdentifier][transfer.Nonce] + expectedScBalance := scBalances[transfer.TokenIdentifier][transfer.Nonce] esdt.CheckAddressHasTokens(t, senderAddress, net.Nodes, - []byte(transfer.tokenIdentifier), transfer.nonce, expectedUserBalance) + []byte(transfer.TokenIdentifier), transfer.Nonce, expectedUserBalance) esdt.CheckAddressHasTokens(t, vaultScAddress, net.Nodes, - []byte(transfer.tokenIdentifier), transfer.nonce, expectedScBalance) + []byte(transfer.TokenIdentifier), transfer.Nonce, expectedScBalance) } } -func deployNonPayableSmartContract( +// DeployNonPayableSmartContract - +func DeployNonPayableSmartContract( t *testing.T, net *integrationTests.TestNetwork, deployerNode *integrationTests.TestProcessorNode, @@ -281,10 +291,323 @@ func deployNonPayableSmartContract( arwen.CreateDeployTxDataNonPayable(scCode), integrationTests.AdditionalGasLimit, ) - waitForOperationCompletion(net, 4) + WaitForOperationCompletion(net, 4) _, err := deployerNode.AccntState.GetExistingAccount(scAddress) require.Nil(t, err) return scAddress } + +// EsdtMultiTransferToVault - +func EsdtMultiTransferToVault(t *testing.T, crossShard bool, scCodeFilename string) { + if testing.Short() { + t.Skip("this is not a short test") + } + + // For cross shard, we use 2 nodes, with node[1] being the SC deployer, and node[0] being the caller + numShards := 1 + nrRoundsToWait := numRoundsSameShard + + if crossShard { + numShards = 2 + nrRoundsToWait = numRoundsCrossShard + } + + net := integrationTests.NewTestNetworkSized(t, numShards, 1, 1) + net.Start() + defer net.Close() + + net.MintNodeAccountsUint64(10000000000) + net.Step() + + senderNode := net.NodesSharded[0][0] + if crossShard { + senderNode = net.NodesSharded[1][0] + } + + expectedIssuerBalance := make(map[string]map[int64]int64) + expectedVaultBalance := make(map[string]map[int64]int64) + + // deploy vault SC + vaultScAddress := DeployNonPayableSmartContract(t, net, net.NodesSharded[0][0], scCodeFilename) + + // issue two fungible tokens + fungibleTokenIdentifier1 := IssueFungibleToken(t, net, senderNode, "FUNG1", 1000) + fungibleTokenIdentifier2 := IssueFungibleToken(t, net, senderNode, "FUNG2", 1000) + + expectedIssuerBalance[fungibleTokenIdentifier1] = make(map[int64]int64) + expectedIssuerBalance[fungibleTokenIdentifier2] = make(map[int64]int64) + expectedVaultBalance[fungibleTokenIdentifier1] = make(map[int64]int64) + expectedVaultBalance[fungibleTokenIdentifier2] = make(map[int64]int64) + + expectedIssuerBalance[fungibleTokenIdentifier1][0] = 1000 + expectedIssuerBalance[fungibleTokenIdentifier2][0] = 1000 + + // issue two NFT, with multiple NFTCreate + nonFungibleTokenIdentifier1 := IssueNft(net, senderNode, "NFT1", false) + nonFungibleTokenIdentifier2 := IssueNft(net, senderNode, "NFT2", false) + + expectedIssuerBalance[nonFungibleTokenIdentifier1] = make(map[int64]int64) + expectedIssuerBalance[nonFungibleTokenIdentifier2] = make(map[int64]int64) + + expectedVaultBalance[nonFungibleTokenIdentifier1] = make(map[int64]int64) + expectedVaultBalance[nonFungibleTokenIdentifier2] = make(map[int64]int64) + + for i := int64(1); i <= 10; i++ { + CreateNFT(t, net, senderNode, nonFungibleTokenIdentifier1, i) + CreateNFT(t, net, senderNode, nonFungibleTokenIdentifier2, i) + + expectedIssuerBalance[nonFungibleTokenIdentifier1][i] = 1 + expectedIssuerBalance[nonFungibleTokenIdentifier2][i] = 1 + } + + // issue two SFTs, with two NFTCreate for each + semiFungibleTokenIdentifier1 := IssueNft(net, senderNode, "SFT1", true) + semiFungibleTokenIdentifier2 := IssueNft(net, senderNode, "SFT2", true) + + expectedIssuerBalance[semiFungibleTokenIdentifier1] = make(map[int64]int64) + expectedIssuerBalance[semiFungibleTokenIdentifier2] = make(map[int64]int64) + + expectedVaultBalance[semiFungibleTokenIdentifier1] = make(map[int64]int64) + expectedVaultBalance[semiFungibleTokenIdentifier2] = make(map[int64]int64) + + for i := int64(1); i <= 2; i++ { + CreateSFT(t, net, senderNode, semiFungibleTokenIdentifier1, i, 1000) + CreateSFT(t, net, senderNode, semiFungibleTokenIdentifier2, i, 1000) + + expectedIssuerBalance[semiFungibleTokenIdentifier1][i] = 1000 + expectedIssuerBalance[semiFungibleTokenIdentifier2][i] = 1000 + } + + // send a single ESDT with multi-transfer + transfers := []*EsdtTransfer{ + { + TokenIdentifier: fungibleTokenIdentifier1, + Nonce: 0, + Amount: 100, + }} + MultiTransferToVault(t, net, senderNode, + vaultScAddress, transfers, nrRoundsToWait, + expectedIssuerBalance, expectedVaultBalance, + ) + + // send two identical transfers with multi-transfer + transfers = []*EsdtTransfer{ + { + TokenIdentifier: fungibleTokenIdentifier1, + Nonce: 0, + Amount: 50, + }, + { + TokenIdentifier: fungibleTokenIdentifier1, + Nonce: 0, + Amount: 50, + }} + MultiTransferToVault(t, net, senderNode, + vaultScAddress, transfers, nrRoundsToWait, + expectedIssuerBalance, expectedVaultBalance, + ) + + // send two different transfers amounts, same token + transfers = []*EsdtTransfer{ + { + TokenIdentifier: fungibleTokenIdentifier1, + Nonce: 0, + Amount: 50, + }, + { + TokenIdentifier: fungibleTokenIdentifier1, + Nonce: 0, + Amount: 100, + }} + MultiTransferToVault(t, net, senderNode, + vaultScAddress, transfers, nrRoundsToWait, + expectedIssuerBalance, expectedVaultBalance, + ) + + // send two different tokens, same amount + transfers = []*EsdtTransfer{ + { + TokenIdentifier: fungibleTokenIdentifier1, + Nonce: 0, + Amount: 100, + }, + { + TokenIdentifier: fungibleTokenIdentifier2, + Nonce: 0, + Amount: 100, + }} + MultiTransferToVault(t, net, senderNode, + vaultScAddress, transfers, nrRoundsToWait, + expectedIssuerBalance, expectedVaultBalance, + ) + + // send single NFT + transfers = []*EsdtTransfer{ + { + TokenIdentifier: nonFungibleTokenIdentifier1, + Nonce: 1, + Amount: 1, + }} + MultiTransferToVault(t, net, senderNode, + vaultScAddress, transfers, nrRoundsToWait, + expectedIssuerBalance, expectedVaultBalance, + ) + + // send two NFTs, same token ID + transfers = []*EsdtTransfer{ + { + TokenIdentifier: nonFungibleTokenIdentifier1, + Nonce: 2, + Amount: 1, + }, + { + TokenIdentifier: nonFungibleTokenIdentifier1, + Nonce: 3, + Amount: 1, + }} + MultiTransferToVault(t, net, senderNode, + vaultScAddress, transfers, nrRoundsToWait, + expectedIssuerBalance, expectedVaultBalance, + ) + + // send two NFTs, different token ID + transfers = []*EsdtTransfer{ + { + TokenIdentifier: nonFungibleTokenIdentifier1, + Nonce: 4, + Amount: 1, + }, + { + TokenIdentifier: nonFungibleTokenIdentifier2, + Nonce: 1, + Amount: 1, + }} + MultiTransferToVault(t, net, senderNode, + vaultScAddress, transfers, nrRoundsToWait, + expectedIssuerBalance, expectedVaultBalance, + ) + + // send fours NFTs, two of each different token ID + transfers = []*EsdtTransfer{ + { + TokenIdentifier: nonFungibleTokenIdentifier1, + Nonce: 5, + Amount: 1, + }, + { + TokenIdentifier: nonFungibleTokenIdentifier2, + Nonce: 2, + Amount: 1, + }, + { + TokenIdentifier: nonFungibleTokenIdentifier1, + Nonce: 6, + Amount: 1, + }, + { + TokenIdentifier: nonFungibleTokenIdentifier2, + Nonce: 3, + Amount: 1, + }} + MultiTransferToVault(t, net, senderNode, + vaultScAddress, transfers, nrRoundsToWait, + expectedIssuerBalance, expectedVaultBalance, + ) + + // send single SFT + transfers = []*EsdtTransfer{ + { + TokenIdentifier: semiFungibleTokenIdentifier1, + Nonce: 1, + Amount: 100, + }} + MultiTransferToVault(t, net, senderNode, + vaultScAddress, transfers, nrRoundsToWait, + expectedIssuerBalance, expectedVaultBalance, + ) + + // send two SFTs, same token ID + transfers = []*EsdtTransfer{ + { + TokenIdentifier: semiFungibleTokenIdentifier1, + Nonce: 1, + Amount: 100, + }, + { + TokenIdentifier: semiFungibleTokenIdentifier1, + Nonce: 2, + Amount: 100, + }} + MultiTransferToVault(t, net, senderNode, + vaultScAddress, transfers, nrRoundsToWait, + expectedIssuerBalance, expectedVaultBalance, + ) + + // send two SFTs, different token ID + transfers = []*EsdtTransfer{ + { + TokenIdentifier: semiFungibleTokenIdentifier1, + Nonce: 1, + Amount: 100, + }, + { + TokenIdentifier: semiFungibleTokenIdentifier2, + Nonce: 1, + Amount: 100, + }} + MultiTransferToVault(t, net, senderNode, + vaultScAddress, transfers, nrRoundsToWait, + expectedIssuerBalance, expectedVaultBalance, + ) + + // send fours SFTs, two of each different token ID + transfers = []*EsdtTransfer{ + { + TokenIdentifier: semiFungibleTokenIdentifier1, + Nonce: 1, + Amount: 100, + }, + { + TokenIdentifier: semiFungibleTokenIdentifier2, + Nonce: 2, + Amount: 100, + }, + { + TokenIdentifier: semiFungibleTokenIdentifier1, + Nonce: 2, + Amount: 50, + }, + { + TokenIdentifier: semiFungibleTokenIdentifier2, + Nonce: 1, + Amount: 200, + }} + MultiTransferToVault(t, net, senderNode, + vaultScAddress, transfers, nrRoundsToWait, + expectedIssuerBalance, expectedVaultBalance, + ) + + // transfer all 3 types + transfers = []*EsdtTransfer{ + { + TokenIdentifier: fungibleTokenIdentifier1, + Nonce: 0, + Amount: 100, + }, + { + TokenIdentifier: semiFungibleTokenIdentifier2, + Nonce: 2, + Amount: 100, + }, + { + TokenIdentifier: nonFungibleTokenIdentifier1, + Nonce: 7, + Amount: 1, + }} + MultiTransferToVault(t, net, senderNode, + vaultScAddress, transfers, nrRoundsToWait, + expectedIssuerBalance, expectedVaultBalance, + ) +} diff --git a/integrationTests/vm/esdt/nft/common.go b/integrationTests/vm/esdt/nft/common.go new file mode 100644 index 00000000000..b1762095f34 --- /dev/null +++ b/integrationTests/vm/esdt/nft/common.go @@ -0,0 +1,122 @@ +package nft + +import ( + "encoding/hex" + "fmt" + "math/big" + "testing" + "time" + + "github.com/ElrondNetwork/elrond-go-core/core" + "github.com/ElrondNetwork/elrond-go/integrationTests" + "github.com/ElrondNetwork/elrond-go/integrationTests/vm/esdt" + "github.com/stretchr/testify/require" +) + +// NftArguments - +type NftArguments struct { + Name []byte + Quantity int64 + Royalties int64 + Hash []byte + Attributes []byte + URI [][]byte +} + +// CreateNFT - +func CreateNFT(tokenIdentifier []byte, issuer *integrationTests.TestProcessorNode, nodes []*integrationTests.TestProcessorNode, args *NftArguments) { + txData := fmt.Sprintf("%s@%s@%s@%s@%s@%s@%s@%s@", + core.BuiltInFunctionESDTNFTCreate, + hex.EncodeToString(tokenIdentifier), + hex.EncodeToString(big.NewInt(args.Quantity).Bytes()), + hex.EncodeToString(args.Name), + hex.EncodeToString(big.NewInt(args.Royalties).Bytes()), + hex.EncodeToString(args.Hash), + hex.EncodeToString(args.Attributes), + hex.EncodeToString(args.URI[0]), + ) + + integrationTests.CreateAndSendTransaction(issuer, nodes, big.NewInt(0), issuer.OwnAccount.Address, txData, integrationTests.AdditionalGasLimit) +} + +// CheckNftData - +func CheckNftData( + t *testing.T, + creator []byte, + address []byte, + nodes []*integrationTests.TestProcessorNode, + tickerID []byte, + args *NftArguments, + nonce uint64, +) { + esdtData := esdt.GetESDTTokenData(t, address, nodes, tickerID, nonce) + + if args.Quantity == 0 { + require.Nil(t, esdtData.TokenMetaData) + return + } + + require.NotNil(t, esdtData.TokenMetaData) + require.Equal(t, creator, esdtData.TokenMetaData.Creator) + require.Equal(t, args.URI[0], esdtData.TokenMetaData.URIs[0]) + require.Equal(t, args.Attributes, esdtData.TokenMetaData.Attributes) + require.Equal(t, args.Name, esdtData.TokenMetaData.Name) + require.Equal(t, args.Hash, esdtData.TokenMetaData.Hash) + require.Equal(t, uint32(args.Royalties), esdtData.TokenMetaData.Royalties) + require.Equal(t, big.NewInt(args.Quantity).Bytes(), esdtData.Value.Bytes()) +} + +// PrepareNFTWithRoles - +func PrepareNFTWithRoles( + t *testing.T, + nodes []*integrationTests.TestProcessorNode, + idxProposers []int, + nftCreator *integrationTests.TestProcessorNode, + round *uint64, + nonce *uint64, + esdtType string, + quantity int64, + roles [][]byte, +) (string, *NftArguments) { + esdt.IssueNFT(nodes, esdtType, "SFT") + + time.Sleep(time.Second) + nrRoundsToPropagateMultiShard := 10 + *nonce, *round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, *nonce, *round, idxProposers) + time.Sleep(time.Second) + + tokenIdentifier := string(integrationTests.GetTokenIdentifier(nodes, []byte("SFT"))) + + // ----- set special roles + esdt.SetRoles(nodes, nftCreator.OwnAccount.Address, []byte(tokenIdentifier), roles) + + time.Sleep(time.Second) + *nonce, *round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, *nonce, *round, idxProposers) + time.Sleep(time.Second) + + nftMetaData := NftArguments{ + Name: []byte("nft name"), + Quantity: quantity, + Royalties: 9000, + Hash: []byte("hash"), + Attributes: []byte("attr"), + URI: [][]byte{[]byte("uri")}, + } + CreateNFT([]byte(tokenIdentifier), nftCreator, nodes, &nftMetaData) + + time.Sleep(time.Second) + *nonce, *round = integrationTests.WaitOperationToBeDone(t, nodes, 3, *nonce, *round, idxProposers) + time.Sleep(time.Second) + + CheckNftData( + t, + nftCreator.OwnAccount.Address, + nftCreator.OwnAccount.Address, + nodes, + []byte(tokenIdentifier), + &nftMetaData, + 1, + ) + + return tokenIdentifier, &nftMetaData +} diff --git a/integrationTests/vm/esdt/nft/esdtNft_test.go b/integrationTests/vm/esdt/nft/esdtNFT/esdtNft_test.go similarity index 82% rename from integrationTests/vm/esdt/nft/esdtNft_test.go rename to integrationTests/vm/esdt/nft/esdtNFT/esdtNft_test.go index 6f215519b63..3f538fbe580 100644 --- a/integrationTests/vm/esdt/nft/esdtNft_test.go +++ b/integrationTests/vm/esdt/nft/esdtNFT/esdtNft_test.go @@ -1,12 +1,11 @@ //go:build !race // +build !race -package nft +package esdtNFT import ( "bytes" "encoding/hex" - "fmt" "math/big" "testing" "time" @@ -14,8 +13,8 @@ import ( "github.com/ElrondNetwork/elrond-go-core/core" "github.com/ElrondNetwork/elrond-go/integrationTests" "github.com/ElrondNetwork/elrond-go/integrationTests/vm/esdt" + "github.com/ElrondNetwork/elrond-go/integrationTests/vm/esdt/nft" "github.com/ElrondNetwork/elrond-go/vm" - "github.com/stretchr/testify/require" ) func TestESDTNonFungibleTokenCreateAndBurn(t *testing.T) { @@ -60,7 +59,7 @@ func TestESDTNonFungibleTokenCreateAndBurn(t *testing.T) { []byte(core.ESDTRoleNFTBurn), } - tokenIdentifier, nftMetaData := prepareNFTWithRoles( + tokenIdentifier, nftMetaData := nft.PrepareNFTWithRoles( t, nodes, idxProposers, @@ -93,8 +92,8 @@ func TestESDTNonFungibleTokenCreateAndBurn(t *testing.T) { time.Sleep(time.Second) // the token data is removed from trie if the quantity is 0, so we should not find it - nftMetaData.quantity = 0 - checkNftData( + nftMetaData.Quantity = 0 + nft.CheckNftData( t, nodes[1].OwnAccount.Address, nodes[1].OwnAccount.Address, @@ -149,7 +148,7 @@ func TestESDTSemiFungibleTokenCreateAddAndBurn(t *testing.T) { } initialQuantity := int64(5) - tokenIdentifier, nftMetaData := prepareNFTWithRoles( + tokenIdentifier, nftMetaData := nft.PrepareNFTWithRoles( t, nodes, idxProposers, @@ -181,8 +180,8 @@ func TestESDTSemiFungibleTokenCreateAddAndBurn(t *testing.T) { nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) time.Sleep(time.Second) - nftMetaData.quantity += quantityToAdd - checkNftData( + nftMetaData.Quantity += quantityToAdd + nft.CheckNftData( t, nodes[1].OwnAccount.Address, nodes[1].OwnAccount.Address, @@ -197,7 +196,7 @@ func TestESDTSemiFungibleTokenCreateAddAndBurn(t *testing.T) { nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) time.Sleep(time.Second) - checkNftData( + nft.CheckNftData( t, nodes[1].OwnAccount.Address, nodes[1].OwnAccount.Address, @@ -226,8 +225,8 @@ func TestESDTSemiFungibleTokenCreateAddAndBurn(t *testing.T) { nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) time.Sleep(time.Second) - nftMetaData.quantity -= quantityToBurn - checkNftData( + nftMetaData.Quantity -= quantityToBurn + nft.CheckNftData( t, nodes[1].OwnAccount.Address, nodes[1].OwnAccount.Address, @@ -279,7 +278,7 @@ func TestESDTNonFungibleTokenTransferSelfShard(t *testing.T) { []byte(core.ESDTRoleNFTCreate), []byte(core.ESDTRoleNFTBurn), } - tokenIdentifier, nftMetaData := prepareNFTWithRoles( + tokenIdentifier, nftMetaData := nft.PrepareNFTWithRoles( t, nodes, idxProposers, @@ -323,7 +322,7 @@ func TestESDTNonFungibleTokenTransferSelfShard(t *testing.T) { time.Sleep(time.Second) // check that the new address owns the NFT - checkNftData( + nft.CheckNftData( t, nodes[1].OwnAccount.Address, nodeInSameShard.OwnAccount.Address, @@ -334,8 +333,8 @@ func TestESDTNonFungibleTokenTransferSelfShard(t *testing.T) { ) // check that the creator doesn't has the token data in trie anymore - nftMetaData.quantity = 0 - checkNftData( + nftMetaData.Quantity = 0 + nft.CheckNftData( t, nodes[1].OwnAccount.Address, nodes[1].OwnAccount.Address, @@ -399,7 +398,7 @@ func TestESDTSemiFungibleTokenTransferCrossShard(t *testing.T) { } initialQuantity := int64(5) - tokenIdentifier, nftMetaData := prepareNFTWithRoles( + tokenIdentifier, nftMetaData := nft.PrepareNFTWithRoles( t, nodes, idxProposers, @@ -431,8 +430,8 @@ func TestESDTSemiFungibleTokenTransferCrossShard(t *testing.T) { nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) time.Sleep(time.Second) - nftMetaData.quantity += quantityToAdd - checkNftData( + nftMetaData.Quantity += quantityToAdd + nft.CheckNftData( t, nodeInDifferentShard.OwnAccount.Address, nodeInDifferentShard.OwnAccount.Address, @@ -447,7 +446,7 @@ func TestESDTSemiFungibleTokenTransferCrossShard(t *testing.T) { nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) time.Sleep(time.Second) - checkNftData( + nft.CheckNftData( t, nodeInDifferentShard.OwnAccount.Address, nodeInDifferentShard.OwnAccount.Address, @@ -476,8 +475,8 @@ func TestESDTSemiFungibleTokenTransferCrossShard(t *testing.T) { nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) time.Sleep(time.Second) - nftMetaData.quantity = initialQuantity + quantityToAdd - quantityToTransfer - checkNftData( + nftMetaData.Quantity = initialQuantity + quantityToAdd - quantityToTransfer + nft.CheckNftData( t, nodeInDifferentShard.OwnAccount.Address, nodeInDifferentShard.OwnAccount.Address, @@ -487,8 +486,8 @@ func TestESDTSemiFungibleTokenTransferCrossShard(t *testing.T) { 1, ) - nftMetaData.quantity = quantityToTransfer - checkNftData( + nftMetaData.Quantity = quantityToTransfer + nft.CheckNftData( t, nodeInDifferentShard.OwnAccount.Address, nodes[0].OwnAccount.Address, @@ -543,7 +542,7 @@ func TestESDTSemiFungibleTokenTransferToSystemScAddressShouldReceiveBack(t *test } initialQuantity := int64(5) - tokenIdentifier, nftMetaData := prepareNFTWithRoles( + tokenIdentifier, nftMetaData := nft.PrepareNFTWithRoles( t, nodes, idxProposers, @@ -575,8 +574,8 @@ func TestESDTSemiFungibleTokenTransferToSystemScAddressShouldReceiveBack(t *test nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) time.Sleep(time.Second) - nftMetaData.quantity += quantityToAdd - checkNftData( + nftMetaData.Quantity += quantityToAdd + nft.CheckNftData( t, nodes[0].OwnAccount.Address, nodes[0].OwnAccount.Address, @@ -591,7 +590,7 @@ func TestESDTSemiFungibleTokenTransferToSystemScAddressShouldReceiveBack(t *test nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) time.Sleep(time.Second) - checkNftData( + nft.CheckNftData( t, nodes[0].OwnAccount.Address, nodes[0].OwnAccount.Address, @@ -620,8 +619,8 @@ func TestESDTSemiFungibleTokenTransferToSystemScAddressShouldReceiveBack(t *test nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) time.Sleep(time.Second) - nftMetaData.quantity = 0 // make sure that the ESDT SC address didn't receive the token - checkNftData( + nftMetaData.Quantity = 0 // make sure that the ESDT SC address didn't receive the token + nft.CheckNftData( t, nodes[0].OwnAccount.Address, vm.ESDTSCAddress, @@ -631,8 +630,8 @@ func TestESDTSemiFungibleTokenTransferToSystemScAddressShouldReceiveBack(t *test 1, ) - nftMetaData.quantity = initialQuantity + quantityToAdd // should have the same quantity like before transferring - checkNftData( + nftMetaData.Quantity = initialQuantity + quantityToAdd // should have the same quantity like before transferring + nft.CheckNftData( t, nodes[0].OwnAccount.Address, nodes[0].OwnAccount.Address, @@ -666,7 +665,7 @@ func testNFTSendCreateRole(t *testing.T, numOfShards int) { nftCreator := nodes[0] initialQuantity := int64(1) - tokenIdentifier, nftMetaData := prepareNFTWithRoles( + tokenIdentifier, nftMetaData := nft.PrepareNFTWithRoles( t, nodes, idxProposers, @@ -705,7 +704,7 @@ func testNFTSendCreateRole(t *testing.T, numOfShards int) { nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) time.Sleep(time.Second) - createNFT( + nft.CreateNFT( []byte(tokenIdentifier), nextNftCreator, nodes, @@ -717,7 +716,7 @@ func testNFTSendCreateRole(t *testing.T, numOfShards int) { nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) time.Sleep(time.Second) - checkNftData( + nft.CheckNftData( t, nextNftCreator.OwnAccount.Address, nextNftCreator.OwnAccount.Address, @@ -809,7 +808,7 @@ func testESDTSemiFungibleTokenTransferRole(t *testing.T, numOfShards int) { } initialQuantity := int64(5) - tokenIdentifier, nftMetaData := prepareNFTWithRoles( + tokenIdentifier, nftMetaData := nft.PrepareNFTWithRoles( t, nodes, idxProposers, @@ -841,8 +840,8 @@ func testESDTSemiFungibleTokenTransferRole(t *testing.T, numOfShards int) { nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) time.Sleep(time.Second) - nftMetaData.quantity += quantityToAdd - checkNftData( + nftMetaData.Quantity += quantityToAdd + nft.CheckNftData( t, nodeInDifferentShard.OwnAccount.Address, nodeInDifferentShard.OwnAccount.Address, @@ -857,7 +856,7 @@ func testESDTSemiFungibleTokenTransferRole(t *testing.T, numOfShards int) { nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) time.Sleep(time.Second) - checkNftData( + nft.CheckNftData( t, nodeInDifferentShard.OwnAccount.Address, nodeInDifferentShard.OwnAccount.Address, @@ -886,8 +885,8 @@ func testESDTSemiFungibleTokenTransferRole(t *testing.T, numOfShards int) { nonce, round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, nonce, round, idxProposers) time.Sleep(time.Second) - nftMetaData.quantity = initialQuantity + quantityToAdd - quantityToTransfer - checkNftData( + nftMetaData.Quantity = initialQuantity + quantityToAdd - quantityToTransfer + nft.CheckNftData( t, nodeInDifferentShard.OwnAccount.Address, nodeInDifferentShard.OwnAccount.Address, @@ -897,8 +896,8 @@ func testESDTSemiFungibleTokenTransferRole(t *testing.T, numOfShards int) { 1, ) - nftMetaData.quantity = quantityToTransfer - checkNftData( + nftMetaData.Quantity = quantityToTransfer + nft.CheckNftData( t, nodeInDifferentShard.OwnAccount.Address, nodes[0].OwnAccount.Address, @@ -908,107 +907,3 @@ func testESDTSemiFungibleTokenTransferRole(t *testing.T, numOfShards int) { 1, ) } - -func prepareNFTWithRoles( - t *testing.T, - nodes []*integrationTests.TestProcessorNode, - idxProposers []int, - nftCreator *integrationTests.TestProcessorNode, - round *uint64, - nonce *uint64, - esdtType string, - quantity int64, - roles [][]byte, -) (string, *nftArguments) { - esdt.IssueNFT(nodes, esdtType, "SFT") - - time.Sleep(time.Second) - nrRoundsToPropagateMultiShard := 10 - *nonce, *round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, *nonce, *round, idxProposers) - time.Sleep(time.Second) - - tokenIdentifier := string(integrationTests.GetTokenIdentifier(nodes, []byte("SFT"))) - - // ----- set special roles - esdt.SetRoles(nodes, nftCreator.OwnAccount.Address, []byte(tokenIdentifier), roles) - - time.Sleep(time.Second) - *nonce, *round = integrationTests.WaitOperationToBeDone(t, nodes, nrRoundsToPropagateMultiShard, *nonce, *round, idxProposers) - time.Sleep(time.Second) - - nftMetaData := nftArguments{ - name: []byte("nft name"), - quantity: quantity, - royalties: 9000, - hash: []byte("hash"), - attributes: []byte("attr"), - uri: [][]byte{[]byte("uri")}, - } - createNFT([]byte(tokenIdentifier), nftCreator, nodes, &nftMetaData) - - time.Sleep(time.Second) - *nonce, *round = integrationTests.WaitOperationToBeDone(t, nodes, 3, *nonce, *round, idxProposers) - time.Sleep(time.Second) - - checkNftData( - t, - nftCreator.OwnAccount.Address, - nftCreator.OwnAccount.Address, - nodes, - []byte(tokenIdentifier), - &nftMetaData, - 1, - ) - - return tokenIdentifier, &nftMetaData -} - -type nftArguments struct { - name []byte - quantity int64 - royalties int64 - hash []byte - attributes []byte - uri [][]byte -} - -func createNFT(tokenIdentifier []byte, issuer *integrationTests.TestProcessorNode, nodes []*integrationTests.TestProcessorNode, args *nftArguments) { - txData := fmt.Sprintf("%s@%s@%s@%s@%s@%s@%s@%s@", - core.BuiltInFunctionESDTNFTCreate, - hex.EncodeToString(tokenIdentifier), - hex.EncodeToString(big.NewInt(args.quantity).Bytes()), - hex.EncodeToString(args.name), - hex.EncodeToString(big.NewInt(args.royalties).Bytes()), - hex.EncodeToString(args.hash), - hex.EncodeToString(args.attributes), - hex.EncodeToString(args.uri[0]), - ) - - integrationTests.CreateAndSendTransaction(issuer, nodes, big.NewInt(0), issuer.OwnAccount.Address, txData, integrationTests.AdditionalGasLimit) -} - -func checkNftData( - t *testing.T, - creator []byte, - address []byte, - nodes []*integrationTests.TestProcessorNode, - tickerID []byte, - args *nftArguments, - nonce uint64, -) { - esdtData := esdt.GetESDTTokenData(t, address, nodes, tickerID, nonce) - - if args.quantity == 0 { - require.Nil(t, esdtData.TokenMetaData) - return - } - - require.NotNil(t, esdtData.TokenMetaData) - require.Equal(t, creator, esdtData.TokenMetaData.Creator) - require.Equal(t, args.uri[0], esdtData.TokenMetaData.URIs[0]) - require.Equal(t, args.attributes, esdtData.TokenMetaData.Attributes) - require.Equal(t, args.name, esdtData.TokenMetaData.Name) - require.Equal(t, args.hash, esdtData.TokenMetaData.Hash) - require.Equal(t, uint32(args.royalties), esdtData.TokenMetaData.Royalties) - require.Equal(t, big.NewInt(args.quantity).Bytes(), esdtData.Value.Bytes()) -} diff --git a/integrationTests/vm/esdt/nft/esdtNFTSCs_test.go b/integrationTests/vm/esdt/nft/esdtNFTSCs/esdtNFTSCs_test.go similarity index 98% rename from integrationTests/vm/esdt/nft/esdtNFTSCs_test.go rename to integrationTests/vm/esdt/nft/esdtNFTSCs/esdtNFTSCs_test.go index 25ffddbe1b6..2794c0aa8fa 100644 --- a/integrationTests/vm/esdt/nft/esdtNFTSCs_test.go +++ b/integrationTests/vm/esdt/nft/esdtNFTSCs/esdtNFTSCs_test.go @@ -1,6 +1,7 @@ +//go:build !race // +build !race -package nft +package esdtNFTSCs import ( "encoding/hex" @@ -11,6 +12,7 @@ import ( "github.com/ElrondNetwork/elrond-go-core/core" "github.com/ElrondNetwork/elrond-go/integrationTests" "github.com/ElrondNetwork/elrond-go/integrationTests/vm/esdt" + "github.com/ElrondNetwork/elrond-go/integrationTests/vm/esdt/nft" "github.com/stretchr/testify/require" ) @@ -292,7 +294,7 @@ func TestESDTTransferNFTBetweenContractsAcceptAndNotAcceptWithRevert(t *testing. checkAddressHasNft(t, scAddress, scAddress, nodes, []byte(tokenIdentifier), 2, big.NewInt(1)) checkAddressHasNft(t, scAddress, scAddress, nodes, []byte(tokenIdentifier), 1, big.NewInt(1)) - destinationSCAddress := esdt.DeployNonPayableSmartContract(t, nodes, idxProposers, &nonce, &round, "../testdata/nft-receiver.wasm") + destinationSCAddress := esdt.DeployNonPayableSmartContract(t, nodes, idxProposers, &nonce, &round, "../../testdata/nft-receiver.wasm") txData = []byte("transferNftViaAsyncCall" + "@" + hex.EncodeToString(destinationSCAddress) + "@" + hex.EncodeToString([]byte(tokenIdentifier)) + "@" + hex.EncodeToString(big.NewInt(1).Bytes()) + "@" + hex.EncodeToString(big.NewInt(1).Bytes()) + "@" + hex.EncodeToString([]byte("wrongFunctionToCall"))) @@ -382,7 +384,7 @@ func TestESDTTransferNFTToSCIntraShard(t *testing.T) { []byte(core.ESDTRoleNFTCreate), []byte(core.ESDTRoleNFTBurn), } - tokenIdentifier, _ := prepareNFTWithRoles( + tokenIdentifier, _ := nft.PrepareNFTWithRoles( t, nodes, idxProposers, @@ -452,7 +454,7 @@ func TestESDTTransferNFTToSCCrossShard(t *testing.T) { []byte(core.ESDTRoleNFTCreate), []byte(core.ESDTRoleNFTBurn), } - tokenIdentifier, _ := prepareNFTWithRoles( + tokenIdentifier, _ := nft.PrepareNFTWithRoles( t, nodes, idxProposers, @@ -528,7 +530,7 @@ func deployAndIssueNFTSFTThroughSC( issueFunc string, rolesEncoded string, ) ([]byte, string) { - scAddress := esdt.DeployNonPayableSmartContract(t, nodes, idxProposers, nonce, round, "../testdata/local-esdt-and-nft.wasm") + scAddress := esdt.DeployNonPayableSmartContract(t, nodes, idxProposers, nonce, round, "../../testdata/local-esdt-and-nft.wasm") issuePrice := big.NewInt(1000) txData := []byte(issueFunc + "@" + hex.EncodeToString([]byte("TOKEN")) + From bf604959a0e667c6f496063f70a48d68081e772b Mon Sep 17 00:00:00 2001 From: Iulian Pascalau Date: Thu, 28 Apr 2022 12:34:54 +0300 Subject: [PATCH 35/43] - fixed one more integration test --- integrationTests/vm/esdt/nft/esdtNFTSCs/esdtNFTSCs_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integrationTests/vm/esdt/nft/esdtNFTSCs/esdtNFTSCs_test.go b/integrationTests/vm/esdt/nft/esdtNFTSCs/esdtNFTSCs_test.go index 2794c0aa8fa..699a0bd4544 100644 --- a/integrationTests/vm/esdt/nft/esdtNFTSCs/esdtNFTSCs_test.go +++ b/integrationTests/vm/esdt/nft/esdtNFTSCs/esdtNFTSCs_test.go @@ -398,7 +398,7 @@ func TestESDTTransferNFTToSCIntraShard(t *testing.T) { nonceArg := hex.EncodeToString(big.NewInt(0).SetUint64(1).Bytes()) quantityToTransfer := hex.EncodeToString(big.NewInt(1).Bytes()) - destinationSCAddress := esdt.DeployNonPayableSmartContract(t, nodes, idxProposers, &nonce, &round, "../testdata/nft-receiver.wasm") + destinationSCAddress := esdt.DeployNonPayableSmartContract(t, nodes, idxProposers, &nonce, &round, "../../testdata/nft-receiver.wasm") txData := core.BuiltInFunctionESDTNFTTransfer + "@" + hex.EncodeToString([]byte(tokenIdentifier)) + "@" + nonceArg + "@" + quantityToTransfer + "@" + hex.EncodeToString(destinationSCAddress) + "@" + hex.EncodeToString([]byte("acceptAndReturnCallData")) integrationTests.CreateAndSendTransaction( @@ -437,7 +437,7 @@ func TestESDTTransferNFTToSCCrossShard(t *testing.T) { round = integrationTests.IncrementAndPrintRound(round) nonce++ - destinationSCAddress := esdt.DeployNonPayableSmartContract(t, nodes, idxProposers, &nonce, &round, "../testdata/nft-receiver.wasm") + destinationSCAddress := esdt.DeployNonPayableSmartContract(t, nodes, idxProposers, &nonce, &round, "../../testdata/nft-receiver.wasm") destinationSCShardID := nodes[0].ShardCoordinator.ComputeId(destinationSCAddress) From eec08d722e7559151fdd46e10e996b58ffd753bd Mon Sep 17 00:00:00 2001 From: Iulian Pascalau Date: Thu, 28 Apr 2022 17:14:56 +0300 Subject: [PATCH 36/43] - added new status metric in network/status endpoint --- statusHandler/statusMetricsProvider.go | 9 ++++++++- statusHandler/statusMetricsProvider_test.go | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/statusHandler/statusMetricsProvider.go b/statusHandler/statusMetricsProvider.go index b4222c2edf7..867ae08458d 100644 --- a/statusHandler/statusMetricsProvider.go +++ b/statusHandler/statusMetricsProvider.go @@ -263,7 +263,6 @@ func (sm *statusMetrics) EnableEpochsMetrics() map[string]interface{} { // NetworkMetrics will return metrics related to current configuration func (sm *statusMetrics) NetworkMetrics() map[string]interface{} { sm.mutUint64Operations.RLock() - defer sm.mutUint64Operations.RUnlock() networkMetrics := make(map[string]interface{}) @@ -290,6 +289,14 @@ func (sm *statusMetrics) NetworkMetrics() map[string]interface{} { noncesPassedInEpoch = currentNonce - nonceAtEpochStart } networkMetrics[common.MetricNoncesPassedInCurrentEpoch] = noncesPassedInEpoch + sm.mutUint64Operations.RUnlock() + + sm.mutStringOperations.RLock() + crossCheckValue := sm.stringMetrics[common.MetricCrossCheckBlockHeight] + if len(crossCheckValue) > 0 { + networkMetrics[common.MetricCrossCheckBlockHeight] = crossCheckValue + } + sm.mutStringOperations.RUnlock() return networkMetrics } diff --git a/statusHandler/statusMetricsProvider_test.go b/statusHandler/statusMetricsProvider_test.go index ff13928d315..1ff9f0d58c2 100644 --- a/statusHandler/statusMetricsProvider_test.go +++ b/statusHandler/statusMetricsProvider_test.go @@ -223,8 +223,18 @@ func TestStatusMetrics_NetworkMetrics(t *testing.T) { "erd_nonces_passed_in_current_epoch": uint64(85), } - configMetrics := sm.NetworkMetrics() - assert.Equal(t, expectedConfig, configMetrics) + t.Run("no cross check value", func(t *testing.T) { + configMetrics := sm.NetworkMetrics() + assert.Equal(t, expectedConfig, configMetrics) + }) + t.Run("with cross check value", func(t *testing.T) { + crossCheckValue := "0: 9169897, 1: 9166353, 2: 9170524, " + sm.SetStringValue(common.MetricCrossCheckBlockHeight, crossCheckValue) + + configMetrics := sm.NetworkMetrics() + expectedConfig[common.MetricCrossCheckBlockHeight] = crossCheckValue + assert.Equal(t, expectedConfig, configMetrics) + }) } func TestStatusMetrics_EnableEpochMetrics(t *testing.T) { @@ -393,5 +403,5 @@ func TestStatusMetrics_ConcurrentOperations(t *testing.T) { wg.Wait() elapsedTime := time.Since(startTime) - require.True(t, elapsedTime < 10 * time.Second, "if the test isn't finished within 10 seconds, there might be a deadlock somewhere") + require.True(t, elapsedTime < 10*time.Second, "if the test isn't finished within 10 seconds, there might be a deadlock somewhere") } From ef390b39f9e919e5801d304547866818ea6e32ba Mon Sep 17 00:00:00 2001 From: Iulian Pascalau Date: Thu, 28 Apr 2022 17:22:42 +0300 Subject: [PATCH 37/43] - code refactoring --- statusHandler/statusMetricsProvider.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/statusHandler/statusMetricsProvider.go b/statusHandler/statusMetricsProvider.go index 867ae08458d..03c3ee828b9 100644 --- a/statusHandler/statusMetricsProvider.go +++ b/statusHandler/statusMetricsProvider.go @@ -262,10 +262,18 @@ func (sm *statusMetrics) EnableEpochsMetrics() map[string]interface{} { // NetworkMetrics will return metrics related to current configuration func (sm *statusMetrics) NetworkMetrics() map[string]interface{} { - sm.mutUint64Operations.RLock() - networkMetrics := make(map[string]interface{}) + sm.saveUint64MetricsInMap(networkMetrics) + sm.saveStringMetricsInMap(networkMetrics) + + return networkMetrics +} + +func (sm *statusMetrics) saveUint64MetricsInMap(networkMetrics map[string]interface{}) { + sm.mutUint64Operations.RLock() + defer sm.mutUint64Operations.RUnlock() + currentRound := sm.uint64Metrics[common.MetricCurrentRound] roundNumberAtEpochStart := sm.uint64Metrics[common.MetricRoundAtEpochStart] @@ -289,14 +297,14 @@ func (sm *statusMetrics) NetworkMetrics() map[string]interface{} { noncesPassedInEpoch = currentNonce - nonceAtEpochStart } networkMetrics[common.MetricNoncesPassedInCurrentEpoch] = noncesPassedInEpoch - sm.mutUint64Operations.RUnlock() +} +func (sm *statusMetrics) saveStringMetricsInMap(networkMetrics map[string]interface{}) { sm.mutStringOperations.RLock() + defer sm.mutStringOperations.RUnlock() + crossCheckValue := sm.stringMetrics[common.MetricCrossCheckBlockHeight] if len(crossCheckValue) > 0 { networkMetrics[common.MetricCrossCheckBlockHeight] = crossCheckValue } - sm.mutStringOperations.RUnlock() - - return networkMetrics } From 34e2006d08bccdd01009202dde2f479f064fedc0 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Mon, 2 May 2022 17:36:20 +0300 Subject: [PATCH 38/43] indexer v1.2.23 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4ff6922d757..9cd6b94033d 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc9 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.22 + github.com/ElrondNetwork/elastic-indexer-go v1.2.23 github.com/ElrondNetwork/elrond-go-core v1.1.15 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.7 diff --git a/go.sum b/go.sum index efc690f9be6..7ee4b85d509 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.22 h1:Vw5c9oUNuZ6tWuLuqwAwrOC1+cHpeU/MyseldgdGdUY= -github.com/ElrondNetwork/elastic-indexer-go v1.2.22/go.mod h1:XkrkGcomheEZyMC1/OoANQ9KV0OCZF6+UP8lSPRrE9I= +github.com/ElrondNetwork/elastic-indexer-go v1.2.23 h1:BlEhC27FLWkL4ePagW62YTivOasdjV7EkNy+gyI2q4g= +github.com/ElrondNetwork/elastic-indexer-go v1.2.23/go.mod h1:XkrkGcomheEZyMC1/OoANQ9KV0OCZF6+UP8lSPRrE9I= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From 107a309c66d5bdb8243d0cfe2a67f8f475f402a8 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Fri, 6 May 2022 13:29:38 +0300 Subject: [PATCH 39/43] indexer v1.2.24 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9cd6b94033d..975b2e08bc9 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc9 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.23 + github.com/ElrondNetwork/elastic-indexer-go v1.2.24 github.com/ElrondNetwork/elrond-go-core v1.1.15 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.7 diff --git a/go.sum b/go.sum index 7ee4b85d509..ff18e72e853 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.23 h1:BlEhC27FLWkL4ePagW62YTivOasdjV7EkNy+gyI2q4g= -github.com/ElrondNetwork/elastic-indexer-go v1.2.23/go.mod h1:XkrkGcomheEZyMC1/OoANQ9KV0OCZF6+UP8lSPRrE9I= +github.com/ElrondNetwork/elastic-indexer-go v1.2.24 h1:PwVIoWwOJMKPCOH2V4gceMSz/Jy24AjhECn6+mrYKTI= +github.com/ElrondNetwork/elastic-indexer-go v1.2.24/go.mod h1:XkrkGcomheEZyMC1/OoANQ9KV0OCZF6+UP8lSPRrE9I= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From 3cad6e6b2e9fdaf47f20937f7badbe99e661591e Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Fri, 6 May 2022 16:11:11 +0300 Subject: [PATCH 40/43] indexer v1.2.25 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 975b2e08bc9..4047a64b30a 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.34-rc9 github.com/ElrondNetwork/concurrent-map v0.1.3 github.com/ElrondNetwork/covalent-indexer-go v1.0.6 - github.com/ElrondNetwork/elastic-indexer-go v1.2.24 + github.com/ElrondNetwork/elastic-indexer-go v1.2.25 github.com/ElrondNetwork/elrond-go-core v1.1.15 github.com/ElrondNetwork/elrond-go-crypto v1.0.1 github.com/ElrondNetwork/elrond-go-logger v1.0.7 From 3a67e05b4ba62772106411650658eb266ec656fb Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Fri, 6 May 2022 16:11:31 +0300 Subject: [PATCH 41/43] go mod tidy --- go.sum | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.sum b/go.sum index ff18e72e853..a77de3020ff 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04 github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6 h1:+LNKItUc+Pb7WuTbil3VuiLMmdQ1AY7lBJM476PtVNE= github.com/ElrondNetwork/covalent-indexer-go v1.0.6/go.mod h1:j3h2g96vqhJAuj3aEX2PWhomae2/o7YfXGEfweNXEeQ= -github.com/ElrondNetwork/elastic-indexer-go v1.2.24 h1:PwVIoWwOJMKPCOH2V4gceMSz/Jy24AjhECn6+mrYKTI= -github.com/ElrondNetwork/elastic-indexer-go v1.2.24/go.mod h1:XkrkGcomheEZyMC1/OoANQ9KV0OCZF6+UP8lSPRrE9I= +github.com/ElrondNetwork/elastic-indexer-go v1.2.25 h1:21ala1EQTu/30umkJxLTgIWikA17Iw8bP61EqK4poMo= +github.com/ElrondNetwork/elastic-indexer-go v1.2.25/go.mod h1:XkrkGcomheEZyMC1/OoANQ9KV0OCZF6+UP8lSPRrE9I= github.com/ElrondNetwork/elrond-go-core v1.0.0/go.mod h1:FQMem7fFF4+8pQ6lVsBZq6yO+smD0nV23P4bJpmPjTo= github.com/ElrondNetwork/elrond-go-core v1.1.6/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= github.com/ElrondNetwork/elrond-go-core v1.1.7/go.mod h1:O9FkkTT2H9kxCzfn40TbhoCDXzGmUrRVusMomhK/Y3g= From aff5a916cc2361fcb659cd63b2b2869eedb76620 Mon Sep 17 00:00:00 2001 From: Iuga Mihai Date: Wed, 11 May 2022 14:58:48 +0300 Subject: [PATCH 42/43] revert --- cmd/node/config/external.toml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/cmd/node/config/external.toml b/cmd/node/config/external.toml index d361de87fa3..7902306a5dd 100644 --- a/cmd/node/config/external.toml +++ b/cmd/node/config/external.toml @@ -4,17 +4,16 @@ #the node might loose rating (even facing penalties) due to the fact that #the indexer is called synchronously and might block due to external causes. #Strongly suggested to activate this on a regular observer node. - Enabled = false - IndexerCacheSize = 0 + Enabled = false + IndexerCacheSize = 0 BulkRequestMaxSizeInBytes = 4194304 # 4MB - URL = "http://localhost:9200" - UseKibana = false - Username = "" - Password = "" + URL = "http://localhost:9200" + UseKibana = false + Username = "" + Password = "" # EnabledIndexes represents a slice of indexes that will be enabled for indexing. Full list is: # ["rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations"] - EnabledIndexes = ["rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations"] - + EnabledIndexes = ["rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations"] # EventNotifierConnector defines settings needed to configure and launch the event notifier component [EventNotifierConnector] # Enabled will turn on or off the event notifier connector From f12e872ee99039b2aaf086d348accb60b354268c Mon Sep 17 00:00:00 2001 From: Iulian Pascalau Date: Fri, 13 May 2022 12:54:27 +0300 Subject: [PATCH 43/43] - linter fixes --- cmd/termui/presenter/common.go | 71 ------------------- .../termuic/termuiRenders/widgetsRender.go | 12 ++-- consensus/spos/bls/subroundBlock_test.go | 3 - 3 files changed, 6 insertions(+), 80 deletions(-) diff --git a/cmd/termui/presenter/common.go b/cmd/termui/presenter/common.go index eaf06a7c8e7..8678a23f21d 100644 --- a/cmd/termui/presenter/common.go +++ b/cmd/termui/presenter/common.go @@ -1,12 +1,5 @@ package presenter -import ( - "math" - "math/big" - - "github.com/ElrondNetwork/elrond-go/common" -) - const metricNotAvailable = "N/A" func (psh *PresenterStatusHandler) getFromCacheAsUint64(metric string) uint64 { @@ -42,67 +35,3 @@ func (psh *PresenterStatusHandler) getFromCacheAsString(metric string) string { return valStr } - -func (psh *PresenterStatusHandler) getBigIntFromStringMetric(metric string) *big.Int { - stringValue := psh.getFromCacheAsString(metric) - bigIntValue, ok := big.NewInt(0).SetString(stringValue, 10) - if !ok { - return big.NewInt(0) - } - - return bigIntValue -} - -func areEqualWithZero(parameters ...uint64) bool { - for _, param := range parameters { - if param == 0 { - return true - } - } - - return false -} - -func (psh *PresenterStatusHandler) computeChanceToBeInConsensus() float64 { - consensusGroupSize := psh.getFromCacheAsUint64(common.MetricConsensusGroupSize) - numValidators := psh.getFromCacheAsUint64(common.MetricNumValidators) - isChanceZero := areEqualWithZero(consensusGroupSize, numValidators) - if isChanceZero { - return 0 - } - - return float64(consensusGroupSize) / float64(numValidators) -} - -func (psh *PresenterStatusHandler) computeRoundsPerHourAccordingToHitRate() float64 { - totalBlocks := psh.GetProbableHighestNonce() - rounds := psh.GetCurrentRound() - roundDuration := psh.GetRoundTime() - secondsInAnHour := uint64(3600) - isRoundsPerHourZero := areEqualWithZero(totalBlocks, rounds, roundDuration) - if isRoundsPerHourZero { - return 0 - } - - hitRate := float64(totalBlocks) / float64(rounds) - roundsPerHour := float64(secondsInAnHour) / float64(roundDuration) - return hitRate * roundsPerHour -} - -func (psh *PresenterStatusHandler) computeRewardsInErd() *big.Float { - rewardsValue := psh.getBigIntFromStringMetric(common.MetricRewardsValue) - denomination := psh.getFromCacheAsUint64(common.MetricDenomination) - denominationCoefficientFloat := 1.0 - if denomination > 0 { - denominationCoefficientFloat /= math.Pow10(int(denomination)) - } - - denominationCoefficient := big.NewFloat(denominationCoefficientFloat) - - if rewardsValue.Cmp(big.NewInt(0)) <= 0 { - return big.NewFloat(0) - } - - rewardsInErd := big.NewFloat(0).Mul(big.NewFloat(0).SetInt(rewardsValue), denominationCoefficient) - return rewardsInErd -} diff --git a/cmd/termui/view/termuic/termuiRenders/widgetsRender.go b/cmd/termui/view/termuic/termuiRenders/widgetsRender.go index 0bcc478948e..b025f038e3e 100644 --- a/cmd/termui/view/termuic/termuiRenders/widgetsRender.go +++ b/cmd/termui/view/termuic/termuiRenders/widgetsRender.go @@ -37,7 +37,7 @@ type WidgetsRender struct { presenter view.Presenter } -//NewWidgetsRender method will create new WidgetsRender that display termui console +// NewWidgetsRender method will create new WidgetsRender that display termui console func NewWidgetsRender(presenter view.Presenter, grid *DrawableContainer) (*WidgetsRender, error) { if presenter == nil || presenter.IsInterfaceNil() { return nil, view.ErrNilPresenterInterface @@ -106,7 +106,7 @@ func (wr *WidgetsRender) setGrid() { wr.container.SetBottom(gridBottom) } -//RefreshData method is used to prepare data that are displayed on container +// RefreshData method is used to prepare data that are displayed on container func (wr *WidgetsRender) RefreshData(numMillisecondsRefreshTime int) { wr.prepareInstanceInfo() wr.prepareChainInfo(numMillisecondsRefreshTime) @@ -116,7 +116,7 @@ func (wr *WidgetsRender) RefreshData(numMillisecondsRefreshTime int) { } func (wr *WidgetsRender) prepareInstanceInfo() { - //8 rows and one column + // 8 rows and one column numRows := 8 rows := make([][]string, numRows) @@ -138,7 +138,7 @@ func (wr *WidgetsRender) prepareInstanceInfo() { fmt.Sprintf("Node name: %s (Shard %s - %s)", nodeName, shardIdStr, - strings.Title(nodeTypeAndListDisplay), + nodeTypeAndListDisplay, ), } @@ -174,7 +174,7 @@ func (wr *WidgetsRender) prepareInstanceInfo() { } func (wr *WidgetsRender) prepareChainInfo(numMillisecondsRefreshTime int) { - //10 rows and one column + // 10 rows and one column numRows := 10 rows := make([][]string, numRows) @@ -266,7 +266,7 @@ func computeRedundancyStr(redundancyLevel int64, redundancyIsMainActive string) } func (wr *WidgetsRender) prepareBlockInfo() { - //7 rows and one column + // 7 rows and one column numRows := 8 rows := make([][]string, numRows) diff --git a/consensus/spos/bls/subroundBlock_test.go b/consensus/spos/bls/subroundBlock_test.go index 8241c6bc3be..21130cb280b 100644 --- a/consensus/spos/bls/subroundBlock_test.go +++ b/consensus/spos/bls/subroundBlock_test.go @@ -998,9 +998,6 @@ func TestSubroundBlock_CallFuncRemainingTimeWithStructShouldWork(t *testing.T) { time.Sleep(200 * time.Millisecond) assert.True(t, remainingTimeInCurrentRound() < 0) - - roundStartTime = roundStartTime.Add(500 * time.Millisecond) - assert.True(t, remainingTimeInCurrentRound() < 0) } func TestSubroundBlock_CallFuncRemainingTimeWithStructShouldNotWork(t *testing.T) {