Skip to content

Commit

Permalink
Merge pull request #141 from renproject/feat/update-solana-ffi
Browse files Browse the repository at this point in the history
Update solana-ffi to support token assets
  • Loading branch information
tok-kkk authored Mar 29, 2022
2 parents c2d9c2e + 73a71f4 commit d475196
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: ca488a932fea16a4fc09456383c10aa22a6b8585
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v1
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: ca488a932fea16a4fc09456383c10aa22a6b8585
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v1
Expand Down Expand Up @@ -245,7 +245,7 @@ jobs:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: ca488a932fea16a4fc09456383c10aa22a6b8585
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v1
Expand Down Expand Up @@ -370,7 +370,7 @@ jobs:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: ca488a932fea16a4fc09456383c10aa22a6b8585
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v1
Expand Down Expand Up @@ -447,7 +447,7 @@ jobs:
git clone https://github.com/renproject/solana-ffi.git
cd solana-ffi
git checkout ${{ env.SOLANA_FFI_COMMIT }}
make clean
eval `ssh-agent -s`
make
- name: Run vetting
Expand Down Expand Up @@ -495,7 +495,7 @@ jobs:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: ca488a932fea16a4fc09456383c10aa22a6b8585
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v1
Expand Down Expand Up @@ -620,7 +620,7 @@ jobs:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: ca488a932fea16a4fc09456383c10aa22a6b8585
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v1
Expand Down Expand Up @@ -747,7 +747,7 @@ jobs:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: ca488a932fea16a4fc09456383c10aa22a6b8585
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v1
Expand Down Expand Up @@ -871,7 +871,7 @@ jobs:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: ca488a932fea16a4fc09456383c10aa22a6b8585
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v1
Expand Down Expand Up @@ -995,7 +995,7 @@ jobs:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: ca488a932fea16a4fc09456383c10aa22a6b8585
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v1
Expand Down Expand Up @@ -1119,7 +1119,7 @@ jobs:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: ca488a932fea16a4fc09456383c10aa22a6b8585
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v1
Expand Down Expand Up @@ -1243,7 +1243,7 @@ jobs:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: ca488a932fea16a4fc09456383c10aa22a6b8585
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v1
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ RUN mkdir -p src/github.com/renproject
WORKDIR $GOPATH/src/github.com/renproject
RUN git clone https://github.com/renproject/solana-ffi
WORKDIR $GOPATH/src/github.com/renproject/solana-ffi
RUN git checkout ca488a932fea16a4fc09456383c10aa22a6b8585
RUN git checkout 720c0143d8655bfcd412ae73c949474df2c1dcf3
RUN make clean && make
RUN go install ./...
2 changes: 1 addition & 1 deletion chain/solana/solana-ffi
22 changes: 16 additions & 6 deletions chain/solana/solana_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var _ = Describe("Solana", func() {
time.Sleep(10 * time.Second)
recipient := []byte("mwjUmhAW68zCtgZpW5b1xD5g7MZew6xPV4")
Expect(err).NotTo(HaveOccurred())
burnCount := cgo.GatewayGetBurnCount(solana.DefaultClientRPCURL)
burnCount := cgo.GatewayGetBurnCount(solana.DefaultClientRPCURL, selector)
burnAmount := uint64(500000000) // 5 tokens.
burnSig := cgo.GatewayBurn(keypairPath, solana.DefaultClientRPCURL, selector, burnCount, burnAmount, uint32(len(recipient)), recipient)
logger.Debug("Burn", zap.String("tx signature", string(burnSig)))
Expand Down Expand Up @@ -108,19 +108,29 @@ var _ = Describe("Solana", func() {

// The registry (in the CI test environment) is pre-populated with gateway
// addresses for BTC/toSolana selector.
zero := pack.NewU256FromU8(pack.U8(0)).Bytes32()
btcSelectorHash := [32]byte{}
copy(btcSelectorHash[:], crypto.Keccak256([]byte("BTC/toSolana")))
zero := pack.NewU256FromU8(pack.U8(0)).Bytes32()
lunaSelectorHash := [32]byte{}
copy(lunaSelectorHash[:], crypto.Keccak256([]byte("LUNA/toSolana")))
daiSelectorHash := [32]byte{}
copy(daiSelectorHash[:], crypto.Keccak256([]byte("DAI/toSolana")))

addrEncodeDecoder := solana.NewAddressEncodeDecoder()
expectedBtcGateway, _ := addrEncodeDecoder.DecodeAddress(multichain.Address("FDdKRjbBeFtyu5c66cZghJsTTjDTT1aD3zsgTWMTpaif"))
expectedBtcGateway, _ := addrEncodeDecoder.DecodeAddress("FDdKRjbBeFtyu5c66cZghJsTTjDTT1aD3zsgTWMTpaif")
expectedLunaGateway, _ := addrEncodeDecoder.DecodeAddress("3zfUUYDVp68fk9Z8FoKxEcEFqSMhE5UZ3Mw8mGhm5WRt")
expectedDaiGateway, _ := addrEncodeDecoder.DecodeAddress("rZJ8SoJBNWq8Qi6QTNTdVv78DPW6mn2fJUw7CPUvSgA")

Expect(registry.Count).To(Equal(uint64(1)))
Expect(registry.Count).To(Equal(uint64(3)))
Expect(registry.Selectors[0]).To(Equal(btcSelectorHash))
Expect(registry.Selectors[1]).To(Equal(zero))
Expect(registry.Selectors[1]).To(Equal(lunaSelectorHash))
Expect(registry.Selectors[2]).To(Equal(daiSelectorHash))
Expect(registry.Selectors[3]).To(Equal(zero))
Expect(len(registry.Selectors)).To(Equal(32))
Expect(registry.Gateways[0][:]).To(Equal([]byte(expectedBtcGateway)))
Expect(registry.Gateways[1]).To(Equal(zero))
Expect(registry.Gateways[1][:]).To(Equal([]byte(expectedLunaGateway)))
Expect(registry.Gateways[2][:]).To(Equal([]byte(expectedDaiGateway)))
Expect(registry.Gateways[3]).To(Equal(zero))
Expect(len(registry.Gateways)).To(Equal(32))
})
})
Expand Down

0 comments on commit d475196

Please sign in to comment.