Skip to content

Commit b8ca557

Browse files
g3coborispovod
andauthored
[DFI-637] multisig support (#194)
* [DFI-632] Migrate to new dvm response structure * [DFI-632] Fixed max gas value for VM * [DFI-637] Multisig suppurt * [DFI-637] fixed move scripts * [DFI-632] fixed XFI * [DFI-632] added status codes * [DFI-637] updated genesis * [DFI-632] fixed linter * [DFI-632] refactored utils * [DFI-637] fixed xfi path * [DFI-637] removed debug code * fix to genesis gen doc * [DFI-632] refactoring * [DFI-637] merge fix Co-authored-by: borispovod <boris@wings.ai>
1 parent 1256df9 commit b8ca557

File tree

7 files changed

+61
-56
lines changed

7 files changed

+61
-56
lines changed

go.mod

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/containerd/containerd v1.3.3 // indirect
1111
github.com/containerd/continuity v0.0.0-20200228182428-0f16d7a0959c // indirect
1212
github.com/cosmos/cosmos-sdk v0.39.0
13-
github.com/dfinance/dvm-proto/go v0.0.0-20200806082036-06b76cf8c183
13+
github.com/dfinance/dvm-proto/go v0.0.0-20200819065410-6b70956c85de
1414
github.com/dfinance/glav v0.0.0-20200731202515-8e21f58877c8
1515
github.com/dfinance/lcs v0.1.7-big
1616
github.com/fsouza/go-dockerclient v1.6.3
@@ -20,6 +20,7 @@ require (
2020
github.com/go-openapi/spec v0.19.9 // indirect
2121
github.com/go-openapi/swag v0.19.9 // indirect
2222
github.com/gogo/protobuf v1.3.1
23+
github.com/golang/protobuf v1.4.1
2324
github.com/gorilla/handlers v1.4.2
2425
github.com/gorilla/mux v1.7.4
2526
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect

go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,14 @@ github.com/dfinance/dvm-proto/go v0.0.0-20200629145843-bfdcef619a26 h1:HjCcumhDV
152152
github.com/dfinance/dvm-proto/go v0.0.0-20200629145843-bfdcef619a26/go.mod h1:Vt1T0G56AYXbsduNKzSkq1RDTNa8PFraSqB9DaTCV0U=
153153
github.com/dfinance/dvm-proto/go v0.0.0-20200806082036-06b76cf8c183 h1:h1gLIUPEbVIVHSrJvC9FPpaVKHXmVmUYAoEEoH/ZxeE=
154154
github.com/dfinance/dvm-proto/go v0.0.0-20200806082036-06b76cf8c183/go.mod h1:Vt1T0G56AYXbsduNKzSkq1RDTNa8PFraSqB9DaTCV0U=
155+
github.com/dfinance/dvm-proto/go v0.0.0-20200819065410-6b70956c85de h1:PZfrjeOs9epAU0n+FpX/JAr/e+5m5/GdfUsgtO8gCOY=
156+
github.com/dfinance/dvm-proto/go v0.0.0-20200819065410-6b70956c85de/go.mod h1:Vt1T0G56AYXbsduNKzSkq1RDTNa8PFraSqB9DaTCV0U=
155157
github.com/dfinance/glav v0.0.0-20200731202515-8e21f58877c8 h1:SpACwa85hu9vFveIBPE4Xe28KiSrwxU8Lge3Pcdtr8s=
156158
github.com/dfinance/glav v0.0.0-20200731202515-8e21f58877c8/go.mod h1:/0gr38+QzVxCNSNKc/WjGKtdTfV8NtMagCNO0/VjOQU=
157159
github.com/dfinance/glav v0.0.0-20200810142408-b45f02eb7f56 h1:fHl+W6KAqVKdTmwpmpAQX8z0ZSH4qf3FS4X/dNJk3cc=
158160
github.com/dfinance/glav v0.0.0-20200810142408-b45f02eb7f56/go.mod h1:/0gr38+QzVxCNSNKc/WjGKtdTfV8NtMagCNO0/VjOQU=
161+
github.com/dfinance/glav v0.0.0-20200814081332-c4701f6c12a6 h1:fZIYncA5BRad0+YnP88cfBfo0ZPgxPSVeuh/jvoGrLc=
162+
github.com/dfinance/glav v0.0.0-20200814081332-c4701f6c12a6/go.mod h1:/0gr38+QzVxCNSNKc/WjGKtdTfV8NtMagCNO0/VjOQU=
159163
github.com/dfinance/lcs v0.1.7-big h1:z+Pvxcxvr6lKSy1vjYJtM5MnCTQ7DBjPitTywoWO9X0=
160164
github.com/dfinance/lcs v0.1.7-big/go.mod h1:0Ir8JvbtxibZYvgTrRbbjNjk2EImCEXOJc3WHuUaSzI=
161165
github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=

x/vm/internal/keeper/common_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const (
6363
CoinsInfo = `{
6464
"currencies": [
6565
{
66-
"path": "01f3a1f15d7b13931f3bd5f957ad154b5cbaa0e1a2c3d4d967f286e8800eeb510d",
66+
"path": "01b9ed21c23abf8c7a53fb868a36e106d45394c30127fb722f8dd2d45aae719585",
6767
"denom": "xfi",
6868
"decimals": 18,
6969
"totalSupply": "100000000000000000000000000"

x/vm/internal/keeper/genesis_ws.json

+29-29
Large diffs are not rendered by default.

x/vm/internal/keeper/integ_test.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ script {
6666
use 0x1::Event;
6767
use {{sender}}::Math;
6868
69-
fun main(_account: &signer, a: u64, b: u64) {
69+
fun main(account: &signer, a: u64, b: u64) {
7070
let c = Math::add(a, b);
71-
Event::emit<u64>(c);
71+
Event::emit<u64>(account, c);
7272
}
7373
}
7474
`
@@ -78,9 +78,9 @@ script {
7878
use 0x1::Event;
7979
use 0x1::Coins;
8080
81-
fun main(_account: &signer) {
81+
fun main(account: &signer) {
8282
let price = Coins::get_price<Coins::ETH, Coins::USDT>();
83-
Event::emit<u128>(price);
83+
Event::emit<u128>(account, price);
8484
}
8585
}
8686
`
@@ -96,7 +96,7 @@ script {
9696
let a = Account::withdraw_from_sender<XFI::T>(account, 523);
9797
let b = Account::withdraw_from_sender<Coins::BTC>(account, 1);
9898
99-
Event::emit<u64>(10);
99+
Event::emit<u64>(account, 10);
100100
101101
assert(c == 1000, 122);
102102
Account::deposit_to_sender(account, a);
@@ -972,13 +972,13 @@ func TestVMKeeper_EventTypeSerialization(t *testing.T) {
972972
field_VT: VT
973973
}
974974
975-
public fun NewFooEvent<T, VT>(arg_T: T, arg_VT: VT): FooEvent<T, VT> {
975+
public fun NewFooEvent<T, VT>(account: &signer, arg_T: T, arg_VT: VT): FooEvent<T, VT> {
976976
let fooEvent = FooEvent<T, VT> {
977977
field_T: arg_T,
978978
field_VT: arg_VT
979979
};
980980
981-
0x1::Event::emit<bool>(true);
981+
0x1::Event::emit<bool>(account, true);
982982
983983
fooEvent
984984
}
@@ -988,18 +988,18 @@ func TestVMKeeper_EventTypeSerialization(t *testing.T) {
988988
script {
989989
use %s::Foo;
990990
991-
fun main(_account: &signer) {
991+
fun main(account: &signer) {
992992
// Event with single tag
993-
0x1::Event::emit<u8>(128);
993+
0x1::Event::emit<u8>(account, 128);
994994
995995
// Event with single vector
996-
0x1::Event::emit<vector<u8>>(x"0102");
996+
0x1::Event::emit<vector<u8>>(account, x"0102");
997997
998998
// Two events:
999999
// 1. Module: single tag
10001000
// 2. Script: generic struct with tag, vector
1001-
let fooEvent = Foo::NewFooEvent<u64, vector<u8>>(1000, x"0102");
1002-
0x1::Event::emit<Foo::FooEvent<u64, vector<u8>>>(fooEvent);
1001+
let fooEvent = Foo::NewFooEvent<u64, vector<u8>>(account, 1000, x"0102");
1002+
0x1::Event::emit<Foo::FooEvent<u64, vector<u8>>>(account, fooEvent);
10031003
}
10041004
}
10051005
`
@@ -1086,7 +1086,7 @@ func TestVMKeeper_EventTypeSerializationGas(t *testing.T) {
10861086
value: T
10871087
}
10881088
1089-
public fun test() {
1089+
public fun test(account: &signer) {
10901090
let a = A {
10911091
value: 10
10921092
};
@@ -1103,7 +1103,7 @@ func TestVMKeeper_EventTypeSerializationGas(t *testing.T) {
11031103
value: c
11041104
};
11051105
1106-
0x1::Event::emit<D<C<B<A>>>>(d);
1106+
0x1::Event::emit<D<C<B<A>>>>(account, d);
11071107
}
11081108
11091109
}
@@ -1112,8 +1112,8 @@ func TestVMKeeper_EventTypeSerializationGas(t *testing.T) {
11121112
script {
11131113
use %s::GasEvent;
11141114
1115-
fun main() {
1116-
GasEvent::test();
1115+
fun main(account: &signer) {
1116+
GasEvent::test(account);
11171117
}
11181118
}
11191119
`
@@ -1209,7 +1209,7 @@ func TestVMKeeper_EventTypeSerializationOutOfGas(t *testing.T) {
12091209
value: T
12101210
}
12111211
1212-
public fun test() {
1212+
public fun test(account: &signer) {
12131213
let a = A {
12141214
value: 10
12151215
};
@@ -1234,7 +1234,7 @@ func TestVMKeeper_EventTypeSerializationOutOfGas(t *testing.T) {
12341234
value: v
12351235
};
12361236
1237-
0x1::Event::emit<M<V<Z<C<B<A>>>>>>(m);
1237+
0x1::Event::emit<M<V<Z<C<B<A>>>>>>(account, m);
12381238
}
12391239
12401240
}
@@ -1243,8 +1243,8 @@ func TestVMKeeper_EventTypeSerializationOutOfGas(t *testing.T) {
12431243
script {
12441244
use %s::OutOfGasEvent;
12451245
1246-
fun main() {
1247-
OutOfGasEvent::test();
1246+
fun main(account: &signer) {
1247+
OutOfGasEvent::test(account);
12481248
}
12491249
}
12501250
`

x/vm/internal/keeper/vm_grpc.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func getVMLimitedGas(gas sdk.Gas) sdk.Gas {
4747
// NewDeployContract creates an object used for publish module requests.
4848
func NewDeployContract(address sdk.AccAddress, maxGas sdk.Gas, code []byte) *vm_grpc.VMPublishModule {
4949
return &vm_grpc.VMPublishModule{
50-
Address: common_vm.Bech32ToLibra(address),
50+
Sender: common_vm.Bech32ToLibra(address),
5151
MaxGasAmount: getVMLimitedGas(maxGas),
5252
GasUnitPrice: types.VmGasPrice,
5353
Code: code,
@@ -65,7 +65,7 @@ func NewExecuteContract(address sdk.AccAddress, maxGas sdk.Gas, code []byte, arg
6565
}
6666

6767
return &vm_grpc.VMExecuteScript{
68-
Address: common_vm.Bech32ToLibra(address),
68+
Senders: [][]byte{common_vm.Bech32ToLibra(address)},
6969
MaxGasAmount: getVMLimitedGas(maxGas),
7070
GasUnitPrice: types.VmGasPrice,
7171
Code: code,

x/vm/internal/keeper/vm_grpc_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ func TestVMKeeper_NewContract(t *testing.T) {
105105
maxGas := uint64(1000000)
106106

107107
contractModule := NewDeployContract(addr, maxGas, code)
108-
require.Equal(t, common_vm.Bech32ToLibra(addr), contractModule.Address)
108+
require.Equal(t, common_vm.Bech32ToLibra(addr), contractModule.Sender)
109109
require.Equal(t, maxGas, contractModule.MaxGasAmount)
110110
require.Equal(t, uint64(types.VmGasPrice), contractModule.GasUnitPrice)
111111
require.Equal(t, code, contractModule.Code)
112112

113113
contractScript, err := NewExecuteContract(addr, maxGas, code, argInputs)
114114
require.NoError(t, err)
115-
require.Equal(t, common_vm.Bech32ToLibra(addr), contractScript.Address)
115+
require.Equal(t, [][]byte{common_vm.Bech32ToLibra(addr)}, contractScript.Senders)
116116
require.Equal(t, maxGas, contractScript.MaxGasAmount)
117117
require.Equal(t, uint64(types.VmGasPrice), contractScript.GasUnitPrice)
118118
require.Equal(t, code, contractScript.Code)
@@ -152,7 +152,7 @@ func TestVMKeeper_NewDeployRequest(t *testing.T) {
152152
t.Fatal(err)
153153
}
154154

155-
require.EqualValues(t, common_vm.Bech32ToLibra(addr), req.Address)
155+
require.EqualValues(t, common_vm.Bech32ToLibra(addr), req.Sender)
156156
require.EqualValues(t, gasLimit, req.MaxGasAmount)
157157
require.EqualValues(t, types.VmGasPrice, req.GasUnitPrice)
158158
require.EqualValues(t, code, req.Code)

0 commit comments

Comments
 (0)