Skip to content
Permalink
Browse files
[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>
  • Loading branch information
g3co and borispovod committed Aug 24, 2020
1 parent 1256df9 commit b8ca5579b862eef6d935fa05e54d21c902a0f21d
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 56 deletions.
3 go.mod
@@ -10,7 +10,7 @@ require (
github.com/containerd/containerd v1.3.3 // indirect
github.com/containerd/continuity v0.0.0-20200228182428-0f16d7a0959c // indirect
github.com/cosmos/cosmos-sdk v0.39.0
github.com/dfinance/dvm-proto/go v0.0.0-20200806082036-06b76cf8c183
github.com/dfinance/dvm-proto/go v0.0.0-20200819065410-6b70956c85de
github.com/dfinance/glav v0.0.0-20200731202515-8e21f58877c8
github.com/dfinance/lcs v0.1.7-big
github.com/fsouza/go-dockerclient v1.6.3
@@ -20,6 +20,7 @@ require (
github.com/go-openapi/spec v0.19.9 // indirect
github.com/go-openapi/swag v0.19.9 // indirect
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.4.1
github.com/gorilla/handlers v1.4.2
github.com/gorilla/mux v1.7.4
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
4 go.sum
@@ -152,10 +152,14 @@ github.com/dfinance/dvm-proto/go v0.0.0-20200629145843-bfdcef619a26 h1:HjCcumhDV
github.com/dfinance/dvm-proto/go v0.0.0-20200629145843-bfdcef619a26/go.mod h1:Vt1T0G56AYXbsduNKzSkq1RDTNa8PFraSqB9DaTCV0U=
github.com/dfinance/dvm-proto/go v0.0.0-20200806082036-06b76cf8c183 h1:h1gLIUPEbVIVHSrJvC9FPpaVKHXmVmUYAoEEoH/ZxeE=
github.com/dfinance/dvm-proto/go v0.0.0-20200806082036-06b76cf8c183/go.mod h1:Vt1T0G56AYXbsduNKzSkq1RDTNa8PFraSqB9DaTCV0U=
github.com/dfinance/dvm-proto/go v0.0.0-20200819065410-6b70956c85de h1:PZfrjeOs9epAU0n+FpX/JAr/e+5m5/GdfUsgtO8gCOY=
github.com/dfinance/dvm-proto/go v0.0.0-20200819065410-6b70956c85de/go.mod h1:Vt1T0G56AYXbsduNKzSkq1RDTNa8PFraSqB9DaTCV0U=
github.com/dfinance/glav v0.0.0-20200731202515-8e21f58877c8 h1:SpACwa85hu9vFveIBPE4Xe28KiSrwxU8Lge3Pcdtr8s=
github.com/dfinance/glav v0.0.0-20200731202515-8e21f58877c8/go.mod h1:/0gr38+QzVxCNSNKc/WjGKtdTfV8NtMagCNO0/VjOQU=
github.com/dfinance/glav v0.0.0-20200810142408-b45f02eb7f56 h1:fHl+W6KAqVKdTmwpmpAQX8z0ZSH4qf3FS4X/dNJk3cc=
github.com/dfinance/glav v0.0.0-20200810142408-b45f02eb7f56/go.mod h1:/0gr38+QzVxCNSNKc/WjGKtdTfV8NtMagCNO0/VjOQU=
github.com/dfinance/glav v0.0.0-20200814081332-c4701f6c12a6 h1:fZIYncA5BRad0+YnP88cfBfo0ZPgxPSVeuh/jvoGrLc=
github.com/dfinance/glav v0.0.0-20200814081332-c4701f6c12a6/go.mod h1:/0gr38+QzVxCNSNKc/WjGKtdTfV8NtMagCNO0/VjOQU=
github.com/dfinance/lcs v0.1.7-big h1:z+Pvxcxvr6lKSy1vjYJtM5MnCTQ7DBjPitTywoWO9X0=
github.com/dfinance/lcs v0.1.7-big/go.mod h1:0Ir8JvbtxibZYvgTrRbbjNjk2EImCEXOJc3WHuUaSzI=
github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
@@ -63,7 +63,7 @@ const (
CoinsInfo = `{
"currencies": [
{
"path": "01f3a1f15d7b13931f3bd5f957ad154b5cbaa0e1a2c3d4d967f286e8800eeb510d",
"path": "01b9ed21c23abf8c7a53fb868a36e106d45394c30127fb722f8dd2d45aae719585",
"denom": "xfi",
"decimals": 18,
"totalSupply": "100000000000000000000000000"

Large diffs are not rendered by default.

@@ -66,9 +66,9 @@ script {
use 0x1::Event;
use {{sender}}::Math;
fun main(_account: &signer, a: u64, b: u64) {
fun main(account: &signer, a: u64, b: u64) {
let c = Math::add(a, b);
Event::emit<u64>(c);
Event::emit<u64>(account, c);
}
}
`
@@ -78,9 +78,9 @@ script {
use 0x1::Event;
use 0x1::Coins;
fun main(_account: &signer) {
fun main(account: &signer) {
let price = Coins::get_price<Coins::ETH, Coins::USDT>();
Event::emit<u128>(price);
Event::emit<u128>(account, price);
}
}
`
@@ -96,7 +96,7 @@ script {
let a = Account::withdraw_from_sender<XFI::T>(account, 523);
let b = Account::withdraw_from_sender<Coins::BTC>(account, 1);
Event::emit<u64>(10);
Event::emit<u64>(account, 10);
assert(c == 1000, 122);
Account::deposit_to_sender(account, a);
@@ -972,13 +972,13 @@ func TestVMKeeper_EventTypeSerialization(t *testing.T) {
field_VT: VT
}
public fun NewFooEvent<T, VT>(arg_T: T, arg_VT: VT): FooEvent<T, VT> {
public fun NewFooEvent<T, VT>(account: &signer, arg_T: T, arg_VT: VT): FooEvent<T, VT> {
let fooEvent = FooEvent<T, VT> {
field_T: arg_T,
field_VT: arg_VT
};
0x1::Event::emit<bool>(true);
0x1::Event::emit<bool>(account, true);
fooEvent
}
@@ -988,18 +988,18 @@ func TestVMKeeper_EventTypeSerialization(t *testing.T) {
script {
use %s::Foo;
fun main(_account: &signer) {
fun main(account: &signer) {
// Event with single tag
0x1::Event::emit<u8>(128);
0x1::Event::emit<u8>(account, 128);
// Event with single vector
0x1::Event::emit<vector<u8>>(x"0102");
0x1::Event::emit<vector<u8>>(account, x"0102");
// Two events:
// 1. Module: single tag
// 2. Script: generic struct with tag, vector
let fooEvent = Foo::NewFooEvent<u64, vector<u8>>(1000, x"0102");
0x1::Event::emit<Foo::FooEvent<u64, vector<u8>>>(fooEvent);
let fooEvent = Foo::NewFooEvent<u64, vector<u8>>(account, 1000, x"0102");
0x1::Event::emit<Foo::FooEvent<u64, vector<u8>>>(account, fooEvent);
}
}
`
@@ -1086,7 +1086,7 @@ func TestVMKeeper_EventTypeSerializationGas(t *testing.T) {
value: T
}
public fun test() {
public fun test(account: &signer) {
let a = A {
value: 10
};
@@ -1103,7 +1103,7 @@ func TestVMKeeper_EventTypeSerializationGas(t *testing.T) {
value: c
};
0x1::Event::emit<D<C<B<A>>>>(d);
0x1::Event::emit<D<C<B<A>>>>(account, d);
}
}
@@ -1112,8 +1112,8 @@ func TestVMKeeper_EventTypeSerializationGas(t *testing.T) {
script {
use %s::GasEvent;
fun main() {
GasEvent::test();
fun main(account: &signer) {
GasEvent::test(account);
}
}
`
@@ -1209,7 +1209,7 @@ func TestVMKeeper_EventTypeSerializationOutOfGas(t *testing.T) {
value: T
}
public fun test() {
public fun test(account: &signer) {
let a = A {
value: 10
};
@@ -1234,7 +1234,7 @@ func TestVMKeeper_EventTypeSerializationOutOfGas(t *testing.T) {
value: v
};
0x1::Event::emit<M<V<Z<C<B<A>>>>>>(m);
0x1::Event::emit<M<V<Z<C<B<A>>>>>>(account, m);
}
}
@@ -1243,8 +1243,8 @@ func TestVMKeeper_EventTypeSerializationOutOfGas(t *testing.T) {
script {
use %s::OutOfGasEvent;
fun main() {
OutOfGasEvent::test();
fun main(account: &signer) {
OutOfGasEvent::test(account);
}
}
`
@@ -47,7 +47,7 @@ func getVMLimitedGas(gas sdk.Gas) sdk.Gas {
// NewDeployContract creates an object used for publish module requests.
func NewDeployContract(address sdk.AccAddress, maxGas sdk.Gas, code []byte) *vm_grpc.VMPublishModule {
return &vm_grpc.VMPublishModule{
Address: common_vm.Bech32ToLibra(address),
Sender: common_vm.Bech32ToLibra(address),
MaxGasAmount: getVMLimitedGas(maxGas),
GasUnitPrice: types.VmGasPrice,
Code: code,
@@ -65,7 +65,7 @@ func NewExecuteContract(address sdk.AccAddress, maxGas sdk.Gas, code []byte, arg
}

return &vm_grpc.VMExecuteScript{
Address: common_vm.Bech32ToLibra(address),
Senders: [][]byte{common_vm.Bech32ToLibra(address)},
MaxGasAmount: getVMLimitedGas(maxGas),
GasUnitPrice: types.VmGasPrice,
Code: code,
@@ -105,14 +105,14 @@ func TestVMKeeper_NewContract(t *testing.T) {
maxGas := uint64(1000000)

contractModule := NewDeployContract(addr, maxGas, code)
require.Equal(t, common_vm.Bech32ToLibra(addr), contractModule.Address)
require.Equal(t, common_vm.Bech32ToLibra(addr), contractModule.Sender)
require.Equal(t, maxGas, contractModule.MaxGasAmount)
require.Equal(t, uint64(types.VmGasPrice), contractModule.GasUnitPrice)
require.Equal(t, code, contractModule.Code)

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

require.EqualValues(t, common_vm.Bech32ToLibra(addr), req.Address)
require.EqualValues(t, common_vm.Bech32ToLibra(addr), req.Sender)
require.EqualValues(t, gasLimit, req.MaxGasAmount)
require.EqualValues(t, types.VmGasPrice, req.GasUnitPrice)
require.EqualValues(t, code, req.Code)

0 comments on commit b8ca557

Please sign in to comment.